Page 2 of 2
Re: circle detection
Posted: 2010-10-11T07:04:49-07:00
by daffy
hi fmw42
thanks for your help and trying things out. i really appreciate that.
i have tried some variation too and like you said results are not predictable.
do you think matlab will be able to detect the circles using template better than IM?
Re: circle detection
Posted: 2010-10-11T09:31:14-07:00
by fmw42
I have no idea about Matlab. Never used it. But check to see if it has Hough transform for circles.
I did some further tests and this now works -- starting with your 4 circle image.
I first negated the image and then did a constrast stretch:
convert circle4.png -alpha off -negate -contrast-stretch 10,10% circle4_n_cs10.png
Then I cropped a minimal area around the upper left corner circle
Then did the compare:
compare -metric rmse -subimage-search circle4_n_cs10.png circle4_n_cs10_ul.png circle4_similarity.png
1062.61 (0.0162144) @ 8,4
The 4 bright spot locations correspond to the best fit of the smaller image circle where its upper left corner would be in the larger image. So you need to offset that by the coordinates of the center of the single circle in its image.
Re: circle detection
Posted: 2010-10-12T11:30:46-07:00
by daffy
hey
thanks for your help
one question, so the gray image with 4 bright spots are the four circles in circle4_n_cs10.png image?
so does my offset will remain constant for fixed size circle or it will change?
Re: circle detection
Posted: 2010-10-12T11:38:41-07:00
by fmw42
daffy wrote:hey
thanks for your help
one question, so the gray image with 4 bright spots are the four circles in circle4_n_cs10.png image?
so does my offset will remain constant for fixed size circle or it will change?
To get the actual coordinates of the centers of the circles in the multiple circle image from the gray image with the 4 dots, you find the brightest point (x,y) for each bright area, then add the coordinates (x,y) of the location of the center of the circle from the template single circle image. The latter is always the same as it is one template image and the center does not change.
Note this only works with one size circle. The template has to be the same size circle as all the circles in the original image.
If you have a picture with multiple size circles that you need to locate, this will not work and you need to use something like the Hough transform for circles which is not part of IM.
see
http://www.cis.rit.edu/class/simg782/le ... _05_10.pdf
http://www.mathworks.com/matlabcentral/ ... -transform
Re: circle detection
Posted: 2010-10-15T07:53:22-07:00
by daffy
hey, thanks a bunch.
i will give that a try and it seems promising ...
i have another question for following image
how should i find the half arc or circle at the bottom of black (fill) circle and make it black too .. so entire black circle would be black without white arc ..
thanks
Re: circle detection
Posted: 2010-10-15T10:02:43-07:00
by fmw42
one way is
convert vhnip.png -fuzz 50% -fill black -opaque white vhnip_tmp50.png
You can play with the -fuzz factor to adjust it differently.
This changes all values within 50% of pure white to full black.
Alternately, in Photoshop or GIMP you can clone over the white or paint over the white with the neighboring black color.
Re: circle detection
Posted: 2010-10-15T10:29:00-07:00
by daffy
that will work only if i have black fill circle,
what if i have some content in black circle (say a text, and it also have white color), i dont want that content to be fuzz by the command,
what would be best way to do it. I tried few things on my own from IM examples, but no luck.
Thanks
Re: circle detection
Posted: 2010-10-15T12:16:49-07:00
by fmw42
You really need to do that with some GUI based paint program.
But the only way I can think of is to make a binary mask identifying the region you want to change, then process the image as above, then use the mask to replace the areas with processed data where the mask is white and use the original image where the mask is black.
see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/channels/#masks
Re: circle detection
Posted: 2010-10-15T13:10:29-07:00
by daffy
the text that will contain in the black fill circle is not constant, is there a way to create dynamic mask and apply to image?
i guess, in order to create dynamic mask i need to extract image which will require, edge detection or something, i may be wrong.
also the content position is not fix, it could be anywhere in black circle, that makes it harder for me to find the content and remove the unneeded white arcs.
let me know your thoughts.
Re: circle detection
Posted: 2010-10-15T14:29:16-07:00
by fmw42
no automatic way that I know if you are trying to keep text but remove the little white areas.
However if you are trying to remove small text, then there are ways to remove that using -morphology and such.
see
viewtopic.php?f=1&t=12517&p=41498
Anthony has another way, but I cannot recall where he demonstrated that or put that in his pages.