After setting the ROI for a iplimage image with the Cvsetimageroi function, the image processing will be limited to the ROI region, which is equivalent to the image in Roi, and the test code value is only tested with cvcopy (function of copying image). In fact, for any function that handles an image iplimage type, processing an image class object that sets the ROI region is the ROI region for processing it.
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include void Main ()
{
Iplimage *RES,*DST;
Cvrect rect;
rect.x=130,rect.y=30,rect.width=200,rect.height=200;
Res=cvloadimage ("r1.jpg");//Load a picture
Dst=cvcreateimage (Cvsize (200,200), 8, 3);//Create Image Space
Create window
Cvnamedwindow ("res", cv_window_autosize);
Cvnamedwindow ("DST", cv_window_autosize);
Set ROI Area
Cvsetimageroi (Res,rect);
Extract ROI
Cvcopy (RES,DST);
Cancel Settings
Cvresetimageroi (RES);
Display image
Cvshowimage ("res", res);
Cvshowimage ("DST", DST);
Cvwaitkey (0);
Cvdestroywindow ("res");
Cvdestroywindow ("DST");
Cvreleaseimage (&res);
Cvreleaseimage (&DST);
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
OpenCV area of Interest established