I have an image (cv::Mat) with size of 92x112
I want to surround the object in this image with a ellipse then get only this pixels to create another image containing only the object.
I mean, cropping the original image with a ellipse. It's possible?
I am trying drawing a ellipse, but the ellipse don't draw complete, with that:
ellipse(escalada, Point(92/2,112/2), Size(92/2*0.95,112/2*0.85), 0.0, 90.0, 0.0, Scalar(255,0,0), 3, 8);
and made some test with cvSetImageROI
to crop the image, but this method works only with cvRect
.
Some idea?
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 variable i have a image showing the ROI with a ellipse and the rest in black.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With