The entropy of the image was added to the statistics.
This commit is contained in:
@@ -204,6 +204,11 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitc
|
||||
labelMedianValue = new QLabel;
|
||||
labelMedianValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
|
||||
QLabel* entropyLabel = new QLabel( tr( "Entropy:" ) );
|
||||
entropyLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
labelEntropyValue = new QLabel;
|
||||
labelEntropyValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
|
||||
QLabel* percentileLabel = new QLabel( tr( "Percentile:" ) );
|
||||
percentileLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
labelPercentileValue = new QLabel;
|
||||
@@ -225,6 +230,8 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitc
|
||||
statisticsLayout->addWidget( labelStdDevValue, gridRow++, 1 );
|
||||
statisticsLayout->addWidget( medianLabel, gridRow, 0 );
|
||||
statisticsLayout->addWidget( labelMedianValue, gridRow++, 1 );
|
||||
statisticsLayout->addWidget( entropyLabel, gridRow, 0 );
|
||||
statisticsLayout->addWidget( labelEntropyValue, gridRow++, 1 );
|
||||
|
||||
QGroupBox* statisticsGroup = new QGroupBox( tr( "Statistics" ) );
|
||||
statisticsGroup->setLayout( statisticsLayout );
|
||||
@@ -474,6 +481,9 @@ void FramePropertiesDock::updateStatistiques()
|
||||
double median = frame->getMedian( channel, min, max );
|
||||
labelMedianValue->setText( value.setNum( median, 'f', 1 ) );
|
||||
|
||||
double entropy = frame->getEntropy( channel, min, max );
|
||||
labelEntropyValue->setText( value.setNum( entropy, 'f', 2 ) );
|
||||
|
||||
double percentile = ( pixels > 0 ? ( 100.0 * counts / pixels ) : 0.0 );
|
||||
labelPercentileValue->setText( value.setNum( percentile, 'f', 1 ) );
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ private:
|
||||
QLabel* labelMeanValue;
|
||||
QLabel* labelStdDevValue;
|
||||
QLabel* labelMedianValue;
|
||||
QLabel* labelEntropyValue;
|
||||
QLabel* labelPercentileValue;
|
||||
|
||||
QLabel* colorsLabel;
|
||||
|
||||
@@ -940,6 +940,10 @@ void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
double median = frame->getMedian( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
|
||||
tipText += value.setNum( median, 'f', 1 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Entropy:" ) + cellMid;
|
||||
double entropy = frame->getEntropy( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
|
||||
tipText += value.setNum( entropy, 'f', 2 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Percent:" ) + cellMid;
|
||||
double percentile = ( pixels > 0 ? ( 100.0 * counts / pixels ) : 0.0 );
|
||||
tipText += value.setNum( percentile, 'f', 1 ) + cellEnd;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user