将图像的HSV中的SV最大化

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
void saturate_sv(IplImage* img)
{
    for(int y=0;y<img->height;y++)
    {
        uchar* ptr=(uchar*)(img->imageData+y*img->widthStep);
        for(int x=0;x<img->width;x++)
        {
          ptr[3*x+1]=255;
          ptr[3*x+2]=255;
        }
    }
    
}
int main()
{
    IplImage* image=cvLoadImage("test.jpg");
    cvNamedWindow("Example");
    cvShowImage("Example",image);
    saturate_sv(image);
    cvShowImage("Later",image);
    cvReleaseImage(&image);
    cvWaitKey(0);
    cvDestroyWindow("Example");
    cvDestroyWindow("Later");
 
}

其实(3*x+1)值得是G通道,(3*x+2)值得是R通道 ,自然(3*x)就是B通道

那为什么R,G通道变成255,图像的S,V会最大化,我就不不懂了~

posted @ 2012-05-30 16:59  Epirus  阅读(297)  评论(0编辑  收藏  举报