changes in the enumerations in order to make code simpler in frame statistics
This commit is contained in:
1 parent
8f97089f0d
commit
cafbf41ac9
3 files changed
+54
-97
No files matched your search
+15
-15
@@ -527,24 +527,24 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
|
||||
switch( m_channelType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelHistogram: // Y channel.
|
||||
max = histogram->getMaximum( PlaYUVerFrameStats::YChannel );
|
||||
max = histogram->getMaximum( LUMA );
|
||||
break;
|
||||
case HistogramWidget::SecondChannelHistogram: // Cb channel.
|
||||
max = histogram->getMaximum( PlaYUVerFrameStats::CbChannel );
|
||||
max = histogram->getMaximum( CHROMA_U );
|
||||
break;
|
||||
case HistogramWidget::ThirdChannelHistogram: // Cr channel.
|
||||
max = histogram->getMaximum( PlaYUVerFrameStats::CrChannel );
|
||||
max = histogram->getMaximum( CHROMA_V );
|
||||
break;
|
||||
case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
|
||||
max = histogram->getMaximum( PlaYUVerFrameStats::AlphaChannel );
|
||||
max = histogram->getMaximum( COLOR_A );
|
||||
break;
|
||||
|
||||
case HistogramWidget::ColorChannelsHistogram: // All color channels.
|
||||
max = qMax( qMax( histogram->getMaximum( PlaYUVerFrameStats::YChannel ), histogram->getMaximum( PlaYUVerFrameStats::CbChannel ) ),
|
||||
histogram->getMaximum( PlaYUVerFrameStats::CrChannel ) );
|
||||
max = qMax( qMax( histogram->getMaximum( LUMA ), histogram->getMaximum( CHROMA_U ) ),
|
||||
histogram->getMaximum( CHROMA_V ) );
|
||||
break;
|
||||
case HistogramWidget::LumaHistogram: // Luminance.
|
||||
max = histogram->getMaximum( PlaYUVerFrameStats::LumaChannel );
|
||||
max = histogram->getMaximum( LUMA );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -591,24 +591,24 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
|
||||
switch( m_channelType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelHistogram: // Y channel.
|
||||
v = histogram->getHistogramValue( PlaYUVerFrameStats::YChannel, i++ );
|
||||
v = histogram->getHistogramValue( LUMA, i++ );
|
||||
break;
|
||||
case HistogramWidget::SecondChannelHistogram: // Cb channel.
|
||||
v = histogram->getHistogramValue( PlaYUVerFrameStats::CbChannel, i++ );
|
||||
v = histogram->getHistogramValue( CHROMA_U, i++ );
|
||||
break;
|
||||
case HistogramWidget::ThirdChannelHistogram: // Cr channel.
|
||||
v = histogram->getHistogramValue( PlaYUVerFrameStats::CrChannel, i++ );
|
||||
v = histogram->getHistogramValue( CHROMA_V, i++ );
|
||||
break;
|
||||
case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
|
||||
v = histogram->getHistogramValue( PlaYUVerFrameStats::AlphaChannel, i++ );
|
||||
v = histogram->getHistogramValue( COLOR_A, i++ );
|
||||
break;
|
||||
case HistogramWidget::ColorChannelsHistogram: // All color.
|
||||
vr = histogram->getHistogramValue( PlaYUVerFrameStats::YChannel, i );
|
||||
vg = histogram->getHistogramValue( PlaYUVerFrameStats::CbChannel, i );
|
||||
vb = histogram->getHistogramValue( PlaYUVerFrameStats::CrChannel, i++ );
|
||||
vr = histogram->getHistogramValue( LUMA, i );
|
||||
vg = histogram->getHistogramValue( CHROMA_U, i );
|
||||
vb = histogram->getHistogramValue( CHROMA_U, i++ );
|
||||
break;
|
||||
case HistogramWidget::LumaHistogram: // Luminance.
|
||||
v = histogram->getHistogramValue( PlaYUVerFrameStats::LumaChannel, i++ );
|
||||
v = histogram->getHistogramValue( LUMA, i++ );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
+38
-60
@@ -45,15 +45,15 @@ PlaYUVerFrameStats::~PlaYUVerFrameStats()
|
||||
{
|
||||
if( m_puiHistogram )
|
||||
{
|
||||
delete [] m_puiHistogram;
|
||||
//freeMem1D( m_puiHistogram );
|
||||
//delete[] m_puiHistogram;
|
||||
freeMem1D( m_puiHistogram );
|
||||
}
|
||||
m_puiHistogram = NULL;
|
||||
m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
// statistics
|
||||
Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt options )
|
||||
Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame )
|
||||
{
|
||||
m_pppImageData = pcFrame->getPelBufferYUV();
|
||||
m_uiImageWidth = pcFrame->getWidth();
|
||||
@@ -64,12 +64,7 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op
|
||||
imageColorSpace = pcFrame->getColorSpace();
|
||||
imageChromaSize = pcFrame->getChromaLength();
|
||||
|
||||
if( options == CalcLumaWhenRGB )
|
||||
calcLuma = true;
|
||||
else
|
||||
calcLuma = false;
|
||||
|
||||
if( calcLuma && ( imageColorSpace == PlaYUVerFrame::COLOR_RGB ) )
|
||||
if( imageColorSpace == PlaYUVerFrame::COLOR_RGB || imageColorSpace == PlaYUVerFrame::COLOR_ARGB )
|
||||
histoChannels = m_uiChannels + 1;
|
||||
else
|
||||
histoChannels = m_uiChannels;
|
||||
@@ -80,15 +75,15 @@ Void PlaYUVerFrameStats::calcHistogram()
|
||||
if( m_bHasHistogram )
|
||||
return;
|
||||
|
||||
m_bHasHistogram = new UInt[m_uiHistoSegments * histoChannels];
|
||||
//getMem1D<UInt>( &( m_puiHistogram ), m_uiHistoSegments * histoChannels );
|
||||
if( !m_puiHistogram )
|
||||
{
|
||||
// qWarning() << "PlaYUVerFrameStats::calcHistogramValuess: "
|
||||
// "Unable to allocate memory!" << endl;
|
||||
return;
|
||||
//m_puiHistogram = new UInt[m_uiHistoSegments * histoChannels];
|
||||
getMem1D<UInt>( &( m_puiHistogram ), m_uiHistoSegments * histoChannels );
|
||||
if( !m_puiHistogram )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_bRunningFlag = true;
|
||||
|
||||
UInt i, j;
|
||||
@@ -109,9 +104,8 @@ Void PlaYUVerFrameStats::calcHistogram()
|
||||
for( j = 1; j < m_uiChannels; j++ )
|
||||
{
|
||||
m_puiHistogram[*( data[j] ) + j * m_uiHistoSegments]++;
|
||||
}
|
||||
for( j = 1; j < m_uiChannels; j++ )
|
||||
data[j] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -128,7 +122,7 @@ Void PlaYUVerFrameStats::calcHistogram()
|
||||
{
|
||||
m_puiHistogram[*( data[j] ) + j * m_uiHistoSegments]++;
|
||||
}
|
||||
if( calcLuma && ( imageColorSpace == PlaYUVerFrame::COLOR_RGB || imageColorSpace == PlaYUVerFrame::COLOR_ARGB ) )
|
||||
if( ( imageColorSpace == PlaYUVerFrame::COLOR_RGB || imageColorSpace == PlaYUVerFrame::COLOR_ARGB ) )
|
||||
{
|
||||
PlaYUVerFrame::Pixel currPixel( imageColorSpace, *( data[COLOR_R] ), *( data[COLOR_G] ), *( data[COLOR_B] ) );
|
||||
luma = PlaYUVerFrame::ConvertPixel( currPixel, PlaYUVerFrame::COLOR_YUV ).Y();
|
||||
@@ -154,70 +148,54 @@ Int PlaYUVerFrameStats::getRealHistoChannel( Int channel )
|
||||
switch( imageColorSpace )
|
||||
{
|
||||
case PlaYUVerFrame::COLOR_GRAY:
|
||||
if( channel != LumaChannel )
|
||||
if( channel != LUMA )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
histoChannel = 0;
|
||||
break;
|
||||
case PlaYUVerFrame::COLOR_RGB:
|
||||
if( channel != RedChannel && channel != GreenChannel && channel != BlueChannel && ( channel != LumaChannel && calcLuma ) )
|
||||
if( channel != COLOR_R && channel != COLOR_G && channel != COLOR_B && channel != LUMA )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( channel == RedChannel )
|
||||
histoChannel = 0;
|
||||
|
||||
if( channel == GreenChannel )
|
||||
histoChannel = 1;
|
||||
|
||||
if( channel == BlueChannel )
|
||||
histoChannel = 2;
|
||||
|
||||
if( channel == LumaChannel )
|
||||
if( channel == LUMA )
|
||||
{
|
||||
histoChannel = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
histoChannel = channel;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PlaYUVerFrame::COLOR_ARGB:
|
||||
if( channel != RedChannel && channel != GreenChannel && channel != BlueChannel && channel != AlphaChannel && ( channel != LumaChannel && calcLuma ) )
|
||||
if( channel != COLOR_R && channel != COLOR_G && channel != COLOR_B && channel != COLOR_A && channel != LUMA )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( channel == AlphaChannel )
|
||||
histoChannel = 0;
|
||||
|
||||
if( channel == RedChannel )
|
||||
histoChannel = 1;
|
||||
|
||||
if( channel == GreenChannel )
|
||||
histoChannel = 2;
|
||||
|
||||
if( channel == BlueChannel )
|
||||
histoChannel = 3;
|
||||
|
||||
if( channel == LumaChannel )
|
||||
if( channel == LUMA )
|
||||
{
|
||||
histoChannel = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
histoChannel = channel;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PlaYUVerFrame::COLOR_YUV:
|
||||
if( channel != LumaChannel && channel != YChannel && channel != CbChannel && channel != CrChannel )
|
||||
if( channel != LUMA && channel != CHROMA_U && channel != CHROMA_V )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( channel == YChannel || channel == LumaChannel )
|
||||
histoChannel = 0;
|
||||
|
||||
if( channel == CbChannel )
|
||||
histoChannel = 1;
|
||||
|
||||
if( channel == CrChannel )
|
||||
histoChannel = 2;
|
||||
histoChannel = channel;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -233,7 +211,7 @@ Double PlaYUVerFrameStats::getCount( Int channel, UInt start, UInt end )
|
||||
Int indexStart;
|
||||
Double count = 0.0;
|
||||
|
||||
if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
if( !m_bHasHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -256,7 +234,7 @@ Double PlaYUVerFrameStats::getCount( Int channel, UInt start, UInt end )
|
||||
|
||||
Double PlaYUVerFrameStats::getPixels()
|
||||
{
|
||||
if( !m_puiHistogram )
|
||||
if( !m_bHasHistogram )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -271,7 +249,7 @@ Double PlaYUVerFrameStats::getMean( Int channel, UInt start, UInt end )
|
||||
Double mean = 0.0;
|
||||
Double count;
|
||||
|
||||
if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
if( !m_bHasHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -307,7 +285,7 @@ Int PlaYUVerFrameStats::getMedian( Int channel, UInt start, UInt end )
|
||||
Double sum = 0.0;
|
||||
Double count;
|
||||
|
||||
if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
if( !m_bHasHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -341,7 +319,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end )
|
||||
Double count;
|
||||
Double mean;
|
||||
|
||||
if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
if( !m_bHasHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -386,7 +364,7 @@ Double PlaYUVerFrameStats::getHistogramValue( Int channel, UInt bin )
|
||||
Int histoChannel;
|
||||
Int indexStart;
|
||||
|
||||
if( !m_puiHistogram || bin < 0 || bin > m_uiHistoSegments - 1 )
|
||||
if( !m_bHasHistogram || bin < 0 || bin > m_uiHistoSegments - 1 )
|
||||
return 0.0;
|
||||
|
||||
histoChannel = getRealHistoChannel( channel );
|
||||
@@ -410,7 +388,7 @@ Double PlaYUVerFrameStats::getMaximum( Int channel )
|
||||
Int histoChannel;
|
||||
Int indexStart;
|
||||
|
||||
if( !m_puiHistogram )
|
||||
if( !m_bHasHistogram )
|
||||
return 0.0;
|
||||
|
||||
histoChannel = getRealHistoChannel( channel );
|
||||
|
||||
@@ -39,24 +39,6 @@ class PlaYUVerFrameStats
|
||||
|
||||
public:
|
||||
|
||||
enum StatisticsChannel
|
||||
{
|
||||
LumaChannel = 0,
|
||||
RedChannel = 1,
|
||||
GreenChannel = 2,
|
||||
BlueChannel = 3,
|
||||
AlphaChannel = 4,
|
||||
YChannel = 1,
|
||||
CbChannel = 2,
|
||||
CrChannel = 3
|
||||
};
|
||||
|
||||
enum StatisticsOptions
|
||||
{
|
||||
CalcLumaWhenRGB = 1
|
||||
};
|
||||
|
||||
public:
|
||||
PlaYUVerFrameStats();
|
||||
~PlaYUVerFrameStats();
|
||||
|
||||
@@ -97,9 +79,6 @@ private:
|
||||
/** The histogram data.*/
|
||||
UInt* m_puiHistogram;
|
||||
|
||||
/** If true, calc the luminosity channel histogram when the image is RGB */
|
||||
Bool calcLuma;
|
||||
|
||||
/** If the image is RGB and calcLuma is true, we have 1 more channel */
|
||||
Int histoChannels;
|
||||
|
||||
@@ -123,7 +102,7 @@ protected:
|
||||
|
||||
Bool m_bHasHistogram;
|
||||
|
||||
Void xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt options = CalcLumaWhenRGB );
|
||||
Void xSetupStatistics( const PlaYUVerFrame *pcFrame );
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user