From cd1c8693d843c099be5e22867f9f54850576b641 Mon Sep 17 00:00:00 2001 From: elenagvo Date: Fri, 22 Dec 2017 12:55:38 +0300 Subject: [PATCH] HAL for minMaxIdx --- modules/core/src/hal_replacement.hpp | 16 ++++++++++++++++ modules/core/src/stat.cpp | 4 ++++ modules/core/test/test_arithm.cpp | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index c0477e69b0..1a558f2532 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -712,6 +712,22 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s #define cv_hal_gemm64fc hal_ni_gemm64fc //! @endcond +/** + @brief Finds the global minimum and maximum in an array. + @param src_data,src_step Source image + @param width,height Source image dimensions + @param depth Depth of source image + @param minVal,maxVal Pointer to the returned global minimum and maximum in an array. + @param minIdx,maxIdx Pointer to the returned minimum and maximum location. + @param mask Specified array region. +*/ +inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal, + int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } + +//! @cond IGNORED +#define cv_hal_minMaxIdx hal_ni_minMaxIdx +//! @endcond + //! @} diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index 8a512a9511..d43e31cb7a 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -2713,6 +2713,10 @@ void cv::minMaxIdx(InputArray _src, double* minVal, Mat src = _src.getMat(), mask = _mask.getMat(); + if (src.dims <= 2) + CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, src.step, src.cols, src.rows, src.depth(), minVal, maxVal, + minIdx, maxIdx, mask.data); + CV_OVX_RUN(!ovx::skipSmallImages(src.cols, src.rows), openvx_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask)) diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index c5b5ede44c..130619be54 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -1867,6 +1867,24 @@ TEST(Core_BoolVector, support) ASSERT_FLOAT_EQ((float)nz/n, (float)(mean(test)[0])); } +TEST(MinMaxLoc, Mat_UcharMax_Without_Loc) +{ + Mat_ mat(50, 50); + uchar iMaxVal = numeric_limits::max(); + mat.setTo(iMaxVal); + + double min, max; + Point minLoc, maxLoc; + + minMaxLoc(mat, &min, &max, &minLoc, &maxLoc, Mat()); + + ASSERT_EQ(iMaxVal, min); + ASSERT_EQ(iMaxVal, max); + + ASSERT_EQ(Point(0, 0), minLoc); + ASSERT_EQ(Point(0, 0), maxLoc); +} + TEST(MinMaxLoc, Mat_IntMax_Without_Mask) { Mat_ mat(50, 50);