资源描述:
《MATLAB实现数字图像增强.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验4MATLAB实现数字图像增强姓名:**班级:***学号:***-8-直方图变换(直方图均衡化和直方图规定化)实现图像增强,histeq,imhist命令,编写.m文件,完成以下功能任选一幅灰度图像imread,显示原图像及直方图,然后对图像进行均衡化处理,并显示处理后图像及其直方图,与原图像作比较;仿教材或1实例,对原图做直方图规定化,观察其效果。实验程序:%直方图均衡化I=imread('moon.tif')J=histeq(I)I=imread('moon.tif')J=histeq(I)
2、subplot(2,2,1),imshow(I),title('原始图像')subplot(2,2,2),imshow(J),title('直方图均衡化图像')subplot(2,2,3),imhist(I),title('原始图像直方图')subplot(2,2,4),imhist(J),title('均衡化直方图')%直方图规定化¯I=imread('moon.tif');J=histeq(I,32);[count,x]=imhist(J);Q=imread('moon.tif');figure
3、,subplot(2,2,1),imshow(Q)subplot(2,2,3),imhist(Q)M=histeq(Q,count);subplot(2,2,2),imshow(M)subplot(2,2,4),imhist(M)实验结果:直方图均衡化-8-直方图规定化灰度变换,利用直接灰度变换法对任选的一副图像进行灰度变换(imjust函数),要求将原图像0.5到0.75的灰度级扩展到范围[01],再实现明暗转换(负片图像),显示原图,直方图,处理后的图像。实验程序:%灰度变换I=imread('
4、moon.tif')J=imadjust(I,[0.5,0.75],[])Q=double(I);M=255-Q;Z=uint8(M);subplot(2,3,1),imshow(I),title('原始图像')subplot(2,3,2),imshow(J),title('灰度变换图像')subplot(2,3,3),imshow(Z),title('负片图像')subplot(2,3,4),imhist(I),title('原始图像直方图’)subplot(2,3,5),imhist(J),ti
5、tle('灰度变换图像直方图')subplot(2,3,6),imhist(Z),title('负片图像直方图')实验结果:-8-A、请采用二维中值滤波函数medfilt2对受椒盐噪声干扰的任意一副图像滤波,窗口分别采用3*3,5*5;采用MATLAB中的函数filter2对受高斯噪声干扰的同一图像进行均值滤波;采用三种不同锐化算子对图像进行锐化处理,显示图像效果。实验程序:椒盐噪声:I=imread('moon.tif');I1=imnoise(I,'salt&pepper',0.04);%添加椒
6、盐噪声I2=double(I1)/255;H1=[1/91/91/9;1/91/91/9;1/91/91/9];J1=conv2(I2,H1,'same');J2=medfilt2(I2,[33]);J3=medfilt2(I2,[55]);subplot(2,3,1),imshow(I),title('原始图像')subplot(2,3,2),imshow(I1),title('添加椒盐噪声后图像')subplot(2,3,3),imshow(J1),title('低通滤波')subplot(2,
7、3,4),imshow(J2),title('3*3窗口')%3*3subplot(2,3,5),imshow(J3),title('5*5窗口')%5*5高斯噪声:I=imread('moon.tif');I1=imnoise(I,'gaussian',0,0.02);%Ä£Äâ¾ùֵΪ0·½²îΪ0.02µÄ¸ß˹ÔëÉù£¬I2=double(I1)/255;H1=[1/91/91/9;1/91/91/9;1/91/91/9];J1=conv2(I2,H1,'same');J2=med
8、filt2(I2,[33]);subplot(2,2,1),imshow(I),title('原始图像')-8-subplot(2,2,2),imshow(I1),title('添加高斯噪声')subplot(2,2,3),imshow(J1),title('低通滤波')subplot(2,2,4),imshow(J2),title('中值滤波')3种锐化算子:I=imread('moon.tif');H=fspecial('sobel');subplot(2,2,1