OthersOthersTechnology Deep Dive

Understanding Spatial Noise and Its Reduction Methods Using Convolution

Convolution is a mathematical operation used in image processing to apply filters to images. These filters are used for spatial noise reduction in images with variations or irregularities in the pixel values that are unrelated to the actual features of the scene being captured. This blog delves into different filtering techniques, such as average smoothing, Gaussian filtering, median filtering, bilateral filtering, non-local means, and Wiener filtering

Spatial noise in imaging is the variations or irregularities in the pixel values of an image that are unrelated to the actual features of the scene being captured. This type of noise occurs at the pixel level and can introduce unwanted randomness or fluctuations in the visual information.

Spatial noise majorly occurs due to sensor imperfections. The individual pixels in a sensor vary from each other in terms of the sensitivity of minor defects. This leads to spatial noise in the image captured.

There are also various other sources of spatial noise. External environmental factors such as temperature difference, electromagnetic interference, and vibration can also introduce spatial noise into the imaging system. Spatial noise can also occur during the digitization process when the continuous range of analog signal values is converted into discrete digital values. This leads to quantization errors and, in turn, gives rise to quantization noise.

In this blog, we’ll be covering the different types of spatial noise reduction methods.

What is Convolution Operation?

Convolution is a formal mathematical operation used in image processing applications. The different types of noise reduction methods in the following section are done using convolution operation.

Convolution is done using a small matrix called a kernel or filter comprised of integers. Differently sized kernels containing different patterns of numbers produce different results under convolution. The size of the kernel is arbitrary, but 3×3 is used more often. The anchor point in the kernel (See Figure 1) is used to know the position of the kernel with respect to the image.

Kernel or FilterFigure 1: Kernel or Filter

The kernel is slid or convolved across the entire image. The positioning of the kernel on top of the image pixel starts from the top left corner. And it is moved sequentially till the end. At each position, the element-wise multiplication of the kernel and the underlying image patch is computed. This is followed by summing up these products to obtain the value for the corresponding pixel in the output image.


Mathematically, the convolution operation for a 2D image (I) and a 2D kernel (K) is given by:

The elements at the center, i.e., in [2,2] of the image matrix under the convolution kernel, will be given the weighted value resulting from the above formula (the center position [2,2] can vary depending on the convolution kernel window size) . This process is repeated for the entirety of the image pixels, and the pixel’s integer values are replaced with the resulting values.

Let us take a look at different filtering techniques by which noise reduction is done in images.

Types of Spatial De-Noising with Convolution

1. Average Smoothing

In average smoothing, the intensity difference between pixel-to-pixel (i.e., the noise in the image) is reduced by an averaging technique. The kernel/matrix used in average smoothing is shown below.

Kernel Used in Average Smoothing            Figure 2: Kernel Used in Average Smoothing

In average smoothing, the kernel window used is a square matrix with equal weights. It is usually a square matrix of size (n x n), where ‘n’ is an odd number. The ‘n’ being odd is to have a well-defined, symmetric neighborhood around each data point. The above given (Figure 2) matrix is a 3×3 kernel, with the weights evenly distributed.

The kernel window will be placed above the image pixel being processed (i.e., slide the kernel across each data point in the image). The average of the data points in the image matrix under the kernel window is calculated. The current data point in the image pixel is replaced with the calculated average. This process is repeated for every data point in the image.

Average Smoothing ExampleFigure 2: Average Smoothing Example

In the above example, the kernel window is placed over the green highlighted area in the image. The center pixel of the image ‘37’ is replaced with the weighted average of all the pixel data points under the kernel window. Here, the weighted average ‘39’ is calculated as follows,

Weighted Average=((30×1)+(35×1)+(37×1)+(40×1)+(37×1)+(43×1)+(40×1)+(43×1)+(42×1))/9

In the case of image pixels in the boundary, the convolution kernel extends beyond the image boundaries. There are several common approaches to solving this boundary issue. One such method commonly used to deal with the boundary pixels during convolution is called zero-padding (zero-fill).

In the zero-padding Technique, pixels outside the image boundary are assumed to have a value of zero. This is the simplest method, where pixels beyond the image boundary are treated as if they have zero intensity. There are also other methods used to deal with the boundary problem, such as mirror padding, wrap-padding, clamp padding, edge padding, etc.

The following figure shows the before and after of an image that has undergone average smoothing denoising.

before smoothing

after smoothing 

Figure 3: Before and After Average Smoothing

The average smoothing process effectively blurs or smoothens the signal, reducing the impact of random noise. However, it’s essential to strike a balance with the window size since a window that is too small might not effectively smooth the noise, and a window that is too large might blur the signal too much, losing important details.

Keep in mind that average smoothing is a basic technique and more sophisticated methods like Gaussian smoothing or median filtering are often used for better noise reduction in specific applications.

2. Gaussian Filter

Gaussian filter is a spatial noise reduction method used for reducing high-frequency noise. This filtering technique uses the Gaussian function to perform convolution.

The difference between the Gaussian filtering technique and average smoothing is that, in Gaussian filtering, more weight values are assigned to the points closer to the center pixels, and lesser weight values are assigned to points far away from the center pixel. This results in a smoother transition. This varying weight distribution allows the Gaussian filter to reduce noise effectively while preserving important details in the image.

In the case of a Gaussian filter, the kernel is based on the discrete approximation of the Gaussian function.

Figure 4: Example of Gaussian Filter Kernel with Standard Deviation of 1

In the above example, the standard deviation is assumed to be 1. The values in the matrix are the weights assigned to the neighboring pixels during the convolution operation. The central pixel has the highest weight, and the weights decrease as we move away from the center.

To apply the Gaussian filter, you convolve the image with this kernel (Figure 4) kernel using standard convolution techniques. The resulting pixel value at each position is a weighted average of the surrounding pixels, with higher weights assigned to closer neighbors according to the Gaussian distribution.


After Gaussian Filtering 

Figure 5: Before and After Gaussian Filtering

[Image Source: Image Processing Github Repository]

3. Median Filter

The Median filtering technique is commonly used for removing salt-and-pepper noise. It is widely used in the medical field as this kind of noise is prevalent in medical imaging.

Just as in other filtering techniques discussed above, in a Median filter, a kernel matrix is slid over the entire image. Move the selected window over each pixel in the image, covering one pixel at a time. For each window placement, collect the pixel values within the window and sort them in ascending order. The median is the middle value in the sorted list. Assign the median value as the new value for the pixel at the center of the window. This process is repeated for every pixel in the image.

Figure 6: Median Filtering Example

Before Median Filtering

After Median Filtering 

Figure 7: Before and After Median Filtering

[Image Source: Image Processing Github Repository]

The key advantage of median filtering is its ability to effectively remove salt-and-pepper noise (random bright and dark pixels) in an image without significantly blurring edges. Since the median is less sensitive to extreme values than the mean, it tends to preserve edges and details in the image.

4. Bilateral Filter

Bilateral filtering is a non-linear, edge-preserving noise filtering technique. It is particularly effective in smoothing images while preserving edges. The filter takes into account both the spatial distance between pixels and the intensity differences, allowing it to retain important image features while reducing noise.

The steps involved in the Bilateral filtering technique are as follows:

  1. Select a Window: Similar to other filtering techniques, bilateral filtering also uses a window or a kernel of a specific size (commonly 3×3, 5×5, or 7×7). This window will slide over the entire image.
  2. Calculate Gaussian Weights for Spatial Distance: For each pixel in the window, calculate a spatial weight based on the spatial distance between the center pixel and the surrounding pixels. The weight is usually calculated using a Gaussian function, giving higher weights to nearby pixels and lower weights to distant pixels.
  3. Calculate Gaussian Weights for Intensity Differences: For each pixel in the window, calculate an intensity weight based on the difference in intensity values between the center pixel and the surrounding pixels.
  4. Compute the Weighted Average: Compute the weighted average of the intensity values within the window using the bilateral filter weights.
  5. Repeat for Each Pixel: Slide the window over each pixel in the image and repeat the process, computing the weighted average for each pixel.

Bilateral filtering does not blur the images too much because it considers both how far pixels are from each other and how different their colors are. This helps preserve the important details, like edges in the image.

Before Bilateral Filtering

After Bilateral Filtering 

Figure 8: Before and After Bilateral Filtering

The key difference in bilateral filtering is that the weights in the convolution kernel are not fixed but depend on the spatial and intensity relationships between pixels.

5. Nonlocal Means

Non-local Means (NLM) is a technique used in image denoising, aiming to reduce noise while preserving image details. Unlike traditional denoising methods, which operate locally on each pixel or small neighborhood, non-local means consider similarities across the entire image for better noise reduction. The NLM does not use the convolution technique to do the filtering but uses the NLM algorithm.

The steps involved in the NLM technique are as follows:

  1. Similarity Measurement: For each pixel in the image, the non-local means algorithm measures the similarity between the pixel and all other pixels in the image. This is done by comparing patches (small regions around each pixel) rather than individual pixel values.
  2. Patch Matching: The algorithm looks for patches in the image that are similar to the patch around the target pixel. The similarity is often measured using a weighted Euclidean distance, considering both spatial and intensity differences.
  3. Weighted Averaging: Once similar patches are identified, their pixel values are combined to calculate a weighted average. The weights are determined by the similarity between the patches. Patches that are more similar contribute more to the average.
  4. Noise Reduction: The calculated weighted average becomes the denoised value for the target pixel. This process is repeated for every pixel in the image, resulting in a denoised version of the original image.

Figure 9: Scheme of NL-means strategy.

It can be observed from the above figure that, similar pixel neighborhoods give a large weight, w(p, q1) and w(p,q2), while much different neighborhoods give a small weight w(p,q3).

The non-local means technique leverages the idea that similar structures in an image should have similar noise characteristics. By final output image’s non-local similarities, the algorithm can effectively distinguish between signal and noise, leading to improved denoising performance.

6. Weiner Filter

The Wiener filter assumes that the given image is a combination of a true underlying image (signal) and additive noise. The Wiener filter calculates the Power Spectral Density (PSD) of both the signal (the true image) and the noise. The PSD provides information about how the energy is distributed across different frequencies in the signal and the noise. It considers the Signal-to-Noise Ratio (SNR), which is a measure of how strong the signal is compared to the noise. A high SNR means a strong signal and less noticeable noise.

Using the information from the PSD and SNR, the Wiener filter creates a filter function. This function is designed to attenuate (reduce) frequencies dominated by noise while preserving frequencies dominated by the signal. The filter adapts its behavior based on the characteristics of the signal and noise.

In simpler terms, the Wiener filter is like a smart cleaner for images that understands which parts of the image are important (signal) and which parts are unwanted noise. It then applies a special filter to keep the important stuff while reducing the noise, resulting in a clearer and cleaner image. The key is adapting the filter based on the statistical properties of the signal and noise, making it a powerful tool for image denoising.


Figure 10: Before and After Images of Weiner Filter

[Image Source: Image Processing Github Repository]

Low-Noise Cameras Offered by e-con Systems

e-con Systems has over 20+ years of experience in designing, developing, and manufacturing OEM cameras. Over the years, we’ve developed a wide range of low-noise cameras with efficient noise reduction algorithms, in-built ISP systems, etc.

Some of our popular low-noise cameras are listed below:

Visit our Markets Page, to explore more of the cameras developed by us.

We also provide customisation services to meet the specific requirements of your application. Write to us at camerasolutions@e-consystems.com for your queries.

Related posts