test_ssim.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #define TEST_CASE_NAME CV_Quality_SSIM
  6. namespace opencv_test
  7. {
  8. namespace quality_test
  9. {
  10. // expected ssim per channel
  11. const cv::Scalar
  12. SSIM_EXPECTED_1 = { .1501 }
  13. , SSIM_EXPECTED_2 = { .7541, .7742, .8095 }
  14. ;
  15. // static method
  16. TEST(TEST_CASE_NAME, static_)
  17. {
  18. cv::Mat qMat = {};
  19. quality_expect_near(quality::QualitySSIM::compute(get_testfile_1a(), get_testfile_1a(), qMat), cv::Scalar(1.)); // ref vs ref == 1.
  20. check_quality_map(qMat);
  21. }
  22. // single channel, with/without opencl
  23. TEST(TEST_CASE_NAME, single_channel)
  24. {
  25. auto fn = []() { quality_test(quality::QualitySSIM::create(get_testfile_1a()), get_testfile_1b(), SSIM_EXPECTED_1); };
  26. OCL_OFF(fn());
  27. OCL_ON(fn());
  28. }
  29. // multi-channel
  30. TEST(TEST_CASE_NAME, multi_channel)
  31. {
  32. quality_test(quality::QualitySSIM::create(get_testfile_2a()), get_testfile_2b(), SSIM_EXPECTED_2);
  33. }
  34. // internal a/b test
  35. /*
  36. TEST(TEST_CASE_NAME, performance)
  37. {
  38. auto ref = get_testfile_1a();
  39. auto cmp = get_testfile_1b();
  40. quality_performance_test("SSIM", [&]() { cv::quality::QualitySSIM::compute(ref, cmp, cv::noArray()); });
  41. }
  42. */
  43. }
  44. } // namespace