数字图像处理作业Word下载.docx
- 文档编号:18340858
- 上传时间:2022-12-15
- 格式:DOCX
- 页数:14
- 大小:1.30MB
数字图像处理作业Word下载.docx
《数字图像处理作业Word下载.docx》由会员分享,可在线阅读,更多相关《数字图像处理作业Word下载.docx(14页珍藏版)》请在冰豆网上搜索。
%g2=power(exp(imfilter(log(double(c)),4*fspecial('
average'
2))),1/4);
%几何均值滤波
g2=exp(imfilter(log(double(c)),fspecial('
1)));
subplot(2,4,5),imshow(uint8(g2)),title('
几何均值滤波'
g3=medfilt2(c,[5,5]);
%中值滤波
subplot(2,4,6),imshow(g3),title('
中值滤波'
i=ones(5,5)/20;
g4=imfilter(c,i);
subplot(2,4,7),imshow(g4),title('
修正后的α均值滤波'
运行结果:
(2)matlab程序代码(使用含有自己的图片)
\Users\SUN\Desktop\i.jpg'
%读图像
a1=rgb2gray(a);
b=imnoise(a1,'
%算术均值滤波
2、
(1)matlab程序代码(使用电路板图片)
A=imread('
\DocumentsandSettings\Administrator\桌面\a.tif'
B=imnoise(A,'
0,1000/255^2);
%加入0均值,方差1000的噪声
subplot(2,3,1),imshow(A),title('
%显示图片
subplot(2,3,2),imshow(B),title('
h=ones(7,7)/49;
g1=imfilter(B,h);
subplot(2,3,4),imshow(g1),title('
);
%算数均值滤波
g2=power(exp(imfilter(log(double(B)),49*fspecial('
7))),1/49);
%几何均值滤波
subplot(2,3,5),imshow(uint8(g2)),title('
forn=1:
1:
444
form=1:
D=B(n:
n+6,m:
m+6);
C=B(n+3,m+3);
a=var(double(D(:
)));
b=sum(double(D(:
)))/numel(D);
E=C-1000/225^2/a*(C-b);
F(n,m)=uint8(E);
end
end
g3=F;
subplot(2,3,6),imshow(g3),title('
自适应噪声消减滤波'
)%自适应噪声消减滤波
\DocumentsandSettings\Administrator\桌面\i.jpg'
%读图像
I=rgb2gray(A);
B=imnoise(I,'
%加入0均值,方差1000的噪声
subplot(2,3,1),imshow(I),title('
%显示图片
%算数均值滤波
359%自适应噪声消减滤波
398
)
3、
(1)matlab程序代码(使用电路板图片)
0.25);
%加入概率Pa=Pb=0.25的椒盐噪声污染了的图像
subplot(2,2,1),imshow(a),title('
subplot(2,2,2),imshow(b),title('
椒盐噪声污染'
g1=medfilt2(b,[7,7]);
subplot(2,2,3),imshow(g1),title('
[Im,In]=size(b);
%自适应中值滤波
nmin=3;
nmax=7;
Imf=b;
I_ex=[zeros((nmax-1)/2,In+(nmax-1));
zeros(Im,(nmax-1)/2),b,zeros(Im,(nmax-1)/2);
zeros((nmax-1)/2,In+(nmax-1))];
forx=1:
Im
fory=1:
In
forn=nmin:
2:
nmax
Sxy=I_ex(x+(nmax-1)/2-(n-1)/2:
x+(nmax-1)/2+(n-1)/2,y+(nmax-1)/2-(n-1)/2:
y+(nmax-1)/2+(n-1)/2);
Smax=max(max(Sxy));
Smin=min(min(Sxy));
Smed=median(median(Sxy));
if(Smed>
Smin&
&
Smed<
Smax)
if(Imf(x,y)<
=Smin||Imf(x,y)>
=Smax)
Imf(x,y)=Smed;
break
subplot(2,2,4),imshow(Imf),title('
自适应中值滤波'
%自适应中值滤波
clear
二、图像增强
(1)频域锐化增强
matlab程序代码:
I=imread('
\Users\SUN\Desktop\b.tif'
subplot(1,2,1),imshow(I);
title('
原图像'
s=fftshift(fft2(I));
[a,b]=size(s);
a0=round(a/2);
b0=round(b/2);
d=10;
p=0.2;
q=0.5;
fori=1:
a
forj=1:
b
distance=sqrt((i-a0)^2+(j-b0)^2);
ifdistance<
=dh=0;
elseh=1;
end;
s(i,j)=(p+q*h)*s(i,j);
end;
s=uint8(real(ifft2(ifftshift(s))));
subplot(1,2,2),imshow(s+I);
title('
频域增强'
(2)空域锐化增强
I=im2double(I);
figure;
)
[heightwidthR]=size(I);
fori=2:
height-1
forj=2:
width-1
L(i,j)=4*I(i,j)-I(i-1,j)-I(i+1,j)-I(i,j-1)-I(i,j+1);
end
end
T=L;
G(i,j)=0.3*L(i,j)+0.7*I(i,j);
if(L(i,j)<
0.12)
L(i,j)=1;
elseL(i,j)=0;
[m,n]=size(T);
AL(1:
m,1:
n)=I(1:
n)+T(1:
n);
subplot(1,2,2),imshow(AL);
空域增强'
三、人脸检测
image_source=imread('
\Users\SUN\Desktop\h.jpg'
figure,imshow(image_source),title('
源图像'
image_templet=imread('
R=image_source(:
:
1);
G=image_source(:
2);
B=image_source(:
3);
R1=image_templet(:
G1=image_templet(:
B1=image_templet(:
image3=zeros(size(image_source));
image4=image_source;
R3=image3(:
G3=image3(:
B3=image3(:
r=30;
%颜色半径30
[m,n]=size(R1);
sum=0;
m
n
sum=sum+double(R1(i,j));
average_R=sum/(m*n);
%R模板平均灰度
sum=sum+double(G1(i,j));
average_G=sum/(m*n);
%G模板平均灰度
sum=sum+double(B1(i,j));
average_B=sum/(m*n);
%B模板平均灰度
[m,n]=size(R);
ifR(i,j)<
=average_R+r&
R(i,j)>
=average_R&
G(i,j)<
=average_G+r&
G(i,j)>
=average_G&
B(i,j)<
=average_B+r&
B(i,j)>
=average_B
R3(i,j)=R(i,j);
=average_R-r&
=average_G-r&
=average_B&
=average_B-r
ifG(i,j)<
R(i,j)<
B(i,j)<
G3(i,j)=G(i,j);
ifG(i,j)<
ifB(i,j)<
=average_G
B3(i,j)=B(i,j);
=average_B-r&
=average_G-r
image3(:
1)=R3;
2)=G3;
3)=B3;
figure,imshow(image3),title('
分通道检测图像'
image3gray=rgb2gray(image3);
figure,imshow(image3gray),title('
分通道检测图像灰度化'
image3bw=im2bw(image3gray);
SE1=strel('
square'
%腐蚀
image3erode=imerode(image3bw,SE1,'
same'
figure,imshow(image3erode),title('
分通道检测图像二值化腐蚀'
SE2=strel('
image3dilate=imdilate(image3erode,SE2,'
%膨胀
figure,imshow(image3dilate),title('
分通道检测图像二值化膨胀'
[L,num]=bwlabel(image3dilate,4);
%区域标记
temp1=zeros(1,num);
if(num>
0)
fork=1:
num
fori=1:
if(L(i,j)==k)
temp1(1,k)=temp1(1,k)+1;
%面积
if(temp1(1,k)<
600)%如果不用腐蚀膨胀则改小此值(600100)
temp1(1,k)=0;
L(i,j)=0;
figure,imshow(L);
去掉小面积区域'
disk'
image3dilate=imdilate(L,SE2,'
figure,imshow(image3dilate);
膨胀面积区域'
L=imfill(image3dilate,'
holes'
填充区域'
if(L(i,j)==0)
image4(i,j,:
)=0;
figure,imshow(image4);
分割区域'
holdon;
figure,imshow(image_source);
最终图像'
[l,num]=bwlabel(L,8);
status=regionprops(l,'
BoundingBox'
rectangle('
Position'
status(i).BoundingBox,'
edgecolor'
'
r'
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字图像 处理 作业