matlab图像处理的几个实例_第1页
matlab图像处理的几个实例_第2页
matlab图像处理的几个实例_第3页
matlab图像处理的几个实例_第4页
matlab图像处理的几个实例_第5页
已阅读5页,还剩3页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Matlab图像处理的几个实例(初学者用)1.图像的基本信息及其加减乘除clear,clc;P=imread('yjx.jpg'whosPQ=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(gg1),title();subplot(423),imshow(gg2),title();subplot(424),imshow(gg3),title();subplot(425),imshow(K),title();subplot(426),imshow(L),title();subplot(427),imshow(cf),title();subplot(428),imshow(sf),title();2.图像缩放clear,clc;I=imread('dt.jpg'A=imresize(I,0.1,);B=imresize(I,0.4,);C=imresize(I,0.7,);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('水平缩放与垂直缩放比例为);subplot(326),imshow(F),title('水平缩放与垂直缩放比例为);

灰度变换、直方图变换clear,clc;fg=imread('fg.jpg'zl=imread('zl.jpg'hfg=rgb2gray(fg);fg1=double(hfg);out1=255*(fg1/255).^0.7;out1(find(out1>255))=255;fg1=uint8(fg1);out1=uint8(out1);img=rgb2gray(zl);[harm,x]=imhist(img);J=histeq(hfg,harm);figuresubplot(421),imshow(fg1),title(复古灰度图');subplot(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('直方图变换后的复古图对应的直方图');

傅里叶变换、频域滤波1.傅里叶变换clear,clc;rgb=imread('zl.jpg'rgb=imresize(rgb,0.7,);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(:,:,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),title(逆变换得到的原图'

2.频域滤波clear,clc;I=rgb2gray(imread());J=imnoise(I,'gaussian'Jzz1=medfilt2(J,[33]);Jzz2=medfilt2(J,[1010]);XJ=imnoise(I,&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);fori=1:Mforj=1:Nd=sqrt((i-m)^2+(j-n)^2);h1=1/(1+0.414*(d/d0)^(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(J3),title('低通滤波图');

彩色图像处理clear,clc;rgb=imread('yjx.jpg'fR=rgb(:,:,1);fG=rgb(:,:,2);fB=rgb(:,:,3);R=rgb;R(:,:,[23])=0;G=rgb;G(:,:,[13])=0;B=rgb;B(:,:,[12])=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(341),imshow(rgb),title(原图');subplot(342),imshow(R),title('图像的红色分量');subplot(343),imshow(G),title('图像的绿色分量');subplot(344),imshow(B),title('图像的蓝色分量');subplot(345),imshow(yiq),title(彩色空间');subplot(346),imshow(fY),title('亮度');subplot(347),imshow(fI),title('色调');subplot(348),imshow(fQ),title('饱和度');subplot(349),imshow(RGB),title(均衡化后的彩色图像);

邻插线插

次方平放垂缩为2:1

平放垂缩

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论