Improve histogram measurement and display.
Now it is possible to show histogram of luminance in RGB frames
This commit is contained in:
13 files changed
+463
-600
No files matched your search
+31
-72
@@ -42,8 +42,8 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
|
||||
channelLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
|
||||
|
||||
channelCB = new QComboBox;
|
||||
channelCB->addItem( tr( "Luminance" ) );
|
||||
channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) );
|
||||
//channelCB->addItem( tr( "Luminance" ) );
|
||||
//channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) );
|
||||
|
||||
channelCB->setWhatsThis( tr( "<p>Select here the histogram channel to display:<p>"
|
||||
"<b>Luminance</b>: Display luminance (perceived brightness).<p>"
|
||||
@@ -218,8 +218,6 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
|
||||
statisticsLayout->addWidget( labelStdDevValue, gridRow++, 1 );
|
||||
statisticsLayout->addWidget( medianLabel, gridRow, 0 );
|
||||
statisticsLayout->addWidget( labelMedianValue, gridRow++, 1 );
|
||||
// statisticsLayout->addWidget( percentileLabel, 5, 0 );
|
||||
// statisticsLayout->addWidget( labelPercentileValue, 5, 1 );
|
||||
|
||||
QGroupBox* statisticsGroup = new QGroupBox( tr( "Statistics" ) );
|
||||
statisticsGroup->setLayout( statisticsLayout );
|
||||
@@ -298,21 +296,20 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
|
||||
if( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_RGBA )
|
||||
{
|
||||
channelCB->clear();
|
||||
channelCB->clear();
|
||||
channelCB->insertItem( LuminosityChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" );
|
||||
channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-red.png" ), "Red" );
|
||||
channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-green.png" ), "Green" );
|
||||
channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-blue.png" ), "Blue" );
|
||||
channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
|
||||
channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Red", PlaYUVerFrame::HIST_COLOR_R );
|
||||
channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Green", PlaYUVerFrame::HIST_COLOR_G );
|
||||
channelCB->addItem( QIcon( ":/images/channel-blue.png" ), "Blue", PlaYUVerFrame::HIST_COLOR_B );
|
||||
if( colorSpace == PlaYUVerPixel::COLOR_RGBA )
|
||||
{
|
||||
channelCB->insertItem( AlphaChannel, QIcon( ":/images/channel-alpha.png" ), "Alpha" );
|
||||
channelCB->addItem( QIcon( ":/images/channel-alpha.png" ), "Alpha", PlaYUVerFrame::HIST_COLOR_A );
|
||||
}
|
||||
channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "Colors" );
|
||||
channelCB->addItem( QIcon( ":/images/channel-all.png" ), "Colors", PlaYUVerFrame::HIST_ALL_CHANNELS );
|
||||
|
||||
colorsCB->clear();
|
||||
colorsCB->addItem( "Red" );
|
||||
colorsCB->addItem( "Green" );
|
||||
colorsCB->addItem( "Blue" );
|
||||
colorsCB->addItem( "Red", PlaYUVerFrame::HIST_COLOR_R );
|
||||
colorsCB->addItem( "Green", PlaYUVerFrame::HIST_COLOR_G );
|
||||
colorsCB->addItem( "Blue", PlaYUVerFrame::HIST_COLOR_B );
|
||||
colorsCB->setEnabled( false );
|
||||
colorsCB->setWhatsThis( tr( "<p>Select here the main color displayed with Colors Channel mode:"
|
||||
"<p><b>Red</b>: Draw the Red image channel in the foreground.<p>"
|
||||
@@ -324,15 +321,15 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
|
||||
else if( colorSpace == PlaYUVerPixel::COLOR_YUV )
|
||||
{
|
||||
channelCB->clear();
|
||||
channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" );
|
||||
channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-red.png" ), "Chroma U" );
|
||||
channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-green.png" ), "Chroma V" );
|
||||
channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "All Channels" );
|
||||
channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
|
||||
channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Chroma U", PlaYUVerFrame::HIST_CHROMA_U );
|
||||
channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Chroma V", PlaYUVerFrame::HIST_CHROMA_V );
|
||||
channelCB->addItem( QIcon( ":/images/channel-all.png" ), "All Channels", PlaYUVerFrame::HIST_ALL_CHANNELS );
|
||||
|
||||
colorsCB->clear();
|
||||
colorsCB->addItem( "Luminance" );
|
||||
colorsCB->addItem( "Chroma U" );
|
||||
colorsCB->addItem( "Chroma V" );
|
||||
colorsCB->addItem( "Luminance", PlaYUVerFrame::HIST_LUMA );
|
||||
colorsCB->addItem( "Chroma U", PlaYUVerFrame::HIST_CHROMA_U );
|
||||
colorsCB->addItem( "Chroma V", PlaYUVerFrame::HIST_CHROMA_V );
|
||||
colorsCB->setEnabled( false );
|
||||
colorsCB->setWhatsThis( tr( "<p>Select here the main color displayed with Colors Channel mode:"
|
||||
"<p><b>Luminance</b>: DraupdateDataw the Luminance channel in the "
|
||||
@@ -346,8 +343,7 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
|
||||
else
|
||||
{
|
||||
channelCB->clear();
|
||||
channelCB->addItem( tr( "Luminance" ) );
|
||||
channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) );
|
||||
channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
|
||||
colorsCB->hide();
|
||||
colorsLabel->hide();
|
||||
}
|
||||
@@ -436,8 +432,8 @@ Void FramePropertiesDock::updateStatistiques()
|
||||
Int max = maxInterv->value();
|
||||
Int channel = histogramWidget->m_channelType;
|
||||
|
||||
if( channel == HistogramWidget::ColorChannelsHistogram )
|
||||
channel = colorsCB->currentIndex();
|
||||
if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
|
||||
channel = colorsCB->itemData( colorsCB->currentIndex() ).toInt();
|
||||
|
||||
PlaYUVerFrame* frame;
|
||||
|
||||
@@ -449,7 +445,7 @@ Void FramePropertiesDock::updateStatistiques()
|
||||
if( frame )
|
||||
{
|
||||
QString rangeText =
|
||||
"[" + QString::number( frame->getMin( channel ) ) + ":" + QString::number( frame->getMax( channel ) ) + "]";
|
||||
"[" + QString::number( frame->getMinimumPelValue( channel ) ) + ":" + QString::number( frame->getMaximumPelValue( channel ) ) + "]";
|
||||
labelRangeValue->setText( rangeText );
|
||||
|
||||
double mean = frame->getMean( channel, min, max );
|
||||
@@ -461,7 +457,7 @@ Void FramePropertiesDock::updateStatistiques()
|
||||
double stddev = frame->getStdDev( channel, min, max );
|
||||
labelStdDevValue->setText( value.setNum( stddev, 'f', 1 ) );
|
||||
|
||||
double counts = frame->getCount( channel, min, max );
|
||||
double counts = frame->getNumPixelsRange( channel, min, max );
|
||||
labelCountValue->setText( value.setNum( (float)counts, 'f', 0 ) );
|
||||
|
||||
double median = frame->getMedian( channel, min, max );
|
||||
@@ -509,41 +505,15 @@ Void FramePropertiesDock::slotHistogramComputationFailed()
|
||||
m_pcFrame = NULL;
|
||||
}
|
||||
|
||||
Void FramePropertiesDock::slotChannelChanged( Int channel )
|
||||
Void FramePropertiesDock::slotChannelChanged( Int index )
|
||||
{
|
||||
if( m_pcFrame->getColorSpace() == PlaYUVerPixel::COLOR_YUV )
|
||||
channel += 1;
|
||||
if( channel == AlphaChannel && m_pcFrame->getColorSpace() != PlaYUVerPixel::COLOR_RGBA )
|
||||
channel = ColorChannels;
|
||||
Int channel = channelCB->itemData( index ).toInt();
|
||||
|
||||
switch( channel )
|
||||
{
|
||||
case FirstChannel:
|
||||
histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
|
||||
colorsCB->setEnabled( false );
|
||||
break;
|
||||
case SecondChannel:
|
||||
histogramWidget->m_channelType = HistogramWidget::SecondChannelHistogram;
|
||||
colorsCB->setEnabled( false );
|
||||
break;
|
||||
case ThirdChannel:
|
||||
histogramWidget->m_channelType = HistogramWidget::ThirdChannelHistogram;
|
||||
colorsCB->setEnabled( false );
|
||||
break;
|
||||
case AlphaChannel:
|
||||
histogramWidget->m_channelType = HistogramWidget::AlphaChannelHistogram;
|
||||
colorsCB->setEnabled( false );
|
||||
break;
|
||||
case ColorChannels:
|
||||
histogramWidget->m_channelType = HistogramWidget::ColorChannelsHistogram;
|
||||
histogramWidget->m_channelType = channel;
|
||||
if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
|
||||
colorsCB->setEnabled( true );
|
||||
break;
|
||||
default: // Luminance.
|
||||
// histogramWidget->m_channelType = HistogramWidget::LumaHistogram;
|
||||
histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
|
||||
else
|
||||
colorsCB->setEnabled( false );
|
||||
break;
|
||||
}
|
||||
histogramWidget->update();
|
||||
updateStatistiques();
|
||||
}
|
||||
@@ -554,21 +524,10 @@ Void FramePropertiesDock::slotScaleChanged( Int scale )
|
||||
histogramWidget->update();
|
||||
}
|
||||
|
||||
Void FramePropertiesDock::slotColorsChanged( Int color )
|
||||
Void FramePropertiesDock::slotColorsChanged( Int index )
|
||||
{
|
||||
switch( color )
|
||||
{
|
||||
case AllColorsGreen:
|
||||
histogramWidget->m_colorType = HistogramWidget::SecondChannelColor;
|
||||
break;
|
||||
case AllColorsBlue:
|
||||
histogramWidget->m_colorType = HistogramWidget::ThirdChannelColor;
|
||||
break;
|
||||
default: // Red.
|
||||
histogramWidget->m_colorType = HistogramWidget::FirstChannelColor;
|
||||
break;
|
||||
}
|
||||
|
||||
Int color = colorsCB->itemData( index ).toInt();
|
||||
histogramWidget->m_colorType = color;
|
||||
histogramWidget->update();
|
||||
updateStatistiques();
|
||||
}
|
||||
|
||||
@@ -48,23 +48,6 @@ public:
|
||||
Void stopHistogram();
|
||||
|
||||
private:
|
||||
enum ColorChannel
|
||||
{
|
||||
LuminosityChannel = 0,
|
||||
FirstChannel = 1,
|
||||
SecondChannel = 2,
|
||||
ThirdChannel = 3,
|
||||
ColorChannels = 4,
|
||||
AlphaChannel = 5,
|
||||
};
|
||||
|
||||
enum AllColorsColorType
|
||||
{
|
||||
AllColorsRed = 0,
|
||||
AllColorsGreen,
|
||||
AllColorsBlue
|
||||
};
|
||||
|
||||
PlaYUVerFrame* m_pcFrame;
|
||||
PlaYUVerFrame* m_pcSelectedFrame;
|
||||
Int m_iLastFrameType;
|
||||
@@ -106,9 +89,9 @@ private:
|
||||
private Q_SLOTS:
|
||||
void slotRefreshOptions( int range );
|
||||
void slotHistogramComputationFailed( void );
|
||||
void slotChannelChanged( int channel );
|
||||
void slotChannelChanged( int index );
|
||||
void slotScaleChanged( int scale );
|
||||
void slotColorsChanged( int color );
|
||||
void slotColorsChanged( int index );
|
||||
void slotRenderingChanged( int rendering );
|
||||
void slotMinValueChanged( int );
|
||||
void slotMaxValueChanged( int );
|
||||
|
||||
+105
-146
@@ -79,8 +79,8 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Event
|
||||
*/
|
||||
* Custom Event
|
||||
*/
|
||||
class EventData : public QEvent
|
||||
{
|
||||
public:
|
||||
@@ -154,13 +154,13 @@ public:
|
||||
bool statisticsVisible; // Display tooltip histogram statistics.
|
||||
bool inSelected;
|
||||
bool selectMode; // If true, a part of the histogram can be
|
||||
// selected !
|
||||
// selected !
|
||||
bool blinkFlag;
|
||||
bool blinkComputation; // If true, a message will be displayed during
|
||||
// histogram computation, else nothing (limit
|
||||
// flicker effect in widget especially for small
|
||||
// image/computation time).
|
||||
bool lumaChannel; // Compute luminance channel if true.
|
||||
// histogram computation, else nothing (limit
|
||||
// flicker effect in widget especially for small
|
||||
// image/computation time).
|
||||
bool lumaChannel; // Compute luminance channel if true.
|
||||
bool inInitialRepaintWait;
|
||||
|
||||
QTimer* blinkTimer;
|
||||
@@ -180,10 +180,9 @@ HistogramWidget::HistogramWidget( Int width, Int height, QWidget* parent )
|
||||
|
||||
d = new HistogramWidgetPrivate;
|
||||
|
||||
// m_channelType = LumaHistogram;
|
||||
m_channelType = FirstChannelHistogram;
|
||||
m_channelType = PlaYUVerFrame::HIST_LUMA;
|
||||
m_scaleType = LogScaleHistogram;
|
||||
m_colorType = FirstChannelColor;
|
||||
m_colorType = -1;
|
||||
m_renderingType = FullImageHistogram;
|
||||
|
||||
setOptions( HistogramWidget::BlinkComputation | HistogramWidget::SelectMode | HistogramWidget::ShowLumaChannel );
|
||||
@@ -211,12 +210,6 @@ HistogramWidget::~HistogramWidget()
|
||||
{
|
||||
d->blinkTimer->stop();
|
||||
|
||||
// if( m_imageHistogram )
|
||||
// delete m_imageHistogram;
|
||||
//
|
||||
// if( m_selectionHistogram )
|
||||
// delete m_selectionHistogram;
|
||||
|
||||
delete m_imageWorker;
|
||||
delete m_selectionWorker;
|
||||
|
||||
@@ -327,16 +320,6 @@ Void HistogramWidget::customEvent( QEvent* event )
|
||||
// Remove old histogram data from memory.
|
||||
m_fullImage = NULL;
|
||||
m_selectionImage = NULL;
|
||||
// if( m_imageHistogram )
|
||||
// {
|
||||
// delete m_imageHistogram;
|
||||
// m_imageHistogram = 0;
|
||||
// }
|
||||
// if( m_selectionHistogram )
|
||||
// {
|
||||
// delete m_selectionHistogram;
|
||||
// m_selectionHistogram = 0;
|
||||
// }
|
||||
emit signalHistogramComputationFailed();
|
||||
}
|
||||
}
|
||||
@@ -519,34 +502,12 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
yb = 0;
|
||||
max = 0.0;
|
||||
|
||||
switch( m_channelType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelHistogram: // Y channel.
|
||||
max = frame->getMaximum( LUMA );
|
||||
break;
|
||||
case HistogramWidget::SecondChannelHistogram: // Cb channel.
|
||||
max = frame->getMaximum( CHROMA_U );
|
||||
break;
|
||||
case HistogramWidget::ThirdChannelHistogram: // Cr channel.
|
||||
max = frame->getMaximum( CHROMA_V );
|
||||
break;
|
||||
case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
|
||||
max = frame->getMaximum( COLOR_A );
|
||||
break;
|
||||
|
||||
case HistogramWidget::ColorChannelsHistogram: // All color channels.
|
||||
max = qMax( qMax( frame->getMaximum( LUMA ), frame->getMaximum( CHROMA_U ) ), frame->getMaximum( CHROMA_V ) );
|
||||
break;
|
||||
// case HistogramWidget::LumaHistogram: // Luminance.
|
||||
// max = frame->getMaximum( LUMA );
|
||||
// break;
|
||||
}
|
||||
max = frame->getMaximum( m_channelType );
|
||||
|
||||
switch( m_scaleType )
|
||||
{
|
||||
case HistogramWidget::LinScaleHistogram:
|
||||
break;
|
||||
|
||||
case HistogramWidget::LogScaleHistogram:
|
||||
if( max > 0.0 )
|
||||
max = log( max );
|
||||
@@ -569,8 +530,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
double value_r = 0.0, value_g = 0.0, value_b = 0.0; // For all channels.
|
||||
int i, j;
|
||||
|
||||
i = ( x * frame->getHistogramSegment() ) / wWidth;
|
||||
j = ( ( x + 1 ) * frame->getHistogramSegment() ) / wWidth;
|
||||
i = ( x * frame->getNumHistogramSegment() ) / wWidth;
|
||||
j = ( ( x + 1 ) * frame->getNumHistogramSegment() ) / wWidth;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -582,37 +543,12 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
vg = 0.0;
|
||||
vb = 0.0;
|
||||
|
||||
switch( m_channelType )
|
||||
if( m_channelType == PlaYUVerFrame::HIST_ALL_CHANNELS )
|
||||
{
|
||||
case HistogramWidget::FirstChannelHistogram: // Y channel.
|
||||
v = frame->getHistogramValue( LUMA, i++ );
|
||||
break;
|
||||
case HistogramWidget::SecondChannelHistogram: // Cb channel.
|
||||
v = frame->getHistogramValue( CHROMA_U, i++ );
|
||||
break;
|
||||
case HistogramWidget::ThirdChannelHistogram: // Cr channel.
|
||||
v = frame->getHistogramValue( CHROMA_V, i++ );
|
||||
break;
|
||||
case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
|
||||
v = frame->getHistogramValue( COLOR_A, i++ );
|
||||
break;
|
||||
case HistogramWidget::ColorChannelsHistogram: // All color.
|
||||
vr = frame->getHistogramValue( LUMA, i );
|
||||
vg = frame->getHistogramValue( CHROMA_U, i );
|
||||
vb = frame->getHistogramValue( CHROMA_V, i++ );
|
||||
break;
|
||||
// case HistogramWidget::LumaHistogram: // Luminance.
|
||||
// v = frame->getHistogramValue( LUMA, i++ );
|
||||
// break;
|
||||
}
|
||||
vr = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_ONE, i );
|
||||
vg = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_TWO, i );
|
||||
vb = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_THREE, i );
|
||||
|
||||
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
|
||||
{
|
||||
if( v > value )
|
||||
value = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( vr > value_r )
|
||||
value_r = vr;
|
||||
if( vg > value_g )
|
||||
@@ -620,9 +556,16 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
if( vb > value_b )
|
||||
value_b = vb;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = frame->getHistogramValue( m_channelType, i );
|
||||
if( v > value )
|
||||
value = v;
|
||||
}
|
||||
i++;
|
||||
} while( i < j );
|
||||
|
||||
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
|
||||
if( m_channelType != PlaYUVerFrame::HIST_ALL_CHANNELS )
|
||||
{
|
||||
switch( m_scaleType )
|
||||
{
|
||||
@@ -673,7 +616,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
|
||||
// Drawing the histogram + selection or only the histogram.
|
||||
|
||||
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
|
||||
if( m_channelType != PlaYUVerFrame::HIST_ALL_CHANNELS )
|
||||
{
|
||||
if( d->selectMode == true ) // Selection mode enable ?
|
||||
{
|
||||
@@ -726,17 +669,23 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
// colors channel mode?
|
||||
switch( m_colorType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelColor:
|
||||
case PlaYUVerFrame::HIST_LUMA:
|
||||
case PlaYUVerFrame::HIST_COLOR_R:
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
break;
|
||||
|
||||
case HistogramWidget::SecondChannelColor:
|
||||
case PlaYUVerFrame::HIST_CHROMA_U:
|
||||
case PlaYUVerFrame::HIST_COLOR_G:
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
break;
|
||||
|
||||
default:
|
||||
case PlaYUVerFrame::HIST_CHROMA_V:
|
||||
case PlaYUVerFrame::HIST_COLOR_B:
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_ASSERT( 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -745,12 +694,13 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
// colors channel mode?
|
||||
switch( m_colorType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelColor:
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
|
||||
case PlaYUVerFrame::HIST_LUMA:
|
||||
case PlaYUVerFrame::HIST_COLOR_R:
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
@@ -762,12 +712,13 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
|
||||
break;
|
||||
|
||||
case HistogramWidget::SecondChannelColor:
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
|
||||
case PlaYUVerFrame::HIST_CHROMA_U:
|
||||
case PlaYUVerFrame::HIST_COLOR_G:
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
@@ -778,23 +729,25 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
|
||||
|
||||
break;
|
||||
case PlaYUVerFrame::HIST_CHROMA_V:
|
||||
case PlaYUVerFrame::HIST_COLOR_B:
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
|
||||
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
|
||||
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
|
||||
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
|
||||
|
||||
break;
|
||||
default:
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
|
||||
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
|
||||
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
|
||||
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
|
||||
|
||||
break;
|
||||
Q_ASSERT( 0 );
|
||||
}
|
||||
|
||||
if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 )
|
||||
@@ -810,15 +763,16 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
// colors channel mode?
|
||||
switch( m_colorType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelColor:
|
||||
case PlaYUVerFrame::HIST_LUMA:
|
||||
case PlaYUVerFrame::HIST_COLOR_R:
|
||||
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
@@ -830,15 +784,16 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
|
||||
break;
|
||||
|
||||
case HistogramWidget::SecondChannelColor:
|
||||
case PlaYUVerFrame::HIST_CHROMA_U:
|
||||
case PlaYUVerFrame::HIST_COLOR_G:
|
||||
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
@@ -850,25 +805,28 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
|
||||
break;
|
||||
|
||||
case PlaYUVerFrame::HIST_CHROMA_V:
|
||||
case PlaYUVerFrame::HIST_COLOR_B:
|
||||
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
|
||||
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
|
||||
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
|
||||
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
|
||||
|
||||
break;
|
||||
default:
|
||||
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yr );
|
||||
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yg );
|
||||
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
|
||||
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight, x, wHeight - yb );
|
||||
|
||||
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
|
||||
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
|
||||
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
|
||||
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
|
||||
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
|
||||
|
||||
break;
|
||||
Q_ASSERT( 0 );
|
||||
}
|
||||
|
||||
if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 )
|
||||
@@ -889,22 +847,23 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
{
|
||||
switch( m_channelType )
|
||||
{
|
||||
case HistogramWidget::FirstChannelHistogram:
|
||||
case PlaYUVerFrame::HIST_CHROMA_V:
|
||||
case PlaYUVerFrame::HIST_COLOR_R:
|
||||
guidePos = d->colorGuide.red();
|
||||
break;
|
||||
|
||||
case HistogramWidget::SecondChannelHistogram:
|
||||
case PlaYUVerFrame::HIST_COLOR_G:
|
||||
guidePos = d->colorGuide.green();
|
||||
break;
|
||||
|
||||
case HistogramWidget::ThirdChannelHistogram:
|
||||
case PlaYUVerFrame::HIST_CHROMA_U:
|
||||
case PlaYUVerFrame::HIST_COLOR_B:
|
||||
guidePos = d->colorGuide.blue();
|
||||
break;
|
||||
|
||||
// case HistogramWidget::LumaHistogram:
|
||||
// guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green()
|
||||
// ), d->colorGuide.blue() );
|
||||
// break;
|
||||
case PlaYUVerFrame::HIST_LUMA:
|
||||
guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() );
|
||||
break;
|
||||
|
||||
default: // Alpha.
|
||||
guidePos = -1;
|
||||
@@ -913,7 +872,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
|
||||
if( guidePos != -1 )
|
||||
{
|
||||
int xGuide = ( guidePos * wWidth ) / frame->getHistogramSegment();
|
||||
int xGuide = ( guidePos * wWidth ) / frame->getNumHistogramSegment();
|
||||
p1.drawLine( xGuide, 0, xGuide, wHeight );
|
||||
|
||||
QString string = tr( "x:%1" ).arg( guidePos );
|
||||
@@ -950,7 +909,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
tipText = "<table cellspacing=0 cellpadding=0>";
|
||||
|
||||
tipText += cellBeg + tr( "Mean:" ) + cellMid;
|
||||
double mean = frame->getMean( m_channelType, 0, frame->getHistogramSegment() - 1 );
|
||||
double mean = frame->getMean( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
|
||||
tipText += value.setNum( mean, 'f', 1 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Pixels:" ) + cellMid;
|
||||
@@ -958,15 +917,15 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
tipText += value.setNum( (float)pixels, 'f', 0 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Std dev.:" ) + cellMid;
|
||||
double stddev = frame->getStdDev( m_channelType, 0, frame->getHistogramSegment() - 1 );
|
||||
double stddev = frame->getStdDev( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
|
||||
tipText += value.setNum( stddev, 'f', 1 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Selected:" ) + cellMid;
|
||||
double counts = frame->getCount( m_channelType, 0, frame->getHistogramSegment() - 1 );
|
||||
double counts = frame->getNumPixelsRange( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
|
||||
tipText += value.setNum( (float)counts, 'f', 0 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Median:" ) + cellMid;
|
||||
double median = frame->getMedian( m_channelType, 0, frame->getHistogramSegment() - 1 );
|
||||
double median = frame->getMedian( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
|
||||
tipText += value.setNum( median, 'f', 1 ) + cellEnd;
|
||||
|
||||
tipText += cellBeg + tr( "Percent:" ) + cellMid;
|
||||
|
||||
@@ -43,20 +43,6 @@ class HistogramWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum HistogramChannel
|
||||
{
|
||||
/** Luminance */
|
||||
// LumaHistogram = 0,
|
||||
/** Channels */
|
||||
FirstChannelHistogram = 0,
|
||||
SecondChannelHistogram,
|
||||
ThirdChannelHistogram,
|
||||
/** Alpha channel */
|
||||
AlphaChannelHistogram,
|
||||
/** All color channels */
|
||||
ColorChannelsHistogram,
|
||||
};
|
||||
|
||||
enum HistogramScale
|
||||
{
|
||||
/** Linear scale */
|
||||
@@ -65,14 +51,6 @@ public:
|
||||
LogScaleHistogram
|
||||
};
|
||||
|
||||
enum HistogramAllColorMode
|
||||
{
|
||||
// Select wich component is shown in foreground
|
||||
FirstChannelColor,
|
||||
SecondChannelColor,
|
||||
ThirdChannelColor,
|
||||
};
|
||||
|
||||
enum HistogramRendering
|
||||
{
|
||||
/** Full image histogram rendering */
|
||||
|
||||
@@ -990,7 +990,7 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
|
||||
strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY );
|
||||
|
||||
Int colorSpace = m_pcCurrFrame->getColorSpace();
|
||||
PlaYUVerPixel pixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
|
||||
PlaYUVerPixel pixelValue = m_pcCurrFrame->getPixel( pos.x(), pos.y() );
|
||||
switch( colorSpace )
|
||||
{
|
||||
case PlaYUVerPixel::COLOR_GRAY:
|
||||
|
||||
+22
-15
@@ -487,7 +487,7 @@ Void ViewArea::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
Int imageWidth = m_pixmap.width();
|
||||
Int imageHeight = m_pixmap.height();
|
||||
PlaYUVerPixel sPixelValue;
|
||||
PlaYUVerPixel pixelValue;
|
||||
|
||||
QFont font( "Helvetica" );
|
||||
font.setPixelSize( 12 );
|
||||
@@ -508,51 +508,58 @@ Void ViewArea::paintEvent( QPaintEvent* event )
|
||||
|
||||
if( frFormat == PlaYUVerPixel::COLOR_YUV )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( sPixelValue.Y() < m_uiPixelHalfScale )
|
||||
if( pixelValue.Y() < m_uiPixelHalfScale )
|
||||
paInter.setPen( QColor( Qt::white ) );
|
||||
else
|
||||
paInter.setPen( QColor( Qt::black ) );
|
||||
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter,
|
||||
"Y: " + QString::number( sPixelValue.Y() ) + "\n" +
|
||||
"U: " + QString::number( sPixelValue.Cb() ) + "\n" +
|
||||
"V: " + QString::number( sPixelValue.Cr() ) );
|
||||
"Y: " + QString::number( pixelValue.Y() ) + "\n" +
|
||||
"U: " + QString::number( pixelValue.Cb() ) + "\n" +
|
||||
"V: " + QString::number( pixelValue.Cr() ) );
|
||||
}
|
||||
if( frFormat == PlaYUVerPixel::COLOR_GRAY )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( sPixelValue.Y() < m_uiPixelHalfScale )
|
||||
if( pixelValue.Y() < m_uiPixelHalfScale )
|
||||
paInter.setPen( QColor( Qt::white ) );
|
||||
else
|
||||
paInter.setPen( QColor( Qt::black ) );
|
||||
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( sPixelValue.Y() ) );
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( pixelValue.Y() ) );
|
||||
}
|
||||
|
||||
if( ( frFormat == PlaYUVerPixel::COLOR_RGB ) )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
|
||||
if( ( pixelValue.R() + pixelValue.G() + pixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
|
||||
paInter.setPen( QColor( Qt::white ) );
|
||||
else
|
||||
paInter.setPen( QColor( Qt::black ) );
|
||||
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.R() ) + "\nG: " + QString::number( sPixelValue.G() ) + "\nB: " + QString::number( sPixelValue.B() ) );
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter,
|
||||
"R: " + QString::number( pixelValue.R() ) +
|
||||
"\nG: " + QString::number( pixelValue.G() ) +
|
||||
"\nB: " + QString::number( pixelValue.B() ) );
|
||||
}
|
||||
if( ( frFormat == PlaYUVerPixel::COLOR_RGBA ) )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
|
||||
if( ( pixelValue.R() + pixelValue.G() + pixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
|
||||
paInter.setPen( QColor( Qt::white ) );
|
||||
else
|
||||
paInter.setPen( QColor( Qt::black ) );
|
||||
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.R() ) + "\nG: " + QString::number( sPixelValue.G() ) + "\nB: " + QString::number( sPixelValue.B() ) + "\nA: " + QString::number( sPixelValue.A() ) );
|
||||
paInter.drawText( pixelRect, Qt::AlignCenter,
|
||||
"R: " + QString::number( pixelValue.R() ) +
|
||||
"\nG: " + QString::number( pixelValue.G() ) +
|
||||
"\nB: " + QString::number( pixelValue.B() ) +
|
||||
"\nA: " + QString::number( pixelValue.A() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user