views:

444

answers:

3

Hi all, how can I draw a circle around a white space in a image file with OpenCV (C language)?

image example:

alt text

thanks a lot!

A: 

You don't really need opencv for that, you just loop over your image and calculate the bounding box surrounding the white blob, get the center and the radius of your circle is the length from the center to any corner. Then just use GDI or something to draw your circle.

Blindy
in that program I use functions of OpenCV so I think is better use OpenCV that implements also the drawing of a circle
frx08
+2  A: 

First you can use FindContours to find all (in your case 1) contours (blobs/regions) in the image, then you can draw a circle or any other shape you want around the contour.

Edit: To draw a circle you can use Circle.

nimcap
how can I draw any shape around the contour?(where I get the coordinates)
frx08
@frx08: You can use `cvBoundingRect()` to find the coordinates, if I am not mistaken.
nimcap
+1  A: 

you can compute moments first, then get circle info from it.

rcen