Top Banner
Suhas Deshpande 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. b) Padding of zeros means adding a DC component (constant value) along both the axes. Thus there is increase in the signal strength both along the x axis and y axis corresponding to the zeros padded along y axis and x axis. 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
10

Frequency Image Processing

May 31, 2015

Download

Technology

suhas deshpande

Selectrd Problem solutions for Ch 4(Frequency Domain Image Processing) of Digital Image
Processing 3E by Gonzalez and Woods
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Frequency Image Processing

Suhas Deshpande

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.

b) Padding of zeros means adding a DC component (constant value) along

both the axes. Thus there is increase in the signal strength both along the x axis and

y axis corresponding to the zeros padded along y axis and x axis.

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

Page 2: Frequency Image Processing

Suhas Deshpande

008275577

i.e. All spacial components when (x+y) is odd are negative. Thus the Fourier

spectrum transition is shown in figure:

Computing the DFT: Converts the image to frequency domain.

Taking Complex Conjugate of Transform: The Fourier Transform consists of two

components; real and imaginary. Conjugating the conjugate negates the imaginary

part. Thus the magnitude of the Transform is unchanged but the phase of the

transform is reversed by 180˚ i.e. causing a rotation of 180˚ in the image.

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

Page 3: Frequency Image Processing

Suhas Deshpande

008275577

in the image cannot be seen as bright in filtered image because DC component is

filtered out by the filter.

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.

The same process is repeated with Butterworth and Ideal filters.

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.

Page 4: Frequency Image Processing

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.

F1(u,v) = [lp(u,v)]*[hp(u,v)]; F2(u,v) = [hp(u,v)]*[lp(u,v)]

Since matrix multiplication is not commutative.

The product involves the transfer function matrices and matrix

multiplication is not commutative. Thus the order of the filter affects the final

transfer function of the filter and thus the filtering process. The two images

resulting from the order of filtering reversals are different as explained earlier.

4.38

The transfer function of a Gaussian high pass filter is given by

Thus K times high pass filter the transfer function is

Therefore,

Page 5: Frequency Image Processing

Suhas Deshpande

008275577

Page 6: Frequency Image Processing

Suhas Deshpande

008275577

Page 7: Frequency Image Processing

Suhas Deshpande

008275577

Page 8: Frequency Image Processing

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');

Page 9: Frequency Image Processing

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

Page 10: Frequency Image Processing

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);