Digital Image Processing4Word文档格式.docx
《Digital Image Processing4Word文档格式.docx》由会员分享,可在线阅读,更多相关《Digital Image Processing4Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
1)
Computetheforward2DFFTofthe
lenna
imageusingtheMATLABIMAGEPROCESSINGTOOLBOXfunctionFFT2.
2)
LowpassFilterDesign
3)
HighpassFilterDesign
4)
TwoDimensionalFilterDesign
C.Results
Thecommandis:
imglenna=imread('
lenna.gif'
);
imgFFT=fft2(double(imglenna)./255);
imgFFT=fftshift(imgFFT);
ThefunctionfftshiftisusefulforvisualizingtheFouriertransformwiththezero-frequency(直流分量)componentinthemiddleofthespectrum.
a)
Computethelogmagnitudeandphase(i.e.,MATLABIMAGEPROCESSINGTOOLBOXfunction
ANGLE.
imgLogMag=log(abs(imgFFT)+1);
imgPhase=angle(imgFFT);
b)
Computetheinverse2DFFTofthe
imageusingtheMATLABIMAGEPROCESSINGTOOLBOXfunction
IFFT2.
imgIFFT=abs(ifft2(imgFFT))
c)
Plottheoriginal
image,logmagnitude,phase,andinversetransformedimages.
figure;
subplot(221);
imshow(imglenna);
title('
OriginalImage'
subplot(222);
imshow(imgLogMag,[]);
LogMaganitudeofFFT'
subplot(223);
imshow(imgPhase,[]);
PhaseofFFT'
subplot(224);
imshow(imgIFFT,[]);
InverseFFT'
Theresultis:
Figure1:
Original,logmagnitude,phase,andinversetransformedimages
a)UsetheMATLABIMAGEPROCESSINGTOOLBOXfunctionFSPECIALtodesignan11x11Gaussianlowpassfilterwithavalueofsequalto1.3.
LowpassFilter=fspecial('
gaussian'
[1111],1.3);
b)Computetheforward2DFFTofthefilterkernelusingthesamesizeFFTasthatofthelennaimage.UtilizetheSIZEfunctionfromtheexampleonthewebsite.
imgSize=size(imglenna);
imgRows=imgSize
(1);
imgCols=imgSize
(2);
LowpassFFT=fftshift(fft2(LowpassFilter,imgRows,imgCols));
Wecangettherowandcolumnoftheimageandusethefunctionfft2toComputetheforward2DFFTofthefilterkernel
c)Fromtheresultsinb)computeandplotthelogmagnitudeandphaseoftheGaussianLowpassFilterkernel.
subplot(121);
imshow(log(abs(LowpassFFT)+1),[]);
LogMagnitude'
subplot(122);
imshow(angle(LowpassFFT),[]);
Phase'
Figure2:
logmagnitudeandphaseoftheGaussianLowpassFilterkernel
Fromtheresult,wecanfindthecenteroflogmagnitudeisbrightandthephaseisalternatinglightanddarkstripes.
d)Utilizingtheresultsin1)and2b)performthefilteringfunctionG(u,v)=H(u,v)*F(u,v),whereH(u,v)=2DFFToftheGaussianFilterKernel,andF(u,v)=2DFFTofthelennaimage.Plotthelogmagnitudeandphaseofthelowpassfilteredimage.
imgFiltered=LowpassFFT.*imgFFT;
imshow(log(abs(imgFiltered)+1),[]);
imshow(angle(imgFiltered),[]);
Figure3:
logmagnitudeandphaseofthelowpassfilteredimage
e)Computeandplottheinverse2DFFTofthelowpassfilteredimage.
imgLowpassFiltered=abs(ifft2(imgFiltered));
imgLowpassFiltered=circshift(imgLowpassFiltered,[-1.*floor(length(LowpassFilter)/2)-1.*floor(length(LowpassFilter)/2)]);
imshow(imgLowpassFiltered,[]);
InverseFFTofLowpassFilteredImage'
Figure4:
theinverse2DFFTofthelowpassfilteredimage
Fromtheresult,wecanfindtheimageafterlowpassfiliterisfuzzyandthehigh-frequencycomponentsoftheimagearelost.
a)UsetheMATLABIMAGEPROCESSINGTOOLBOXfunctionFSPECIALtodesignalaplacianhighpassfilter.
HighpassFilter=fspecial('
laplacian'
HighpassFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));
c)Fromtheresultsinb)computeandplotthelogmagnitudeandphaseoftheLaplacianhighpassFilterkernel.
imshow(log(abs(HighpassFFT)+1),[]);
imshow(angle(HighpassFFT),[]);
Figure5:
logmagnitudeandphaseoftheLaplacianhighpassFilterkernel
Fromtheresult,wecanfindthecenterofthelogmagnitudeisdarkandthereisacleardividinglineinphase.
d)Utilizingtheresultsin1)and3b)performthefilteringfunctionG(u,v)=H(u,v)*F(u,v),whereH(u,v)=2DFFToftheGaussianFilterKernel,andF(u,v)=2DFFTofthelennaimage.Plotthelogmagnitudeandphaseofthelowpassfilteredimage.Thecommandis:
imgFiltered=HighpassFFT.*imgFFT;
Figure6:
e)Computeandplottheinverse2DFFTofthehighpassfilteredimageusingtheIFFT2function.
imgHighpassFiltered=abs(ifft2(imgFiltered));
imgHighpassFiltered=circshift(imgHighpassFiltered,[-1.*floor(length(HighpassFilter)/2)-1.*floor(length(HighpassFilter)/2)]);
imshow(imgHighpassFiltered,[]);
InverseFFTofHighpassFilteredImage'
Figure7:
InverseFFTofHighpassFilteredImage
Fromtheresult,wecanfindtheimageafterHighpassFilteronlycontainsthecontourwithfrequencycomponents.
Theobjectiveofthisexerciseidtoutilizethefilterdesignfunctions:
1.
Use[f1,f2]=freqspace(21,'
meshgrid'
commandtodesignthesamplinggridforthefilter.
2.
Once1)iscompletedcomputetheradiusvectorsforthefollowingfilterdesignsforthefilterdesignfunctions:
Theradiusvectorsarethefollowing:
Bandpass:
(r<
0.1)|(r>
0.6)
Lowpass:
r>
0.6
Highpass:
r<
[f1,f2]=freqspace(21,'
r=sqrt(f1.^2+f2.^2);
Hd=ones(size(f1));
Bandpass=Hd;
Lowpass=Hd;
Highpass=Hd;
Bandpass((r<
0.1)|(r>
0.6))=0;
Lowpass(r>
0.6)=0;
Highpass(r<
Foreachofthefilteringalgorithmsdothefollowing:
Designabandpass,lowpass,andhighpassfilter
Computetheforward2DFFTofthefilterkernelsusingthesamesizeFFTasthatofthelennaimage.
Utilizethe
SIZE
functionfromtheexampleonthewebsite.
Usetheresultsin2)computeandplotthelogmagnitudeandphaseofeachrespectivefilterkernel.
Utilizingtheresultsin2)performthefilteringfunctionG(u,v)=H(u,v)*F(u,v),whereH(u,v)=2DFFToftherespectivefilterkernel,andF(u,v)=2DFFTofthelennaimage.
Plotthelogmagnitudeandphaseofthefilteredimage.
5)
Computeandplottheinverse2DFFTofeachfilteredimage.
Withthefilterdesignfunctionsfsamp2,thecommandis:
BandpassFilter=fsamp2(Bandpass);
LowpassFilter=fsamp2(Lowpass);
HighpassFilter=fsamp2(Highpass);
BandpassFilterFFT=fftshift(fft2(BandpassFilter,imgRows,imgCols));
LowpassFilterFFT=fftshift(fft2(LowpassFilter,imgRows,imgCols));
HighpassFilterFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));
Theresultsare:
Figure8:
LogMagnitudeandPhaseofbandpass,lowpass,andhighpassfilter
Figure9:
logmagnitude,phaseandinverse2DFFTofeachfilteredimage
Fromtheresults,wecanfindthattheimageafterLowpassFilterisfuzzy.TheimageafterHighpassandBandpassisdistortionbutretaindifferentfrequencycomponentsoftheimage.
Withthefilterdesignfunctionsfwind1,thecommandis:
BandpassFilter=fwind1(Bandpass,hamming(21));
HighpassFilter=fwind1(Highpass,hamming(21));
LowpassFilter=fwind1(Lowpass,hamming(21));
Theresultsare:
Figure10:
LogMagnitudeandPhaseofbandpass,lowpass,andhighpassfilter
Figure11:
Fromtheresults,wecanfindthatimageafterLowpassFilterisbetter.TheimageafterHighpassFilterretainsminimalinformation.TheimageafterBandpassFilterretainpartofinformation.
Withthefilterdesignfunctionsfwind2,thecommandis:
window=fspecial('
21,2);
window=window./max(max(window));
BandpassFilter=fwind2(Bandpass,window);
HighpassFilter=fwind2(Highpass,window);
LowpassFilter=fwind2(Lowpass,window);
Figure12:
Figure13:
Fromtheresults,wecanfindthattheimageafterHighpassFilterretainhighfrequencycomponentsoftheimagecontour.TheimageafterLowpassFilterlostlessinformationcomparedwiththeoriginalimage.AndtheimageafterBandpassFilterisdarkcomparedwiththeoriginalimage.
D.Conclusions
TheeffectofLowpassFilterinFrequencydomainistoremovethehighfrequencynoiseoftheimage,andtheabilitydependsontheformandcutofffrequencyofthefilter.LowpassFilterwillal