0

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!

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
frx08
  • 4,222
  • 8
  • 37
  • 45

3 Answers3

2

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
  • 10,062
  • 15
  • 61
  • 69
1

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

rcen
  • 11
  • 2
0

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
  • 65,249
  • 10
  • 91
  • 131
  • in that program I use functions of OpenCV so I think is better use OpenCV that implements also the drawing of a circle – frx08 Mar 13 '10 at 18:35