@ -57,6 +57,9 @@
# include "opencv2/core/types.hpp"
# include "opencv2/core/types_c.h"
# include "opencv2/highgui.hpp"
namespace xphotoInternal
{
# include "photomontage.hpp"
@ -66,22 +69,18 @@ namespace xphotoInternal
namespace cv
{
template < typename Tp , unsigned int cn >
static void shiftMapInpaint ( const Mat & src , const Mat & mask , Mat & dst )
static void shiftMapInpaint ( const Mat & src , const Mat & mask , Mat & dst ,
const int nTransform = 60 , const int psize = 8 )
{
const int nTransform = 60 ; // number of dominant transforms for stitching
const int psize = 8 ; // single ANNF patch size
/** Preparing input **/
cv : : Mat img ;
cvtColor ( src , img , CV_RGB2Lab ) ;
src . convertTo ( img , CV_32F ) ;
img . setTo ( 0 , 255 - mask ) ;
img . convertTo ( img , CV_32F ) ;
/** ANNF computation **/
std : : vector < Matx33f > transforms ( nTransform ) ;
xphotoInternal : : getANNF ( img , transforms ,
nTransform , psize ) ;
xphotoInternal : : dominantTransforms ( img ,
transforms , nTransform , psize ) ;
/** Warping **/
std : : vector < Mat > images ( nTransform + 1 ) ; // source image transformed with transforms
@ -109,8 +108,7 @@ namespace cv
. assignResImage ( photomontageResult ) ;
/** Writing result **/
photomontageResult . convertTo ( photomontageResult , dst . type ( ) ) ;
cvtColor ( photomontageResult , dst , CV_Lab2RGB ) ;
photomontageResult . convertTo ( dst , dst . type ( ) ) ;
}
template < typename Tp , unsigned int cn >
@ -143,66 +141,90 @@ namespace cv
switch ( src . type ( ) )
{
//case CV_8UC1:
// inpaint <uchar, 1>( src, mask, dst, algorithmType );
// break;
//case CV_8UC2:
// inpaint <uchar, 2>( src, mask, dst, algorithmType );
// break;
case CV_8SC1 :
inpaint < char , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_8SC2 :
inpaint < char , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_8SC3 :
inpaint < char , 3 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_8SC4 :
inpaint < char , 4 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_8UC1 :
inpaint < uchar , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_8UC2 :
inpaint < uchar , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_8UC3 :
inpaint < uchar , 3 > ( src , mask , dst , algorithmType ) ;
break ;
//case CV_8UC4:
// inpaint <uchar, 4>( src, mask, dst, algorithmType );
// break;
//case CV_16SC1:
// inpaint <short, 1>( src, mask, dst, algorithmType );
// break;
//case CV_16SC2:
// inpaint <short, 2>( src, mask, dst, algorithmType );
// break;
case CV_8UC4 :
inpaint < uchar , 4 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16SC1 :
inpaint < short , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16SC2 :
inpaint < short , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16SC3 :
inpaint < short , 3 > ( src , mask , dst , algorithmType ) ;
break ;
//case CV_16SC4:
// inpaint <short, 4>( src, mask, dst, algorithmType );
// break;
//case CV_32SC1:
// inpaint <int, 1>( src, mask, dst, algorithmType );
// break;
//case CV_32SC2:
// inpaint <int, 2>( src, mask, dst, algorithmType );
// break;
case CV_16SC4 :
inpaint < short , 4 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16UC1 :
inpaint < ushort , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16UC2 :
inpaint < ushort , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16UC3 :
inpaint < ushort , 3 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_16UC4 :
inpaint < ushort , 4 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_32SC1 :
inpaint < int , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_32SC2 :
inpaint < int , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_32SC3 :
inpaint < int , 3 > ( src , mask , dst , algorithmType ) ;
break ;
//case CV_32SC4:
// inpaint <int, 4>( src, mask, dst, algorithmType );
// break;
//case CV_32FC1:
// inpaint <float, 1>( src, mask, dst, algorithmType );
// break;
//case CV_32FC2:
// inpaint <float, 2>( src, mask, dst, algorithmType );
// break;
case CV_32SC4 :
inpaint < int , 4 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_32FC1 :
inpaint < float , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_32FC2 :
inpaint < float , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_32FC3 :
inpaint < float , 3 > ( src , mask , dst , algorithmType ) ;
break ;
//case CV_32FC4:
// inpaint <float, 4>( src, mask, dst, algorithmType );
// break;
//case CV_64FC1:
// inpaint <double, 1>( src, mask, dst, algorithmType );
// break;
//case CV_64FC2:
// inpaint <double, 2>( src, mask, dst, algorithmType );
// break;
case CV_32FC4 :
inpaint < float , 4 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_64FC1 :
inpaint < double , 1 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_64FC2 :
inpaint < double , 2 > ( src , mask , dst , algorithmType ) ;
break ;
case CV_64FC3 :
inpaint < double , 3 > ( src , mask , dst , algorithmType ) ;
break ;
//case CV_64FC4:
// inpaint <double, 4>( src, mask, dst, algorithmType );
// break;
case CV_64FC4 :
inpaint < double , 4 > ( src , mask , dst , algorithmType ) ;
break ;
default :
CV_Error_ ( CV_StsNotImplemented ,
( " Unsupported source image format (=%d) " ,