1. Description
This experiment is designed to smooth an image, using linear filters, the discrete Fourier transform, and the use of a bilateral smoothing filter. The effect on attenuation of noise, as well as the blurring of edges is a consideration.
2. Methods
To test the smoothing filters, onion cells were stained with methylene blue and images through a microscope at 100X magnification were taken by digital camera. The image was decimated to a 256-by-256 matrix, representing a standard grayscale image. The resulting image had poor contrast, but provides some input to the filtering techniques to be explored.
The results are primarily based on this sample image, and use of MATLAB to perform Fourier transforms and a set of bilateral weighted sums. Since this process starts with a 256 grayscale image, some amount of error due to image quantization is expected. Operations are carried out using double-precision floating point to minimize this source of error.
3. Results
At first, the low-contrast image is amplified using a simple linear function.
Original Image:
|
Amplified Image:
|
The magnitude spectrum exposes a vertical line in the spectrum, as well as a general diagonal component which reflects the strong spatial period of the onion cells oriented in that direction. In all cases, the magnitude spectra are shown with pixels of intensity proportional to the logarithm of the magnitude at each frequency, or more specifically, log |F(u,v)|. A vertical line appears to represent a brightness gradient in the image. This portion of the signal is filtered out of the frequency domain.
Magnitude Spectrum:
|
Phase Spectrum:
|
Filtered Magnitude Spectrum:
|
Filtered Image:
|
Filter Input Image:
|
Filter Input Magnified:
|
The vertical gradient is possibly due to lighting of the microscope slide, or some other variable inherent in the way the image was acquired. Since the vertical signal was attenuated, we can re-amplify the image to take advantage of more of the 256 grayscales. The following image is then used as input to various smoothing filters.
The smoothing approach first attempted will apply 2-D convolution, applying a moving average commonly used to smooth images. Symmetric low-pass 9-point and 25-point filters were used, demonstrating the smoothing of the image.
9-point average:
|
9-point magnified:
|
25-point average:
|
25-point magnified:
|
Compared to the image before smoothing, noise visible in the original image is reduced, at the expense of a strong blurring of the edges of the onion cell walls and other details. The reduction of high-frequency signal is evident when looking at the Fourier transform. For instance, in the image filtered with the 25-point filter, the magnitudes at higher frequencies are strongly attenuated.
To make comparisons in the frequency domains, another approach examined is the bilateral filter, which tends to preserve edges in the image. Using Gaussian functions to weigh both the spatial distance, and the closeness in radiosity, a weighted average is applied to each point. The higher frequencies are preserved in the bilateral case.
25-point spectrum:
|
Bilateral spectrum:
|
Bilateral filter:
|
Bilateral magnified:
|
Before/After:
|
The bilateral filter, mapping image f to image g, was computed with the following calculation:
g(x0,y0) = Sx,y f(x,y) WD WR, where WD=e-((x-x0)2+(y-y0)2) / sD2 and WR=e-(f(x,y)-f(x0,y0))2 / sR2
The parameters sD and sR can be related to the mean variance, both in the domain and in the range. The weight WD is dependent on the function domain, the same as the impulse response of a linear filter. However, the weight WR changes matters, creating a filter in the range as well. We know that signals, when constructively added n times, increase in strength by a factor of n. But noise, added n times, increases by a factor of n1/2. Linear smoothing filters assume that nearby pixels have similar values.
This does not necessarily yield constructive signal addition with high signal frequencies present. The range weight, WR, prevents summation components from diluting sinc functions in the Fourier transform. These techniques can be expanded to color images by making the radiosity weight factor dependent on the sum of the squares of color differences in the red, green, and blue signals. This is shown below using an image of a landscape, with color filtering of the image.
Original Image:
|
Random Noise Added:
|
Linear filter:
|
Bilateral filter:
|
4. Conclusions
Each of the filters effectively smoothes the data, with varying degrees of blurring. The bilateral filter has the added benefit of preserving the edges, although at the expense of added computational work and variable results in terms of what types of noise are attenuated.
