Add WeightedPSNR module
This commit is contained in:
1 parent
0afae69f94
commit
eff93de754
7 files changed
+186
-8
No files matched your search
@@ -58,14 +58,18 @@ Void PlaYUVerAppModuleIf::update()
|
||||
Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads )
|
||||
{
|
||||
Bool bRet = false;
|
||||
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
if( m_pcDisplaySubWindow )
|
||||
if( m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
m_pcDisplaySubWindow->setFillWindow( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcSubWindow[0]->setFillWindow( true );
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
m_pcDisplaySubWindow->setFillWindow( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcSubWindow[0]->setFillWindow( true );
|
||||
}
|
||||
}
|
||||
if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) )
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ class QAction;
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
#define PLAYUVER_THREADED_MODULES
|
||||
//#define PLAYUVER_THREADED_MODULES
|
||||
|
||||
class VideoSubWindow;
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ set(PlaYUVer_Lib_SRCS
|
||||
PlaYUVerFrame.cpp
|
||||
PlaYUVerPixel.cpp
|
||||
PlaYUVerFramePixelFormats.cpp
|
||||
# PlaYUVerFrameStats.cpp
|
||||
# PlaYUVerFrameStats.cpp
|
||||
# Stream
|
||||
PlaYUVerStream.cpp
|
||||
StreamHandlerRaw.cpp
|
||||
|
||||
@@ -43,6 +43,7 @@ ADD_MODULE( SetChromaHalfScale "SetChromaHalfScale" )
|
||||
ADD_MODULE( EightBitsSampling "EightBitsSampling" )
|
||||
ADD_MODULE( FrameCrop "FrameCrop" )
|
||||
ADD_MODULE( LumaAverage "LumaAverage" )
|
||||
ADD_MODULE( WeightedPSNR "WeightedPSNR" )
|
||||
IF( USE_OPENCV )
|
||||
ADD_MODULE( DisparityStereoBM "DisparityStereoBM" )
|
||||
ADD_MODULE( DisparityStereoSGBM "DisparityStereoSGBM" )
|
||||
|
||||
@@ -48,6 +48,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory()
|
||||
Register( "FrameShift", &FrameShift::Create );
|
||||
Register( "EightBitsSampling", &EightBitsSampling::Create );
|
||||
Register( "LumaAverage", &LumaAverage::Create );
|
||||
Register( "WeightedPSNR", &WeightedPSNR::Create );
|
||||
#ifdef USE_OPENCV
|
||||
//Register( "DisparityStereoVar", &DisparityStereoVar::Create );
|
||||
Register( "DisparityStereoBM", &DisparityStereoBM::Create );
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file WeightedPSNR.cpp
|
||||
* \brief Weighted PSNR quality module
|
||||
*/
|
||||
|
||||
#include "WeightedPSNR.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
WeightedPSNR::WeightedPSNR()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = MODULE_API_2;
|
||||
m_iModuleType = FRAME_MEASUREMENT_MODULE;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "WeightedPSNR";
|
||||
m_pchModuleTooltip = "Measure the weighted PSNR between two images";
|
||||
m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS;
|
||||
m_uiNumberOfFrames = MODULE_REQUIRES_THREE_FRAMES;
|
||||
|
||||
m_cModuleOptions.addOptions()/**/
|
||||
( "Component", m_uiComponent, "Select the component to compute quality [0]" );
|
||||
|
||||
m_uiComponent = 0;
|
||||
|
||||
}
|
||||
|
||||
Bool WeightedPSNR::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
for( UInt i = 1; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | PlaYUVerFrame::MATCH_RESOLUTION | PlaYUVerFrame::MATCH_BITS ) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Double measureWMSE( Int component, PlaYUVerFrame* Org, PlaYUVerFrame* Rec, PlaYUVerFrame* Mask )
|
||||
{
|
||||
Pel* pMaskPelYUV = Mask->getPelBufferYUV()[0][0];
|
||||
Pel* pRecPelYUV = Rec->getPelBufferYUV()[component][0];
|
||||
Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0];
|
||||
|
||||
Double aux_pel_1, aux_pel_2, aux_pel_mask;
|
||||
Int diff = 0;
|
||||
Double ssd = 0;
|
||||
UInt count = 0;
|
||||
|
||||
UInt numberOfPixels = 0;
|
||||
if( component == LUMA )
|
||||
{
|
||||
numberOfPixels = Org->getHeight() * Org->getWidth();
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfPixels = Rec->getChromaLength();
|
||||
}
|
||||
|
||||
for( UInt i = 0; i < numberOfPixels; i++ )
|
||||
{
|
||||
aux_pel_mask = *pMaskPelYUV++;
|
||||
aux_pel_1 = *pRecPelYUV++;
|
||||
aux_pel_2 = *pOrgPelYUV++;
|
||||
diff = aux_pel_1 - aux_pel_2;
|
||||
ssd += ( aux_pel_mask * diff * diff );
|
||||
count += aux_pel_mask;
|
||||
}
|
||||
if( ssd == 0.0 )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
return ssd / Double( count );
|
||||
}
|
||||
|
||||
|
||||
Double WeightedPSNR::measure( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
Double dPSNR = 100;
|
||||
Double dMaxValue = ( 1 << apcFrameList[1]->getBitsPel() ) - 1;
|
||||
Double dMSE = measureWMSE( m_uiComponent, apcFrameList[1], apcFrameList[2], apcFrameList[0] );
|
||||
if( dMSE != 0 )
|
||||
dPSNR = 10 * log10( ( dMaxValue * dMaxValue ) / dMSE );
|
||||
return dPSNR;
|
||||
}
|
||||
|
||||
Void WeightedPSNR::destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file WeightedPSNR.h
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#ifndef __WEIGHTEDPSNR_H__
|
||||
#define __WEIGHTEDPSNR_H__
|
||||
|
||||
#include "lib/PlaYUVerModuleIf.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class WeightedPSNR: public PlaYUVerModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( WeightedPSNR )
|
||||
|
||||
private:
|
||||
UInt m_uiComponent;
|
||||
|
||||
public:
|
||||
WeightedPSNR();
|
||||
virtual ~WeightedPSNR()
|
||||
{
|
||||
}
|
||||
Bool create( std::vector<PlaYUVerFrame*> apcFrameList );
|
||||
Double measure( std::vector<PlaYUVerFrame*> apcFrameList );
|
||||
Void destroy();
|
||||
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __WEIGHTEDPSNR_H__
|
||||
|
||||
Reference in new issue
Block a user