Thursday, March 22, 2012

Get a sub image by OpenCV

The following code segment comes from the following link:
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 ));

    // sub-image
    result = cvCreateImage( cvSize(roi.width, roi.height), image->depth, image->nChannels );
    cvResetImageROI(image); // release image ROI
    return result;

No comments:

Post a Comment