perf_denoising.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
  5. // Third party copyrights are property of their respective owners.
  6. #include "../perf_precomp.hpp"
  7. #include "opencv2/ts/ocl_perf.hpp"
  8. #ifdef HAVE_OPENCL
  9. namespace opencv_test {
  10. namespace ocl {
  11. OCL_PERF_TEST(Photo, DenoisingGrayscale)
  12. {
  13. Mat _original = imread(getDataPath("cv/denoising/lena_noised_gaussian_sigma=10.png"), IMREAD_GRAYSCALE);
  14. ASSERT_FALSE(_original.empty()) << "Could not load input image";
  15. UMat result(_original.size(), _original.type()), original;
  16. _original.copyTo(original);
  17. declare.in(original).out(result).iterations(10);
  18. OCL_TEST_CYCLE()
  19. cv::fastNlMeansDenoising(original, result, 10);
  20. SANITY_CHECK(result, 1);
  21. }
  22. OCL_PERF_TEST(Photo, DenoisingColored)
  23. {
  24. Mat _original = imread(getDataPath("cv/denoising/lena_noised_gaussian_sigma=10.png"));
  25. ASSERT_FALSE(_original.empty()) << "Could not load input image";
  26. UMat result(_original.size(), _original.type()), original;
  27. _original.copyTo(original);
  28. declare.in(original).out(result).iterations(10);
  29. OCL_TEST_CYCLE()
  30. cv::fastNlMeansDenoisingColored(original, result, 10, 10);
  31. SANITY_CHECK(result, 2);
  32. }
  33. OCL_PERF_TEST(Photo, DISABLED_DenoisingGrayscaleMulti)
  34. {
  35. const int imgs_count = 3;
  36. vector<UMat> original(imgs_count);
  37. Mat tmp;
  38. for (int i = 0; i < imgs_count; i++)
  39. {
  40. string original_path = format("cv/denoising/lena_noised_gaussian_sigma=20_multi_%d.png", i);
  41. tmp = imread(getDataPath(original_path), IMREAD_GRAYSCALE);
  42. ASSERT_FALSE(tmp.empty()) << "Could not load input image " << original_path;
  43. tmp.copyTo(original[i]);
  44. declare.in(original[i]);
  45. }
  46. UMat result(tmp.size(), tmp.type());
  47. declare.out(result).iterations(10);
  48. OCL_TEST_CYCLE()
  49. cv::fastNlMeansDenoisingMulti(original, result, imgs_count / 2, imgs_count, 15);
  50. SANITY_CHECK(result);
  51. }
  52. OCL_PERF_TEST(Photo, DISABLED_DenoisingColoredMulti)
  53. {
  54. const int imgs_count = 3;
  55. vector<UMat> original(imgs_count);
  56. Mat tmp;
  57. for (int i = 0; i < imgs_count; i++)
  58. {
  59. string original_path = format("cv/denoising/lena_noised_gaussian_sigma=20_multi_%d.png", i);
  60. tmp = imread(getDataPath(original_path), IMREAD_COLOR);
  61. ASSERT_FALSE(tmp.empty()) << "Could not load input image " << original_path;
  62. tmp.copyTo(original[i]);
  63. declare.in(original[i]);
  64. }
  65. UMat result(tmp.size(), tmp.type());
  66. declare.out(result).iterations(10);
  67. OCL_TEST_CYCLE()
  68. cv::fastNlMeansDenoisingColoredMulti(original, result, imgs_count / 2, imgs_count, 10, 15);
  69. SANITY_CHECK(result);
  70. }
  71. } } // namespace opencv_test::ocl
  72. #endif // HAVE_OPENCL