OpenCV-将JPG图像的第二个通道和第三个通道的值设置为最大值

来源:互联网 发布:守望先锋生涯数据出错 编辑:程序博客网 时间:2024/06/05 23:36

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;}
运行结果:



阅读全文
0 0
原创粉丝点击