赞
踩
实验思路:
先对原图进行几何变化(旋转)变成长方形,再对图像进行分割
实验代码:
- clear
- clc
- init=imread('C:\Users\joczu\Desktop\作业3.bmp');
- %图像旋转
- G=rgb2gray(init);
- E=edge(G);
- theta=1:180;
- [R,xp]=radon(E,theta);
- [E,J]=find(R>=max(max(R)));
- Q=90-J;
- I=imrotate(G,Q,'bilinear','crop');
- %图像切割
- s=I(:,:,1);
- bw=im2bw(s,graythresh(s)); %graythresh自动找比较合适的阈值
- se=strel('disk',1); %创建切割形状
- bw2=imclose(bw,se);
- figure(1);
- imshow(bw2);
- perim=bwperim(bw2,8); %表示从输入图像BW1中返回只包括对象边缘坐标
- r=I(:,:,1);
- %g=I(:,:,2);
- %b=I(:,:,3);
- r(perim)=250;
- %g(perim)=0;
- %b(perim)=0;
- I(:,:,1)=r;
- %I(:,:,2)=g;
- %I(:,:,3)=b;
- figure(2);
- imshow(I);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。