From 3a3c0128205482b7ef6de47cc479596fc9cd811f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 10 Apr 2016 21:05:34 +0100 Subject: [PATCH] Fix the wrong statistics value in the frame information dock --- app/FramePropertiesDock.cpp | 6 ++--- app/HistogramWidget.cpp | 44 +++++++++++++++++++------------------ app/HistogramWidget.h | 4 ++-- lib/PlaYUVerFrame.cpp | 16 +++++++------- lib/PlaYUVerFrame.h | 2 +- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/app/FramePropertiesDock.cpp b/app/FramePropertiesDock.cpp index f4dde99..d9ee2f3 100644 --- a/app/FramePropertiesDock.cpp +++ b/app/FramePropertiesDock.cpp @@ -427,10 +427,9 @@ Void FramePropertiesDock::updateStatistiques() Int min = minInterv->value(); Int max = maxInterv->value(); Int channel = histogramWidget->m_channelType; - //Int channel = channelCB->currentIndex(); if( channel == HistogramWidget::ColorChannelsHistogram ) - channel = colorsCB->currentIndex() + 1; + channel = colorsCB->currentIndex(); PlaYUVerFrame* frame; @@ -528,7 +527,8 @@ Void FramePropertiesDock::slotChannelChanged( Int channel ) colorsCB->setEnabled( true ); break; default: // Luminance. - histogramWidget->m_channelType = HistogramWidget::LumaHistogram; + //histogramWidget->m_channelType = HistogramWidget::LumaHistogram; + histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram; colorsCB->setEnabled( false ); break; } diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp index cd398f0..3f6be8b 100644 --- a/app/HistogramWidget.cpp +++ b/app/HistogramWidget.cpp @@ -24,7 +24,7 @@ */ //TODO: -// - Optimizar paintEvent. Parece haver codigo redundante !! +// - Optimizar paintEvent. Parece haver codigo redundante !! #include "config.h" #include #include @@ -63,6 +63,8 @@ public: // eventData->histogram = m_histogram; // QCoreApplication::postEvent( m_parent, eventData ); + eventData->starting = true; + m_pcFrame->calcHistogram(); eventData->starting = false; @@ -167,7 +169,7 @@ public: }; //////////////////////////////////////////////////////////////////////////////// -// Constructors +// Constructors //////////////////////////////////////////////////////////////////////////////// //Constructor without image data @@ -178,7 +180,8 @@ HistogramWidget::HistogramWidget( Int width, Int height, QWidget *parent ) : d = new HistogramWidgetPrivate; - m_channelType = LumaHistogram; +// m_channelType = LumaHistogram; + m_channelType = FirstChannelHistogram; m_scaleType = LogScaleHistogram; m_colorType = FirstChannelColor; m_renderingType = FullImageHistogram; @@ -202,7 +205,7 @@ HistogramWidget::HistogramWidget( Int width, Int height, QWidget *parent ) : } //////////////////////////////////////////////////////////////////////////////// -// Destructor +// Destructor //////////////////////////////////////////////////////////////////////////////// HistogramWidget::~HistogramWidget() { @@ -220,7 +223,7 @@ HistogramWidget::~HistogramWidget() delete d; } //////////////////////////////////////////////////////////////////////////////// -// Setup Functions +// Setup Functions //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::setOptions( HistogramOptions options ) @@ -249,7 +252,7 @@ Void HistogramWidget::reset() } //////////////////////////////////////////////////////////////////////////////// -// Custom Event Handler +// Custom Event Handler //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::customEvent( QEvent *event ) @@ -341,7 +344,7 @@ Void HistogramWidget::customEvent( QEvent *event ) //delete ed; } //////////////////////////////////////////////////////////////////////////////// -// Data Loading Functions +// Data Loading Functions //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::setDataLoading() @@ -390,13 +393,12 @@ Void HistogramWidget::stopHistogramComputation() } //////////////////////////////////////////////////////////////////////////////// -// Update Data Methods +// Update Data Methods //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::updateData( PlaYUVerFrame *pcFrame, PlaYUVerFrame *pcFrameSelection ) { d->imageBits = pcFrame->getBitsPel(); - //d->imageColorSpace = image.getPelFormat(); d->imageColorSpace = pcFrame->getColorSpace(); d->imageChannels = pcFrame->getNumberChannels(); @@ -429,7 +431,7 @@ Void HistogramWidget::slotBlinkTimerDone() } //////////////////////////////////////////////////////////////////////////////// -// Paint Event +// Paint Event //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::paintEvent( QPaintEvent * ) @@ -534,9 +536,9 @@ Void HistogramWidget::paintEvent( QPaintEvent * ) 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; +// case HistogramWidget::LumaHistogram: // Luminance. +// max = frame->getMaximum( LUMA ); +// break; } switch( m_scaleType ) @@ -596,11 +598,11 @@ Void HistogramWidget::paintEvent( QPaintEvent * ) case HistogramWidget::ColorChannelsHistogram: // All color. vr = frame->getHistogramValue( LUMA, i ); vg = frame->getHistogramValue( CHROMA_U, i ); - vb = frame->getHistogramValue( CHROMA_U, i++ ); - break; - case HistogramWidget::LumaHistogram: // Luminance. - v = frame->getHistogramValue( LUMA, i++ ); + vb = frame->getHistogramValue( CHROMA_V, i++ ); break; +// case HistogramWidget::LumaHistogram: // Luminance. +// v = frame->getHistogramValue( LUMA, i++ ); +// break; } @@ -900,9 +902,9 @@ Void HistogramWidget::paintEvent( QPaintEvent * ) guidePos = d->colorGuide.blue(); break; - case HistogramWidget::LumaHistogram: - guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() ); - break; +// case HistogramWidget::LumaHistogram: +// guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() ); +// break; default: // Alpha. guidePos = -1; @@ -985,7 +987,7 @@ Void HistogramWidget::paintEvent( QPaintEvent * ) } //////////////////////////////////////////////////////////////////////////////// -// Mouse Events +// Mouse Events //////////////////////////////////////////////////////////////////////////////// Void HistogramWidget::mousePressEvent( QMouseEvent * e ) diff --git a/app/HistogramWidget.h b/app/HistogramWidget.h index dee1452..16da264 100644 --- a/app/HistogramWidget.h +++ b/app/HistogramWidget.h @@ -49,9 +49,9 @@ public: enum HistogramChannel { /** Luminance */ - LumaHistogram = 0, + //LumaHistogram = 0, /** Channels */ - FirstChannelHistogram, + FirstChannelHistogram = 0, SecondChannelHistogram, ThirdChannelHistogram, /** Alpha channel */ diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index a861c46..8d81865 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -681,11 +681,11 @@ Int PlaYUVerFrame::getRealHistoChannel( Int channel ) } else { - if( channel == LUMA ) - { - histoChannel = 3; - } - else +// if( channel == LUMA ) +// { +// histoChannel = 3; +// } +// else { histoChannel = channel; } @@ -724,12 +724,12 @@ Int PlaYUVerFrame::getRealHistoChannel( Int channel ) return histoChannel; } -Double PlaYUVerFrame::getCount( Int channel, UInt start, UInt end ) +UInt PlaYUVerFrame::getCount( Int channel, UInt start, UInt end ) { UInt i; Int histoChannel; Int indexStart; - Double count = 0.0; + UInt count = 0; if( !m_bHasHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) { @@ -740,7 +740,7 @@ Double PlaYUVerFrame::getCount( Int channel, UInt start, UInt end ) if( histoChannel == -1 ) { - return 0.0; + return 0; } indexStart = histoChannel * m_uiHistoSegments; diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index b8efb41..98e5ff6 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -229,7 +229,7 @@ public: */ Void calcHistogram(); - Double getCount( Int channel, UInt start, UInt end ); + UInt getCount( Int channel, UInt start, UInt end ); Double getMean( Int channel, UInt start, UInt end ); Int getMedian( Int channel, UInt start, UInt end ); Double getStdDev( Int channel, UInt start, UInt end );