Page 1 of 1

Hough Transform

Posted: 2013-06-18T02:30:14-07:00
by gowribala
Hi

I am new to Image processing. I have edge detected image,it have two circles.

I have to find the center and radius of two concentric circles.

I choose the hough transform for that detection. For proceeding hough transform i should know the two or three points that lies on the circumference of circle from edge detected image.but i don't know how to take points from edge detected image.

Please guide me....

Re: Hough Transform

Posted: 2013-06-18T06:29:24-07:00
by snibgo
Suppose you have a white circle on a black background. You want to find three points on the circle. Windows script; adjust for other languages.

Code: Select all

%IM%convert -size 1000x1000 xc:Black ^
  -fill None -stroke White ^
  -draw "circle 345,665 485,665" ^
  test.png


rem Find a white pixel
%IM%compare -metric RMSE test.png xc:White -subimage-search Null:
rem Result is 0 (0) @ 337,525

rem Overwrite this and other nearby white pixels.
%IM%convert test.png ^
  -fill Red -stroke Red ^
  -draw "circle 337,525 357,525" ^
  test.png

rem Find another white pixel
%IM%compare -metric RMSE test.png xc:White -subimage-search Null:
rem Result is 0 (0) @ 360,526

rem Overwrite this and other nearby white pixels.
%IM%convert test.png ^
  -fill Red -stroke Red ^
  -draw "circle 360,526 380,526" ^
  test.png

rem Find another white pixel
%IM%compare -metric RMSE test.png xc:White -subimage-search Null:
rem Result is 0 (0) @ 315,528
Three points are at (337,525), (360,526), (315,528).

For best accuracy, you might do this twice. The first time gets an approximate centre and radius, which gives a better guess for the radius of the red circles.

Re: Hough Transform

Posted: 2013-06-18T23:45:42-07:00
by gowribala
Thanks for your reply...

But how do you find the three points [ (337,525), (360,526), (315,528)].

Only i have black edges(circles) on white background,i don't know the any parameters of circles.

I have only image with pixel value is 0 for edges(circles) and 255 for white background,from that how can i take points on edges.

Could you please explain me....

Re: Hough Transform

Posted: 2013-06-19T00:05:38-07:00
by snibgo
If you have black circles on a white background, use "-negate".

The compare command gives each coordinate. Your script needs to read this.

Re: Hough Transform

Posted: 2013-06-19T05:11:49-07:00
by gowribala
Thanks for your reply...

I don't have any prior knowledge in mat lab. I want to develop my code in c language.

could you please explain the logic to find points on edge...

Re: Hough Transform

Posted: 2013-06-19T05:36:55-07:00
by snibgo
I don't understand your question.

You can convert a file to ppm format ...

Code: Select all

convert x.png -compress None x.ppm
... and the result is text values for the pixels. A program in C can very easily and quickly read this file to find pixels that are black, white or anything else.

Re: Hough Transform

Posted: 2013-10-17T09:56:16-07:00
by backspaces
OT, but I thought IM didn't have a Hough Transform.

Is there a way to create a HT in IM? Or are their programs that are available for a HT via use of IM?

-- Owen

Re: Hough Transform

Posted: 2013-10-17T14:00:21-07:00
by fmw42
IM does not currently have Hough Transforms as far as I know. Snibgo was showing you how to calculate an ellipse shape by picking a few points, if I understand what he is doing.

If you want Hough Transforms, perhaps see OpenCV