1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-21 23:01:45 +08:00
Files
opencv_contrib/modules/ximgproc/test/test_niblack_threshold.cpp
shimat bebfd71748 Merge pull request #2491 from shimat:sauvola_r
ximgproc: [niBlackThreshold] add R parameter for Sauvola's method

* added R parameter to niBlackThreshold

* replace tab to 4 spaces

* add niblackThreshold test (sauvola)

* changed test case of sauvola

* Update modules/ximgproc/include/opencv2/ximgproc.hpp
2020-04-07 20:06:01 +00:00

30 lines
945 B
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace opencv_test { namespace {
TEST(ximgproc_niBlackThreshold, sauvola)
{
Mat src = (Mat_<uchar>(3, 3) << 1, 1, 1, 2, 2, 2, 3, 3, 3);
Mat dst;
cv::ximgproc::niBlackThreshold(src, dst, 255, THRESH_BINARY, 3, 1, BINARIZATION_SAUVOLA, 1);
EXPECT_EQ(CV_8U, dst.type());
EXPECT_EQ(3, dst.rows);
EXPECT_EQ(3, dst.cols);
EXPECT_EQ(0, dst.at<uchar>(0, 0));
EXPECT_EQ(0, dst.at<uchar>(0, 1));
EXPECT_EQ(0, dst.at<uchar>(0, 2));
EXPECT_EQ(0, dst.at<uchar>(1, 0));
EXPECT_EQ(0, dst.at<uchar>(1, 1));
EXPECT_EQ(0, dst.at<uchar>(1, 2));
EXPECT_EQ(255, dst.at<uchar>(2, 0));
EXPECT_EQ(255, dst.at<uchar>(2, 1));
EXPECT_EQ(255, dst.at<uchar>(2, 2));
}
}} // namespace