Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this task you will learn how image blurring can be accomplished more efficien

ID: 3796544 • Letter: I

Question

In this task you will learn how image blurring can be accomplished more efficiently using MATLAB's built-in functions. Please read the help files of fspecial and imfilter. The first of these functions is used to construct the kernel and the second one is used to perform blurring (or. more generally, filtering). First, construct a 3'3 averaging kernel using H = fspecial('average', [3 3]); How docs H compare with the 3'3 matrix shown in Task 1? Then, perform image blurring using X3_l = imfilter(X, H, 'symmetric', 'same'); Make sure you understand what each argument of imfilter means. Note that there is no need to extend the image this time, imfilter docs that automatically based on the kernel size. How does the resulting image compare with that obtained in Task 1? Repeat fspecial and imfilter for the 5'5 averaging kernel, store the resulting image in X3_2. and compare the result with the image obtained in Task 2. Finally, using fspecial, create a Gaussian kernel of size 5'5 with. Then perform blurring using imfilter, store the resulting image in X3_3 and compare it with the image from Task 2. as well as X3_2.

Explanation / Answer

As you have not mention about the image given in task 1 and task 2, the comparision of imagge in task 3 with task 1 and 2 is not possible.

below is the explanation of fspecial and imfilter with the example code

fspecial
This function is used to create a 2D special filters

the syntax of this function is

h = fspecial(type)
or
h = fspecial(type,parameters)


in
h = fspecial(type) it creates a 2D filter, h of the type specified.Function returns h as a corelation kernel, this is appropriate form to use with imfilter.
the different values for type can be

'prewitt' for a Prewitt horizontal edge-emphasizing filter
'gaussian' for a Gaussian lowpass filter
'average' for an averaging filter
'laplacian' for a filter approximating the two-dimensional Laplacian operator
'sobel' for a Sobel horizontal edge-emphasizing filter
'log' for a Laplacian of Gaussian filter
'unsharp' for an unsharp contrast enhancement filter


Similarly the h = fspecial(type,parameters) works same but according to parametrs specified
eg

h = fspecial('average',hsize) this returns a averaging filter h, of size hsize, where hsize can be a vector n rows and m column, the default value of hsize is [3 3]

imfilter

this is used for multidimensional image filtering

syntax of this is

B = imfilter (A,H)
or
B = imfilter(A,H,opt1,opt2,...)

In the above syntax A is the multidimensional array , with H as multidimensional filter.
In other syntax the options can be with respect to boundary, correlation and convolution or output.

the boundary options are

X for 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' for   Input array values outside the bounds of the array are computed by mirror-reflecting the array across the array border.
'replicate' for   Input array values outside the bounds of the array are assumed to equal the nearest array border value.
'circular' for   Input array values outside the bounds of the array are computed by implicitly assuming the input array is periodic.


correlation and convolution option

'corr' for imfilter performs multidimensional filtering using correlation, which is the same way that filter2 performs filtering. When no correlation or convolution option is specified, imfilter uses correlation.
'conv' for imfilter performs multidimensional filtering using convolution.


output size options are

'same' for The output array is the same size as the input array. This is the default behavior when no output size options are specified.
'full' for The output array is the full filtered result, and so is larger than the input array.


Example code


    I = imread('sunflower.tif');                 %to read the image
    subplot(2,2,1);imshow(I);title('Original Image');     %to display the original image
    H = fspecial('average',[3 3]);                               % returns an averaging filter using ones(n(1),n(2))/(n(1)*n(2))
    X3_1 = imfilter(X,H,'symmetric','same');           % returns a mirror-reflected image with same size as input
    subplot(2,2,2);imshow(X3_1);title('symmetrically reflected Image');

in above example code you can change the hsize of fspecial to [5 5] for 5*5 matric kernel, and type to Gaussian.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote