#include "cv.h"
#include "highgui.h"
int main()
{
IplImage* img = cvLoadImage( "homework_3-6.jpg" );
/*创建两个图像,尺寸为200*300,深度、通道数、原点、每一行字节数(widthstep)与起始地址(imagedata)均与img相同*/
IplImage* dst1 = cvCreateImageHeader( cvSize(200,300), img->depth, img->nChannels );
IplImage* dst2 = cvCreateImageHeader( cvSize(200,300), img->depth, img->nChannels );
dst1->origin = img->origin;
dst2->origin = img->origin;
dst1->widthStep = img->widthStep;
dst2->widthStep = img->widthStep;
dst1->imageData = img->imageData + 10*img->widthStep + 5*img->nChannels;
dst2->imageData = img->imageData + 60*img->widthStep + 50*img->nChannels;
/*将dst中的每一个元素的每一位取反,再赋回给dst*/
cvNot( dst1, dst1 );
cvNot( dst2, dst2 );
/*显示*/
cvNamedWindow( "homework_3-6", CV_WINDOW_AUTOSIZE );
cvShowImage( "homework_3-6", img );
/*释放内存,销毁窗口*/
cvWaitKey(0);
cvReleaseImageHeader( &dst1 );
cvReleaseImageHeader( &dst2 );
return 0;
}
《学习OpenCV》练习3-6
最新推荐文章于 2019-07-04 15:02:31 发布