Digital Image Processing3.docx

上传人:b****5 文档编号:8571329 上传时间:2023-01-31 格式:DOCX 页数:14 大小:1.45MB
下载 相关 举报
Digital Image Processing3.docx_第1页
第1页 / 共14页
Digital Image Processing3.docx_第2页
第2页 / 共14页
Digital Image Processing3.docx_第3页
第3页 / 共14页
Digital Image Processing3.docx_第4页
第4页 / 共14页
Digital Image Processing3.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

Digital Image Processing3.docx

《Digital Image Processing3.docx》由会员分享,可在线阅读,更多相关《Digital Image Processing3.docx(14页珍藏版)》请在冰豆网上搜索。

Digital Image Processing3.docx

DigitalImageProcessing3

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

ThefunctionfftshiftisusefulforvisualizingtheFouriertransformwiththezero-frequencycomponentinthemiddleofthespectrum.

 a)  Computethelogmagnitudeandphase(i.e.,MATLABIMAGEPROCESSINGTOOLBOXfunction ANGLE.

Thecommandis:

imgLogMag=log(abs(imgFFT)+1);

imgPhase=angle(imgFFT);

b)  Computetheinverse2DFFTofthe lenna imageusingtheMATLABIMAGEPROCESSINGTOOLBOXfunction IFFT2.

Thecommandis:

imgIFFT=abs(ifft2(imgFFT))

c)  Plottheoriginal lenna image,logmagnitude,phase,andinversetransformedimages.

Thecommandis:

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

Theresultis:

Figure1:

Original,logmagnitude,phase,andinversetransformedimages

2)  LowpassFilterDesign

a)UsetheMATLABIMAGEPROCESSINGTOOLBOXfunctionFSPECIALtodesignan11x11Gaussianlowpassfilterwithavalueofsequalto1.3.

Thecommandis:

LowpassFilter=fspecial('gaussian',[1111],1.3);

b)Computetheforward2DFFTofthefilterkernelusingthesamesizeFFTasthatofthelennaimage.UtilizetheSIZEfunctionfromtheexampleonthewebsite.

Thecommandis:

imgSize=size(imglenna);

imgRows=imgSize

(1);

imgCols=imgSize

(2);

LowpassFFT=fftshift(fft2(LowpassFilter,imgRows,imgCols));

Wecangettherowandcolumnoftheimageandusethefunctionfft2toComputetheforward2DFFTofthefilterkernel

c)Fromtheresultsinb)computeandplotthelogmagnitudeandphaseoftheGaussianLowpassFilterkernel.

Thecommandis:

figure;

subplot(121);

imshow(log(abs(LowpassFFT)+1),[]);

title('LogMagnitude');

subplot(122);

imshow(angle(LowpassFFT),[]);

title('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.

Thecommandis:

imgFiltered=LowpassFFT.*imgFFT;

figure;

subplot(121);

imshow(log(abs(imgFiltered)+1),[]);

title('LogMagnitude');

subplot(122);

imshow(angle(imgFiltered),[]);

title('Phase');

Figure3:

logmagnitudeandphaseofthelowpassfilteredimage

e)Computeandplottheinverse2DFFTofthelowpassfilteredimage.

Thecommandis:

figure;

imgLowpassFiltered=abs(ifft2(imgFiltered));

imgLowpassFiltered=circshift(imgLowpassFiltered,[-1.*floor(length(LowpassFilter)/2)-1.*floor(length(LowpassFilter)/2)]);

imshow(imgLowpassFiltered,[]);

title('InverseFFTofLowpassFilteredImage');

Figure4:

theinverse2DFFTofthelowpassfilteredimage

Fromtheresult,wecanfindtheimageafterlowpassfiliterisfuzzyandthehigh-frequencycomponentsoftheimagearelost.

3)  HighpassFilterDesign

a)UsetheMATLABIMAGEPROCESSINGTOOLBOXfunctionFSPECIALtodesignalaplacianhighpassfilter.

Thecommandis:

HighpassFilter=fspecial('laplacian');

b)Computetheforward2DFFTofthefilterkernelusingthesamesizeFFTasthatofthelennaimage.UtilizetheSIZEfunctionfromtheexampleonthewebsite.

Thecommandis:

HighpassFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));

c)Fromtheresultsinb)computeandplotthelogmagnitudeandphaseoftheLaplacianhighpassFilterkernel.

Thecommandis:

figure;

subplot(121);

imshow(log(abs(HighpassFFT)+1),[]);

title('LogMagnitude');

subplot(122);

imshow(angle(HighpassFFT),[]);

title('Phase');

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;

figure;

subplot(121);

imshow(log(abs(imgFiltered)+1),[]);

title('LogMagnitude');

subplot(122);

imshow(angle(imgFiltered),[]);

title('Phase');

Figure6:

logmagnitudeandphaseofthelowpassfilteredimage

e)Computeandplottheinverse2DFFTofthehighpassfilteredimageusingtheIFFT2function.

Thecommandis:

figure;

imgHighpassFiltered=abs(ifft2(imgFiltered));

imgHighpassFiltered=circshift(imgHighpassFiltered,[-1.*floor(length(HighpassFilter)/2)-1.*floor(length(HighpassFilter)/2)]);

imshow(imgHighpassFiltered,[]);

title('InverseFFTofHighpassFilteredImage');

Figure7:

InverseFFTofHighpassFilteredImage

Fromtheresult,wecanfindtheimageafterHighpassFilteronlycontainsthecontourwithfrequencycomponents.

4)  TwoDimensionalFilterDesign

a)  Theobjectiveofthisexerciseidtoutilizethefilterdesignfunctions:

fsamp2,fwind1,andfwind2.

1. Use[f1,f2]=freqspace(21,'meshgrid');commandtodesignthesamplinggridforthefilter.

2.  Once1)iscompletedcomputetheradiusvectorsforthefollowingfilterdesignsforthefilterdesignfunctions:

fsamp2,fwind1,andfwind2.

  a)  Theradiusvectorsarethefollowing:

Bandpass:

(r<0.1)|(r>0.6)

Lowpass:

  r>0.6

Highpass:

  r<0.6

Thecommandis:

[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.

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

BandpassFilterFFT=fftshift(fft2(BandpassFilter,imgRows,imgCols));

LowpassFilterFFT=fftshift(fft2(LowpassFilter,imgRows,imgCols));

HighpassFilterFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));

Theresultsare:

Figure10:

LogMagnitudeandPhaseofbandpass,lowpass,andhighpassfilter

Figure11:

logmagnitude,phaseandinverse2DFFTofeachfilteredimage

Fromtheresults,wecanfindthatimageafterLowpassFilterisbetter.TheimageafterHighpassFilterretainsminimalinformation.TheimageafterBandpassFilterretainpartofinformation.

Withthefilterdesignfunctionsfwind2,thecommandis:

window=fspecial('gaussian',21,2);

window=window./max(max(window));

BandpassFilter=fwind2(Bandpass,window);

HighpassFilter=fwind2(Highpass,window);

LowpassFilter=fwind2(Lowpass,window);

BandpassFilterFFT=fftshift(fft2(BandpassFilter,imgRows,imgCols));

LowpassFilterFFT=fftshift(fft2(LowpassFilter,imgRows,imgCols));

HighpassFilterFFT=fftshift(fft2(HighpassFilter,imgRows,imgCols));

Theresultsare:

Figure12:

LogMagnitudeandPhaseofbandpass,lowpass,andhighpassfilter

Figure13:

logmagnitude,phaseandinverse2DFFTofeachfilteredimage

Fromtheresults,wecanfindthattheimageafterHighpassFilterretainhighfrequencycomponentsoftheimagecontour.TheimageafterLowpassFilterlostlessinformationcomparedwiththeoriginalimage.AndtheimageafterBandpassFilterisdarkcomparedwiththeoriginalimage.

D.Conclusions

TheeffectofLowpassFilterinFrequencydomainistoremovethehighfrequencynoiseoftheimage,andtheabilitydependsontheformandcutofffrequencyofthefilter.LowpassFilterwillalsocauseimagefuzzybyremovingthenoise.

HighpassFil

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 家庭教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1