1 #include "PDFHistogram2D.h" 8 memset(
m_data, 0, 256 * 256 *
sizeof(
long));
17 memset(
m_data, 0, 256 * 256 *
sizeof(
long));
23 byte x =
static_cast<byte
>(MIN(255, MAX(0, point[0])));
24 byte y =
static_cast<byte
>(MIN(255, MAX(0, point[1])));
31 byte x =
static_cast<byte
>(MIN(255, MAX(0, point[0])));
32 byte y =
static_cast<byte
>(MIN(255, MAX(0, point[1])));
39 for (
int iter = 0; iter < nIt; iter++) {
40 memcpy(tmp,
m_data, 256 * 256 *
sizeof(
long));
41 for (
int x = 1; x < 255; x++)
42 for (
int y = 1; y < 255; y++)
43 m_data[x][y] = static_cast<long>(0.125 * (tmp[x][y-1] + tmp[x-1][y] + 4 * tmp[x][y] + tmp[x+1][y] + tmp[x][y+1]));
49 fwrite(&
m_data,
sizeof(
long), 256 * 256, pFile);
50 fwrite(&
m_nPoints,
sizeof(
long), 1, pFile);
55 fread(&
m_data,
sizeof(
long), 256 * 256, pFile);
56 fread(&
m_nPoints,
sizeof(
long), 1, pFile);
virtual void reset(void)
Resets class variables.
virtual void saveFile(FILE *pFile) const
Saves the random model into the file.
long m_nPoints
The number of samples, added with the addPoint() function.
void smooth(int nIt=1)
Performs the gaussian smoothing on histogram.
Interface class for Probability Density Function (PDF)
virtual ~CPDFHistogram2D(void)
virtual void loadFile(FILE *pFile)
Loads the random model from the file.
virtual void addPoint(Scalar point)
Adds a sample point for PDF estimation.
virtual double getDensity(Scalar point)
Returns the probability density value for the argument point.