Subtracting one photo from another

This technique is suitable when two photos have been taken with the same exposure settings and with the camera fixed (eg, on a tripod) but something in the scene has moved or changed in some way. Subtraction shows only things which changed.

Fix the camera and use manual settings to take two photos. Automatic settings might be different for each image, so manual is best. Fixing the camera ensures that an unchanging background will be the same in both photos (except for possible noise if a high ISO setting was used). Subtracting the photos will produce an image in which only those things which changed will be seen.

 Example

The original 2 images:

The result of subtraction (notice small differences in the foliage, probably due to a breeze):

 How to subtract photos in Affinity Photo or Photoshop

If you put each photo on a different layer in the same file one of the possible blending modes for the upper layer is Subtract. However, that by itself will not produce the desired result. We will need some other things too.

If the range of brightnesses in each image (pixel values in each colour channel) is from 0 to M (maximum) then subtracting one image from another produces a possible range from -M to +M. (think about it: M - 0 = +M but the other extreme is 0 - M = -M). Neither Affinity Photo (AP) nor Photoshop (PS) is able to display negative pixel values. Such values all become zero, shown as black. So everything that was brighter in the second, subtracted, image than it was in the first image will become black.

The way to deal with this is to have a Curves adjustment layer for each image. This must be a different one for each image and only affect that image, not both of them. In AP that means dragging the adjustment layer just under the relevant layer so it is shown by a drop arrow in the layers panel. PS does it differently: there is an icon to click to say whether an adjustment applies to the whole stack of layers or only the one immediately beneath it.

We need to adjust the initial straight line in each curves diagram. For the lower layer (to be subtracted from) the left end of the line has to be dragged up half-way, so the pixels go from M/2 to M. For the upper layer the right end of the line must be dragged down from M to M/2. Then subtraction will produce the range from 0 to M. Things which are unchanged between the two images will appear as mid-grey, at M/2 for all colour channels. Other pixels will be brighter or darker depending on whether they were brighter in the first or second image.

This is the curve setting in AP for the subtracted image (upper layer in the layers panel). The red line here was the original. The blue line has had its right end dragged down half way. This applies to all 3 colour channels.

 How to subtract photos with GRIP

  1. Open both images in GRIP by using the Open option on GRIP's main File menu. The images will be in two separate windows with their own menus.
  2. If the images were taken in RAW mode see how to open RAW images.
  3. If GRIP's main window is hidden by image windows bring it to the front by typing Ctrl-G.
  4. On GRIP's file menu select "List and select images". A new window will be displayed, containing a table of all the images which are now open. This window has its own menu bar.
  5. Select both images in the table. This can be done in various ways:
    • Hold the Shift or Ctrl key down and click on each row in the table.
    • On the table's Edit menu, choose "Select all" (assuming only our 2 images are open).
    • Type Ctrl-A (assuming only our 2 images are open).
  6. When just two images have been selected, the table's Combine menu will show that options "Subtract selected images" and "Reverse subtract selected images" are available. Select either of these and see the result of subtracting either the second image from the first (result in the first image's window) or the first from the second (result in the second image window). In both cases those pixels which have not changed will appear as mid-grey (level 127 in each channel if the image was 8-bit, level 32767 in each channel for 16-bit images). Other pixels will be brighter or darker than that depending on how different they were between the two images.
  7. Reverse subtraction is only a convenience. You could get the same result by using normal subtraction and then selecting Invert from the Levels menu of the result image.
  8. If you want the background of the subtraction to be black (zero in every channel) you could then go to the Levels menu, select Curves, and use the V-shape option in the drop-down list. The V-shape is specifically available for this purpose but it may have other uses. Doing this "rectifies" the subtraction so that all changes are brighter than the background and you will no longer be able to tell in which original photo a given pixel was brighter.
  9. Save the result by using the "Save as" option of the Image menu of the result.

As with all these things, experiment a bit with the steps given here to see which sequence produces the best result.

Next page