0

I have a rectangle that I want to extract the ellipse form of it from a given image. My code looks like:

RotatedRect ellipse ;
float p1 = (float) rect.width/2 + rect.x;
float p2 = (float) rect.height/2 + rect.y;
CvPoint2D32f p = cvPoint2D32f(p1,p2);
ellipse.center = p;
ellipse.angle = 0;
ellipse.size =  cvSize2D32f((float)rect.width, (float)rect.height);
ellipse( image_colored, minEllipse, CV_RGB(255,255,255), 2, 8 );

The input of this code are: an image (image_colored) and CvRect (rect). The last line of code, draws a white ellipse inside the "image_colored", but I am looking to crop the generated ellipse in an other image or just color the rest of the image in black.

Any help, will be highly appreciated. Thank you.

PS: I can not use the function cvEllipse(...) as it was suggested in this link. Because cvEllipse does not accept an object of type CvPoint2D32f, neither CvSize2D32f type.

Community
  • 1
  • 1
  • "I can not use the function cvEllipse(...) as it was suggested" -- that's ok. stick with the c++ api for the better. avoid any cv*functions or structures from the deprecated c-api – berak Dec 16 '13 at 18:33

1 Answers1

2

Make an image with a filled ellipse and use this as a mask combined (bitwise and) with your image OpenCV bitwise_and + mask or Segmenting Lungs and nodules in CT images

Community
  • 1
  • 1
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263