Hough Transform

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
gowribala
Posts: 14
Joined: 2013-06-03T02:43:37-07:00
Authentication code: 6789

Hough Transform

Post 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....
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hough Transform

Post 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.
snibgo's IM pages: im.snibgo.com
gowribala
Posts: 14
Joined: 2013-06-03T02:43:37-07:00
Authentication code: 6789

Re: Hough Transform

Post 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....
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hough Transform

Post 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.
snibgo's IM pages: im.snibgo.com
gowribala
Posts: 14
Joined: 2013-06-03T02:43:37-07:00
Authentication code: 6789

Re: Hough Transform

Post 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...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hough Transform

Post 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.
snibgo's IM pages: im.snibgo.com
backspaces
Posts: 3
Joined: 2013-10-17T09:38:51-07:00
Authentication code: 6789

Re: Hough Transform

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Hough Transform

Post 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
Post Reply