matlab图像处理的几个实例.docx

上传人:小** 文档编号:88201438 上传时间:2019-04-20 格式:DOCX 页数:12 大小:411.34KB
返回 下载 相关 举报
matlab图像处理的几个实例.docx_第1页
第1页 / 共12页
matlab图像处理的几个实例.docx_第2页
第2页 / 共12页
matlab图像处理的几个实例.docx_第3页
第3页 / 共12页
matlab图像处理的几个实例.docx_第4页
第4页 / 共12页
matlab图像处理的几个实例.docx_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《matlab图像处理的几个实例.docx》由会员分享,可在线阅读,更多相关《matlab图像处理的几个实例.docx(12页珍藏版)》请在金锄头文库上搜索。

1、Matlab图像处理的几个实例(初学者用)1.图像的基本信息及其加减乘除clear,clc;P=imread(yjx.jpg);whos PQ=imread(dt.jpg);P=im2double(P);Q=im2double(Q);gg1=im2bw(P,0.3);gg2=im2bw(P,0.5);gg3=im2bw(P,0.8);K=imadd(gg1,gg2);L=imsubtract(gg2,gg3);cf=immultiply(P,Q);sf=imdivide(Q,P);subplot(421),imshow(P),title(郁金香原图);subplot(422),imshow(g

2、g1),title(0.3);subplot(423),imshow(gg2),title(0.5);subplot(424),imshow(gg3),title(0.8);subplot(425),imshow(K),title(0.3+0.5);subplot(426),imshow(L),title(0.5-0.3);subplot(427),imshow(cf),title(P*Q);subplot(428),imshow(sf),title(P/Q);2.图像缩放clear,clc;I=imread(dt.jpg);A=imresize(I,0.1,nearest);B=imresi

3、ze(I,0.4,bilinear);C=imresize(I,0.7,bicubic);D=imresize(I,100,200);F=imresize(I,400,100);figuresubplot(321),imshow(I),title(原图);subplot(322),imshow(A),title(最邻近插值);subplot(323),imshow(B),title(双线性插值);subplot(324),imshow(C),title(二次立方插值);subplot(325),imshow(D),title(水平缩放与垂直缩放比例为2:1);subplot(326),imsh

4、ow(F),title(水平缩放与垂直缩放比例为1:4);灰度变换、直方图变换clear,clc;fg=imread(fg.jpg);zl=imread(zl.jpg);hfg=rgb2gray(fg);fg1=double(hfg);out1=255*(fg1/255).0.7;out1(find(out1255)=255;fg1=uint8(fg1);out1=uint8(out1);img=rgb2gray(zl);harm,x=imhist(img);J=histeq(hfg,harm);figuresubplot(421),imshow(fg1),title(复古灰度图);subpl

5、ot(422),imhist(fg1),title(复古灰度图的直方图);subplot(423),imshow(out1),title(对复古灰度图像进行幂次变换);subplot(424),imhist(out1),title(幂次变换图像的直方图);subplot(425),imshow(img),title(朱莉);subplot(426),imhist(img),title(朱莉图像对应的直方图);subplot(427),imshow(J),title(直方图变换后的复古图);subplot(428),imhist(J),title(直方图变换后的复古图对应的直方图);傅里叶变换、

6、频域滤波1. 傅里叶变换clear,clc;rgb=imread(zl.jpg);rgb=imresize(rgb,0.7,bilinear);rgb=im2double(rgb);fR=rgb(:,:,1);fG=rgb(:,:,2);fB=rgb(:,:,3);flyfR=fft2(fR);flyfG=fft2(fG);flyfB=fft2(fB);Frgb(:,:,1)=flyfR;Frgb(:,:,2)=flyfG;Frgb(:,:,3)=flyfB;tzR=fftshift(flyfR);tzG=fftshift(flyfG);tzB=fftshift(flyfB);tzF(:,:,

7、1)=tzR;tzF(:,:,2)=tzG;tzF(:,:,3)=tzB;iflyfR=ifft2(flyfR);iflyfG=ifft2(flyfG);iflyfB=ifft2(flyfB);out(:,:,1)=iflyfR;out(:,:,2)=iflyfG;out(:,:,3)=iflyfB;figuresubplot(221),imshow(rgb),title(原图);subplot(222),imshow(Frgb),title(图像频谱);subplot(223),imshow(tzF),title(调整中心后的图像频谱);subplot(224),imshow(out),ti

8、tle(逆变换得到的原图);2.频域滤波clear,clc;I=rgb2gray(imread(ml.jpg);J=imnoise(I,gaussian,0.1);Jzz1=medfilt2(J,3 3);Jzz2=medfilt2(J,10 10);XJ=imnoise(I,salt & pepper);f=im2double(XJ);g=fft2(f);g=fftshift(g);M,N=size(g);nn=2;d0=50;m=fix(M/2);n=fix(M/2);for i=1:M for j=1:N d=sqrt(i-m)2+(j-n)2); h1=1/(1+0.414*(d/d0

9、)(2*nn); result1(i,j)=h1*g(i,j); endendresult1=ifftshift(result1);J2=ifft2(result1);J3=im2uint8(real(J2);figuresubplot(231),imshow(I),title(原图的灰度图像);subplot(232),imshow(J),title(加高斯噪声);subplot(233),imshow(Jzz1),title(模板3*3中值滤波后的图像);subplot(234),imshow(Jzz2),title(模板10*10中值滤波后的图像);subplot(235),imshow

10、(J3),title(低通滤波图);彩色图像处理clear,clc;rgb=imread(yjx.jpg);fR=rgb(:,:,1);fG=rgb(:,:,2);fB=rgb(:,:,3);R=rgb;R(:,:,2 3)=0;G=rgb;G(:,:,1 3)=0;B=rgb;B(:,:,1 2)=0;yiq=rgb2ntsc(rgb);fY=yiq(:,:,1);fI=yiq(:,:,2);fQ=yiq(:,:,3);fR=histeq(fR,256);fG=histeq(fG,256);fB=histeq(fB,256);RGB=cat(3,fR,fG,fB);figuresubplot

11、(341),imshow(rgb),title(原图);subplot(342),imshow(R),title(图像的红色分量);subplot(343),imshow(G),title(图像的绿色分量);subplot(344),imshow(B),title(图像的蓝色分量);subplot(345),imshow(yiq),title(NTSC彩色空间);subplot(346),imshow(fY),title(亮度);subplot(347),imshow(fI),title(色调);subplot(348),imshow(fQ),title(饱和度);subplot(349),imshow(RGB),title(rgb均衡化后的彩色图像);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号