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.
5
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
6
// Third party copyrights are property of their respective owners.
8
#include "../test_precomp.hpp"
9
#include "opencv2/ts/ocl_test.hpp"
16
PARAM_TEST_CASE(FastNlMeansDenoisingTestBase, Channels, int, bool, bool)
18
int cn, normType, templateWindowSize, searchWindowSize;
20
bool use_roi, use_image;
22
TEST_DECLARE_INPUT_PARAMETER(src);
23
TEST_DECLARE_OUTPUT_PARAMETER(dst);
28
normType = GET_PARAM(1);
29
use_roi = GET_PARAM(2);
30
use_image = GET_PARAM(3);
32
templateWindowSize = 7;
33
searchWindowSize = 21;
36
for (int i=0; i<cn; i++)
40
virtual void generateTestData()
42
const int type = CV_8UC(cn);
46
image = readImage("denoising/lena_noised_gaussian_sigma=10.png",
47
cn == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
48
ASSERT_FALSE(image.empty());
51
Size roiSize = use_image ? image.size() : randomSize(1, MAX_VALUE);
52
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
53
randomSubMat(src, src_roi, roiSize, srcBorder, type, 0, 255);
55
ASSERT_TRUE(cn > 0 && cn <= 4);
57
int from_to[] = { 0,0, 1,1 };
58
src_roi.create(roiSize, type);
59
mixChannels(&image, 1, &src_roi, 1, from_to, 2);
62
int from_to[] = { 0,0, 1,1, 2,2, 1,3};
63
src_roi.create(roiSize, type);
64
mixChannels(&image, 1, &src_roi, 1, from_to, 4);
66
else image.copyTo(src_roi);
69
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
70
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 0, 255);
72
UMAT_UPLOAD_INPUT_PARAMETER(src);
73
UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
77
typedef FastNlMeansDenoisingTestBase FastNlMeansDenoising;
79
OCL_TEST_P(FastNlMeansDenoising, Mat)
81
for (int j = 0; j < test_loop_times; j++)
85
OCL_OFF(cv::fastNlMeansDenoising(src_roi, dst_roi, std::vector<float>(1, h[0]), templateWindowSize, searchWindowSize, normType));
86
OCL_ON(cv::fastNlMeansDenoising(usrc_roi, udst_roi, std::vector<float>(1, h[0]), templateWindowSize, searchWindowSize, normType));
88
OCL_EXPECT_MATS_NEAR(dst, 1);
92
typedef FastNlMeansDenoisingTestBase FastNlMeansDenoising_hsep;
94
OCL_TEST_P(FastNlMeansDenoising_hsep, Mat)
96
for (int j = 0; j < test_loop_times; j++)
100
OCL_OFF(cv::fastNlMeansDenoising(src_roi, dst_roi, h, templateWindowSize, searchWindowSize, normType));
101
OCL_ON(cv::fastNlMeansDenoising(usrc_roi, udst_roi, h, templateWindowSize, searchWindowSize, normType));
103
OCL_EXPECT_MATS_NEAR(dst, 1);
107
typedef FastNlMeansDenoisingTestBase FastNlMeansDenoisingColored;
109
OCL_TEST_P(FastNlMeansDenoisingColored, Mat)
111
for (int j = 0; j < test_loop_times; j++)
115
OCL_OFF(cv::fastNlMeansDenoisingColored(src_roi, dst_roi, h[0], h[0], templateWindowSize, searchWindowSize));
116
OCL_ON(cv::fastNlMeansDenoisingColored(usrc_roi, udst_roi, h[0], h[0], templateWindowSize, searchWindowSize));
118
OCL_EXPECT_MATS_NEAR(dst, 1);
122
OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoising,
123
Combine(Values(1, 2, 3, 4), Values((int)NORM_L2, (int)NORM_L1),
124
Bool(), Values(true)));
125
OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoising_hsep,
126
Combine(Values(1, 2, 3, 4), Values((int)NORM_L2, (int)NORM_L1),
127
Bool(), Values(true)));
128
OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoisingColored,
129
Combine(Values(3, 4), Values((int)NORM_L2), Bool(), Values(false)));
131
} } // namespace cvtest::ocl
133
#endif // HAVE_OPENCL