数图 图像增强.docx

上传人:b****6 文档编号:14032621 上传时间:2023-06-20 格式:DOCX 页数:16 大小:261.92KB
下载 相关 举报
数图 图像增强.docx_第1页
第1页 / 共16页
数图 图像增强.docx_第2页
第2页 / 共16页
数图 图像增强.docx_第3页
第3页 / 共16页
数图 图像增强.docx_第4页
第4页 / 共16页
数图 图像增强.docx_第5页
第5页 / 共16页
数图 图像增强.docx_第6页
第6页 / 共16页
数图 图像增强.docx_第7页
第7页 / 共16页
数图 图像增强.docx_第8页
第8页 / 共16页
数图 图像增强.docx_第9页
第9页 / 共16页
数图 图像增强.docx_第10页
第10页 / 共16页
数图 图像增强.docx_第11页
第11页 / 共16页
数图 图像增强.docx_第12页
第12页 / 共16页
数图 图像增强.docx_第13页
第13页 / 共16页
数图 图像增强.docx_第14页
第14页 / 共16页
数图 图像增强.docx_第15页
第15页 / 共16页
数图 图像增强.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

数图 图像增强.docx

《数图 图像增强.docx》由会员分享,可在线阅读,更多相关《数图 图像增强.docx(16页珍藏版)》请在冰点文库上搜索。

数图 图像增强.docx

数图图像增强

实验2图像增强

一、实验目的

1、掌握图像增强方法(点操作、直方图均衡、局域操作)

2、掌握伪彩色处理

3、理解点扩展函数恢复方法

二、实验内容

使用Matlab或者VC实现下面几个内容:

(1)根据灰度映射关系进行灰度调整。

例如根据下面变换曲线,写出变换表达式,并进行图像灰度映射增强。

改变参数看看增强结果有何变化。

(2)实现直方图均衡算法

(3)实现局域变换增强。

(平均平滑、高斯平滑、中指滤波)

(4)实现真彩图像转换为灰度图像,实现伪彩色处理。

例如可以根据下图进行伪彩色变换,变换的结果可以使真彩图像,也可以是索引图像,比较结果有何不同。

(5)

(6)模拟匀速直线运动模糊并进行恢复

 

三、实验结果

使用Matlab或者VC实现下面几个内容:

1、根据灰度映射关系进行灰度调整。

例如根据下面变换曲线,写出变换表达式,并进行图像灰度映射增强。

改变参数看看增强结果有何变化。

I=imread('111.bmp');

[d1,d2,d3]=size(I);

if(d3>1)

I=rgb2gray(I);

end

Im=double(I);

A=0.5;B=0;

darker=Im*A+B;

A=1;B=0;

mover=Im*A+B;

A=1.5;B=0;

lighter=Im*A+B;

A=-1;B=255;

reverser=Im*A+B;

J1=uint8(darker);

J2=uint8(mover);

J3=uint8(lighter);

J4=uint8(reverser);

subplot(2,3,1),imshow(I);title('原图');

subplot(2,3,2),imshow(J1);title('减小对比度');

subplot(2,3,5),imshow(J2);title('灰度值上移');

subplot(2,3,3),imshow(J3);title('增大对比度');

subplot(2,3,6),imshow(J4);title('反相');

2、实现直方图均衡算法

I=imread('111.jpg');

[d1,d2,d3]=size(I);

if(d3>1)

I=rgb2gray(I);

end

I=double(I)/255;

Im=uint8(255*I*0.5+0.5);

subplot(2,2,1);imshow(Im);title('原图');

gp=zeros(1,256);

fori=1:

256

gp(i)=length(find(Im==(i-1)))/(d1*d2);

end

subplot(2,2,2);

bar(0:

255,gp);

title('原图恢复直方图');

newGp=zeros(1,256);

S1=zeros(1,256);

S2=zeros(1,256);

tmp=0;

fori=1:

256;

tmp=tmp+gp(i);

S1(i)=tmp;

S2(i)=round(S1(i)*256);

end

fori=1:

256

newGp(i)=sum(gp(find(S2==i)));

end

subplot(2,2,4);

bar(0:

255,newGp);

title('均衡化后直方图');

newGrayPic=Im;

fori=1:

256

newGrayPic(find(Im==(i-1)))=S2(i);

end

subplot(2,2,3);imshow(newGrayPic);title('均衡化后');

3、实现局域变换增强。

(平均平滑、高斯平滑、中指滤波)

平均平滑

x=imread('111.jpg');

h=fspecial('average');

y=imfilter(x,h);

subplot(1,2,1);

imshow(x);

subplot(1,2,2);

imshow(y);

高斯平滑

I=rgb2gray(imread('111.jpg'));

subplot(2,2,1);

imshow(I);

xlabel('a.原图');

I=imnoise(I,'gaussian',0,0.005);

subplot(2,2,2);

imshow(I);

xlabel('b.加入高斯噪声');

r=50;

Im=double(I);

F=fft2(Im);

F_result=fftshift(F);

g=F_result;

[m,n]=size(F_result);

M=fix(m/2);

N=fix(n/2);

foru=1:

m

forv=1:

n

D=sqrt((u-M)^2+(v-N)^2);

H=1-exp(-D^2/(2*r^2));

F_result(u,v)=F_result(u,v)*H;

end

end

G_result=fftshift(F_result);

g_result=fft2(G_result);

f=real(g_result);

f=uint8(f);

subplot(2,2,3);

imshow(f);

xlabel('c.高斯高通滤波后');

subplot(2,2,4);

imshow(f);

xlabel('d.高斯低通滤波后');

S=0;

S1=0;

fori=1:

M

forj=1:

N

L=(abs(F_result(i,j)))^2;

S=S+L;

end

end

fori=1:

M

forj=1:

N

L1=(abs(g(i,j)))^2;

S1=S1+L;

end

end

I=rgb2gray(imread('1.jpg'));

I=imnoise(I,'gaussian',0,0.005);

r=5;

Im=double(I);

F=fft2(Im);

F_result=fftshift(F);

g=F_result;

[m,n]=size(F_result);

N=fix(n/2);

foru=1:

m

forv=1:

n

D=sqrt((u-M)^2+(v-N)^2);

H=1-exp(-D^2/(2*r^2));

F_result(u,v)=F_result(u,v)*H;

end

end

G_result=fftshift(F_result);

g_result=fft2(G_result);

f=real(g_result);

f=uint8(f);

subplot(2,2,4);

imshow(f);

xlabel('d.高斯低通滤波后');

S=0;

S1=0;

fori=1:

M

forj=1:

N

L=(abs(F_result(i,j)))^2;

S=S+L;

end

end

fori=1:

M

forj=1:

N

L1=(abs(g(i,j)))^2;

S1=S1+L1;

end

end

中值滤波

I=imread('1.jpg')

I=rgb2gray(I);

J1=imnoise(I,'gaussian',0,0.005);

subplot(1,2,1);imshow(I);

xlabel('原图');

K2=medfilt2(J1);

subplot(1,2,2);imshow(K2);

xlabel('中值滤波后')

4、实现真彩图像转换为灰度图像,实现伪彩色处理。

例如可以根据下图进行伪彩色变换,变换的结果可以使真彩图像,也可以是索引图像,比较结果有何不同。

5、

I=imread('1.jpg');

I=double(I);

[MN]=size(I);

L=256;

fori=1:

M

forj=1:

N

ifI(i,j)

R(i,j)=0;

G(i,j)=4*I(i,j);

B(i,j)=L;

elseifI(i,j)<=L/2

R(i,j)=0;

G(i,j)=L;

B(i,j)=-4*I(i,j)+2*L;

elseifI(i,j)<=3*L/4

R(i,j)=4*I(i,j)-2*L;

G(i,j)=L;

B(i,j)=0;

else

R(i,j)=L;

G(i,j)=-4*I(i,j)+4*L;

B(i,j)=0;

end

end

end

end

end

fori=1:

M

forj=1:

N

G2C(i,j,1)=R(i,j);

G2C(i,j,2)=G(i,j);

G2C(i,j,3)=B(i,j);

end

end

G2C=G2C/256;

figure;

imshow(G2C);

6、模拟匀速直线运动模糊并进行恢复

I=imread('1.jpg');

subplot(2,3,1);

imshow(I,[]);

title('原图像');

PSF=fspecial('motion',40,75);

MF=imfilter(I,PSF,'circular');

noise=imnoise(zeros(size(I)),'gaussian',0,0.001);

MFN=imadd(MF,im2uint8(noise));

subplot(2,3,2);

imshow(MFN,[]);

title('运动模糊图像');

NSR=sum(noise(:

).^2)/sum(MFN(:

).^2);

subplot(2,3,3);

imshow(deconvwnr(MFN,PSF,NSR),[]);

title('逆滤波复原');

subplot(2,3,4);

imshow(deconvwnr(MFN,PSF,NSR),[]);

title('维纳滤波复原');

NP=0.002*prod(size(I));

[reg1LAGRA]=deconvreg(MFN,PSF,NP/3.0);

subplot(2,3,5);

imshow(reg1);

title('最小二乘滤波复原');

四、实验小结

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

当前位置:首页 > 职业教育 > 中职中专

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2