/*#include <cv.h>
#include <highgui.h>
void main( int argc, char** argv )
{
IplImage* src=cvLoadImage("E:\\picture\\刘亦非\\刘亦非\\happy.BMP");;
if( argc == 2 && (src=cvLoadImage(argv[1], 1))!= 0)
{
IplImage* h_plane = cvCreateImage( cvGetSize(src), 8, 1 );
IplImage* s_plane = cvCreateImage( cvGetSize(src), 8, 1 );
IplImage* v_plane = cvCreateImage( cvGetSize(src), 8, 1 );
IplImage* planes[] = { h_plane, s_plane };
IplImage* hsv = cvCreateImage( cvGetSize(src), 8, 3 );
int h_bins = 30, s_bins = 32;
int hist_size[] = {h_bins, s_bins};
hue varies from 0 (~0°red) to 180 (~360°red again)
float h_ranges[] = { 0, 180 };
saturation varies from 0 (black-gray-white) to 255 (pure spectrum color)
float s_ranges[] = { 0, 255 };
float* ranges[] = { h_ranges, s_ranges };
int scale = 10;
IplImage* hist_img = cvCreateImage( cvSize(h_bins*scale,s_bins*scale), 8, 3 );
CvHistogram* hist;
float max_value = 0;
int h, s;
cvCvtColor( src, hsv, CV_BGR2HSV );
cvCvtPixToPlane( hsv, h_plane, s_plane, v_plane, 0 );
hist = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 );
cvCalcHist( planes, hist, 0, 0 );
cvGetMinMaxHistValue( hist, 0, &max_value, 0, 0 );
cvZero( hist_img );
for( h = 0; h < h_bins; h++ )
{
for( s = 0; s < s_bins; s++ )
{
float bin_val = cvQueryHistValue_2D( hist, h, s );
int intensity = cvRound(bin_val*255/max_value);
cvRectangle( hist_img, cvPoint( h*scale, s*scale ),
cvPoint( (h+1)*scale - 1, (s+1)*scale - 1),
CV_RGB(intensity,intensity,intensity), graw a grayscale histogram.
if you have idea how to do it
nicer let us know
CV_FILLED );
}
}
cvNamedWindow( "Source", 1 );
cvShowImage( "Source", src );
cvNamedWindow( "H-S Histogram", 1 );
cvShowImage( "H-S Histogram", hist_img );
cvWaitKey(0);
}
}*/
//一维灰度直方图
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
int HistogramBlock = 256;
float HistogramRange1[2]={0,255};
float *HistogramRange[1]={&HistogramRange1[0]};
void main()
{
IplImage *Image1;
CvHistogram *Histogram1;
IplImage *HistogramImage1;
Image1=cvLoadImage("F:\\opencv编程\\3.BMP",0);
Histogram1 = cvCreateHist(1,&HistogramBlock,CV_HIST_ARRAY,HistogramRange);
HistogramImage1 = cvCreateImage(cvSize(256,300),8,1);
HistogramImage1->origin=1;
cvCalcHist(&Image1,Histogram1);
printf("type is : %d\n",Histogram1->type);
printf("Low Bound is : %.f\n",Histogram1->thresh[0][0]);
printf("Up Bound is : %.f\n",Histogram1->thresh[0][1]);
printf("The Block is : %d\n",((CvMatND *) Histogram1->bins)->dim[0].size);
printf("\nGray Level Values:\n");
for(int i=0;i<HistogramBlock;i++)
{
printf("%.f \n",((CvMatND *) Histogram1->bins)->data.fl[i]);
cvLine(HistogramImage1,cvPoint(i,0),cvPoint(i,(int)(cvQueryHistValue_1D(Histogram1,i)/10)),CV_RGB(127,127,127));
}
cvNamedWindow("Histogram",1);
cvNamedWindow("Riverbank",1);
cvShowImage("Riverbank",Image1);
cvShowImage("Histogram",HistogramImage1);
cvWaitKey(0);
}
/*制定灰度范围的灰度直方图
#define CV_HIST_ARRAY 0
#define CV_HIST_SPARSE 1
#define CV_HIST_TREE CV_HIST_SPARSE
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
int HistogramBlock = 50;
int HistogramBlockWidth;
float HistogramRange1[2]={30,200};
float *HistogramRange[1]={&HistogramRange1[0]};
void main()
{
IplImage *Image1;
CvHistogram *Histogram1;
IplImage *HistogramImage1;
CvPoint Point1;
CvPoint Point2;
Image1=cvLoadImage("E:\\picture\\刘亦非\\刘亦非\\happy.BMP",0);
Histogram1 = cvCreateHist(1,&HistogramBlock,CV_HIST_ARRAY,HistogramRange);
HistogramImage1 = cvCreateImage(cvSize(256,300),8,3);
cvSetZero(HistogramImage1);
HistogramImage1->origin=1;
HistogramBlockWidth=256/HistogramBlock;
printf("The Bolck Width is : %d\n",HistogramBlockWidth);
cvCalcHist(&Image1,Histogram1);
printf("Gray Level Values:\n");
for(int i=0;i<HistogramBlock;i++)
{
printf("%.f \n",((CvMatND *) Histogram1->bins)->data.fl[i]);
Point1=cvPoint(i*HistogramBlockWidth,0);
Point2=cvPoint((i+1)*HistogramBlockWidth,(int)cvQueryHistValue_1D(Histogram1,i)/50);
cvRectangle(HistogramImage1,Point1,Point2,CV_RGB(0,0,127));
}
cvNamedWindow("Histogram",1);
cvNamedWindow("Riverbank",1);
cvShowImage("Riverbank",Image1);
cvShowImage("Histogram",HistogramImage1);
cvWaitKey(0);
}
*/
/****************************
* change image histogram example
* date:08-11-1
* author: wml
* copyright:1.0
*****************************/
/*#include <cv.h>
#include <highgui.h>
#include <cvaux.h>
#include <cxcore.h>
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#pragma comment(lib,"cv")
#pragma comment(lib,"cvaux")
#pragma comment(lib,"cxcore")
#pragma comment(lib,"highgui")
int Histogram3DBlock[3] = {256,256,256};
float HistogramRange1[6]={0,255,0,255,0,255};
float *HistogramRange[3]={&HistogramRange1[0],&HistogramRange1[2],&HistogramRange1[4]};
void Print3DHistogram(CvHistogram *Histogram,int BlockSize);
void main()
{
CvHistogram *Histogram1;
IplImage *Image1=cvLoadImage("E:\\picture\\刘亦非\\刘亦非\\happy.BMP",1);
IplImage *RedImage=cvCreateImage(cvGetSize(Image1),8,1);
IplImage *GreenImage=cvCreateImage(cvGetSize(Image1),8,1);
IplImage *BlueImage=cvCreateImage(cvGetSize(Image1),8,1);
IplImage *ImageArray[3]={RedImage,GreenImage,BlueImage};
cvSplit(Image1,BlueImage,GreenImage,RedImage,0);
Histogram1 = cvCreateHist(3,Histogram3DBlock,CV_HIST_SPARSE,HistogramRange);
cvCalcHist(ImageArray,Histogram1);
printf("3D Historgram Data\n");
Print3DHistogram(Histogram1,256);
cvNamedWindow("Riverbank",1);
cvShowImage("Riverbank",Image1);
cvWaitKey(0);
}
void Print3DHistogram(CvHistogram *Histogram,int BlockSize)
{
for(int i=0;i<BlockSize;i++)
{
for(int j=0;j<BlockSize;j++)
{
for(int k=0;k<BlockSize;k++)
{
if(cvQueryHistValue_3D(Histogram,i,j,k)>10)
{
printf("%5.f",cvQueryHistValue_3D(Histogram,i,j,k));
}
}
// printf("***");
}
printf("\n");
}
}
*/
没有合适的资源?快使用搜索试试~ 我知道了~
hist--example.rar_exe直方图在那_hist
共13个文件
pdb:2个
dsw:1个
exe:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 158 浏览量
2022-09-24
14:19:54
上传
评论
收藏 252KB RAR 举报
温馨提示
各种直方图的求法。可以求取并显示各种直方图。
资源推荐
资源详情
资源评论
收起资源包目录
hist--example.rar (13个子文件)
hist--example
直方图.plg 789B
直方图.opt 48KB
直方图.dsw 537B
直方图.dsp 3KB
直方图.ncb 41KB
Debug
vc60.idb 193KB
直方图.obj 18KB
直方图.pch 183KB
vc60.pdb 132KB
直方图.ilk 206KB
直方图.pdb 457KB
直方图.exe 184KB
直方图.cpp 7KB
共 13 条
- 1
资源评论
JaniceLu
- 粉丝: 95
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功