Add different interpolation techniques to the ERP to NxN conversion

This commit is contained in:
2019-03-12 02:18:11 +00:00
parent 432d2c6cad
commit cff796a4b7
2 changed files with 33 additions and 6 deletions
+31 -5
View File
@@ -44,11 +44,19 @@ ThreeSixtyDownsampling::ThreeSixtyDownsampling()
m_uiNumberOfFrames = 1;
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_OPTIONS;
m_cModuleOptions.addOptions() /**/
( "Downsampling", m_bDownsampling, "ERP to NxN [true]" );
m_cModuleOptions.addOptions() /**/
( "Downsampling", m_bDownsampling, "ERP to NxN [true]" ) /**/
( "Interpolation", m_iInterpolation, "Interpolation method (1-5) [1]" );
// INTER_NEAREST - a nearest-neighbor interpolation
// INTER_LINEAR - a bilinear interpolation (used by default)
// INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
// INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
// INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
m_bDownsampling = true;
m_iInterpolation = 1;
m_pcOutputFrame = NULL;
m_bDownsampling = true;
}
bool ThreeSixtyDownsampling::create( std::vector<CalypFrame*> apcFrameList )
@@ -56,6 +64,24 @@ bool ThreeSixtyDownsampling::create( std::vector<CalypFrame*> apcFrameList )
_BASIC_MODULE_API_2_CHECK_
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
m_isOdd = !( m_pcOutputFrame->getHeight() % 2 );
switch( m_iInterpolation )
{
case 2:
m_iInterpolation = cv::INTER_LINEAR;
break;
case 3:
m_iInterpolation = cv::INTER_AREA;
break;
case 4:
m_iInterpolation = cv::INTER_CUBIC;
break;
case 5:
m_iInterpolation = cv::INTER_LANCZOS4;
break;
default:
m_iInterpolation = cv::INTER_NEAREST;
}
return true;
}
@@ -92,14 +118,14 @@ CalypFrame* ThreeSixtyDownsampling::process( std::vector<CalypFrame*> apcFrameLi
// resize
if( m_bDownsampling )
{
cv::resize( cvIn.row( ypos ), cvDownsample, cvDownsample.size() );
cv::resize( cvIn.row( ypos ), cvDownsample, cvDownsample.size(), 0, 0, m_iInterpolation );
cvOutput = cvDownsample;
}
else
{
Mat cvauxin = cvIn.row( ypos ).colRange( xpos, xpos + lineWidth );
cvauxin.copyTo( cvDownsample );
cv::resize( cvDownsample, cvUpsample, cvUpsample.size() );
cv::resize( cvDownsample, cvUpsample, cvUpsample.size(), 0, 0, m_iInterpolation );
cvOutput = cvUpsample;
}
+2 -1
View File
@@ -32,8 +32,9 @@ class ThreeSixtyDownsampling : public CalypModuleIf
{
REGISTER_CLASS_FACTORY( ThreeSixtyDownsampling )
private:
bool m_bDownsampling;
bool m_isOdd;
bool m_bDownsampling;
int m_iInterpolation;
public:
ThreeSixtyDownsampling();