Add different interpolation techniques to the ERP to NxN conversion
This commit is contained in:
2 files changed
+33
-6
No files matched your search
@@ -44,11 +44,19 @@ ThreeSixtyDownsampling::ThreeSixtyDownsampling()
|
|||||||
m_uiNumberOfFrames = 1;
|
m_uiNumberOfFrames = 1;
|
||||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_OPTIONS;
|
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_OPTIONS;
|
||||||
|
|
||||||
m_cModuleOptions.addOptions() /**/
|
m_cModuleOptions.addOptions() /**/
|
||||||
( "Downsampling", m_bDownsampling, "ERP to NxN [true]" );
|
( "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_pcOutputFrame = NULL;
|
||||||
m_bDownsampling = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreeSixtyDownsampling::create( std::vector<CalypFrame*> apcFrameList )
|
bool ThreeSixtyDownsampling::create( std::vector<CalypFrame*> apcFrameList )
|
||||||
@@ -56,6 +64,24 @@ bool ThreeSixtyDownsampling::create( std::vector<CalypFrame*> apcFrameList )
|
|||||||
_BASIC_MODULE_API_2_CHECK_
|
_BASIC_MODULE_API_2_CHECK_
|
||||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||||
m_isOdd = !( m_pcOutputFrame->getHeight() % 2 );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,14 +118,14 @@ CalypFrame* ThreeSixtyDownsampling::process( std::vector<CalypFrame*> apcFrameLi
|
|||||||
// resize
|
// resize
|
||||||
if( m_bDownsampling )
|
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;
|
cvOutput = cvDownsample;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mat cvauxin = cvIn.row( ypos ).colRange( xpos, xpos + lineWidth );
|
Mat cvauxin = cvIn.row( ypos ).colRange( xpos, xpos + lineWidth );
|
||||||
cvauxin.copyTo( cvDownsample );
|
cvauxin.copyTo( cvDownsample );
|
||||||
cv::resize( cvDownsample, cvUpsample, cvUpsample.size() );
|
cv::resize( cvDownsample, cvUpsample, cvUpsample.size(), 0, 0, m_iInterpolation );
|
||||||
cvOutput = cvUpsample;
|
cvOutput = cvUpsample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ class ThreeSixtyDownsampling : public CalypModuleIf
|
|||||||
{
|
{
|
||||||
REGISTER_CLASS_FACTORY( ThreeSixtyDownsampling )
|
REGISTER_CLASS_FACTORY( ThreeSixtyDownsampling )
|
||||||
private:
|
private:
|
||||||
bool m_bDownsampling;
|
|
||||||
bool m_isOdd;
|
bool m_isOdd;
|
||||||
|
bool m_bDownsampling;
|
||||||
|
int m_iInterpolation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreeSixtyDownsampling();
|
ThreeSixtyDownsampling();
|
||||||
|
|||||||
Reference in new issue
Block a user