Something relates to Computer Science and Technology, something relates to China and something I am not sure!
Thursday, March 22, 2012
Get a sub image by OpenCV
The following code segment comes from the following link:
http://blog.weisu.org/2007/10/opencv-get-sub-image.html
and tells you how to get a sub image by OpenCV. If you want to use this code, do not forget release the return value, the iamge :)
IplImage* Sub_Image(IplImage *image, CvRect roi)
{
IplImage *result;
// set ROI, you may use following two funs:
//cvSetImageROI( image, cvRect( 0, 0, image->width, image->height ));
cvSetImageROI(image,roi);
// sub-image
result = cvCreateImage( cvSize(roi.width, roi.height), image->depth, image->nChannels );
cvCopy(image,result);
cvResetImageROI(image); // release image ROI
return result;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment