2.1.24.4.46 ocmath_us_frequency_count
Description
Frequency Count for type ushort.
Syntax
int ocmath_us_frequency_count( USHORT * pSource, uint nSourceSize, uint * pDest, uint nDestSize, USHORT usBinBegin, USHORT usBinIncrement )
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
- usBinBegin
- [input] first bin's left edge
- usBinIncrement
- [input] width of each bins
Return
Returns OE_NOERROR(0) on success.
Examples
EX1
void ocmath_us_frequency_count_Ex1()
{
vector<ushort> 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
ushort binW = 1; //width of each bin
int iSize = 5; //size of vecFCount
vecFCount.SetSize(iSize);
uint nMissingValues = ocmath_us_minmax(vecData, i1, i2, NULL, &min, &max);
bool bRet = ocmath_us_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 usBinBegin to usBinIncrement* nDestSize ([usBinBegin, usBinIncrement* nDestSize))with usBinIncrement as interval.
See Also
vectorbase::FrequencyCount, ocmath_f_frequency_count, ocmath_b_frequency_count
Header to Include
origin.h
Reference
|