您的当前位置:首页正文

福建农林大学数字图像实验三

2020-01-21 来源:步旅网
福建农林大学计算机与信息学院

课程名称:姓 名:系:专 业:年 级:学 号:指导教师:职 称:实验报告

数字图像处理(双语) (Digital Image Processing)

王智勇

计算机科学与技术

计算机科学与技术 2012级 3126010032 王长缨 副教授 2014~2015学年下学期

福建农林大学计算机与信息学院实验报告

系: 计算机科学与技术 专业:计算机科学与技术 年级:2012级 姓名: 王智勇 学号: 3126010032 实验室号 田家炳510 计算机号 33 实验时间:2015年5月 20 日 指导教师签字: 成绩:

Experiment III Implement convolution filter to obtain image smoothing as well as

edge enhancement (validated)(2 periods)

Objective

Get fully understand of the notion of the convolution and its applications on image smoothing and enhancement

Methodology

Convolute an image with different dedicated designed function to get image smoothing and image edge enhancement by means of MATLAB.

Environment

Hardware: General PC

Operating system: Windows XP

Calculating platform: MATLAB 6.5 or higher version

Experiment in detail:

1.Image smoothing with different size of spatial masks

A. Image smoothing with arithmetic averaging filter (spatial convolution).

function [r]=avgfilter(gray,n) a(1:n,1:n)=1;

[row,col]=size(gray); gray1=double(gray); gray2=gray1; for i=1:row-n+1 for j=1:col-n+1

c=gray1(i:i+(n-1),j:j+(n-1)).*a; s=sum(sum(c));

gray2(i+(n-1)/2,j+(n-1)/2)=s/(n*n); end end

r=uint8(gray2);

B. Make a comparison of noise reduction by both median filter and averaging filter.

function [r]=midfilter(gray,n) [row,col]=size(gray); gray1=double(gray); gray2=gray1; for i=1:row-n+1 for j=1:col-n+1

c=gray1(i:i+(n-1),j:j+(n-1)); e=c(1,:); for u=2:n

e=[e,c(u,:)]; end

mm=median(e);

gray2(i+(n-1)/2,j+(n-1)/2)=mm; end end

r=uint8(gray2);

2.Edge enhancement by means of spatial filtering.

A. Develop a program to implement a Gradient Mask to obtain edge of an object (in compare with the function provided by Matlab)

>> subplot(231);imshow(xx);title('原图'); >> eSoble=edge(xx,'sobel');

>> subplot(232);imshow(eSoble);title('Soble图'); >> ePrewitt=edge(xx,'prewitt');

>> subplot(233);imshow(ePrewitt);title('Prewitt图'); >> eRobert=edge(xx,'roberts');

>> subplot(234);imshow(eRobert);title('Robert图'); >> eLog=edge(xx,'log');

>> subplot(235);imshow(eLog);title('Log图'); >> eCanny=edge(xx,'canny');

>> subplot(236);imshow(eCanny);title('Canny图');

B. Image enhancement with High-Boost Filtering Mask and compare with the result of the operation defined by equation 2f(x,y)f(x,y) g(x,y)2 f(x,y)f(x,y)

>> subplot(131);imshow(xx);title('原图'); >> H=[-1 -1 -1;-1 -9 -1;-1 -1 -1]; >> xhigh=filter2(H,xx);

>> subplot(132);imshow(xhigh,[]);title('高通滤波'); >> xxdouble=double(xx); >> M=[1 1 1;1 1 1;1 1 1]/9; >> xmask=double(xhigh); >> xmask2=filter2(M,xmask); >> xm=xmask-xmask2;

>> subplot(133);imshow(xm,[]);title('掩膜处理');

Experimental result

Data in whatever chart, image and other form is required with explanations in English respectively.

Questions and discussions

A theoretical and experimental discussion in English for each question is required.

因篇幅问题不能全部显示,请点此查看更多更全内容