Lab 1
Lab 1
Lab
Exercise 1.1
% Exercise 1
f=imread('building-600by600.tif');
figure, imshow(f)
f = double(f);
F = fft2(f);
S = fftshift(log(1 + abs(F)));
figure, imshow(S, [ ])
This shows that the image clearly has the Fourier transform.
1.2
h=
1 0 -1
2 0 -2
1 0 -1
h = fspecial('sobel')'; display(h)
1.3
% Exercise 1.3
plot(h);
>> PQ = paddedsize(size(f));
H1 = ifftshift(H);
figure, imshow(abs(H), [ ])
figure, imshow(abs(H1), [ ])
These commands show the frequency of the image, and the inverse Fourier transform shift.
1.5
% Exercise 1.5
gs = imfilter(f, h);
1.6
1.7
% Exercise 1.7
imshow(gs, [])
imshow(gf, [])
Exercise 1.8
% Exercise 1.7
imshow(abs(gs), [])
imshow(abs(gf), [])
1.9
% Exercise 1.7
imshow(abs(gs), [])
imshow(abs(gf), [])
2.1
LPI = fftshift(lpfilter('ideal', 500, 500, 50)); figure, LPI_plot=surf(LPI(1:10:end, 1:10:end)); axis off
set(LPI_plot, 'FaceColor',[160/255 195/255 170/255], 'FaceAlpha',1,... 'EdgeAlpha',0.5) figure,
imshow(LPI,[])
2.2
LPB = fftshift(lpfilter('butterworth', 500, 500, 50,2)); figure, LPB_plot=surf(LPB(1:10:end, 1:10:end)); axis
off set(LPB_plot, 'FaceColor',[160/255 195/255 170/255], 'FaceAlpha',1,... 'EdgeAlpha',0.5) figure,
imshow(LPB,[])
2.3
axis off
'EdgeAlpha',0.5)
figure, imshow(LPB,[])
3.1
Exercise 3.2
This exercise showed that the butterworth filter is the clearest, since the others create quite a bit of
distortion and lower frequency.
Exercise 4
These two images look different because they have clear filters applied to the left image.
% Exercise 4
f=imread('testpattern512.tif');
PQ=paddedsize(size(f));
D0=50;
%Gaussian lowpass transfer function.
HLPG=hpfilter('Gaussian',PQ(1),PQ(2),D0);
%filter the image
gLPG=dftfilt(f,HLPG,'symmetric');
figure,imshow(gLPG)
%scale the intensities to the range [0,1]
gLPGS=intensityScaling(gLPG);
figure,imshow(gLPGS)
Exercise 5
% Exercise 5
f=imread('chestXray-dark.tif');
figure(1),imshow(f)
PQ=paddedsize(size(f));
D0=round(0.05*PQ(1));
H=hpfilter('butterworth',PQ(1),PQ(2),D0,2);
ghp=dftfilt(f,H,'symmetric');
ghps=intensityScaling(ghp);
figure(2), imshow(ghps)
Hemp=0.5 + 2.0*H;
gemp=dftfilt(f,Hemp,'symmetric');
gemps=intensityScaling(gemp);
figure(3),imshow(gemps)
geq=histeq(gemp,128);
figure(4),imshow(geq)
The first image is the normal xray, the second image is the filter with butterworth applie, the third image
is the image with the discrete time filter, and the last image shows an equalized version of the image.