Professional Documents
Culture Documents
Assignmentch4 1292730032457 Phpapp01
Assignmentch4 1292730032457 Phpapp01
008275577
4.22 a) Due to zero padding we add an intensity gradient around the original
borders of the image, which creates a high frequency component. The zeros added
itself is a DC component. Thus the change reflects almost all the frequency
components in the frequency spectrum. There is an increase in the contrast since
the size of the image increases and total information (intensities) remains the same.
Thus the corresponding contrast increases for the padded image.
4.33 The MATLAB code DIP.m creats a transformation of the image in the right to
image in the left. This can be explained as:
Steps involved
Multiplying the image by (-1)(x+y): This is done to centralize the Fourier spectrum
of the image. The 2D spectrum array has the DC component, X[0,0] is at the
upper-left corner and the highest frequency component is X[M/2,N/2] in the
middle. The high frequency components are around the middle, while the low
frequency components are around the four sides. It is preferable to centralize the
spectrum by shifting the spectrum by M/2 vertically and N/2 horizontally, so that
the DC component and the low frequency components are in the middle while the
high frequency components are around the four sides. The mathematical
explanation is given as follows
Suhas Deshpande
008275577
i.e. All spacial components when (x+y) is odd are negative. Thus the Fourier
spectrum transition is shown in figure:
Taking Inverse Fourier Transform: Converting the image back to Spacial domain.
Multiplying real part with (-1)(x+y): Normalizing the image which was centralized
earlier.
4.36 a)
When the original image is filtered using a low pass filter then high pass
filter the image becomes black with some grey area to show the shape of the hand.
The shape details can be seen because the Gaussian filter does not have a steep cut
off. Thus the Gaussian low pass filter leaves behind some part of the high
frequency components. This can be seen as the shape of the hand. The bright ring
Suhas Deshpande
008275577
When the original image is filtered using high pass filter and then low pass
filter the image looks similar to that in the original image except some blur due to
removal of high frequency component. The bright ring appears as bright because it
is accepted by the low pass filter. This is the high frequency component left back
by the Gaussian high pass filter.
In Butterworth filters the cutoff curve is steeper than Gaussian filter thus the
information lost is more than that in the Gaussian filter. In Ideal filters the data is
lost fully thus gives a black image for low-high pass filter order and a white image
for high-low filter order.
Suhas Deshpande
008275577
b) The order of filtering affects the resulting image. This is because the final
transfer function of the filter with two or more filters is product of the individual
filter transfer function.
4.38
Therefore,
Suhas Deshpande
008275577
Suhas Deshpande
008275577
Suhas Deshpande
008275577
Suhas Deshpande
008275577
MATLAB codes
Q4.33
%% Read
I = imread('DIP.tif');
subplot(1,2,1);
imshow(I);
%% convert to -127 to 128
[m,n] = size(I);
one = ones(m,n);
I = double(I);
I = 2.*(I) - 127.*one;
%% multiply by -1 ^ (x+y)
I1(m,n) = 0;
for x = 1:m
for y = 1:n
I1(x,y) = ((-1)^(x+y))*I(x,y);
end
end
%% FFT
F = fft2(I1);
Fc = conj(F);
%% IFFT
J = ifft2(Fc);
[m,n] = size(J);
%% multiply by -1 ^ (x+y)
J1(m,n) = 0;
for x = 1:m
for y = 1:n
J1(x,y) = ((-1)^(x+y)).*J(x,y);
end
end
subplot(1,2,2)
imshow(J1);
Q 4.36
I = imread('hand_xray.tif');
subplot(1,3,1);
imshow(I);
xlabel('Original Image');
lpf = lpfilter('gauss',8,8,25);
hpf = hpfilter('gauss',8,8,25);
lpf = ifft(double(lpf));
hpf = ifft(double(hpf));
subplot(1,3,2);
Igauss = imfilter(I,lpf,'corr');
Igauss = imfilter(Igauss,hpf,'corr');
subplot(1,3,2);
imshow(Igauss);
xlabel('Low Pass-High Pass');
Iguass = imfilter(I,hpf,'corr');
Igauss = imfilter(Igauss,lpf,'corr');
title('Gaussian Filter');
Suhas Deshpande
008275577
subplot(1,3,3);
imshow(Igauss);
xlabel('High Pass-Low pass');
figure;
subplot(1,3,1);
imshow(I);
xlabel('Original Image');
lpf = lpfilter('ideal',8,8,25);
hpf = hpfilter('ideal',8,8,25);
lpf = ifft(double(lpf));
hpf = ifft(double(hpf));
subplot(1,3,2);
Iideal = imfilter(I,lpf,'corr');
Iideal = imfilter(Iideal,hpf,'corr');
subplot(1,3,2);
imshow(Iideal);
xlabel('Low Pass-High Pass');
Iideal = imfilter(I,hpf,'corr');
Iideal = imfilter(Igauss,lpf,'corr');
title('Ideal Filter');
subplot(1,3,3);
imshow(Iideal);
xlabel('High Pass-Low pass');
figure;
subplot(1,3,1);
imshow(I);
xlabel('Original Image');
lpf = lpfilter('btw',8,8,25,2);
hpf = hpfilter('btw',8,8,25,2);
lpf = ifft(double(lpf));
hpf = ifft(double(hpf));
subplot(1,3,2);
Ibtw = imfilter(I,lpf,'corr');
Ibtw = imfilter(Ibtw,hpf,'corr');
subplot(1,3,2);
imshow(Ibtw);
xlabel('Low Pass-High Pass');
Ibtw = imfilter(I,hpf,'corr');
Ibtw = imfilter(Ibtw,lpf,'corr');
title('Butterworth Filter');
subplot(1,3,3);
imshow(Ibtw);
xlabel('High Pass-Low pass');
Q 4.38
I = imread('ckt.tif');
I = imresize(I,[330 334],'bilinear');
I = fft(double(I));
H = hpfilter('gauss',4,4,30);
K = input('Enter K ')
for i = 1:K
J = I;
I =imfilter(I,H);
end
Suhas Deshpande
008275577
I = real(ifft(double(I)));
J = real(ifft(double(J)));
diff = imabsdiff(I,J);
avg = mean(mean(diff))
subplot(1,2,1);
imshow(I);
subplot(1,2,2);
imshow(J);