# What is the difference between domain and range filtering?

In the context of image processing, I have heard the expressions "domain filtering" and "range filtering". What do these terms refer to? What is the difference between them?

In image processing, an image $$f$$ can be seen as a function from positions (or coordinates) to values (the pixel values). If the image is grayscale, the values are just real numbers in the range $$[0, 1]$$ (or, equivalently, in the range $$[0, 255]$$). However, each pixel of an image can also have a color different than grey (e.g. red). In that case, we need "channels" to represent the color of each pixel. We often have three channels: red, green and blue. Each of these channels have a range $$[0, 1]$$. So, a grayscale image $$f_G$$ can be seen as the following function

$$f_G: [a, b] \times [c, d] \rightarrow [0, 1]$$

where $$a$$ and $$b$$ are respectively the leftmost and rightmost side horizontal coordinates and $$c$$ and $$d$$ are respectively the topmost and bottommost vertical coordinates of the image. Similarly, a colored image can be represented as follows

$$f_C: [a, b] \times [c, d] \rightarrow [0, 1]^3$$

In general, the domain of a function is the input (left-hand side of the $$\rightarrow$$ above and after $$:$$), whereas the range is the output (right-hand side of $$\rightarrow$$). So, in the case of images, the domain are the possible coordinates of the pixels of the image, whereas the range are the possible values of those pixels. It might help to think of a function as a grid of little squares (pixels), each with a value (which can be a scalar or a tuple of scalars).

In general, filtering is the process of updating the value of a pixel as a function of its neighbouring pixels.

In this context, domain filtering refers to filtering using only the coordinates of the pixels. For example, if update the pixel $$p$$ only taking into account its position relative to other pixels (without considering the values of those same neighbouring pixels), then this would be "domain filtering". An example of a domain filtering is Gaussian filtering. More precisely, the weights of the Gaussian filter decay from the center of the neighbourhood (that is, the pixel to be updated) with distance to that same center. So, the pixel in the middle would have a higher weight than the pixel father way from the middle.

Range filtering refers to filtering using the values of the pixels (rather than their positions). More precisely, the weights of the filter, in this case, would decay from the center based on "distance" between the values of the pixels.

There are also filters that perform a combination of these. A famous example of such filter is bilateral filtering.