How to find line using Hough Transform

7 views (last 30 days)
Hi I have a matrix of coordinates such
BW = [380 .2134;
      380.95 .1784;
      381.05 .1374]
and I would like to identify lines using Hough transform. Unfortunately, I do not know how. Examples do not work for my data.

Accepted Answer

Image Analyst
Image Analyst on 14 Dec 2013
Either convert your list of coordinates to a binary image
for k = 1 : size(BW, 1);
binaryImage(BW(k, 2), BW(k, 1)) = true;
end
or else use RANSAC: https://en.wikipedia.org/wiki/Ransac to identify lines in a collection of arbitrary points.
  11 Comments
Dina Abdeltwab
Dina Abdeltwab on 9 Jan 2020
Edited: Dina Abdeltwab on 9 Jan 2020
Thanks alot for your help, i did it but by this it is manual not automatic and i want it to be automatic . last thing , the code of polyfit you mentioned to give two red lines on the binary image , could you tell me how to apply these two lines on the original gray scale image after applying them on it's binary image ? @Image Analyst .sorry for annoying you
Image Analyst
Image Analyst on 9 Jan 2020
You can burn the lines into the image like this:
for k = 1 : length(xLine)
col = round(xLine(k))
row = round(yLine(k))
grayImage(row, col) = 255;
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!