mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
fixed bug in IPP-accelerated morphology; added several IPP imgwarp functions (by Klim)
This commit is contained in:
parent
e6ec3dd17f
commit
e85e4d3ab9
@ -1850,12 +1850,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
|||||||
int k, sx, sy, dx, dy;
|
int k, sx, sy, dx, dy;
|
||||||
|
|
||||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||||
int mode =
|
int mode = interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR : 0;
|
||||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
|
|
||||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
|
||||||
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC :
|
|
||||||
interpolation == INTER_AREA && inv_scale_x * inv_scale_y > 1 ? IPPI_INTER_NN :
|
|
||||||
0;
|
|
||||||
int type = src.type();
|
int type = src.type();
|
||||||
ippiResizeSqrPixelFunc ippFunc =
|
ippiResizeSqrPixelFunc ippFunc =
|
||||||
type == CV_8UC1 ? (ippiResizeSqrPixelFunc)ippiResizeSqrPixel_8u_C1R :
|
type == CV_8UC1 ? (ippiResizeSqrPixelFunc)ippiResizeSqrPixel_8u_C1R :
|
||||||
@ -1871,7 +1866,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
|||||||
type == CV_32FC3 ? (ippiResizeSqrPixelFunc)ippiResizeSqrPixel_32f_C3R :
|
type == CV_32FC3 ? (ippiResizeSqrPixelFunc)ippiResizeSqrPixel_32f_C3R :
|
||||||
type == CV_32FC4 ? (ippiResizeSqrPixelFunc)ippiResizeSqrPixel_32f_C4R :
|
type == CV_32FC4 ? (ippiResizeSqrPixelFunc)ippiResizeSqrPixel_32f_C4R :
|
||||||
0;
|
0;
|
||||||
if( ippFunc && mode )
|
if( ippFunc && mode != 0 )
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
Range range(0, src.rows);
|
Range range(0, src.rows);
|
||||||
|
@ -1213,11 +1213,10 @@ static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kerne
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
||||||
InputArray _kernel,
|
const Mat& _kernel, Point anchor, int iterations,
|
||||||
const Point &anchor, int iterations,
|
|
||||||
int borderType, const Scalar &borderValue)
|
int borderType, const Scalar &borderValue)
|
||||||
{
|
{
|
||||||
Mat src = _src.getMat(), kernel = _kernel.getMat();
|
Mat src = _src.getMat(), kernel = _kernel;
|
||||||
if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) ||
|
if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) ||
|
||||||
!( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) )
|
!( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) )
|
||||||
|| !( op == MORPH_DILATE || op == MORPH_ERODE) )
|
|| !( op == MORPH_DILATE || op == MORPH_ERODE) )
|
||||||
@ -1248,9 +1247,6 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
|||||||
|
|
||||||
}
|
}
|
||||||
Size ksize = kernel.data ? kernel.size() : Size(3,3);
|
Size ksize = kernel.data ? kernel.size() : Size(3,3);
|
||||||
Point normanchor = normalizeAnchor(anchor, ksize);
|
|
||||||
|
|
||||||
CV_Assert( normanchor.inside(Rect(0, 0, ksize.width, ksize.height)) );
|
|
||||||
|
|
||||||
_dst.create( src.size(), src.type() );
|
_dst.create( src.size(), src.type() );
|
||||||
Mat dst = _dst.getMat();
|
Mat dst = _dst.getMat();
|
||||||
@ -1265,7 +1261,7 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
|||||||
if( !kernel.data )
|
if( !kernel.data )
|
||||||
{
|
{
|
||||||
ksize = Size(1+iterations*2,1+iterations*2);
|
ksize = Size(1+iterations*2,1+iterations*2);
|
||||||
normanchor = Point(iterations, iterations);
|
anchor = Point(iterations, iterations);
|
||||||
rectKernel = true;
|
rectKernel = true;
|
||||||
iterations = 1;
|
iterations = 1;
|
||||||
}
|
}
|
||||||
@ -1273,7 +1269,7 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
|||||||
{
|
{
|
||||||
ksize = Size(ksize.width + (iterations-1)*(ksize.width-1),
|
ksize = Size(ksize.width + (iterations-1)*(ksize.width-1),
|
||||||
ksize.height + (iterations-1)*(ksize.height-1)),
|
ksize.height + (iterations-1)*(ksize.height-1)),
|
||||||
normanchor = Point(normanchor.x*iterations, normanchor.y*iterations);
|
anchor = Point(anchor.x*iterations, anchor.y*iterations);
|
||||||
kernel = Mat();
|
kernel = Mat();
|
||||||
rectKernel = true;
|
rectKernel = true;
|
||||||
iterations = 1;
|
iterations = 1;
|
||||||
@ -1283,7 +1279,7 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
|||||||
if( iterations > 1 )
|
if( iterations > 1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return IPPMorphReplicate( op, src, dst, kernel, ksize, normanchor, rectKernel );
|
return IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1292,18 +1288,19 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
|
|||||||
Point anchor, int iterations,
|
Point anchor, int iterations,
|
||||||
int borderType, const Scalar& borderValue )
|
int borderType, const Scalar& borderValue )
|
||||||
{
|
{
|
||||||
|
Mat kernel = _kernel.getMat();
|
||||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
|
||||||
if( IPPMorphOp(op, _src, _dst, _kernel, anchor, iterations, borderType, borderValue) )
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Mat src = _src.getMat(), kernel = _kernel.getMat();
|
|
||||||
Size ksize = kernel.data ? kernel.size() : Size(3,3);
|
Size ksize = kernel.data ? kernel.size() : Size(3,3);
|
||||||
anchor = normalizeAnchor(anchor, ksize);
|
anchor = normalizeAnchor(anchor, ksize);
|
||||||
|
|
||||||
CV_Assert( anchor.inside(Rect(0, 0, ksize.width, ksize.height)) );
|
CV_Assert( anchor.inside(Rect(0, 0, ksize.width, ksize.height)) );
|
||||||
|
|
||||||
|
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||||
|
if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) )
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Mat src = _src.getMat();
|
||||||
|
|
||||||
_dst.create( src.size(), src.type() );
|
_dst.create( src.size(), src.type() );
|
||||||
Mat dst = _dst.getMat();
|
Mat dst = _dst.getMat();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user