test_niblack_threshold.cpp 945 B

1234567891011121314151617181920212223242526272829
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "test_precomp.hpp"
  5. namespace opencv_test { namespace {
  6. TEST(ximgproc_niBlackThreshold, sauvola)
  7. {
  8. Mat src = (Mat_<uchar>(3, 3) << 1, 1, 1, 2, 2, 2, 3, 3, 3);
  9. Mat dst;
  10. cv::ximgproc::niBlackThreshold(src, dst, 255, THRESH_BINARY, 3, 1, BINARIZATION_SAUVOLA, 1);
  11. EXPECT_EQ(CV_8U, dst.type());
  12. EXPECT_EQ(3, dst.rows);
  13. EXPECT_EQ(3, dst.cols);
  14. EXPECT_EQ(0, dst.at<uchar>(0, 0));
  15. EXPECT_EQ(0, dst.at<uchar>(0, 1));
  16. EXPECT_EQ(0, dst.at<uchar>(0, 2));
  17. EXPECT_EQ(0, dst.at<uchar>(1, 0));
  18. EXPECT_EQ(0, dst.at<uchar>(1, 1));
  19. EXPECT_EQ(0, dst.at<uchar>(1, 2));
  20. EXPECT_EQ(255, dst.at<uchar>(2, 0));
  21. EXPECT_EQ(255, dst.at<uchar>(2, 1));
  22. EXPECT_EQ(255, dst.at<uchar>(2, 2));
  23. }
  24. }} // namespace