| 102 | } |
| 103 | |
| 104 | TEST(rgb_gray, MaxDim) { |
| 105 | size_t largeDim = 65535 * 32 + 1; |
| 106 | array rgb = randu(1, largeDim, 3, u8); |
| 107 | array gray = rgb2gray(rgb); |
| 108 | |
| 109 | vector<uchar> h_rgb(rgb.elements()); |
| 110 | vector<float> h_gray(gray.elements()); |
| 111 | |
| 112 | rgb.host(&h_rgb[0]); |
| 113 | gray.host(&h_gray[0]); |
| 114 | |
| 115 | int num = gray.elements(); |
| 116 | int roff = 0; |
| 117 | int goff = num; |
| 118 | int boff = 2 * num; |
| 119 | |
| 120 | const float rPercent = 0.2126f; |
| 121 | const float gPercent = 0.7152f; |
| 122 | const float bPercent = 0.0722f; |
| 123 | |
| 124 | for (int i = 0; i < num; i++) { |
| 125 | float res = rPercent * h_rgb[i + roff] + gPercent * h_rgb[i + goff] + |
| 126 | bPercent * h_rgb[i + boff]; |
| 127 | |
| 128 | ASSERT_FLOAT_EQ(res, h_gray[i]); |
| 129 | } |
| 130 | } |
no test coverage detected