Digital Image Processing4.docx
- 文档编号:7476318
- 上传时间:2023-01-24
- 格式:DOCX
- 页数:22
- 大小:1.62MB
Digital Image Processing4.docx
《Digital Image Processing4.docx》由会员分享,可在线阅读,更多相关《Digital Image Processing4.docx(22页珍藏版)》请在冰豆网上搜索。
DigitalImageProcessing4
DigitalImageProcessing
ComputerProjectReportIII
FourierTransformandFrequencyDomainFiltering
StudentID:
20091613310032
Name:
XiaopengJi
Date:
April18,2012
A.Objectives
i.FamiliarwiththeconceptsandprinciplesofFouriertransform;
ii.ProcessingdigitalimagewithMATLABinFrequencydomain;
iii. Familiarwiththefilterdesignfunctions:
fsamp2,fwind1,andfwind2.
B.Methods
Forthisprojectusetheimagelenna.gif.
1) Computetheforward2DFFTofthe lenna imageusingtheMATLABIMAGEPROCESSINGTOOLBOXfunctionFFT2.
2) LowpassFilterDesign
3) HighpassFilterDesign
4) TwoDimensionalFilterDesign
C.Results
1) Computetheforward2DFFTofthe lenna imageusingtheMATLABIMAGEPROCESSINGTOOLBOXfunctionFFT2.
Thecommandis:
imglenna=imread('lenna.gif');
imgFFT=fft2(double(imglenna)./255);
imgFFT=fftshift(imgFFT);
a) Computethelogmagnitudeandphase(i.e.,MATLABIMAGEPROCESSINGTOOLBOXfunction ANGLE.
imgLogMag=log(abs(imgFFT)+1);
imgPhase=angle(imgFFT);
b) Computetheinverse2DFFTofthe lenna imageusingtheMATLABIMAGEPROCESSINGTOOLBOXfunction IFFT2.
imgIFFT=abs(ifft2(imgFFT))
c) Plottheoriginal lenna image,logmagnitude,phase,andinversetransformedimages.
figure;
subplot(221);
imshow(imglenna);
title('OriginalImage');
subplot(222);
imshow(imgLogMag,[]);
title('LogMaganitudeofFFT');
subplot(223);
imshow(imgPhase,[]);
title('PhaseofFFT');
subplot(224);
imshow(imgIFFT,[]);
title('InverseFFT');
Figure1:
Original,logmagnitude,phase,andinversetransformedimages
2) LowpassFilterDesign
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));
c.)Fromtheresultsinb.)computeandplotthelogmagnitudeandphaseoftheGaussianLowpassFilterkernel.
figure;
subplot(121);
imshow(log(abs(LowpassFFT)+1),[]);
title('LogMagnitude');
subplot(122);
imshow(angle(LowpassFFT),[]);
title('Phase');
Figure2:
logmagnitudeandphaseoftheGaussianLowpassFilterkernel
d.)Utilizingtheresultsin1.)and2b.)performthefilteringfunctionG(u,v)=H(u,v)*F(u,v),whereH(u,v)=2DFFToftheGaussianFilterKernel,andF(u,v)=2DFFTofthelennaimage.Plotthelogmagnitudeandphaseofthelowpassfilteredimage.imgFiltered=LowpassFFT.*imgFFT;
figure;
subplot(121);
imshow(log(abs(imgFiltered)+1),[]);
title('LogMagnitude');
subplot(122);
imshow(angle(imgFiltered),[]);
title('Phase');
Figure3:
logmagnitudeandphaseofthelowpassfilteredimage
e.)Computeandplottheinverse2DFFTofthelowpassfilteredimage.
figure;
imgLowpassFiltered=abs(ifft2(imgFiltered));
imgLowpassFiltered=circshift(imgLowpassFiltered,[-1.*floor(length(LowpassFilter)/2)-1.*floor(length(LowpassFilter)/2)]);
imshow(imgLowpassFiltered,[]);
title('InverseFFTofLowpassFilteredImage');
Figure4:
theinverse2DFFTofthelowpassfilteredimage
3) HighpassFilterDesign
a.)UsetheMATLABIMAGEPROCESSINGTOOLBOXfunctionFSPECIALtodesignalaplacianhighpassfilter.
HighpassFilter=fspecial('laplacian');
b.)Computetheforward2DFFTofthefilterkernelusingthesamesizeFFTasthatofthelennaimage.UtilizetheSIZEfunctionfromtheexampleonthewebsite.
HighpassFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));
c.)Fromtheresultsinb.)computeandplotthelogmagnitudeandphaseoftheLaplacianhighpassFilterkernel.
figure;
subplot(121);
imshow(log(abs(HighpassFFT)+1),[]);
title('LogMagnitude');
subplot(122);
imshow(angle(HighpassFFT),[]);
title('Phase');
Figure5:
logmagnitudeandphaseoftheLaplacianhighpassFilterkernel
d.)Utilizingtheresultsin1.)and3b.)performthefilteringfunctionG(u,v)=H(u,v)*F(u,v),whereH(u,v)=2DFFToftheGaussianFilterKernel,andF(u,v)=2DFFTofthelennaimage.Plotthelogmagnitudeandphaseofthelowpassfilteredimage.imgFiltered=HighpassFFT.*imgFFT;
figure;
subplot(121);
imshow(log(abs(imgFiltered)+1),[]);
title('LogMagnitude');
subplot(122);
imshow(angle(imgFiltered),[]);
title('Phase');
Figure6:
logmagnitudeandphaseofthelowpassfilteredimage
e.)Computeandplottheinverse2DFFTofthehighpassfilteredimageusingtheIFFT2function.
figure;
imgHighpassFiltered=abs(ifft2(imgFiltered));
imgHighpassFiltered=circshift(imgHighpassFiltered,[-1.*floor(length(HighpassFilter)/2)-1.*floor(length(HighpassFilter)/2)]);
imshow(imgHighpassFiltered,[]);
title('InverseFFTofHighpassFilteredImage');
Figure7:
InverseFFTofHighpassFilteredImage
4) TwoDimensionalFilterDesign
a.) Theobjectiveofthisexerciseidtoutilizethefilterdesignfunctions:
fsamp2,fwind1,andfwind2.
1. Use[f1,f2]=freqspace(21,'meshgrid');commandtodesignthesamplinggridforthefilter.
2. Once1.)iscompletedcomputetheradiusvectorsforthefollowingfilterdesignsforthefilterdesignfunctions:
fsamp2,fwind1,andfwind2.
a.) Theradiusvectorsarethefollowing:
1.) Bandpass:
(r<0.1)|(r>0.6)
2.) Lowpass:
r>0.6
3.) Highpass:
r<0.6
[f1,f2]=freqspace(21,'meshgrid');
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<0.6)=0;
b.) Foreachofthefilteringalgorithmsdothefollowing:
1.) Designabandpass,lowpass,andhighpassfilter
2.) Computetheforward2DFFTofthefilterkernelsusingthesamesizeFFTasthatofthelennaimage. Utilizethe SIZE functionfromtheexampleonthewebsite.
3.) Usetheresultsin2.)computeandplotthelogmagnitudeandphaseofeachrespectivefilterkernel.
4.) Utilizingtheresultsin2.)performthefilteringfunctionG(u,v)=H(u,v)*F(u,v),whereH(u,v)=2DFFToftherespectivefilterkernel,andF(u,v)=2DFFTofthelennaimage. Plotthelogmagnitudeandphaseofthefilteredimage.
5.) Computeandplottheinverse2DFFTofeachfilteredimage
thefilterdesignfunctions:
fsamp2
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));
figure;
subplot(321);
imshow(log(abs(BandpassFilterFFT)+1),[]);
title('LogMagnitudeofBandpassFilter');
subplot(322);
imshow(angle(BandpassFilterFFT),[]);
title('PhaseofBandpassFilter');
subplot(323);
imshow(log(abs(LowpassFilterFFT)+1),[]);
title('LogMagnitudeofLowpassFilter');
subplot(324);
imshow(angle(LowpassFilterFFT),[]);
title('PhaseofLowpassFilter');
subplot(325);
imshow(log(abs(HighpassFilterFFT)+1),[]);
title('LogMagnitudeofHighpassFilter');
subplot(326);
imshow(angle(HighpassFilterFFT),[]);
title('PhaseofHighpassFilter');
%Applicationoffilterstoimage.
imgFiltered=imgFFT.*BandpassFilterFFT;
figure;
subplot(331);
imshow(log(1+abs(imgFiltered)));
title('LogMagnitudeofBandpassFilteredImage');
subplot(332);
imshow(angle(imgFiltered));
title('PhaseofBandpassFilteredImage');
subplot(333);
imgLennaFiltered=abs(ifft2(imgFiltered));
imgLennaFiltered=circshift(imgLennaFiltered,[-1.*floor(length(BandpassFilter)/2)-1.*floor(length(BandpassFilter)/2)]);
imshow(imgLennaFiltered);
title('InverseFFTofBandpassFilteredImage');
imgFiltered=imgFFT.*LowpassFilterFFT;
subplot(334);
imshow(log10(1+abs(imgFiltered)));
title('LogMagnitudeofLowpassFilteredImage');
subplot(335);
imagesc(angle(imgFiltered));
title('PhaseofLowpassFilteredImage');
subplot(336);
imgLennaFiltered=abs(ifft2(imgFiltered));
imgLennaFiltered=circshift(imgLennaFiltered,[-1.*floor(length(LowpassFilter)/2)-1.*floor(length(LowpassFilter)/2)]);
imshow(imgLennaFiltered);
title('InverseFFTofLowpassFilteredImage');
imgFiltered=imgFFT.*HighpassFilterFFT;
subplot(337);
imshow(log10(1+abs(imgFiltered)));
title('LogMagnitudeofHighpassFilteredImage');
subplot(338);
imshow(angle(imgFiltered));
title('PhaseofHighpassFilteredImage');
subplot(339);
imgLennaFiltered=abs(ifft2(imgFiltered));
imgLennaFiltered=circshift(imgLennaFiltered,[-1.*floor(length(HighpassFilter)/2)-1.*floor(length(HighpassFilter)/2)]);
imshow(imgLennaFiltered);
title('InverseFFTofHighpassFilteredImage');
Figure8:
LogMagnitudeandPhaseofbandpass,lowpass,andhighpassfilter
Figure9:
logmagnitude,phaseandinverse2DFFTofeachfilteredimage
fwind1
BandpassFilter=fwind1(Bandpass,hamming(21));
HighpassFilter=fwind1(Highpass,hamming(21));
LowpassFilter=fwind1(Lowpass,hamming(21));
BandpassFilterFFT=fftshift(fft2(BandpassFilter,imgRows,imgCols));
LowpassFilterFFT=fftshift(fft2(LowpassFilter,imgRows,imgCols));
HighpassFilterFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));
figure;
subplot(321);
imshow(log(abs(BandpassFilterFFT)+1),[]);
title('LogMagnitudeofBandpassFilter');
subplot(322);
imshow(angle(BandpassFilterFFT),[]);
title('PhaseofBandpassFilter');
subplot(323);
imshow(log(abs(LowpassFilterFFT)+1),[]);
title('LogMagnitudeofLowpassFilter');
subplot(324);
imshow(angle(LowpassFilterFFT),[]);
title('PhaseofLowpassFilter');
subplot(325);
imshow(log(abs(HighpassFilterFFT)+1),[]);
title('LogMagnitudeofHighpassFilter');
subplot(326);
imshow(angle(HighpassFilterFFT),[]);
title('PhaseofHighpassFilter');
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Digital Image Processing4