www.pudn.com > partsumhist.rar > calhistpercent.cpp
#include "StdAfx.h"
/*-------------CalHistPercent------计算直方图百分比----------------------
hist: 输入直方图数列
hist_radio: 输出百分比直方图数列
max_percent: 输出直方图最大百分比
------------------------------------------------------------------------*/
void CalHistPercent(long hist[],float hist_radio[],float &max_percent)
{
float max_value;
int i;
float total=(float)0;
for(i=0;i<256;i++)
total=total+(float)hist[i];
max_value=0; //初始化
for(i=0;i<256;i++) {
//计算比例
if(total>0)
hist_radio[i]=((hist[i]/total)*(float)100);
//求最大像素数
if(max_value