代码是在<<学习opencv>>的第52页,我直接填写了数字和路径
1 #include <cv.h> 2 #include <highgui.h> 3 // ch3_ex3_12 image_name x y width height add# 4 int main(int argc, char** argv) 5 { 6 7 IplImage* src; 8 cvNamedWindow("Example3_12_pre", CV_WINDOW_AUTOSIZE); 9 cvNamedWindow("Example3_12_post", CV_WINDOW_AUTOSIZE); 10 if( ((src=cvLoadImage("adrian.jpg",1)) != 0 )) 11 { 12 int x = 50; 13 int y = 50; 14 int width = 50; 15 int height = 50; 16 int add = 255; 17 cvShowImage( "Example3_12_pre", src); 18 cvSetImageROI(src, cvRect(x,y,width,height)); 19 cvAddS(src, cvScalar(add),src); 20 cvResetImageROI(src); 21 cvShowImage( "Example3_12_post",src); 22 cvWaitKey(); 23 } 24 cvReleaseImage( &src ); 25 cvDestroyWindow("Example3_12_pre"); 26 cvDestroyWindow("Example3_12_post"); 27 return 0; 28 }
原先位置:
调节x (x+=100 下类似):
调节y:
调节宽度
调节高度height: