#include "cv.h"
#include "highgui.h"
int main(){
IplImage* interest_img =cvLoadImage("lena.bmp");
CvRect interest_rect =cvRect(100,200,300,300);
IplImage* sub_img =cvCreateImageHeader(
cvSiz(interest_rect.width, interest_rect.width),
interest_img->depth,
interest_img->nChannels);
sub_img->origin =interest_img->origin;
sub_img->widthStep =interest_img->widthStep;
sub_img->imageData= interest_img->imageData +
interest_rect.y * interest_img->widthStep +
interest_rect.x *interest_img->nChannels;
cvAddS(sub_img,cvScalar(150), sub_img);
cvNamedWindow("sub_img");
cvShowImage("sub_img", sub_img);
cvWaitKey(0);
cvReleaseImageHeader(&sub_img);
cvDestroyWindow("sub_img");
return 0;
}
![](https://img-my.csdn.net/uploads/201301/27/1359289627_6524.png)