1:代码如下:
#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
#include "iostream"
using namespace std;
void saturate_sv(IplImage* img)
{
for(int y=0;y<img->height;y++)
{
uchar* ptr=(uchar*)(img->imageData+y*img->widthStep);//指针ptr指向y行的起始位置。uchar为字节类型。
for(int x=0;x<img->width;x++)
{
ptr[3*x+1]=255;
ptr[3*x+2]=255;
}
}
}
int main()
{
IplImage* img=cvLoadImage("C:\\horse.jpg");
saturate_sv(img);
cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);
cvShowImage("Example1",img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");
return 0;
}
运行结果: