perf_denoising.cpp 2.89 KB
Newer Older
wester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.

#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"

#ifdef HAVE_OPENCL

namespace cvtest {
namespace ocl {

OCL_PERF_TEST(Photo, DenoisingGrayscale)
{
    Mat _original = imread(getDataPath("cv/denoising/lena_noised_gaussian_sigma=10.png"), IMREAD_GRAYSCALE);
    ASSERT_FALSE(_original.empty()) << "Could not load input image";

    UMat result(_original.size(), _original.type()), original;
    _original.copyTo(original);

    declare.in(original).out(result).iterations(10);

    OCL_TEST_CYCLE()
            cv::fastNlMeansDenoising(original, result, 10);

    SANITY_CHECK(result, 1);
}

OCL_PERF_TEST(Photo, DenoisingColored)
{
    Mat _original = imread(getDataPath("cv/denoising/lena_noised_gaussian_sigma=10.png"));
    ASSERT_FALSE(_original.empty()) << "Could not load input image";

    UMat result(_original.size(), _original.type()), original;
    _original.copyTo(original);

    declare.in(original).out(result).iterations(10);

    OCL_TEST_CYCLE()
            cv::fastNlMeansDenoisingColored(original, result, 10, 10);

    SANITY_CHECK(result, 2);
}

OCL_PERF_TEST(Photo, DISABLED_DenoisingGrayscaleMulti)
{
    const int imgs_count = 3;

    vector<UMat> original(imgs_count);
    Mat tmp;
    for (int i = 0; i < imgs_count; i++)
    {
        string original_path = format("cv/denoising/lena_noised_gaussian_sigma=20_multi_%d.png", i);
        tmp = imread(getDataPath(original_path), IMREAD_GRAYSCALE);
        ASSERT_FALSE(tmp.empty()) << "Could not load input image " << original_path;
        tmp.copyTo(original[i]);
        declare.in(original[i]);
    }
    UMat result(tmp.size(), tmp.type());
    declare.out(result).iterations(10);

    OCL_TEST_CYCLE()
            cv::fastNlMeansDenoisingMulti(original, result, imgs_count / 2, imgs_count, 15);

    SANITY_CHECK(result);
}

OCL_PERF_TEST(Photo, DISABLED_DenoisingColoredMulti)
{
    const int imgs_count = 3;

    vector<UMat> original(imgs_count);
    Mat tmp;
    for (int i = 0; i < imgs_count; i++)
    {
        string original_path = format("cv/denoising/lena_noised_gaussian_sigma=20_multi_%d.png", i);
        tmp = imread(getDataPath(original_path), IMREAD_COLOR);
        ASSERT_FALSE(tmp.empty()) << "Could not load input image " << original_path;

        tmp.copyTo(original[i]);
        declare.in(original[i]);
    }
    UMat result(tmp.size(), tmp.type());
    declare.out(result).iterations(10);

    OCL_TEST_CYCLE()
            cv::fastNlMeansDenoisingColoredMulti(original, result, imgs_count / 2, imgs_count, 10, 15);

    SANITY_CHECK(result);
}

} } // namespace cvtest::ocl

#endif // HAVE_OPENCL