1
/*M///////////////////////////////////////////////////////////////////////////////////////
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
11
// For Open Source Computer Vision Library
13
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16
// Third party copyrights are property of their respective owners.
18
// Redistribution and use in source and binary forms, with or without modification,
19
// are permitted provided that the following conditions are met:
21
// * Redistribution's of source code must retain the above copyright notice,
22
// this list of conditions and the following disclaimer.
24
// * Redistribution's in binary form must reproduce the above copyright notice,
25
// this list of conditions and the following disclaimer in the documentation
26
// and/or other materials provided with the distribution.
28
// * The name of the copyright holders may not be used to endorse or promote products
29
// derived from this software without specific prior written permission.
31
// This software is provided by the copyright holders and contributors "as is" and
32
// any express or implied warranties, including, but not limited to, the implied
33
// warranties of merchantability and fitness for a particular purpose are disclaimed.
34
// In no event shall the Intel Corporation or contributors be liable for any direct,
35
// indirect, incidental, special, exemplary, or consequential damages
36
// (including, but not limited to, procurement of substitute goods or services;
37
// loss of use, data, or profits; or business interruption) however caused
38
// and on any theory of liability, whether in contract, strict liability,
39
// or tort (including negligence or otherwise) arising in any way out of
40
// the use of this software, even if advised of the possibility of such damage.
44
#include "test_precomp.hpp"
47
using namespace cv::cuda;
48
using namespace cv::cudev;
49
using namespace cvtest;
54
COLOR_BGR2BGR = COLOR_BGR2RGB,
55
COLOR_BGR2LRGB = COLOR_BGR2RGB,
56
COLOR_BGR2LBGR = COLOR_BGR2RGB
61
#define CVT_COLOR_TEST(src_space, dst_space, src_cn, dst_cn) \
62
TEST(CvtColor, src_space ## _to_ ## dst_space) \
64
const Size size = randomSize(100, 400); \
65
Mat bgrb = randomMat(size, CV_8UC3); \
67
cv::cvtColor(bgrb, srcb, COLOR_BGR ## 2 ## src_space, src_cn); \
68
GpuMat_<SelectIf<src_cn == 1, uchar, uchar ## src_cn>::type> d_srcb(srcb); \
69
GpuMat_<SelectIf<dst_cn == 1, uchar, uchar ## dst_cn>::type> dstb = src_space ## _to_ ## dst_space ## _(d_srcb); \
71
cv::cvtColor(srcb, dstb_gold, COLOR_ ## src_space ## 2 ## dst_space); \
72
EXPECT_MAT_NEAR(dstb_gold, dstb, 2.0); \
73
Mat bgrf = randomMat(size, CV_32FC3, 0, 1); \
75
cv::cvtColor(bgrf, srcf, COLOR_BGR ## 2 ## src_space, src_cn); \
76
GpuMat_<SelectIf<src_cn == 1, float, float ## src_cn>::type> d_srcf(srcf); \
77
GpuMat_<SelectIf<dst_cn == 1, float, float ## dst_cn>::type> dstf = src_space ## _to_ ## dst_space ## _(d_srcf); \
79
cv::cvtColor(srcf, dstf_gold, COLOR_ ## src_space ## 2 ## dst_space); \
80
EXPECT_MAT_NEAR(dstf_gold, dstf, 2.0); \
85
CVT_COLOR_TEST(BGR, RGB, 3, 3)
86
CVT_COLOR_TEST(BGR, BGRA, 3, 4)
87
CVT_COLOR_TEST(BGR, RGBA, 3, 4)
88
CVT_COLOR_TEST(BGRA, BGR, 4, 3)
89
CVT_COLOR_TEST(BGRA, RGB, 4, 3)
90
CVT_COLOR_TEST(BGRA, RGBA, 4, 4)
94
CVT_COLOR_TEST(BGR, GRAY, 3, 1)
95
CVT_COLOR_TEST(RGB, GRAY, 3, 1)
96
CVT_COLOR_TEST(BGRA, GRAY, 4, 1)
97
CVT_COLOR_TEST(RGBA, GRAY, 4, 1)
99
CVT_COLOR_TEST(GRAY, BGR, 1, 3)
100
CVT_COLOR_TEST(GRAY, BGRA, 1, 4)
104
CVT_COLOR_TEST(RGB, YUV, 3, 3)
105
CVT_COLOR_TEST(BGR, YUV, 3, 3)
107
CVT_COLOR_TEST(YUV, RGB, 3, 3)
108
CVT_COLOR_TEST(YUV, BGR, 3, 3)
112
CVT_COLOR_TEST(RGB, YCrCb, 3, 3)
113
CVT_COLOR_TEST(BGR, YCrCb, 3, 3)
115
CVT_COLOR_TEST(YCrCb, RGB, 3, 3)
116
CVT_COLOR_TEST(YCrCb, BGR, 3, 3)
120
CVT_COLOR_TEST(RGB, XYZ, 3, 3)
121
CVT_COLOR_TEST(BGR, XYZ, 3, 3)
123
CVT_COLOR_TEST(XYZ, RGB, 3, 3)
124
CVT_COLOR_TEST(XYZ, BGR, 3, 3)
128
CVT_COLOR_TEST(RGB, HSV, 3, 3)
129
CVT_COLOR_TEST(BGR, HSV, 3, 3)
131
CVT_COLOR_TEST(HSV, RGB, 3, 3)
132
CVT_COLOR_TEST(HSV, BGR, 3, 3)
134
CVT_COLOR_TEST(RGB, HSV_FULL, 3, 3)
135
CVT_COLOR_TEST(BGR, HSV_FULL, 3, 3)
137
CVT_COLOR_TEST(HSV, RGB_FULL, 3, 3)
138
CVT_COLOR_TEST(HSV, BGR_FULL, 3, 3)
142
CVT_COLOR_TEST(RGB, HLS, 3, 3)
143
CVT_COLOR_TEST(BGR, HLS, 3, 3)
145
CVT_COLOR_TEST(HLS, RGB, 3, 3)
146
CVT_COLOR_TEST(HLS, BGR, 3, 3)
148
CVT_COLOR_TEST(RGB, HLS_FULL, 3, 3)
149
CVT_COLOR_TEST(BGR, HLS_FULL, 3, 3)
151
CVT_COLOR_TEST(HLS, RGB_FULL, 3, 3)
152
CVT_COLOR_TEST(HLS, BGR_FULL, 3, 3)
156
CVT_COLOR_TEST(RGB, Lab, 3, 3)
157
CVT_COLOR_TEST(BGR, Lab, 3, 3)
159
CVT_COLOR_TEST(Lab, RGB, 3, 3)
160
CVT_COLOR_TEST(Lab, BGR, 3, 3)
162
CVT_COLOR_TEST(LRGB, Lab, 3, 3)
163
CVT_COLOR_TEST(LBGR, Lab, 3, 3)
165
CVT_COLOR_TEST(Lab, LRGB, 3, 3)
166
CVT_COLOR_TEST(Lab, LBGR, 3, 3)
170
CVT_COLOR_TEST(RGB, Luv, 3, 3)
171
CVT_COLOR_TEST(BGR, Luv, 3, 3)
173
CVT_COLOR_TEST(Luv, RGB, 3, 3)
174
CVT_COLOR_TEST(Luv, BGR, 3, 3)
176
CVT_COLOR_TEST(LRGB, Luv, 3, 3)
177
CVT_COLOR_TEST(LBGR, Luv, 3, 3)
179
CVT_COLOR_TEST(Luv, LRGB, 3, 3)
180
CVT_COLOR_TEST(Luv, LBGR, 3, 3)