- Ever happened to you that you saw a beautiful night scene, but you didn’t have a tripod?
- So you had to shoot handheld and the only way to go was to bump up the ISO.
- But then there was going to be noise everywhere, and non of us likes that…
- That’s when a very simple but effective method can be used to significantly reduce noise.
- Check it for yourself:
Comparison of a single photo vs 8 frames averaged, at 100% magnification. Look at all the details being freed up in the shadows! ISO 6400 on Canon 6D, handheld
The method is called median stacking noise reduction, and in this article I will show you the exact process from shooting to work in Photoshop.
What is median stacking noise reduction?
- You take a bunch of photos with the exact same settings (they will be noisy because of high ISO, but don’t worry)
- In Photoshop you average out the photos so that noise will disappear
So what is median anyway?
Median is one kind of averaging method. It is calculated by putting the numbers in ascending order, and then picking the middle one.
For example, let’s say you have 3 pixels, and you want to take the median of them.
|Median of pixels 1-3||120||51||145|
When to use median stacking noise reduction?
This method is particularly useful in low-light scenarios where you have to handhold the camera and the subject is not moving at all.
So it’s especially useful for night landscape / cityscape photos, and also for compact and smartphone cameras, that are inherently a lot more noisy.
How to reduce noise with median stacking – the shooting part
The key here is to take many photos with similar composition and same exposure. Also, sharpness is key here, so make sure the shutter speed is fast enough (don’t worry about the high ISO!)
Lock exposure and drive mode
- 1 – Set the camera into Manual mode, and adjust the exposure. Make sure to have a fast shutter speed that you can safely handhold
- 2 – Set the camera’s drive mode into Continuous mode
- 3 – Use RAW file format is possible. If you’re in JPG, turn the noise reduction OFF
Compose and shoot
Compose and take 10+ shots. Try not to move when shooting, as you want almost identical frames.
The more photos you take, the better result you’ll get in the end (though requires more computerwork, too).
How to reduce noise with median stacking – the Photoshop part
Edit the photos to taste in Lightroom (optional)
I’m going to demonstrate this on my Noctilucent cloouds over Budapest photo, because it was created with the exact same process.
Once one photo has been edited, Synchronize the settings over to the other frames.
Make sure the edited photo is actively selected, and then select the other photos and click on Synchronize settings:
Once the Sync Settings window pops up, check all parameters to be synchronized.
Open the photos as Layers in Photoshop
In Lightroom while all layers still being selected, right-click on one of them, and go to Edit In → Open as Layers in Photoshop
After that, Photoshop will open, and it will load each photo onto a separate layer:
Alternatively, if you did not use Lightroom, you can just open Photoshop, and go to File → Scripts → Load Files into Stack
Leave the Convert to Smart Object box unchecked (but you can have the Auto Align enabled):
Essentially this will do the exact same thing as “Open as Layers in Photoshop” command in Lightroom.
Check sharpness of each and every photo
- Averaging photos works well only on sharp photos.
- So in Photoshop, go through each layer and check them at 100% magnification.
- You can solo view each layer by holding ALT (Option) and clicking on the eye icon of the layer in Photoshop.
Those layers that are not 100% sharp, just delete.
- As you were probably shooting handheld, the photos are slightly off compared to each other.
- Photoshop can easily fix this.
- Just select all layers and go to Edit → Auto-Align Layers.
Leave it on Auto:
Now all layers should be aligned perfectly (but it’s worth checking with the same method as you did with sharpness)
Convert into Smart Object
With all layers selected, Layer → Smart Object → Convert to Smart Object.
- This will turn all layers into one Smart Object.
- As I already noted, you can skip these steps if you use the Scripts → Load Files into Stack in Photoshop and check the option Auto-Align and Convert to Smart Object.
- Now comes the last step…
Enable Median stacking
With the Smart Object layer selected, go to Layer – Smart Object – Stack Mode – Median.
- Now Photoshop will start working, and you’ll probably have to wait minutes…
- But once it’s done, all you have to do is to Save it!
- As we have a lot of layers, it’s probably a huge PSD file.
- So what I often do is that after I checked that the median stacking went alright, I just export it to 100% JPG or TIFF, and then get rid of the PSD file to save on memory space.
- Here’s a before-after view at 100% magnification:
Single frame taken with Sony RX100 III, at ISO 640 8 frames with the same exposure aligned and median stacked
Here’s another comparison side by side (click to enlarge):
Effectiveness of median stacking noise reduction: single photo vs stacked
You can clearly see how much noise disappeared, and also how many details came out!
Sample images made with median stacking
I think it was worth it, have a look yourself (click on the images to enlarge).
Buda Castle and Chain bridge from Citadel at night in Budapest, Hungary. Median stack 8 frames – ISO 6400, 1/80 sec, handheld Canon 6D – taken on my night photo tour Noctilucent clouds above Buda Castle. Six frames median stacked – Sony RX100 III, ISO 640, 1/20 sec, f/2
Pat David published an excellent article on Petapixel in 2013
Keepcoding has a good article in which he compares different stacking methods (median vs mean)
A Look at Reducing Noise in Photographs Using Median Blending
Between a recent post here on PetaPixel about the Beauty of Space Photography, and my own experiments on blending series of images using averaging techniques, I noticed some rather interesting alignments in technique.
In image averaging, I had previously blended images together by averaging the value of each pixel in an image to produce something entirely new.
The way that this process relates to astrophotography is that the general method is commonly used as a means of noise reduction.
It becomes interesting when you realize that you don’t have to be blending images or taking photos of the cosmos to benefit from the same methods of noise reduction. It works incredibly well for any images that are relatively static.
- Have a look at this image (click it for a larger version):
Although a relatively boring image, the interesting thing about it is that it was shot at ISO 25,600. To be fair, there is a little bit of cheating going on. The result above is derived from combining 10 images of the same scene. This is the power of using median image stacking to increase the signal-to-noise ratio in images.
Here are a few 100% crops to demonstrate what is happening (single ISO 25,600 left, median stack right):
The last image really shows the strength in this technique. The words in the banner “Fast, Focused, Fearless” are not even distinguishable in the single ISO 25,600 shot. Stacking 10 images cleans up the noise enough to clearly read the text.
What Median Stacking Does
Averaging images in Photoshop
Phase One just introduced an update to the IQ4 cameras that allows in-camera capture and averaging of groups of images. If the camera position is fixed, this technique can have the effect of simultaneously:
- Allowing long exposure times without the need for a neutral density filter.
- Deceasing the amount of noise in the final image over what could have been achieved with a single capture.
- Increasing the dynamic range of the final image over what could have been achieved with a single capture.
2, and 3 above are really just two different ways to say the same thing. The amount of noise reduction is the square root of the number of captures. If you have 2 captures, you have 0.707 times as much noise. Four captures, half the noise. 16 captures give you one quarter the noise, and 64 captures get you to one eighth.
I’ve been doing this for some time in post-production. If you want to experiment with it and you are among those who don’t happen to have an IQ4, but do have Photoshop (Ps), it’s pretty easy.
Here’s what to do.
Bring all your images into Ps as layers in a single image. If you’re using Lightroom (Lr), you can select all the images and pick “open as layers in Photoshop”.
- Select all the layers.
- Convert the layers to a smart object.
- In Smart Object, pick Stack Mode, and then Mean.
- If you want to experiment, you can also choose Median.
Select a Web Site
Digital images are prone to various types of noise. Noise is the result of errors in the image acquisition process that result in pixel values that do not reflect the true intensities of the real scene. There are several ways that noise can be introduced into an image, depending on how the image is created. For example:
- If the image is scanned from a photograph made on film, the film grain is a source of noise. Noise can also be the result of damage to the film, or be introduced by the scanner itself.
- If the image is acquired directly in a digital format, the mechanism for gathering the data (such as a CCD detector) can introduce noise.
- Electronic transmission of image data can introduce noise.
To simulate the effects of some of the problems listed above, the toolbox provides the imnoise function, which you can use to add various types of noise to an image. The examples in this section use this function.
You can use linear filtering to remove certain types of noise. Certain filters, such as averaging or Gaussian filters, are appropriate for this purpose. For example, an averaging filter is useful for removing grain noise from a photograph. Because each pixel gets set to the average of the pixels in its neighborhood, local variations caused by grain are reduced.
See What Is Image Filtering in the Spatial Domain? for more information about linear filtering using imfilter.
This example shows how to remove salt and pepper noise from an image using an averaging filter and a median filter to allow comparison of the results. These two types of filtering both set the value of the output pixel to the average of the pixel values in the neighborhood around the corresponding input pixel.
However, with median filtering, the value of an output pixel is determined by the median of the neighborhood pixels, rather than the mean. The median is much less sensitive than the mean to extreme values (called outliers).
Median filtering is therefore better able to remove these outliers without reducing the sharpness of the image.
Note: Median filtering is a specific case of order-statistic filtering, also known as rank filtering. For information about order-statistic filtering, see the reference page for the ordfilt2 function.
Read image into the workspace and display it.
I = imread('eight.tif');
For this example, add salt and pepper noise to the image. This type of noise consists of random pixels being set to black or white (the extremes of the data range).
J = imnoise(I,'salt & pepper',0.02);
Filter the noisy image, J, with an averaging filter and display the results. The example uses a 3-by-3 neighborhood.
Kaverage = filter2(fspecial('average',3),J)/255;
Now use a median filter to filter the noisy image, J. The example also uses a 3-by-3 neighborhood. Display the two filtered images side-by-side for comparison. Notice that medfilt2 does a better job of removing noise, with less blurring of edges of the coins.
Kmedian = medfilt2(J);
This example shows how to use the wiener2 function to apply a Wiener filter (a type of linear filter) to an image adaptively. The Wiener filter tailors itself to the local image variance. Where the variance is large, wiener2 performs little smoothing. Where the variance is small, wiener2 performs more smoothing.
This approach often produces better results than linear filtering. The adaptive filter is more selective than a comparable linear filter, preserving edges and other high-frequency parts of an image.
In addition, there are no design tasks; the wiener2 function handles all preliminary computations and implements the filter for an input image.
wiener2, however, does require more computation time than linear filtering.
wiener2 works best when the noise is constant-power (“white”) additive noise, such as Gaussian noise. The example below applies wiener2 to an image of Saturn with added Gaussian noise.
Read the image into the workspace.
RGB = imread('saturn.png');
Convert the image from truecolor to grayscale.
Add Gaussian noise to the image
J = imnoise(I,'gaussian',0,0.025);
Display the noisy image. Because the image is quite large, display only a portion of the image.
title('Portion of the Image with Added Gaussian Noise');
Remove the noise using the wiener2 function.
Display the processed image. Because the image is quite large, display only a portion of the image.
title('Portion of the Image with Noise Removed by Wiener Filter');
imbilatfilt | imfilter | imgaussfilt | imguidedfilter | locallapfilt | nlfilter
- What Is Image Filtering in the Spatial Domain?