数字图像处理实验2.docx
- 文档编号:26131365
- 上传时间:2023-06-17
- 格式:DOCX
- 页数:20
- 大小:980.78KB
数字图像处理实验2.docx
《数字图像处理实验2.docx》由会员分享,可在线阅读,更多相关《数字图像处理实验2.docx(20页珍藏版)》请在冰豆网上搜索。
数字图像处理实验2
Exercise3
1.Usepicture“Fig0401.tif”todothefollowingquestions:
①Readthepicture,andwritedowntheFouriertransformprogramofit.
>>f=imread('Fig0401.tif');
>>g=fft2(f);
Warning:
FFTNonvaluesofclassUINT8isobsolete.
UseFFTN(DOUBLE(X))orFFTN(SINGLE(X))instead.
>Inuint8.fftnat10
Infft2at19
>>s=abs(g);
>>imshow(s,[])
②Usethefunctionfftshifttocenterthespectrum.
>>fc=fftshift(g);
>>imshow(abs(fc),[])
③Uselogarithmictransformationtoenhancethecenteredspectrum.
>>s2=log(1+abs(fc));
>>imshow(s2,[])
④Visualizethedealingresultsofstep②andstep③.
结果如上
2.GenerateafilterfunctionH
①Usefunctionfspecialtogeneratea‘laplacian’spatialdomainfilterh
>>h=fspecial('laplacian',0.5)
h=
0.33330.33330.3333
0.3333-2.66670.3333
0.33330.33330.3333
②Usefunctionfreqz2toconvertthespatialdomainfilterhtofrequencydomainfilterH.
>>h=freqz2(h);
③Usefunctionfreqz2toshowa3-DperspectiveplotofHandgivetheresult.
>>freqz2(h)
3.UsefunctiondftfilttodotheDFTFilteringwithpicture“lena.bmp”
①Obtainthepaddingparametersofthepictureusefunctionpaddedsize.
>f=imread('lena.bmp');
>>imshow(f)
>>[m,n]=size(f)
m=
256
n=
256
>>PQ=paddedsize(size(f))
PQ=
512512
②Usefunctionfspecialtogeneratea‘unsharp’spatialdomainfilter.
>>h=fspecial('unsharp',0.2)
h=
-0.1667-0.6667-0.1667
-0.66674.3333-0.6667
-0.1667-0.6667-0.1667
③Usefunctionfreqz2toconvertthespatialdomainfilterhtofrequencydomainfilterHof
>>freqz2(h)
④GettheuncenteredformoffrequencydomainfilterH.
>>H=freqz2(h,PQ
(1),PQ
(2));
>>W=ifftshift(H);
>>imshow(abs(H),[])
>>imshow(abs(w),[])
⑤UsefunctiondftfilttodotheDFTFilteringandgivethefinalresult.
>>s=imfilter(double(f),h);
>>d=dftfilt(f,W);
Warning:
FFTNonvaluesofclassUINT8isobsolete.
UseFFTN(DOUBLE(X))orFFTN(SINGLE(X))instead.
>Inuint8.fftnat10
Infft2at21
Indftfiltat17
>>imshow(s,[])
>>imshow(d,[])
4.Trytocomputethedistancesquaredfromeverypointinarectangleofsize7×7totheoriginoftherectanglewithcommanddftuvandgivetheresult.
>>[u,v]=dftuv(7,7);
>>d=u.^2+v.^2
d=
0149941
125101052
458131385
9101318181310
9101318181310
458131385
125101052
5.AssumingM=200,N=200,D0=20,usefunctionlpfiltertodothefollowingquestions:
①Generatea‘ideal’lowpassfilter.
②Generatea‘btw’lowpassfilter.
③Showthecenteredresultofthefilterswhichweregeneratedin①and②,andthentellthedifferencesbetweenthem.
>>h=lpfilter('ideal',200,200,20);
>>p=fftshift(h);
>>iimshow(p)
>>f=lpfilter('btw',200,200,20);
>>k=fftshift(f);
>>imshow(k)
6.3-DVisualizethefilterHgeneratedinquestion5②.
①Usefunctionmeshtodrawthecenteredwireframeplot.
>>mesh(k)
②Usefunctioncolormaptogetagraywireframeplotandabluewireframeplotseparately.
>>colormap(gray)
>>colormap([001])
③Getrideoftheaxisandgridofgraywireframeplot.
>>gridoff
>>axisoff
7.AssumingM=200,N=200,D0=20,usefunctionhpfiltertodothefollowingquestions:
①Generatea‘ideal’highpassfilter.
②Generatea‘gaussian’highpassfilter.
③Showthecenteredresultofthefilterswhichweregeneratedin①and②,andthentellthedifferencesbetweenthem.
>>h=hpfilter('ideal',200,200,20);
>>d=fftshift(h);
>>imshow(d)
>>t=hpfilter('gaussian',200,200,20);
>>g=fftshift(t);
>>imshow(g)
8.3-DVisualizethefilterHgeneratedinquestion7②.
①Usefunctionsurftodrawthecenteredsurfaceplot.
>>t=hpfilter('gaussian',200,200,20);
>>g=fftshift(t);
>>surf(g)
②Smoothandeliminatethemeshlineofthesurfaceplot.
>>shadinginterp
9.UseideallowpassfiltertodoDFTwithpicture“lena.bmp”(D0=50).
>>f=imread('lena.bmp');
>>PQ=paddedsize(size(f));
>>y=lpfilter('ideal',PQ
(1),PQ
(2),50);
>>l=dftfilt(f,y);
Warning:
FFTNonvaluesofclassUINT8isobsolete.
UseFFTN(DOUBLE(X))orFFTN(SINGLE(X))instead.
>Inuint8.fftnat10
Infft2at21
Indftfiltat17
>>imshow(l,[])
10.UseidealhighpassfiltertodoDFTwiththesamepicture“lena.bmp”(D0=50).
>>p=hpfilter('gaussian',PQ
(1),PQ
(2),50);
>>r=dftfilt(f,p);
Warning:
FFTNonvaluesofclassUINT8isobsolete.
UseFFTN(DOUBLE(X))orFFTN(SINGLE(X))instead.
>Inuint8.fftnat10
Infft2at21
Indftfiltat17
>>imshow(r,[])
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字图像 处理 实验