Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
extracting a line from an image using hough transform

Subject: extracting a line from an image using hough transform

From: Anil Kumar Reddy

Date: 17 Feb, 2009 06:56:01

Message: 1 of 8

hello,
  i have been using hough transform to detect lines in an image. how could i display the lines based on the angle theta; for example to detect a horizontal line i need to use a theta value of 180; how to do it?
     thanks in advance

Subject: extracting a line from an image using hough transform

From: Gavrilo Bozovic

Date: 17 Feb, 2009 07:15:11

Message: 2 of 8

"Anil Kumar Reddy " <g_anilkumarreddy@yahoo.co.in> wrote in message <gndn21$3lm$1@fred.mathworks.com>...
> hello,
> i have been using hough transform to detect lines in an image. how could i display the lines based on the angle theta; for example to detect a horizontal line i need to use a theta value of 180; how to do it?
> thanks in advance

Do you want to detect a particular line or just to represent it?

If you just want to represent it, it should be straightforward, like

line([xinit xend],[b b]);

with b = the height of your line.

If it doesn't answer your question, please be more precise!

Subject: extracting a line from an image using hough transform

From: Image Analyst

Date: 17 Feb, 2009 11:24:02

Message: 3 of 8

Anil Kumar Reddy :
Detect or display? Or both? Which is it?

Subject: extracting a line from an image using hough transform

From: Anil Kumar Reddy

Date: 18 Feb, 2009 05:31:01

Message: 4 of 8

i want to detect a horizontal line and represent it. i have used the canny edge detection technique in the hough transform
> > hello,
> > i have been using hough transform to detect lines in an image. how could i display the lines based on the angle theta; for example to detect a horizontal line i need to use a theta value of 180; how to do it?
> > thanks in advance
>
> Do you want to detect a particular line or just to represent it?
>
> If you just want to represent it, it should be straightforward, like
>
> line([xinit xend],[b b]);
>
> with b = the height of your line.
>
> If it doesn't answer your question, please be more precise!

Subject: extracting a line from an image using hough transform

From: Anil Kumar Reddy

Date: 18 Feb, 2009 09:08:01

Message: 5 of 8

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gne6oi$qe7$1@fred.mathworks.com>...
> Anil Kumar Reddy :
> Detect or display? Or both? Which is it?
i want to detect and display the line.the line i need to detect is a horizontal line. how can it be done?
   thank you

Subject: extracting a line from an image using hough transform

From: Dave Robinson

Date: 18 Feb, 2009 09:57:01

Message: 6 of 8

"Anil Kumar Reddy " <g_anilkumarreddy@yahoo.co.in> wrote in message <gngj5h$ncf$1@fred.mathworks.com>...
> "Image Analyst" <imageanalyst@mailinator.com> wrote in message <gne6oi$qe7$1@fred.mathworks.com>...
> > Anil Kumar Reddy :
> > Detect or display? Or both? Which is it?
> i want to detect and display the line.the line i need to detect is a horizontal line. how can it be done?
> thank you

If you know that your line is horizontal, do you actually have to go to the extent of using the Hough transform, which takes a lot of computational horse power?

You might find that you can get your result by simply doing a sum in the row direction. Any truely horizontal line will provide a large peak in the sum vector, which will provide information regarding its length (via the peak amplitude), its width (via the width of the peak) and its position (via the position of the peak).

It is a limited form of the Radon Transform.
help sum
help radon

Hope that helps

Dave Robinson

Subject: extracting a line from an image using hough transform

From: Anil Kumar Reddy

Date: 26 Feb, 2009 05:13:01

Message: 7 of 8

thank you... but i am interested in learning the way to extract a horizontal line by varying theta using hough transform
"Dave Robinson" <dave.robinson@somewhere.biz> wrote in message <gngm1d$1nj$1@fred.mathworks.com>...
> "Anil Kumar Reddy " <g_anilkumarreddy@yahoo.co.in> wrote in message <gngj5h$ncf$1@fred.mathworks.com>...
> > "Image Analyst" <imageanalyst@mailinator.com> wrote in message <gne6oi$qe7$1@fred.mathworks.com>...
> > > Anil Kumar Reddy :
> > > Detect or display? Or both? Which is it?
> > i want to detect and display the line.the line i need to detect is a horizontal line. how can it be done?
> > thank you
>
> If you know that your line is horizontal, do you actually have to go to the extent of using the Hough transform, which takes a lot of computational horse power?
>
> You might find that you can get your result by simply doing a sum in the row direction. Any truely horizontal line will provide a large peak in the sum vector, which will provide information regarding its length (via the peak amplitude), its width (via the width of the peak) and its position (via the position of the peak).
>
> It is a limited form of the Radon Transform.
> help sum
> help radon
>
> Hope that helps
>
> Dave Robinson

Subject: extracting a line from an image using hough transform

From: G. B.

Date: 26 Feb, 2009 07:15:08

Message: 8 of 8

"Anil Kumar Reddy " <g_anilkumarreddy@yahoo.co.in> wrote in message <go58ct$8sq$1@fred.mathworks.com>...
> thank you... but i am interested in learning the way to extract a horizontal line by varying theta using hough transform
> "Dave Robinson" <dave.robinson@somewhere.biz> wrote in message <gngm1d$1nj$1@fred.mathworks.com>...
> > "Anil Kumar Reddy " <g_anilkumarreddy@yahoo.co.in> wrote in message <gngj5h$ncf$1@fred.mathworks.com>...
> > > "Image Analyst" <imageanalyst@mailinator.com> wrote in message <gne6oi$qe7$1@fred.mathworks.com>...
> > > > Anil Kumar Reddy :
> > > > Detect or display? Or both? Which is it?
> > > i want to detect and display the line.the line i need to detect is a horizontal line. how can it be done?
> > > thank you
> >
> > If you know that your line is horizontal, do you actually have to go to the extent of using the Hough transform, which takes a lot of computational horse power?
> >
> > You might find that you can get your result by simply doing a sum in the row direction. Any truely horizontal line will provide a large peak in the sum vector, which will provide information regarding its length (via the peak amplitude), its width (via the width of the peak) and its position (via the position of the peak).
> >
> > It is a limited form of the Radon Transform.
> > help sum
> > help radon
> >
> > Hope that helps
> >
> > Dave Robinson

The Hough matrix contains all the combinations of slope and initial heights, therefore representing all the lines that can exist in your image.

The equation of a line is:

y = m*x + b;

so if you are looking for horizontal lines, you'll have to look at the maximum on the edge of your Hough matrix, where m = theta = 0.

However, I agree with Dave that using a Hough transform to detect a horizontal line is like using a nuke to kill a mosquito: it will do, but at what cost?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us