Bug fixes for filter2D and associated tests.

This commit is contained in:
Aaron Kunze
2014-05-20 22:30:09 -07:00
parent 0ec54982b5
commit ab1a37d564
3 changed files with 36 additions and 17 deletions

View File

@@ -3238,12 +3238,12 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
if (cn <= 2 && ksize.width <= 4 && ksize.height <= 4)
{
pxPerWorkItemX = sz.width % 8 ? sz.width % 4 ? sz.width % 2 ? 1 : 2 : 4 : 8;
pxPerWorkItemY = sz.width % 2 ? 1 : 2;
pxPerWorkItemY = sz.height % 2 ? 1 : 2;
}
else if (cn < 4 || (ksize.width <= 4 && ksize.height <= 4))
{
pxPerWorkItemX = sz.width % 2 ? 1 : 2;
pxPerWorkItemY = sz.width % 2 ? 1 : 2;
pxPerWorkItemY = sz.height % 2 ? 1 : 2;
}
globalsize[0] = sz.width / pxPerWorkItemX;
globalsize[1] = sz.height / pxPerWorkItemY;
@@ -3823,26 +3823,45 @@ void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth,
if( kernel.cols*kernel.rows >= dft_filter_size )
{
Mat temp;
if( src.data != dst.data )
temp = dst;
else
temp.create(dst.size(), dst.type());
// crossCorr doesn't accept non-zero delta with multiple channels
if( src.channels() != 1 && delta != 0 )
{
// The semantics of filter2D require that the delta be applied
// as floating-point math. So wee need an intermediate Mat
// with a float datatype. If the dest is already floats,
// we just use that.
int corrDepth = dst.depth();
if( (dst.depth() == CV_32F || dst.depth() == CV_64F) &&
src.data != dst.data )
{
temp = dst;
}
else
{
corrDepth = dst.depth() == CV_64F ? CV_64F : CV_32F;
temp.create( dst.size(), CV_MAKETYPE(corrDepth, dst.channels()) );
}
crossCorr( src, kernel, temp, src.size(),
CV_MAKETYPE(ddepth, src.channels()),
CV_MAKETYPE(corrDepth, src.channels()),
anchor, 0, borderType );
add( temp, delta, temp );
if ( temp.data != dst.data )
{
temp.convertTo( dst, dst.type() );
}
}
else
{
if( src.data != dst.data )
temp = dst;
else
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);
}
if( temp.data != dst.data )
temp.copyTo(dst);
return;
}