#include "cv.h"
#include "highgui.h"
#include <IOSTREAM.H>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"highgui.lib")
#pragma comment(lib,"cxcore.lib")
CvHistogram* createMyHist(IplImage* image, const char* windowName )
{
if (image->nChannels != 3)
{
return NULL;
}
IplImage* hsv = cvCreateImage(cvGetSize(image),image->depth,3);
cvCvtColor(image,hsv,(image->channelSeq == "RGB")?CV_RGB2HSV:CV_BGR2HSV);//转换成HSV图像
IplImage* h_plane = cvCreateImage(cvGetSize(image),8,1);
IplImage* s_plane = cvCreateImage(cvGetSize(image),8,1);
IplImage* v_plane = cvCreateImage(cvGetSize(image),8,1);
cvCvtPixToPlane(hsv,h_plane,s_plane,v_plane,0);//分成H,S,V三个通道
IplImage* planes[] = {h_plane,s_plane};
//还是准备Hist所需的各种参数
int h_bins = 30; //h分量分成30分
int s_bins = 32; //s分量分成32份
float h_ranges[] = {0,180};//h分量的范围
float s_ranges[] = {0,255};//S
学习opencv第七章7.2
最新推荐文章于 2023-12-12 17:31:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)