cvSetImageROI和cvResetImageROI

#include "cv.h"
#include "highgui.h"

int main()
{

IplImage* img=cvLoadImage("hello.jpg");
CvRect rect;
rect.x=0;
rect.y=0;
rect.height=48;
rect.width=48;
cvSetImageROI( img, rect );
cvNamedWindow( "tem image" );
cvShowImage("tem image",img);///显示pImg大小为48*48
//
IplImage *selimg=cvCreateImage(cvSize(rect.width,rect.height),8,3);
selimg=(IplImage*)cvClone(img);
cvNamedWindow( "select pImage");//可以看到selimg->width,selimg->height还是原图大小
cvShowImage("select pImage",selimg);///显示pImg大小为48*48
cvSaveImage("hello2.jpg",selimg);
cvResetImageROI(img);
cvWaitKey(0);
return 0;
}

你可能感兴趣的:(image,include)