added GPU bilateral filter + tests
[profile/ivi/opencv.git] / modules / gpu / perf / perf_denoising.cpp
1 #include "perf_precomp.hpp"
2
3 using namespace std;
4 using namespace testing;
5
6
7 //////////////////////////////////////////////////////////////////////
8 // BilateralFilter
9
10 DEF_PARAM_TEST(Sz_Depth_Cn_KernelSz, cv::Size, MatDepth , int, int);
11
12 PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter, 
13             Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), GPU_CHANNELS_1_3_4, Values(3, 5, 9)))
14 {
15     declare.time(30.0);
16
17     cv::Size size = GET_PARAM(0);
18     int depth = GET_PARAM(1);
19     int channels = GET_PARAM(2);
20     int kernel_size = GET_PARAM(3);
21
22     float sigma_color = 7;
23     float sigma_spatial = 5;
24     int borderMode = cv::BORDER_REFLECT101;
25
26     int type = CV_MAKE_TYPE(depth, channels);
27
28     cv::Mat src(size, type);
29     fillRandom(src);
30
31      if (runOnGpu)
32     {
33         cv::gpu::GpuMat d_src(src);
34         cv::gpu::GpuMat d_dst;
35
36         cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
37
38         TEST_CYCLE()
39         {
40             cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
41         }
42     }
43     else
44     {
45         cv::Mat dst;
46
47         cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
48
49         TEST_CYCLE()
50         {
51             cv::bilateralFilter(src, dst, kernel_size, sigma_color, sigma_spatial, borderMode);
52         }
53     }
54 }
55
56
57 //////////////////////////////////////////////////////////////////////
58 // nonLocalMeans
59
60 DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth , int, int, int);
61
62 PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans, 
63             Combine(GPU_TYPICAL_MAT_SIZES, Values<MatDepth>(CV_8U), Values(1), Values(21), Values(5, 7)))
64 {
65     declare.time(30.0);
66
67     cv::Size size = GET_PARAM(0);
68     int depth = GET_PARAM(1);
69     int channels = GET_PARAM(2);
70     
71     int search_widow_size = GET_PARAM(3);
72     int block_size = GET_PARAM(4);
73
74     float h = 10;
75     int borderMode = cv::BORDER_REFLECT101;
76     
77     int type = CV_MAKE_TYPE(depth, channels);
78
79     cv::Mat src(size, type);
80     fillRandom(src);
81
82     if (runOnGpu)
83     {
84         cv::gpu::GpuMat d_src(src);
85         cv::gpu::GpuMat d_dst;
86
87         cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
88
89         TEST_CYCLE()
90         {
91             cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
92         }
93     }
94     else
95     {
96         FAIL();
97     }
98 }