test_pyramid.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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(Imgproc_PyrUp, pyrUp_regression_22184)
  7. {
  8. Mat src(100,100,CV_16UC3,Scalar(255,255,255));
  9. Mat dst(100 * 2 + 1, 100 * 2 + 1, CV_16UC3, Scalar(0,0,0));
  10. pyrUp(src, dst, Size(dst.cols, dst.rows));
  11. double min_val = 0;
  12. minMaxLoc(dst, &min_val);
  13. ASSERT_GT(cvRound(min_val), 0);
  14. }
  15. TEST(Imgproc_PyrUp, pyrUp_regression_22194)
  16. {
  17. Mat src(13, 13,CV_16UC3,Scalar(0,0,0));
  18. {
  19. int swidth = src.cols;
  20. int sheight = src.rows;
  21. int cn = src.channels();
  22. int count = 0;
  23. for (int y = 0; y < sheight; y++)
  24. {
  25. ushort *src_c = src.ptr<ushort>(y);
  26. for (int x = 0; x < swidth * cn; x++)
  27. {
  28. src_c[x] = (count++) % 10;
  29. }
  30. }
  31. }
  32. Mat dst(src.cols * 2 - 1, src.rows * 2 - 1, CV_16UC3, Scalar(0,0,0));
  33. pyrUp(src, dst, Size(dst.cols, dst.rows));
  34. {
  35. ushort *dst_c = dst.ptr<ushort>(dst.rows - 1);
  36. ASSERT_EQ(dst_c[0], 6);
  37. ASSERT_EQ(dst_c[1], 6);
  38. ASSERT_EQ(dst_c[2], 1);
  39. }
  40. }
  41. }
  42. }