Experiment No 14
Experiment No 14
EXPERIMENT NO.14
Filtering with imfilter
Introduction :
imfilter: The syntax in matlab is:
B = imfilter(A,H,OPTION1,OPTION2,....)
Boundary Options
Option1 Description
X Input array values outside the bounds of the array are implicitly assumed to have
the value X. When no boundary option is specified, imfilter uses X = 0.
'symmetric' Input array values outside the bounds of the array are computed by mirror-
reflecting the array across the array border.
'replicate' Input array values outside the bounds of the array are assumed to equal the
nearest array border value.
'circular' Input array values outside the bounds of the array are computed by implicitly
assuming the input array is periodic.
Output Size Options
Option Description
'same' The output array is the same size as the input array. This is the default behavior
when no output size options are specified.
'full' The output array is the full filtered result, and so is larger than the input array.
as the filter. A convolution kernel is a correlation kernel that has been rotated 180 degrees.
Procedure:
1- Read the image
I = imread(peppers.png);
2- Design the average filter 5x5
h = ones(5,5)/25;
3- Apply the imfilter in coorelation model
I2 = imfilter(I,h);
4- Apply the imfilter in covelution model
I3 = imfilter(I,h,'conv');
5- Display the image in step 3 and 4
subplot(131),imshow(I), title('Original Image');
subplot(132), imshow(I2), title('Filtered Image with corr')
subplot(133), imshow(I3), title('Filtered Image with conv')
Report:
1- Write a code in Matlab to apply imfilter with gray scale image and average filter in mask
7x7 and replication mode?
2- Write a code in Matlab to apply imfilter with gray scale image and average filter in mask
7x7 and symmatric mode?
3- Write a code in Matlab to apply imfilter with gray scale image and average filter in mask
7x7 and circular mode?
4- Discuss the result in all steps.