The entropy of the image was added to the statistics.

This commit is contained in:
Joao Santos committed 2020-12-10 17:16:38 +00:00
1 parent c1cef58de1
commit f6cc0ffd29
5 files changed
+42

No files matched your search

+26
View File
@@ -1132,6 +1132,32 @@ double CalypFrame::getHistogramValue( unsigned channel, unsigned int bin )
return d->m_puiHistogram[indexStart + bin];
}
double CalypFrame::getEntropy( unsigned channel, unsigned int start, unsigned int end )
{
if( !d->m_bHasHistogram )
return 0;
channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
return 0;
int indexStart = channel * d->m_uiHistoSegments;
double numValues = getNumPixelsRange( channel, start, end );
double entropy = 0.0;
for( unsigned b = start; b < end; b++ )
{
if (d->m_puiHistogram[indexStart + b] == 0)
continue;
double prob = d->m_puiHistogram[indexStart + b] / numValues;
entropy -= prob * log2(prob);
}
return entropy;
}
/*
**************************************************************
* interface to other libs
+1
View File
@@ -382,6 +382,7 @@ public:
double getHistogramValue( unsigned channel, unsigned int bin );
unsigned int getNEBins( unsigned channel );
int getNumHistogramSegment();
double getEntropy( unsigned channel, unsigned int start, unsigned int end );
/**
* interface with OpenCV lib