MATLAB Answers


How to detect perfect edges using hough transform??

Asked by rahul
on 4 Jan 2013

I am using Hough transform to find the edges of an arrow but I am getting only 2 of the required edges.

Original image :-

It has 7 edges.

After Hough transform.

It is showing only 2 edges.

Why???? and how to get the all the edges???

Here is my code....(Its the same code given Matlab tutorials)

I  = imread('d:\test.jpg');
rot = rgb2gray(I);
rotI = imadjust(rot);
BW = edge(rotI,'canny');
[H,T,R] = hough(BW);
P  = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
figure, imshow(rotI), hold on
max_len = 0;
for k = 1:length(lines)
  xy = [lines(k).point1; lines(k).point2];
  % Plot beginnings and ends of lines



No products are associated with this question.

1 Answer

Answer by Image Analyst
on 4 Jan 2013

Spandan (of the Mathworks Image Processing team) gave you the answer in your newsgroup posting of the same question:


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!