dct_image_denoising.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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(xphoto_dctimagedenoising, regression)
  7. {
  8. cv::String subfolder = "cv/xphoto/";
  9. cv::String dir = cvtest::TS::ptr()->get_data_path() + subfolder + "dct_image_denoising/";
  10. int nTests = 1;
  11. double thresholds[] = {0.2};
  12. int psize[] = {8};
  13. double sigma[] = {9.0};
  14. for (int i = 0; i < nTests; ++i)
  15. {
  16. cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1);
  17. cv::Mat src = cv::imread( srcName, 1 );
  18. ASSERT_TRUE(!src.empty());
  19. cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 );
  20. cv::Mat previousResult = cv::imread( previousResultName, 1 );
  21. ASSERT_TRUE(!src.empty());
  22. cv::Mat currentResult;
  23. cv::xphoto::dctDenoising(src, currentResult, sigma[i], psize[i]);
  24. cv::Mat sqrError = ( currentResult - previousResult )
  25. .mul( currentResult - previousResult );
  26. cv::Scalar mse = cv::sum(sqrError) / cv::Scalar::all( double(sqrError.total()*sqrError.channels()) );
  27. EXPECT_LE( mse[0] + mse[1] + mse[2] + mse[3], thresholds[i] );
  28. }
  29. }
  30. }} // namespace