Commit 493679dc authored by Ilya Lavrenov's avatar Ilya Lavrenov

cv::minMaxIdx for cn > 1

parent cd01d705
...@@ -2217,7 +2217,6 @@ icvXMLParse( CvFileStorage* fs ) ...@@ -2217,7 +2217,6 @@ icvXMLParse( CvFileStorage* fs )
ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG ); ptr = icvXMLSkipSpaces( fs, ptr, CV_XML_INSIDE_TAG );
if( memcmp( ptr, "<?xml", 5 ) != 0 ) if( memcmp( ptr, "<?xml", 5 ) != 0 )
CV_PARSE_ERROR( "Valid XML should start with \'<?xml ...?>\'" ); CV_PARSE_ERROR( "Valid XML should start with \'<?xml ...?>\'" );
ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type ); ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type );
......
...@@ -1359,30 +1359,37 @@ void cv::minMaxIdx(InputArray _src, double* minVal, ...@@ -1359,30 +1359,37 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
double* maxVal, int* minIdx, int* maxIdx, double* maxVal, int* minIdx, int* maxIdx,
InputArray _mask) InputArray _mask)
{ {
CV_Assert( (_src.channels() == 1 && (_mask.empty() || _mask.type() == CV_8U)) || int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
(_src.channels() >= 1 && _mask.empty() && !minIdx && !maxIdx) ); CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) ||
(cn > 1 && _mask.empty() && !minIdx && !maxIdx) );
CV_OCL_RUN(_src.isUMat() && _src.dims() <= 2 && (_mask.empty() || _src.size() == _mask.size()), CV_OCL_RUN(_src.isUMat() && _src.dims() <= 2 && (_mask.empty() || _src.size() == _mask.size()),
ocl_minMaxIdx(_src, minVal, maxVal, minIdx, maxIdx, _mask)) ocl_minMaxIdx(_src, minVal, maxVal, minIdx, maxIdx, _mask))
Mat src = _src.getMat(), mask = _mask.getMat(); Mat src = _src.getMat(), mask = _mask.getMat();
int depth = src.depth(), cn = src.channels();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src.total(); size_t total_size = src.total();
int rows = src.size[0], cols = (int)(total_size/rows); int rows = src.size[0], cols = (int)(total_size/rows);
if( cn == 1 && ( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) ) if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
{ {
IppiSize sz = { cols, rows }; IppiSize sz = { cols * cn, rows };
int type = src.type();
if( !mask.empty() ) if( !mask.empty() )
{ {
typedef IppStatus (CV_STDCALL* ippiMaskMinMaxIndxFuncC1)(const void *, int, const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *); typedef IppStatus (CV_STDCALL* ippiMaskMinMaxIndxFuncC1)(const void *, int, const void *, int,
IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
CV_SUPPRESS_DEPRECATED_START
ippiMaskMinMaxIndxFuncC1 ippFuncC1 = ippiMaskMinMaxIndxFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR : type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR :
type == CV_16UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1MR : #ifndef HAVE_IPP_ICV_ONLY
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : type == CV_8SC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1MR :
0; #endif
type == CV_16UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1MR :
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : 0;
CV_SUPPRESS_DEPRECATED_END
if( ippFuncC1 ) if( ippFuncC1 )
{ {
Ipp32f min, max; Ipp32f min, max;
...@@ -1413,11 +1420,17 @@ void cv::minMaxIdx(InputArray _src, double* minVal, ...@@ -1413,11 +1420,17 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
else else
{ {
typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *); typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
CV_SUPPRESS_DEPRECATED_START
ippiMinMaxIndxFuncC1 ippFuncC1 = ippiMinMaxIndxFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R : depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
type == CV_16UC1 ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R : #ifndef HAVE_IPP_ICV_ONLY
type == CV_32FC1 ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R : depth == CV_8S ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1R :
0; #endif
depth == CV_16U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
depth == CV_32F ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R : 0;
CV_SUPPRESS_DEPRECATED_END
if( ippFuncC1 ) if( ippFuncC1 )
{ {
Ipp32f min, max; Ipp32f min, max;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment