[电脑基础知识]matlab图像处理基础实例

上传人:油条 文档编号:33865058 上传时间:2018-02-18 格式:DOC 页数:43 大小:2.94MB
返回 下载 相关 举报
[电脑基础知识]matlab图像处理基础实例_第1页
第1页 / 共43页
[电脑基础知识]matlab图像处理基础实例_第2页
第2页 / 共43页
[电脑基础知识]matlab图像处理基础实例_第3页
第3页 / 共43页
[电脑基础知识]matlab图像处理基础实例_第4页
第4页 / 共43页
[电脑基础知识]matlab图像处理基础实例_第5页
第5页 / 共43页
点击查看更多>>
资源描述

《[电脑基础知识]matlab图像处理基础实例》由会员分享,可在线阅读,更多相关《[电脑基础知识]matlab图像处理基础实例(43页珍藏版)》请在金锄头文库上搜索。

1、边缘检测时先要把其他格式图像转化为灰度图像 f=imread(lbxx.bmp); a=rgb2gray(f); g,t=edge(a,canny); imshow(g)imread imfinfo colormap imshow subplot subimageimadd imsubtract immultiply imdivideimresize imrotate(旋转)imcrop剪贴 a=imread(onion.png); b=imcrop(a,75 68 130 112); subplot(121);imshow(a); subplot(122);imshow(b);roipoly

2、选择图像中的多边形区域?、 a=imread(onion.png); c=200 250 278 248 199 172; r=21 21 75 121 121 75; b=roipoly(a,c,r); subplot(121);imshow(a); subplot(122);imshow(b);roicolor按灰度值选择的区域 a=imread(onion.png); i=rgb2gray(a); b=roicolor(i,128,255); subplot(121);imshow(a); subplot(122);imshow(b);转化指定的多边形区域为二值掩膜poly2mask x

3、=63 186 54 190 63; y=60 60 209 204 60; b=poly2mask(x,y,256,256); imshow(b); holdCurrent plot held plot(x,y,b,LineWidth,2)roifilt2区域滤波a=imread(onion.png);i=rgb2gray(a);c=200 250 278 248 199 172;r=21 21 75 121 121 75;b=roipoly(i,c,r);h=fspecial(unsharp);j=roifilt2(h,i,b);subplot(121),imshow(i);subplot

4、(122),imshow(j);roifill区域填充 a=imread(onion.png); i=rgb2gray(a); c=200 250 278 248 199 172; r=21 21 75 121 121 75; j=roifill(i,c,r); subplot(211);imshow(i); subplot(212);imshow(j);FFT变换f=zeros(100,100);f(20:70,40:60)=1;imshow(f);F=fft2(f);F2=log(abs(F);imshow(F2),colorbar补零操作和改变图像的显示象限f=zeros(100,100

5、);f(20:70,40:60)=1;subplot(121);imshow(f);F=fft2(f,256,256);F2=fftshift(F);subplot(122);imshow(log(abs(F2) 离散余弦变换(dct) a=imread(onion.png); i=rgb2gray(a); j=dct2(i); subplot(131);imshow(log(abs(j),colorbar j(abs(j) k=idct2(j); subplot(132);imshow(i); subplot(133);imshow(k,0,255);info=imfinfo(trees.t

6、if)%显示图像信息edge 提取图像的边缘canny prewitt sobelradon 函数用来计算指定方向上图像矩阵的投影 a=imread(onion.png); i=rgb2gray(a); b=edge(i); theta=0:179; r,xp=radon(b,theta); figure,imagesc(theta,xp,r);colormap(hot); xlabel(theta(degrees); ylabel(xprime); title(r_theta(xprime); colorbarimhist histeqfilter2 均值滤波 a=imread(onion.

7、png); i=rgb2gray(a); imshow(i) k1=filter2(fspecial(average,3),i)/255;%3*3 k2=filter2(fspecial(average,5),i)/255;%5*5 k3=filter2(fspecial(average,7),i)/255;%7*7 figure,imshow(k1) figure,imshow(k2) figure,imshow(k3)wiener2 滤波eg:k=wiener(I,3,3)medfilt2 中值滤波同上deconvwnr 维纳滤波 ?马赫带效应(同等差色带条)减采样? a=imread(f

8、ootball.jpg); b=rgb2gray(a); wid,hei=size(b); quarting=zeros(wid/2+1,hei/2+1); i1=1;j1=1; for i=1:2:widfor j=1:2:heiquarting(i1,j1)=b(i,j);j1=j1+1;endi1=i1+1;j1=1;end figure imshow(uint8(quarting) title(4 倍减采样 ) quarting=zeros(wid/4+1,hei/4+1);i1=1;j1=1;for i=1:4:widfor j=1:4:heiquarting(i1,j1)=b(i,

9、j);j1=j1+1;endi1=i1+1;j1=1;end figure,imshow(uint8(quarting); title(16 倍减采样)结论:在采用不同的减采样过程中,其图像的清晰度和尺寸均发生了变化灰度级转化 a=imread(football.jpg); b=rgb2gray(a); figure;imshow(b) wid,hei=size(b); img2=zeros(wid,hei); for i=1:widfor j=1:heiimg2(i,j)=floor(b(i,j)/128);endend figure;imshow(uint8(img2),0,2) %2 级

10、灰度图像图像的基本运算 i=imread(football.jpg); figure;subplot(231);imshow(i); title(原图 ); j=imadjust(i,.3;.6,.1 .9);%Adjust image intensity values or colormap 图像灰度值或 colormap 调整% J = IMADJUST(I,LOW_IN; HIGH_IN,LOW_OUT; HIGH_OUT) subplot(232);imshow(j);title(线性扩展); i1=double(i);i2=i1/255;c=2;k=c*log(1+i2); subp

11、lot(233);imshow(k); title(非线性扩展 ); m=255-i; subplot(234);imshow(m) title(灰度倒置 ) n1=im2bw(i,.4);n2=im2bw(i,.7); subplot(235);imshow(n1);title(二值化阈值 0.4) subplot(236);imshow(n2);title(二值化阈值 0.7)图像的代数运算加。减,乘法(获取感兴趣的区域)imresize 放大a=imresize(I,2) %比例a=imresize(I,33 24) %非比例imrotate 旋转a=imrotate(I,45)时域旋转

12、多少度,频域也就旋转多少度 i=zeros(256,256); i(88:168,124:132)=1; imshow(i) j=fft2(i);f=abs(j);j1=fftshift(f);figure;imshow(j1,5 50) j=imrotate(i,90,bilinear,crop); figure;imshow(j); j1=fft2(j);f=abs(j1);j2=fftshift(f); figure;imshow(j2,5 50) 边缘检测 a=imread(kids.tif); subplot(211);imshow(a);title(pri) b=edge(a,ca

13、nny);subplot(212);imshow(b);title(by) figure,c=edge(a,prewitt);imshow(c)腐蚀和膨胀 a=imread(football.jpg); subplot(231);imshow(a); title(原灰度图像 ) t=graythresh(a); bw1=im2bw(a,t); se1=strel(square,3);se2=strel(square,5); bw2=imerode(bw1,se1); subplot(232);imshow(bw2) title(3*3 腐蚀 ) bw3=imdilate(bw1,se1);su

14、bplot(233);imshow(bw3);title(3*3 膨胀) bw4=imerode(bw1,se2);subplot(234);imshow(bw4);title(5*5 腐蚀) bw5=imdilate(bw1,se2);subplot(235);imshow(bw5);title(5*5 膨胀)log 算子 x=-2:.06:2; y=-2:.06:2; sigma=.6;y=y; for i=1:(4/.06+1)xx(i,:)=x;yy(:,i)=y;end r=1/(2*pi*sigma4)*(xx.2+yy.2)/(sigma2)-2).*exp(-(xx.2+yy.2)/(sigma2); colormap(jet(16);mesh(xx,yy,r)分水岭算法分割图像 f=imread(lbxx.bmp); f=rgb2gray(f);subplot(221);imshow(f) title(pri) subplot(222);f=double(f);hv=fspecial(prewitt);hh=hv.; gv=abs(imfilter(f,hv,replicate); gh=abs(imfilter(f,hh,replicate); g=sqrt(gv.2+gh.2);subplot(222);l=watershed(

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

当前位置:首页 > 行业资料 > 其它行业文档

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