Page 1 of 2

circle detection

Posted: 2010-10-04T13:13:15-07:00
by daffy
i am new to imagmagick and would like to know if there is any way to detect circle from following image.

i have posted this twice and somehow my account gets delete immediately!!

Image

Re: circle detection

Posted: 2010-10-04T14:40:15-07:00
by fmw42
This is not an easy problem. The best approach is a circle Hough transform. But IM has neither linear nor circular Hough transforms.

Best bet is to try working with edge detection and contrast and noise filtering. See -convolve or -morphology convolve at
http://www.imagemagick.org/Usage/convolve/

and

-edge at http://www.imagemagick.org/script/comma ... ek6l6#edge

Re: circle detection

Posted: 2010-10-05T08:11:06-07:00
by daffy
i tried using circle Hough transform using emgu, but just cant get the circle detected.

i might need to process the image a bit, but dont know what operation will make visible the circle.
http://www.emgu.com/wiki/index.php/Main_Page

Re: circle detection

Posted: 2010-10-05T08:50:19-07:00
by dproc
If the circles are always the same size and shape, or a small set of sizes, then you might just edge detect and clean things up like fmw42 said, but then just cross-correlate with a known good sample(s) that were also edge-detected and cleaned up. You might also try it without edge detection if the images of the objects are usually similar.

Re: circle detection

Posted: 2010-10-05T12:00:43-07:00
by daffy
thanks for the info.
I will try to get the edges with it and see how that goes.

also, once i have the circle edge detected, is there a way to split say an image with 2 such circles into two distinct images ?

thanks again

Re: circle detection

Posted: 2010-10-05T21:49:50-07:00
by anthony
Once you have the circles, you can mask out those areas and extract them from the original (or cleaned) image.

That is purely composition masking.

Re: circle detection

Posted: 2010-10-06T14:31:43-07:00
by daffy
could you please guide me to appropriate example for composition masking.
i am surely not an image processing expert, so need some input or example if possible.

thanks

Re: circle detection

Posted: 2010-10-06T14:54:30-07:00
by fmw42
see http://www.imagemagick.org/Usage/layers/#convert and http://www.imagemagick.org/Usage/compose/#compose


But why do you need image composition for circle detection?

If you want to do things manually, you can measure the center of the circle and a point on the perimeter of the circle and just draw a red circle over your image. see -draw http://www.imagemagick.org/Usage/draw/#circles the circle can be transparent in the middle and just red or some color on its perimeter.

Re: circle detection

Posted: 2010-10-07T07:35:52-07:00
by daffy
actual scenario is,
i have scanned image with a rectangle block (fix size) with bunch of holes (fix size, diameter).
what i am trying to do is, determine each hole distinctly
e.g. if i have 15 holes (5 in each row), i need some way to split them apart from original image and identify them uniquely ..like say

A > 0, 1, 2, 3, 4
B > 5, 6, 7, 8, 9
C > 10, 11, 12, 13, 14

so in about case i will have A0, A1, ....to C14

i am sure there is better way of doing it, but i am just not that savvy in this field.

any help would be appreciated.

Re: circle detection

Posted: 2010-10-07T09:32:47-07:00
by fmw42
can you post a link to your image? I am not sure what you mean by split them apart and identify them? Identify them in what way?

Re: circle detection

Posted: 2010-10-07T11:51:54-07:00
by daffy
Image

i have upload image with 4 circles
so here i take top left corner as start and label it as A then that row contains two columns
and row under it i call it say B

A | 0, 1
B | 2, 3

so in that above image top row is A and bottom is B, first column start at index say 0 and it goes upto 3 to make total of 4 circles.

so i want to identify A0, A1, A2, A3 by splitting them from this original image such that, if i have A3 image with me i know where it belongs to in original image.
let me know if that makes sense.
thanks

Re: circle detection

Posted: 2010-10-07T12:01:59-07:00
by fmw42
You can try template matching. Get a subsection of your image or create a dark circle of the size you have in the image. Then use compare to compare the smaller template circle with the larger image. An example can be seen at viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076 That should produce a two-frame image of which the second is similar to what is shown, but in your case there should be 4 bright dots. The locations of those 4 dots, should be the corresponding location in the larger image where the upper left corner of the template best matches.

see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/#compare

Re: circle detection

Posted: 2010-10-08T06:12:18-07:00
by daffy
i have made this template and try to find circles from the image i get from compare command
but still circles are undetectable.
Image

Re: circle detection

Posted: 2010-10-08T15:55:57-07:00
by fmw42
try one dark centered circle for the template, similar in shading as in your image of multiple circles

Re: circle detection

Posted: 2010-10-08T16:25:02-07:00
by fmw42
I tried several variations and the similarity image is not showing enough variation to pick out the best matches for your images. Sorry I tried negating the images and also making edge images and neither works well enough.