rewrote matchTemplate in C++; added border awareness to crossCorr (ticket #557)

This commit is contained in:
Vadim Pisarevsky
2010-11-12 20:55:32 +00:00
parent 66d10b1815
commit 9e7b8d5f67
4 changed files with 39 additions and 10 deletions

View File

@@ -2994,15 +2994,18 @@ void filter2D( const Mat& src, Mat& dst, int ddepth,
dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
anchor = normalizeAnchor(anchor, kernel.size());
if( kernel.cols*kernel.rows >= dft_filter_size /*&&
kernel.cols <= src.cols && kernel.rows <= src.rows*/ )
if( kernel.cols*kernel.rows >= dft_filter_size )
{
Mat temp;
if( src.data != dst.data )
temp = src;
temp = dst;
else
src.copyTo(temp);
crossCorr( temp, kernel, dst, anchor, delta, borderType );
temp.create(dst.size(), dst.type());
crossCorr( src, kernel, temp, src.size(),
CV_MAKETYPE(ddepth, src.channels()),
anchor, delta, borderType );
if( temp.data != dst.data )
temp.copyTo(dst);
return;
}

View File

@@ -92,6 +92,7 @@ static inline Point normalizeAnchor( Point anchor, Size ksize )
void preprocess2DKernel( const Mat& kernel, vector<Point>& coords, vector<uchar>& coeffs );
void crossCorr( const Mat& src, const Mat& templ, Mat& dst,
Size corrsize, int ctype,
Point anchor=Point(0,0), double delta=0,
int borderType=BORDER_REFLECT_101 );
@@ -124,11 +125,6 @@ void icvSepConvSmall3_32f( float* src, int src_step, float* dst, int dst_step,
#undef CV_CALC_MAX
#define CV_CALC_MAX(a, b) if((a) < (b)) (a) = (b)
void
icvCrossCorr( const CvArr* _img, const CvArr* _templ,
CvArr* _corr, CvPoint anchor=cvPoint(0,0),
double delta=0, int borderType=IPL_BORDER_REPLICATE);
CvStatus CV_STDCALL
icvCopyReplicateBorder_8u( const uchar* src, int srcstep, CvSize srcroi,
uchar* dst, int dststep, CvSize dstroi,

View File

@@ -442,6 +442,7 @@ cvCopyMakeBorder( const CvArr* srcarr, CvArr* dstarr, CvPoint offset,
if( dststep == 0 )
dststep = CV_STUB_STEP;
bordertype &= 15;
if( bordertype == IPL_BORDER_REPLICATE )
{
icvCopyReplicateBorder_8u( src->data.ptr, srcstep, srcsize,