首页 > 代码库 > 改变HSV的H和V部分(比如可以增加图像亮度)

改变HSV的H和V部分(比如可以增加图像亮度)

程序:

效果:增加图像亮度

wKioL1PsZtySAxxoAAGUSEwchqM499.jpg

代码:

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
void Max(IplImage* hsv)
{
for(int rows=0;rows<hsv->height;rows++)
{
float *data=http://www.mamicode.com/(float *)(hsv->imageData+rows*hsv->widthStep);"e:\\picture\\4.jpg");
cvNamedWindow("BGRSrc");
cvShowImage("BGRSrc",BGRSrc);
IplImage* BGR32=cvCreateImage(cvGetSize(BGRSrc),32,BGRSrc->nChannels); 
cvZero(BGR32);
cvConvertScale(BGRSrc,BGR32);//把源图像转换成32位浮点型
IplImage* HSV=cvCreateImage(cvGetSize(BGRSrc),32,BGRSrc->nChannels);
cvZero(HSV);
cvCvtColor(BGR32,HSV,CV_BGR2HSV);//BGR转换为HSV
cvNamedWindow("HSV");
cvShowImage("HSV",HSV);
Max(HSV);                         //改变HSV
cvNamedWindow("HSVMax");
cvShowImage("HSVMax",HSV);
cvZero(BGR32);
cvCvtColor(HSV,BGR32,CV_HSV2BGR); //HSV转换为BGR32位
cvNamedWindow("BGR32Dst");
cvShowImage("BGR32Dst",BGR32);
IplImage* BGRDst=cvCreateImage(cvGetSize(BGRSrc),8,BGRSrc->nChannels);
cvZero(BGRDst);
cvConvertScale(BGR32,BGRDst);   //BGR32位转换为BGR8位
cvNamedWindow("BGRDst");
cvShowImage("BGRDst",BGRDst);
cvWaitKey(0);
cvDestroyWindow("BGRSrc");
cvDestroyWindow("HSV");
cvDestroyWindow("HSVMax");
cvDestroyWindow("BGR32Dst");
cvDestroyWindow("BGRDst");
cvReleaseImage(&BGRSrc);
cvReleaseImage(&BGR32);
cvReleaseImage(&HSV);
cvReleaseImage(&BGRDst);
return 0;
}


本文出自 “flyclc” 博客,请务必保留此出处http://flyclc.blog.51cto.com/1385758/1539972