Exp 3 New
Exp 3 New
Theory:
Spatial domain enhancement is based on a limited number of pixels (neighbor). This means that
the transformed density is calculated by the grey values of certain points within the
neighbourhood, and thus the enhancement of the spatial domain is often called neighbourhood
activity or neighbourhood processing.
The digital image can be interpreted as a two-dimensional function f (x, y), and the x-y plane
displays spatial position information, called the spatial domain. The filtering operation based on
the x-y space neighbourhood is called space domain filtering.
The filtering method is to shift the filter point-by-point in the image function f (x, y) so that the
centre of the filter matches the point of the filter (x, y). The response of the filter at each point (x,
y) is determined on the basis of the particular content of the filter and by means of a predefined
relationship called a prototype.
If the pixel in the vicinity is measured as a linear operation, it is also called linear space domain
filtering, otherwise it is called nonlinear space domain filtering.
Smoothing Filters
Image smoothing is a digital image processing technique that reduces and suppresses image
noises. In the spatial domain, neighborhood averaging can generally be used to achieve the
purpose of smoothing.
Average Smoothing
First, let’s take a look at the smoothing filter at its simplest form — average template and its
implementation. The points in the 3 × 3 neighborhood centered on the point (x, y) are altogether
involved in determining the (x, y) point pixel in the new image “g”. All coefficients being 1 means
that they contribute the same (weight) in the process of calculating the g(x, y) value. The last
coefficient, 1/9, is to ensure that the sum of the entire template elements is 1. This keeps the new
image in the same grayscale range as the original image (e.g., [0, 255]). Such a “w” is called an
average template.
Gaussian Smoothing
The average smoothing treats the same to all the pixels in the neighborhood. In order to reduce
the blur in the smoothing process and obtain a more natural smoothing effect, it is natural to think
to increase the weight of the template center point and reduce the weight of distant points. So that
the new center point intensity is closer to its nearest neighbors. The Gaussian template is based
on such consideration.
Sharpening Filters
Image sharpening filters highlight edges by removing blur. It enhances the grayscale transition of
an image, which is the opposite of image smoothing. The arithmetic operators of smoothing and
sharpening also testifies the fact. While linear smoothing is based on the weighted summation or
integral operation on the neighborhood, the sharpening is based on the derivative (gradient) or
finite difference.
for i= 1:12
sigma= 4;mask_size = [i i];
H = fspecial('gaussian', mask_size, sigma); subplot(4,3,i); image(H);
colormap summer
set(gca,'XTick',[],'YTick', [],'YDir','normal');
[x,y] = meshgrid(1:i,1:i);
text(x(:),y(:),num2str(H(:)),'HorizontalAlignment','center', 'Color', 'w', 'fontsize',8);
pause (0.5);
end
% Sharpening Filter
for i = 3:14
I_sharp = imsharpen(I_smooth,'Radius',i,'Amount',2); subplot(4,3,i-2); imshow(I_sharp);
title(['Sharp Mask Strength' num2str(i) ]);
end
1. What are the Matlab functions that are available for the spatial filtering operations?
2. What is the significance of sigma in the Gaussian mask?
1. Plot the image smoothing output for mask size 13 x 13 and sigma size 7 along with the code?
2. Write a code to plot the Gaussian smoothing mask in 2D?
RESULT