How Does the Non Local Means Filter Work? As I understand,

A local mean filter is the one in which we take a pixel and calculate the mean of color-values of the pixels around them (but in a certain range of area) and the center pixel is replaced by that mean value.
The filter always has a specific size. For instance, 3x3, 5x5, and so on.
The filter sweeps the whole image row by row to achieve a filtered image (spatial domain), or, the FT of the image is multiplied by the FT of the filter (frequency domain).

But, I could not understand the case of a Non-Local Mean (or, median, or whatever) filter.

How is the the value of the non-local mean calculated?
How does that value replaces a pixel?
How does that filter sweeps the image?
Check out the description here.

Basically, it tries to find patterns of pixels all over the image, and average over these self-similarities rather than just using the pixels close to the current pixel.

So to answer your questions:

How is the the value of the non-local mean calculated?


Find all the pixels that are similar to the current pixel (non-local).

Find the average value of these.

How does that value replaces a pixel?


Find the non-local average as above.

Replace the current pixel with this non-local average.

How does that filter sweeps the image?



Well, provided you are creating a new image from the old one so that the mean calculation is being done on the old image and the mean assignment is being done on the new image, it shouldn't really matter.