資源簡介
在VC6.0下基于opencv,實(shí)現(xiàn)將rgb彩色圖像轉(zhuǎn)換為hsv并分解為單通道灰度圖,繪制灰度直方圖,并且將其各個(gè)通道像素值顯示出來。
代碼片段和文件信息
//?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?)?;//設(shè)置直方圖最大高度不超出窗口
IplImage*?imgHist?=?cvCreateImage(?cvSize(?256*scaleX??64*scaleY?)??8??1?);
cvZero(?imgHist?)?;//為直方圖創(chuàng)建圖像
for(int?i=0;i<255;i++)
{
float?histValue?=?cvQueryHistValue_1D(?hist?i?)?;//獲取當(dāng)前像素的bin值
float?nextValue?=?cvQueryHistValue_1D(?hist?i+1?)?;//獲取下個(gè)像素的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
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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
- 上一篇:c語言哈夫曼樹
- 下一篇:大地測量貝塞爾問題的解算
評論
共有 條評論