8 IP Expt Sharpen Spatial Domain Filtering
8 IP Expt Sharpen Spatial Domain Filtering
THEORY :
Filtering is a technique for modifying or enhancing an image. Spatial domain operation or
filtering (the processed value for the current pixel processed value for the current pixel depends on
both itself and surrounding pixels). Hence Filtering is a neighborhood operation, in which the value
of any given pixel in the output image is determined by applying some algorithm to the values of
the pixels in the neighborhood of the corresponding input pixel. A pixel's neighborhood is some set
of pixels, defined by their locations relative to that pixel.
Linear filtering of an image is accomplished through an operation called convolution. Convolution
is a neighborhood operation in which each output pixel is the weighted sum of neighboring input
pixels. The matrix of weights is called the convolution kernel, also known as the filter. A convolution
kernel is a correlation kernel that has been rotated 180 degrees.
Following steps are used to compute the output pixel at position (x,y):
1. Rotate the correlation kernel 180 degrees about its center element to create a convolution kernel.
2. Slide the center element of the convolution kernel so that it lies on top of the (x,y) element of A.
3. Multiply each weight in the rotated convolution kernel by the pixel of A underneath.
4. Sum the individual products from step 3.
Types of filters:
Low pass filter:
High Pass Filter:
g ω f
w(1,-1) w(1,0) w(1,1)
structures of other details in an image. Thus, the enhanced image contains the original image with
The first order derivative at an image location is approximated using intensity difference
values around a pixel. Examples of operators used for computing intensity differences are the
Robert’s cross gradient, Prewitt, and Sobel operators. Robert’s cross gradient operators use an
even sized mask and hence lack in symmetry. Prewitt operator uses a 3×3 mask, but performs
poorly in the presence of noise. Commonly used gradient operator is the sobel operator. It provides
f (x) is ramp or step non-zero at the onset and end of the non-zero at the onset and end of
ramp; non-zero along the ramp the ramp; zero along the ramp
The sign of the derivative
changes at the onset and end of
the ramp.
For a step transition a line
joining these two values crosses
the horizontal axis (i.e. crosses
zero) midway between the two
extremes.
Formulation
To compute 1st derivative at location x
we subtract the value of the function at To compute 2nd derivative at
that location from the next point. location x we use the previous
and the next points in the
computation.
Taking and
The formulated masks give a zero response in areas of The formulated masks give a zero
constant intensity. response in areas of constant intensity.
Applications:
Image denoising
Image enhancement (i.e., “make the image more vivid”)
Edge detection, etc.
Algorithm:
1. Read input image.
2. For each pixel compute the filtered value according to the filter/mask applied.
3. Do this for whole image.
4. Display the input image and filtered images.
%% Laplacian filter is a second derivative edge detector operator .Laplacian is more sensitive to
%noise than sobel and prewitt. Laplacian calculate the difference of center point to the surrounding
%pixels.
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------