下面是我的代码 。。。只画出线 并不能检测矩形 ,求大神指教啊 另外,我附上需检测的图片a=imread('juxing.bmp');
a=rgb2gray(a)
I=dither(a)
ro
ti=imrotate(I,33,'crop')
BW=edge(rotI,'log');
[H,T,R]=hough(BW);
P=houghpeaks(H,18,'threshold',ceil(0.3*max(H(:))));
x=T(P(:,2));y=R(P(:,1));
lines=houghlines(BW,T,R,P,'FillGap',18,'MinLength',8);
figure,imshow(rotI),hold on
max_len=0;
for k=1:length(lines)
xy=[lines(k).point1;lines(k).point2];
plot(xy(:,1),xy(:,2),'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');
end
-
一周热门 更多>