why hough transform detects more lines while there is only one line?
Show older comments

%% Hough Transform
I4 = imbinarize(I4);
BW2 = imcomplement(I4);
[H,theta,rho] = hough(BW2,'RhoResolution',1.8);
figure(2);
imshow(imadjust(rescale(H)),'XData',theta,...
'YData',rho,...
'InitialMagnification','fit');
axis on
axis normal
hold on
colormap(gca,hot)
P = houghpeaks(H,40,'threshold',ceil(0.05*max(H(:))));
x = theta(P(:,2));
y = rho(P(:,1));
lines = houghlines(BW2,theta,rho,P,'FillGap',3,'MinLength',36);
figure(1);subplot(2,2,4);
imshow(I4),
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 beginnings and ends of lines
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
Accepted Answer
More Answers (0)
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!