Demo entry 6648048

1

   

Submitted by anonymous on Oct 22, 2017 at 17:05
Language: Matlab. Code size: 724 Bytes.

im_input1=imread('test05.jpg');
im_input=rgb2gray(im_input1); %转为灰度图像 Canny 边缘检测
[r,c]=size(im_input);
R=[r/2.5 r*0.9 r*0.9 r/2.5 ];
C=[ 0 0 c c ];
BW=roipoly(im_smooth,C,R);
imshow(BW);
im_edge=edge(im_smooth,'canny',[20/255 100/255]); % Canny 边缘检测
imshow(im_edge);
[H, theta, rho] = hough(im_edge, 'ThetaResolution', 0.2); %霍夫变换
imshow(H, [], 'XData', theta, 'YData', rho, 'InitialMagnification', 'fit')
axis on, axis normal
peaks = houghpeaks(H, 3,'Threshold',0.2*max(H(:)),'NhoodSize',[115 115]); %返回 霍夫变换峰值的坐标
for k = 1:length(lines) %for 循环
xy = [lines(k).point1 ; lines(k).point2];
frgb=im_input1(lines(k).point1(2),lines(k).point1(1),3);
plot(xy(:,1), xy(:,2), 'LineWidth', 4, 'Color', [1 1 0]);
end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).