I solve using this:
imagen = imread(nombre_imagen,0); //read image (grayscale)
//Use old C interface
IplImage *res,*roi;
IplImage src(imagen);
res = cvCreateImage(Size(imagen.rows,imagen.cols),8,1);
roi = cvCreateImage(Size(imagen.rows,imagen.cols),8,1);
cvZero(roi);
cvEllipse(roi,cvPoint(src.width/2,src.height/2),cvSize(src.width/2*0.85,src.height/2*0.95),0.0,0.0,360.0,CV_RGB(255,255,255),-1,8,0);
cvAnd(&src, &src, res, roi);
cvReleaseImage(&roi);
then in res res I have an image showing an ROI with an ellipse, and the rest in black.
source
share