• 大小: 1022KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-01-08
  • 语言: C/C++
  • 标签: c++opencv  

资源简介

在VC6.0下基于opencv,实现将rgb彩色图像转换为hsv并分解为单通道灰度图,绘制灰度直方图,并且将其各个通道像素值显示出来。

资源截图

代码片段和文件信息

// get1.cpp : Defines the entry point for the console application.
//

#include “stdafx.h“
#include “cv.h“
#include “highgui.h“
#include “cxcore.h“

IplImage* DrawHistogram(CvHistogram* hist  float scaleX = 1 float scaleY = 1)
{
float histMax = 0 ;
cvGetMinMaxHistValue( hist  0  &histMax  0  0 ) ;//设置直方图最大高度不超出窗口

IplImage* imgHist = cvCreateImage( cvSize( 256*scaleX  64*scaleY )  8  1 );
cvZero( imgHist ) ;//为直方图创建图像

for(int i=0;i<255;i++)
{
float histValue = cvQueryHistValue_1D( hist i ) ;//获取当前像素的bin值
float nextValue = cvQueryHistValue_1D( hist i+1 ) ;//获取下个像素的bin值

CvPoint pt1 = cvPoint(     i*scaleX  64*scaleY) ;
CvPoint pt2 = cvPoint( (i+1)*scaleX  64*scaleY) ;
CvPoint pt3 = cvPoint( (i+1)*scaleX  (1-nextValue/histMax)*64*scale

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-13 10:55  get1\
     目录           0  2014-04-13 10:55  get1\Debug\
     文件        2514  2014-04-13 10:31  get1\Debug\StdAfx.obj
     文件        4132  2014-04-13 10:31  get1\Debug\StdAfx.sbr
     文件     2032640  2014-04-13 10:55  get1\Debug\get1.bsc
     文件      188504  2014-04-13 10:55  get1\Debug\get1.exe
     文件      268388  2014-04-13 10:55  get1\Debug\get1.ilk
     文件       35054  2014-04-13 10:55  get1\Debug\get1.obj
     文件       43520  2014-04-13 10:24  get1\Debug\get1.opt
     文件      335068  2014-04-13 10:31  get1\Debug\get1.pch
     文件      467968  2014-04-13 10:55  get1\Debug\get1.pdb
     文件           0  2014-04-13 10:55  get1\Debug\get1.sbr
     文件      107520  2014-04-13 10:55  get1\Debug\vc60.idb
     文件      151552  2014-04-13 10:55  get1\Debug\vc60.pdb
     文件        1196  2014-04-13 09:04  get1\ReadMe.txt
     文件         291  2014-04-13 09:04  get1\StdAfx.cpp
     文件         769  2014-04-13 09:04  get1\StdAfx.h
     文件        4876  2014-04-13 10:55  get1\get1.cpp
     文件        4574  2014-04-13 10:55  get1\get1.dsp
     文件         516  2014-04-13 09:04  get1\get1.dsw
     文件       33792  2014-04-13 10:55  get1\get1.ncb
     文件       53760  2014-04-13 10:55  get1\get1.opt
     文件        3104  2014-04-13 10:55  get1\get1.plg

评论

共有 条评论