文档详情

matlab图像处理.pptx

发布:2017-02-05约2.99千字共26页下载文档
文本预览下载声明
MATLAB图像处理 info=imfinfo(5.jpg)info = Filename: 5.jpg FileModDate: 18-11月-2016 21:02:24 FileSize: 32465 Format: jpg FormatVersion: Width: 500 Height: 281 BitDepth: 24 ColorType: truecolor FormatSignature: NumberOfSamples: 3 CodingMethod: Huffman CodingProcess: Sequential Comment: {}figure,imshow(j) figure,imshow(j,[0 80])灰度图像显示灰度 subplot(1,3,1),imshow(j); subplot(1,3,2),imhist(j); subplot(1,3,3),imhist(j,16);ii=imadjust(i,[0 0.2],[0.5 1]);imshow(i),figure,imshow(ii) r=imadjust(i,[.2 .3 0;.6 .7 1],[]); imshow(i),figure, imshow(r)i=imread(4.jpg);j=rgb2gray(i);k=gray2ind(j);bw1=edge(k,roberts); bw2=edge(k,prewitt);bw3=edge(k,sobel); subplot(2,2,2),imshow(bw1,[]); subplot(2,2,3),imshow(bw2,[]); subplot(2,2,4),imshow(bw3,[]); subplot(2,2,1),imshow(k,[]);I1=imread(6.jpg);I=rgb2gray(I1);%旋转图像并寻找边缘rotI=imrotate(I,33,crop);BW=edge(rotI,canny);%执行Hough变换并显示Hough矩阵[H,T,R]=hough(BW);figure;imshow(H,[],XData,T,YData,R,InitialMagnification,fit);xlabel(\theta),ylabel(\rho);axis on,axis normal,hold on;%在Hough矩阵中寻找前5个大于Hough矩阵中最大值0.3倍的峰值P=houghpeaks(H,5,threshold,ceil(0.3*max(H(:))));x=T(P(:,2));y=R(P(:,1));%由行、列索引转换成实际坐标plot(x,y,s,color,white);%在Hough矩阵图像中标出峰值位置%找出并绘制直线lines=houghlines(BW,T,R,P,FillGap,5,MinLength,7);%合并距离小于5的线段,丢弃所有长度小于7的直线段figure,imshow(rotI),hold onmax_len=0;for k = 1:length(lines)%依次标出各条直线段 xy=[lines(k).point1;lines(k).point2]; plot(xy(:,1),xy(:,2),x,LineWidth,2,Color,green); %绘制线段端点 plot(xy(1,1),xy(1,2),x,LineWidth,2,Color,yellow); plot(xy(2,1),xy(2,2),x,LineWidth,2,Color,red); %确定最长的线段 len=norm(lines(k).point1-lines(k).point2); if(lenmax_len) max_len=len; xy_long=xy; endend%高亮显示最长线段plot(xy_long(:,1),xy_long(:,2), LineWidth,2,Color,cyan);开运算 :先腐蚀后膨胀的过程称为开运算。它具有消除细小物体、在纤细点处分离物体、和平滑较大物体的边界时又不明显改变其面积的作用。闭运算 :先膨胀后腐蚀的过程称为闭运算。它具有填充物体内细小空洞、连接邻近物体、在不明显改变物体面积的情况下平滑其边界的作用。通常反复施以腐蚀运算,将使一个物体变得不存在。类似地,反复膨胀将把一幅图像中的所有物体合并为一个。例:生成一幅128*128的RGB图像,该图像左上角为红色,左下角为蓝色,右上角为绿色,右下角为黑色。程序:clearrgb_R=zeros(128,128);rgb_R(1:64,1:64)=1;rgb_G=zeros(128,128);rgb_G(1:64,65:128)=1;rgb_B=ze
显示全部
相似文档