ocmath_b_frequency_count
Description
Frequency Count for type byte.
Syntax
int ocmath_b_frequency_count( BYTE * pSource, uint nSourceSize, uint * pDest, uint nDestSize, BYTE bBinBegin, BYTE bBinIncrement )
Parameters
- pSource
- [input] buffer containing data to be counted
- nSourceSize
- [input] size of pSource
- pDest
- [output] buffer of count results
- nDestSize
- [input] size of pDest
- bBinBegin
- [input] first bin's left edge
- bBinIncrement
- [input] width of each bins
Return
Returns OE_NOERROR(0) on success.
Examples
EX1
void ocmath_b_frequency_count_Ex1()
{
vector<byte> vecData = {1, 2, 3, 4, 5};
vector<uint> vecFCount;
uint i1 = 0;
uint i2 = vecData.GetSize()-1;
uint min; //the index for min value in vecData
uint max; //the index for max value in vecData
byte binW = 1; //width of each bin
int iSize = 5; //size of vecFCount
vecFCount.SetSize(iSize);
uint nMissingValues = ocmath_b_minmax(vecData, i1, i2, NULL, &min, &max);
bool bRet = ocmath_b_frequency_count(vecData, vecData.GetSize(), vecFCount, vecFCount.GetSize(), vecData[min], binW);
vector binCenter;
binCenter.Data(vecData[min]+binW/2, vecData[max]-binW/2, binW); // Calculate bin center data
for (int i = 0; i < iSize; i++)
{
printf("%.0f\t",binCenter[i]);
printf("%d\n",vecFCount[i]);
}
}
Remark
Count the frequency from bBinBegin to bBinIncrement* nDestSize ([bBinBegin, bBinIncrement* nDestSize))with bBinIncrement as interval.
See Also
vectorbase::FrequencyCount, ocmath_f_frequency_count, ocmath_us_frequency_count
header to Include
origin.h
Reference
|