Go to the documentation of this file. 16 #include <gmock/gmock.h> 17 #include <gtest/gtest.h> 25 class TCore :
public ::testing::Test
30 #define ECVL_TUPLE(type, ...) \ 31 Image g1_##type = Image({ 1, 1, 1 }, DataType::type, "xyc", ColorType::GRAY); \ 32 View<DataType::type> g1_##type##_v; \ 33 Image g2_##type = Image({ 2, 2, 1 }, DataType::type, "xyc", ColorType::GRAY); \ 34 View<DataType::type> g2_##type##_v; \ 35 Image rgb2_##type = Image({ 2, 2, 3 }, DataType::type, "xyc", ColorType::RGB); \ 36 View<DataType::type> rgb2_##type##_v; \ 45 #define ECVL_TUPLE(type, ...) \ 46 g1_##type##_v = g1_##type; \ 47 g1_##type##_v({ 0,0,0 }) = 50; \ 49 g2_##type##_v = g2_##type; \ 50 g2_##type##_v({ 0,0,0 }) = 50; g2_##type##_v({ 1,0,0 }) = 32; \ 51 g2_##type##_v({ 0,1,0 }) = 14; g2_##type##_v({ 1,1,0 }) = 60; \ 53 rgb2_##type##_v = rgb2_##type; \ 54 rgb2_##type##_v({ 0,0,0 }) = 50; rgb2_##type##_v({ 1,0,0 }) = 32; \ 55 rgb2_##type##_v({ 0,1,0 }) = 14; rgb2_##type##_v({ 1,1,0 }) = 60; \ 56 rgb2_##type##_v({ 0,0,1 }) = 50; rgb2_##type##_v({ 1,0,1 }) = 32; \ 57 rgb2_##type##_v({ 0,1,1 }) = 14; rgb2_##type##_v({ 1,1,1 }) = 60; \ 58 rgb2_##type##_v({ 0,0,2 }) = 50; rgb2_##type##_v({ 1,0,2 }) = 32; \ 59 rgb2_##type##_v({ 0,1,2 }) = 14; rgb2_##type##_v({ 1,1,2 }) = 60; \ 66 using Imgproc = TCore;
68 #define ECVL_TUPLE(type, ...) \ 69 TEST_F(Imgproc, ResizeDim##type) \ 71 if (DataType::type != DataType::int64) { \ 72 ResizeDim(g1_##type, out, {1, 1}, InterpolationType::nearest); \ 73 View<DataType::type> out_v(out); \ 74 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 75 EXPECT_THAT(out.dims_, testing::ElementsAre(1, 1, 1)); \ 77 ResizeDim(g2_##type, out, {2, 1}, InterpolationType::nearest); \ 79 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 80 EXPECT_THAT(out.dims_, testing::ElementsAre(2, 1, 1)); \ 82 ResizeDim(rgb2_##type, out, {2, 1}, InterpolationType::nearest); \ 84 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 85 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) == 32); \ 86 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) == 32); \ 87 EXPECT_THAT(out.dims_, testing::ElementsAre(2, 1, 3)); \ 90 EXPECT_THROW(ResizeDim(g1_##type, out, {1, 1}, InterpolationType::nearest), std::runtime_error); \ 94 TEST_F(Imgproc, ResizeDimSameDst##type) \ 96 if (DataType::type != DataType::int64) { \ 97 ResizeDim(g1_##type, g1_##type, {1, 1}, InterpolationType::nearest); \ 98 View<DataType::type> out_v(g1_##type); \ 99 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 100 EXPECT_THAT(out_v.dims_, testing::ElementsAre(1, 1, 1)); \ 102 ResizeDim(g2_##type, g2_##type, {2, 1}, InterpolationType::nearest); \ 104 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 105 EXPECT_THAT(out_v.dims_, testing::ElementsAre(2, 1, 1)); \ 107 ResizeDim(rgb2_##type, rgb2_##type, {2, 1}, InterpolationType::nearest); \ 108 out_v = rgb2_##type; \ 109 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 110 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) == 32); \ 111 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) == 32); \ 112 EXPECT_THAT(out_v.dims_, testing::ElementsAre(2, 1, 3)); \ 115 EXPECT_THROW(ResizeDim(g1_##type, g1_##type, {1, 1}, InterpolationType::nearest), std::runtime_error); \ 119 TEST_F(Imgproc, ResizeScale##type) \ 121 if (DataType::type != DataType::int64) { \ 122 ResizeScale(g1_##type, out, {1, 1}, InterpolationType::nearest); \ 123 View<DataType::type> out_v(out); \ 124 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 125 EXPECT_THAT(out.dims_, testing::ElementsAre(1, 1, 1)); \ 127 ResizeScale(g2_##type, out, {1, 0.5}, InterpolationType::nearest); \ 129 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 130 EXPECT_THAT(out.dims_, testing::ElementsAre(2, 1, 1)); \ 132 ResizeScale(rgb2_##type, out, {1, 0.5}, InterpolationType::nearest); \ 134 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 135 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) == 32); \ 136 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) == 32); \ 137 EXPECT_THAT(out.dims_, testing::ElementsAre(2, 1, 3)); \ 140 EXPECT_THROW(ResizeScale(g1_##type, out, {1, 1}, InterpolationType::nearest), std::runtime_error); \ 144 TEST_F(Imgproc, ResizeScaleSameDst##type) \ 146 if (DataType::type != DataType::int64) { \ 147 ResizeScale(g1_##type, g1_##type, {1, 1}, InterpolationType::nearest); \ 148 View<DataType::type> out_v(g1_##type); \ 149 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 150 EXPECT_THAT(out_v.dims_, testing::ElementsAre(1, 1, 1)); \ 152 ResizeScale(g2_##type, g2_##type, {1, 0.5}, InterpolationType::nearest); \ 154 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 155 EXPECT_THAT(out_v.dims_, testing::ElementsAre(2, 1, 1)); \ 157 ResizeScale(rgb2_##type, rgb2_##type, {1, 0.5}, InterpolationType::nearest); \ 158 out_v = rgb2_##type; \ 159 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 160 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) == 32); \ 161 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) == 32); \ 162 EXPECT_THAT(out_v.dims_, testing::ElementsAre(2, 1, 3)); \ 165 EXPECT_THROW(ResizeScale(g1_##type, g1_##type, {1, 1}, InterpolationType::nearest), std::runtime_error); \ 169 TEST_F(Imgproc, Flip2D##type) \ 171 Flip2D(g1_##type, out); \ 172 View<DataType::type> out_v(out); \ 173 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 175 Flip2D(g2_##type, out); \ 177 EXPECT_TRUE(out_v({ 0,0,0 }) == 14); EXPECT_TRUE(out_v({ 1,0,0 }) == 60); \ 178 EXPECT_TRUE(out_v({ 0,1,0 }) == 50); EXPECT_TRUE(out_v({ 1,1,0 }) == 32); \ 180 Flip2D(rgb2_##type, out); \ 182 EXPECT_TRUE(out_v({ 0,0,0 }) == 14); EXPECT_TRUE(out_v({ 1,0,0 }) == 60); \ 183 EXPECT_TRUE(out_v({ 0,1,0 }) == 50); EXPECT_TRUE(out_v({ 1,1,0 }) == 32); \ 184 EXPECT_TRUE(out_v({ 0,0,1 }) == 14); EXPECT_TRUE(out_v({ 1,0,1 }) == 60); \ 185 EXPECT_TRUE(out_v({ 0,1,1 }) == 50); EXPECT_TRUE(out_v({ 1,1,1 }) == 32); \ 186 EXPECT_TRUE(out_v({ 0,0,2 }) == 14); EXPECT_TRUE(out_v({ 1,0,2 }) == 60); \ 187 EXPECT_TRUE(out_v({ 0,1,2 }) == 50); EXPECT_TRUE(out_v({ 1,1,2 }) == 32); \ 190 TEST_F(Imgproc, Flip2DSameDst##type) \ 192 Flip2D(g1_##type, g1_##type); \ 193 View<DataType::type> out_v(g1_##type); \ 194 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 196 Flip2D(g2_##type, g2_##type); \ 198 EXPECT_TRUE(out_v({ 0,0,0 }) == 14); EXPECT_TRUE(out_v({ 1,0,0 }) == 60); \ 199 EXPECT_TRUE(out_v({ 0,1,0 }) == 50); EXPECT_TRUE(out_v({ 1,1,0 }) == 32); \ 201 Flip2D(rgb2_##type, rgb2_##type); \ 202 out_v = rgb2_##type; \ 203 EXPECT_TRUE(out_v({ 0,0,0 }) == 14); EXPECT_TRUE(out_v({ 1,0,0 }) == 60); \ 204 EXPECT_TRUE(out_v({ 0,1,0 }) == 50); EXPECT_TRUE(out_v({ 1,1,0 }) == 32); \ 205 EXPECT_TRUE(out_v({ 0,0,1 }) == 14); EXPECT_TRUE(out_v({ 1,0,1 }) == 60); \ 206 EXPECT_TRUE(out_v({ 0,1,1 }) == 50); EXPECT_TRUE(out_v({ 1,1,1 }) == 32); \ 207 EXPECT_TRUE(out_v({ 0,0,2 }) == 14); EXPECT_TRUE(out_v({ 1,0,2 }) == 60); \ 208 EXPECT_TRUE(out_v({ 0,1,2 }) == 50); EXPECT_TRUE(out_v({ 1,1,2 }) == 32); \ 211 TEST_F(Imgproc, Mirror2D##type) \ 213 Mirror2D(g1_##type, out); \ 214 View<DataType::type> out_v(out); \ 215 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 217 Mirror2D(g2_##type, out); \ 219 EXPECT_TRUE(out_v({ 0,0,0 }) == 32); EXPECT_TRUE(out_v({ 1,0,0 }) == 50); \ 220 EXPECT_TRUE(out_v({ 0,1,0 }) == 60); EXPECT_TRUE(out_v({ 1,1,0 }) == 14); \ 222 Mirror2D(rgb2_##type, out); \ 224 EXPECT_TRUE(out_v({ 0,0,0 }) == 32); EXPECT_TRUE(out_v({ 1,0,0 }) == 50); \ 225 EXPECT_TRUE(out_v({ 0,1,0 }) == 60); EXPECT_TRUE(out_v({ 1,1,0 }) == 14); \ 226 EXPECT_TRUE(out_v({ 0,0,1 }) == 32); EXPECT_TRUE(out_v({ 1,0,1 }) == 50); \ 227 EXPECT_TRUE(out_v({ 0,1,1 }) == 60); EXPECT_TRUE(out_v({ 1,1,1 }) == 14); \ 228 EXPECT_TRUE(out_v({ 0,0,2 }) == 32); EXPECT_TRUE(out_v({ 1,0,2 }) == 50); \ 229 EXPECT_TRUE(out_v({ 0,1,2 }) == 60); EXPECT_TRUE(out_v({ 1,1,2 }) == 14); \ 232 TEST_F(Imgproc, Mirror2DSameDst##type) \ 234 Mirror2D(g1_##type, g1_##type); \ 235 View<DataType::type> out_v(g1_##type); \ 236 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 238 Mirror2D(g2_##type, g2_##type); \ 240 EXPECT_TRUE(out_v({ 0,0,0 }) == 32); EXPECT_TRUE(out_v({ 1,0,0 }) == 50); \ 241 EXPECT_TRUE(out_v({ 0,1,0 }) == 60); EXPECT_TRUE(out_v({ 1,1,0 }) == 14); \ 243 Mirror2D(rgb2_##type, rgb2_##type); \ 244 out_v = rgb2_##type; \ 245 EXPECT_TRUE(out_v({ 0,0,0 }) == 32); EXPECT_TRUE(out_v({ 1,0,0 }) == 50); \ 246 EXPECT_TRUE(out_v({ 0,1,0 }) == 60); EXPECT_TRUE(out_v({ 1,1,0 }) == 14); \ 247 EXPECT_TRUE(out_v({ 0,0,1 }) == 32); EXPECT_TRUE(out_v({ 1,0,1 }) == 50); \ 248 EXPECT_TRUE(out_v({ 0,1,1 }) == 60); EXPECT_TRUE(out_v({ 1,1,1 }) == 14); \ 249 EXPECT_TRUE(out_v({ 0,0,2 }) == 32); EXPECT_TRUE(out_v({ 1,0,2 }) == 50); \ 250 EXPECT_TRUE(out_v({ 0,1,2 }) == 60); EXPECT_TRUE(out_v({ 1,1,2 }) == 14); \ 253 TEST_F(Imgproc, Threshold##type) \ 255 Threshold(g1_##type, out, 35, 127, ThresholdingType::BINARY); \ 256 View<DataType::type> out_v(out); \ 257 EXPECT_TRUE(out_v({ 0,0,0 }) == 127); \ 259 Threshold(g1_##type, out, 35, 127, ThresholdingType::BINARY_INV); \ 261 EXPECT_TRUE(out_v({ 0,0,0 }) == 0); \ 263 Threshold(g2_##type, out, 35, 127, ThresholdingType::BINARY); \ 265 EXPECT_TRUE(out_v({ 0,0,0 }) == 127); EXPECT_TRUE(out_v({ 1,0,0 }) == 0); \ 266 EXPECT_TRUE(out_v({ 0,1,0 }) == 0); EXPECT_TRUE(out_v({ 1,1,0 }) == 127); \ 268 Threshold(g2_##type, out, 35, 127, ThresholdingType::BINARY_INV); \ 270 EXPECT_TRUE(out_v({ 0,0,0 }) == 0); EXPECT_TRUE(out_v({ 1,0,0 }) == 127); \ 271 EXPECT_TRUE(out_v({ 0,1,0 }) == 127); EXPECT_TRUE(out_v({ 1,1,0 }) == 0); \ 273 Threshold(rgb2_##type, out, 35, 127, ThresholdingType::BINARY); \ 275 EXPECT_TRUE(out_v({ 0,0,0 }) == 127); EXPECT_TRUE(out_v({ 1,0,0 }) == 0); \ 276 EXPECT_TRUE(out_v({ 0,1,0 }) == 0); EXPECT_TRUE(out_v({ 1,1,0 }) == 127); \ 277 EXPECT_TRUE(out_v({ 0,0,1 }) == 127); EXPECT_TRUE(out_v({ 1,0,1 }) == 0); \ 278 EXPECT_TRUE(out_v({ 0,1,1 }) == 0); EXPECT_TRUE(out_v({ 1,1,1 }) == 127); \ 279 EXPECT_TRUE(out_v({ 0,0,2 }) == 127); EXPECT_TRUE(out_v({ 1,0,2 }) == 0); \ 280 EXPECT_TRUE(out_v({ 0,1,2 }) == 0); EXPECT_TRUE(out_v({ 1,1,2 }) == 127); \ 282 Threshold(rgb2_##type, out, 35, 127, ThresholdingType::BINARY_INV); \ 284 EXPECT_TRUE(out_v({ 0,0,0 }) == 0); EXPECT_TRUE(out_v({ 1,0,0 }) == 127); \ 285 EXPECT_TRUE(out_v({ 0,1,0 }) == 127); EXPECT_TRUE(out_v({ 1,1,0 }) == 0); \ 286 EXPECT_TRUE(out_v({ 0,0,1 }) == 0); EXPECT_TRUE(out_v({ 1,0,1 }) == 127); \ 287 EXPECT_TRUE(out_v({ 0,1,1 }) == 127); EXPECT_TRUE(out_v({ 1,1,1 }) == 0); \ 288 EXPECT_TRUE(out_v({ 0,0,2 }) == 0); EXPECT_TRUE(out_v({ 1,0,2 }) == 127); \ 289 EXPECT_TRUE(out_v({ 0,1,2 }) == 127); EXPECT_TRUE(out_v({ 1,1,2 }) == 0); \ 292 TEST_F(Imgproc, ThresholdSameDst##type) \ 294 Threshold(g1_##type, g1_##type, 35, 127, ThresholdingType::BINARY); \ 295 View<DataType::type> out_v(g1_##type); \ 296 EXPECT_TRUE(out_v({ 0,0,0 }) == 127); \ 298 Threshold(g1_##type, g1_##type, 35, 127, ThresholdingType::BINARY_INV); \ 300 EXPECT_TRUE(out_v({ 0,0,0 }) == 0); \ 302 Threshold(g2_##type, g2_##type, 35, 127, ThresholdingType::BINARY); \ 304 EXPECT_TRUE(out_v({ 0,0,0 }) == 127); EXPECT_TRUE(out_v({ 1,0,0 }) == 0); \ 305 EXPECT_TRUE(out_v({ 0,1,0 }) == 0); EXPECT_TRUE(out_v({ 1,1,0 }) == 127); \ 307 Threshold(g2_##type, g2_##type, 35, 127, ThresholdingType::BINARY_INV); \ 309 EXPECT_TRUE(out_v({ 0,0,0 }) == 0); EXPECT_TRUE(out_v({ 1,0,0 }) == 127); \ 310 EXPECT_TRUE(out_v({ 0,1,0 }) == 127); EXPECT_TRUE(out_v({ 1,1,0 }) == 0); \ 312 Threshold(rgb2_##type, rgb2_##type, 35, 127, ThresholdingType::BINARY); \ 313 out_v = rgb2_##type; \ 314 EXPECT_TRUE(out_v({ 0,0,0 }) == 127); EXPECT_TRUE(out_v({ 1,0,0 }) == 0); \ 315 EXPECT_TRUE(out_v({ 0,1,0 }) == 0); EXPECT_TRUE(out_v({ 1,1,0 }) == 127); \ 316 EXPECT_TRUE(out_v({ 0,0,1 }) == 127); EXPECT_TRUE(out_v({ 1,0,1 }) == 0); \ 317 EXPECT_TRUE(out_v({ 0,1,1 }) == 0); EXPECT_TRUE(out_v({ 1,1,1 }) == 127); \ 318 EXPECT_TRUE(out_v({ 0,0,2 }) == 127); EXPECT_TRUE(out_v({ 1,0,2 }) == 0); \ 319 EXPECT_TRUE(out_v({ 0,1,2 }) == 0); EXPECT_TRUE(out_v({ 1,1,2 }) == 127); \ 321 Threshold(rgb2_##type, rgb2_##type, 35, 127, ThresholdingType::BINARY_INV); \ 322 out_v = rgb2_##type; \ 323 EXPECT_TRUE(out_v({ 0,0,0 }) == 0); EXPECT_TRUE(out_v({ 1,0,0 }) == 127); \ 324 EXPECT_TRUE(out_v({ 0,1,0 }) == 127); EXPECT_TRUE(out_v({ 1,1,0 }) == 0); \ 325 EXPECT_TRUE(out_v({ 0,0,1 }) == 0); EXPECT_TRUE(out_v({ 1,0,1 }) == 127); \ 326 EXPECT_TRUE(out_v({ 0,1,1 }) == 127); EXPECT_TRUE(out_v({ 1,1,1 }) == 0); \ 327 EXPECT_TRUE(out_v({ 0,0,2 }) == 0); EXPECT_TRUE(out_v({ 1,0,2 }) == 127); \ 328 EXPECT_TRUE(out_v({ 0,1,2 }) == 127); EXPECT_TRUE(out_v({ 1,1,2 }) == 0); \ 331 TEST_F(Imgproc, HConcat##type) \ 333 HConcat({ g1_##type, g1_##type }, out); \ 334 View<DataType::type> out_v(out); \ 335 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 50); \ 337 HConcat({ g2_##type, g2_##type }, out); \ 339 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); EXPECT_TRUE(out_v({ 2,0,0 }) == 50); EXPECT_TRUE(out_v({ 3,0,0 }) = 32); \ 340 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); EXPECT_TRUE(out_v({ 2,1,0 }) == 14); EXPECT_TRUE(out_v({ 3,1,0 }) = 60); \ 342 HConcat({ rgb2_##type, rgb2_##type }, out); \ 344 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); EXPECT_TRUE(out_v({ 2,0,0 }) == 50); EXPECT_TRUE(out_v({ 3,0,0 }) = 32); \ 345 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); EXPECT_TRUE(out_v({ 2,1,0 }) == 14); EXPECT_TRUE(out_v({ 3,1,0 }) = 60); \ 346 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) = 32); EXPECT_TRUE(out_v({ 2,0,1 }) == 50); EXPECT_TRUE(out_v({ 3,0,1 }) = 32); \ 347 EXPECT_TRUE(out_v({ 0,1,1 }) == 14); EXPECT_TRUE(out_v({ 1,1,1 }) = 60); EXPECT_TRUE(out_v({ 2,1,1 }) == 14); EXPECT_TRUE(out_v({ 3,1,1 }) = 60); \ 348 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) = 32); EXPECT_TRUE(out_v({ 2,0,2 }) == 50); EXPECT_TRUE(out_v({ 3,0,2 }) = 32); \ 349 EXPECT_TRUE(out_v({ 0,1,2 }) == 14); EXPECT_TRUE(out_v({ 1,1,2 }) = 60); EXPECT_TRUE(out_v({ 2,1,2 }) == 14); EXPECT_TRUE(out_v({ 3,1,2 }) = 60); \ 352 TEST_F(Imgproc, HConcatSameDst##type) \ 354 HConcat({ g1_##type, g1_##type }, g1_##type); \ 355 View<DataType::type> out_v(g1_##type); \ 356 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 50); \ 358 HConcat({ g2_##type, g2_##type }, g2_##type); \ 360 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); EXPECT_TRUE(out_v({ 2,0,0 }) == 50); EXPECT_TRUE(out_v({ 3,0,0 }) = 32); \ 361 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); EXPECT_TRUE(out_v({ 2,1,0 }) == 14); EXPECT_TRUE(out_v({ 3,1,0 }) = 60); \ 363 HConcat({ rgb2_##type, rgb2_##type }, rgb2_##type); \ 364 out_v = rgb2_##type; \ 365 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); EXPECT_TRUE(out_v({ 2,0,0 }) == 50); EXPECT_TRUE(out_v({ 3,0,0 }) = 32); \ 366 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); EXPECT_TRUE(out_v({ 2,1,0 }) == 14); EXPECT_TRUE(out_v({ 3,1,0 }) = 60); \ 367 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) = 32); EXPECT_TRUE(out_v({ 2,0,1 }) == 50); EXPECT_TRUE(out_v({ 3,0,1 }) = 32); \ 368 EXPECT_TRUE(out_v({ 0,1,1 }) == 14); EXPECT_TRUE(out_v({ 1,1,1 }) = 60); EXPECT_TRUE(out_v({ 2,1,1 }) == 14); EXPECT_TRUE(out_v({ 3,1,1 }) = 60); \ 369 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) = 32); EXPECT_TRUE(out_v({ 2,0,2 }) == 50); EXPECT_TRUE(out_v({ 3,0,2 }) = 32); \ 370 EXPECT_TRUE(out_v({ 0,1,2 }) == 14); EXPECT_TRUE(out_v({ 1,1,2 }) = 60); EXPECT_TRUE(out_v({ 2,1,2 }) == 14); EXPECT_TRUE(out_v({ 3,1,2 }) = 60); \ 373 TEST_F(Imgproc, VConcat##type) \ 375 VConcat({ g1_##type, g1_##type }, out); \ 376 View<DataType::type> out_v(out); \ 377 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 378 EXPECT_TRUE(out_v({ 0,1,0 }) == 50); \ 380 VConcat({ g2_##type, g2_##type }, out); \ 382 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); \ 383 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); \ 384 EXPECT_TRUE(out_v({ 0,2,0 }) == 50); EXPECT_TRUE(out_v({ 1,2,0 }) = 32); \ 385 EXPECT_TRUE(out_v({ 0,3,0 }) == 14); EXPECT_TRUE(out_v({ 1,3,0 }) = 60); \ 387 VConcat({ rgb2_##type, rgb2_##type }, out); \ 389 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); \ 390 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); \ 391 EXPECT_TRUE(out_v({ 0,2,0 }) == 50); EXPECT_TRUE(out_v({ 1,2,0 }) = 32); \ 392 EXPECT_TRUE(out_v({ 0,3,0 }) == 14); EXPECT_TRUE(out_v({ 1,3,0 }) = 60); \ 393 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) = 32); \ 394 EXPECT_TRUE(out_v({ 0,1,1 }) == 14); EXPECT_TRUE(out_v({ 1,1,1 }) = 60); \ 395 EXPECT_TRUE(out_v({ 0,2,1 }) == 50); EXPECT_TRUE(out_v({ 1,2,1 }) = 32); \ 396 EXPECT_TRUE(out_v({ 0,3,1 }) == 14); EXPECT_TRUE(out_v({ 1,3,1 }) = 60); \ 397 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) = 32); \ 398 EXPECT_TRUE(out_v({ 0,1,2 }) == 14); EXPECT_TRUE(out_v({ 1,1,2 }) = 60); \ 399 EXPECT_TRUE(out_v({ 0,2,2 }) == 50); EXPECT_TRUE(out_v({ 1,2,2 }) = 32); \ 400 EXPECT_TRUE(out_v({ 0,3,2 }) == 14); EXPECT_TRUE(out_v({ 1,3,2 }) = 60); \ 403 TEST_F(Imgproc, VConcatSameDst##type) \ 405 VConcat({ g1_##type, g1_##type }, g1_##type); \ 406 View<DataType::type> out_v(g1_##type); \ 407 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 408 EXPECT_TRUE(out_v({ 0,1,0 }) == 50); \ 410 VConcat({ g2_##type, g2_##type }, g2_##type); \ 412 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); \ 413 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); \ 414 EXPECT_TRUE(out_v({ 0,2,0 }) == 50); EXPECT_TRUE(out_v({ 1,2,0 }) = 32); \ 415 EXPECT_TRUE(out_v({ 0,3,0 }) == 14); EXPECT_TRUE(out_v({ 1,3,0 }) = 60); \ 417 VConcat({ rgb2_##type, rgb2_##type }, rgb2_##type); \ 418 out_v = rgb2_##type; \ 419 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) = 32); \ 420 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) = 60); \ 421 EXPECT_TRUE(out_v({ 0,2,0 }) == 50); EXPECT_TRUE(out_v({ 1,2,0 }) = 32); \ 422 EXPECT_TRUE(out_v({ 0,3,0 }) == 14); EXPECT_TRUE(out_v({ 1,3,0 }) = 60); \ 423 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) = 32); \ 424 EXPECT_TRUE(out_v({ 0,1,1 }) == 14); EXPECT_TRUE(out_v({ 1,1,1 }) = 60); \ 425 EXPECT_TRUE(out_v({ 0,2,1 }) == 50); EXPECT_TRUE(out_v({ 1,2,1 }) = 32); \ 426 EXPECT_TRUE(out_v({ 0,3,1 }) == 14); EXPECT_TRUE(out_v({ 1,3,1 }) = 60); \ 427 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) = 32); \ 428 EXPECT_TRUE(out_v({ 0,1,2 }) == 14); EXPECT_TRUE(out_v({ 1,1,2 }) = 60); \ 429 EXPECT_TRUE(out_v({ 0,2,2 }) == 50); EXPECT_TRUE(out_v({ 1,2,2 }) = 32); \ 430 EXPECT_TRUE(out_v({ 0,3,2 }) == 14); EXPECT_TRUE(out_v({ 1,3,2 }) = 60); \ 433 TEST_F(Imgproc, Transpose##type) \ 435 Transpose(g1_##type, out); \ 436 View<DataType::type> out_v(out); \ 437 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 439 Transpose(g2_##type, out); \ 441 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 14); \ 442 EXPECT_TRUE(out_v({ 0,1,0 }) == 32); EXPECT_TRUE(out_v({ 1,1,0 }) == 60); \ 444 Transpose(rgb2_##type, out); \ 446 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 14); \ 447 EXPECT_TRUE(out_v({ 0,1,0 }) == 32); EXPECT_TRUE(out_v({ 1,1,0 }) == 60); \ 448 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) == 14); \ 449 EXPECT_TRUE(out_v({ 0,1,1 }) == 32); EXPECT_TRUE(out_v({ 1,1,1 }) == 60); \ 450 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) == 14); \ 451 EXPECT_TRUE(out_v({ 0,1,2 }) == 32); EXPECT_TRUE(out_v({ 1,1,2 }) == 60); \ 454 TEST_F(Imgproc, TransposeSameDst##type) \ 456 Transpose(g1_##type, g1_##type); \ 457 View<DataType::type> out_v(g1_##type); \ 458 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 460 Transpose(g2_##type, g2_##type); \ 462 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 14); \ 463 EXPECT_TRUE(out_v({ 0,1,0 }) == 32); EXPECT_TRUE(out_v({ 1,1,0 }) == 60); \ 465 Transpose(rgb2_##type, rgb2_##type); \ 466 out_v = rgb2_##type; \ 467 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 14); \ 468 EXPECT_TRUE(out_v({ 0,1,0 }) == 32); EXPECT_TRUE(out_v({ 1,1,0 }) == 60); \ 469 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); EXPECT_TRUE(out_v({ 1,0,1 }) == 14); \ 470 EXPECT_TRUE(out_v({ 0,1,1 }) == 32); EXPECT_TRUE(out_v({ 1,1,1 }) == 60); \ 471 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); EXPECT_TRUE(out_v({ 1,0,2 }) == 14); \ 472 EXPECT_TRUE(out_v({ 0,1,2 }) == 32); EXPECT_TRUE(out_v({ 1,1,2 }) == 60); \ 475 TEST_F(Imgproc, GridDistortion##type) \ 477 if (DataType::type != DataType::int64) { \ 478 GridDistortion(g1_##type, out); \ 479 View<DataType::type> out_v(out); \ 480 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 482 GridDistortion(g2_##type, out); \ 484 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 485 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 486 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 487 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 489 GridDistortion(rgb2_##type, out); \ 491 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 492 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 493 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 494 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 497 EXPECT_THROW(GridDistortion(g1_##type, out), std::runtime_error); \ 501 TEST_F(Imgproc, GridDistortionSameDst##type) \ 503 if (DataType::type != DataType::int64) { \ 504 GridDistortion(g1_##type, g1_##type); \ 505 View<DataType::type> out_v(g1_##type); \ 506 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 508 GridDistortion(g2_##type, g2_##type); \ 510 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 511 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 512 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 513 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 515 GridDistortion(rgb2_##type, rgb2_##type); \ 516 out_v = rgb2_##type; \ 517 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 518 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 519 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 520 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 523 EXPECT_THROW(GridDistortion(g1_##type, g1_##type), std::runtime_error); \ 527 TEST_F(Imgproc, ElasticTransform##type) \ 529 if (DataType::type != DataType::int64) { \ 530 ElasticTransform(g1_##type, out); \ 531 View<DataType::type> out_v(out); \ 532 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 534 ElasticTransform(g2_##type, out); \ 536 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 537 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 538 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 539 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 541 ElasticTransform(rgb2_##type, out); \ 543 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 544 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 545 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 546 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 549 EXPECT_THROW(ElasticTransform(g1_##type, out), std::runtime_error); \ 553 TEST_F(Imgproc, ElasticTransformSameDst##type) \ 555 if (DataType::type != DataType::int64) { \ 556 ElasticTransform(g1_##type, g1_##type); \ 557 View<DataType::type> out_v(g1_##type); \ 558 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 560 ElasticTransform(g2_##type, g2_##type); \ 562 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 563 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 564 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 565 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 567 ElasticTransform(rgb2_##type, rgb2_##type); \ 568 out_v = rgb2_##type; \ 569 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 570 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 571 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 572 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 575 EXPECT_THROW(ElasticTransform(g1_##type, g1_##type), std::runtime_error); \ 579 TEST_F(Imgproc, OpticalDistortion##type) \ 581 if (DataType::type != DataType::int64) { \ 582 OpticalDistortion(g1_##type, out); \ 583 View<DataType::type> out_v(out); \ 584 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 586 OpticalDistortion(g2_##type, out); \ 588 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 589 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 590 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 591 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 593 OpticalDistortion(rgb2_##type, out); \ 595 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 596 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 597 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 598 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 601 EXPECT_THROW(OpticalDistortion(g1_##type, out), std::runtime_error); \ 605 TEST_F(Imgproc, OpticalDistortionSameDst##type) \ 607 if (DataType::type != DataType::int64) { \ 608 OpticalDistortion(g1_##type, g1_##type); \ 609 View<DataType::type> out_v(g1_##type); \ 610 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 612 OpticalDistortion(g2_##type, g2_##type); \ 614 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 615 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 616 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 617 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 619 OpticalDistortion(rgb2_##type, rgb2_##type); \ 620 out_v = rgb2_##type; \ 621 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 622 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 623 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 624 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 627 EXPECT_THROW(OpticalDistortion(g1_##type, g1_##type), std::runtime_error); \ 630 TEST_F(Imgproc, Salt##type) \ 632 Salt(g1_##type, out, 0.5, false, 0); \ 633 View<DataType::type> out_v(out); \ 634 EXPECT_EQ(g1_##type.dims_, out_v.dims_); \ 635 EXPECT_EQ(g1_##type.colortype_, out_v.colortype_); \ 636 EXPECT_EQ(g1_##type.elemtype_, out_v.elemtype_); \ 637 EXPECT_EQ(g1_##type.channels_, out_v.channels_); \ 639 Salt(g2_##type, out, 0.5, false, 0); \ 641 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 642 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 643 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 644 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 646 Salt(rgb2_##type, out, 0.5, false, 0); \ 648 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 649 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 650 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 651 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 654 TEST_F(Imgproc, SaltSameDst##type) \ 656 Salt(g1_##type, g1_##type, 0.5, false, 0); \ 657 View<DataType::type> out_v(g1_##type); \ 658 EXPECT_EQ(g1_##type.dims_, out_v.dims_); \ 659 EXPECT_EQ(g1_##type.colortype_, out_v.colortype_); \ 660 EXPECT_EQ(g1_##type.elemtype_, out_v.elemtype_); \ 661 EXPECT_EQ(g1_##type.channels_, out_v.channels_); \ 663 Salt(g2_##type, g2_##type, 0.5, false, 0); \ 665 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 666 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 667 EXPECT_EQ(g2_##type.elemtype_, out_v.elemtype_); \ 668 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 670 Salt(rgb2_##type, rgb2_##type, 0.5, false, 0); \ 671 out_v = rgb2_##type; \ 672 EXPECT_EQ(rgb2_##type.dims_, out_v.dims_); \ 673 EXPECT_EQ(rgb2_##type.colortype_, out_v.colortype_); \ 674 EXPECT_EQ(rgb2_##type.elemtype_, out_v.elemtype_); \ 675 EXPECT_EQ(rgb2_##type.channels_, out_v.channels_); \ 678 TEST_F(Imgproc, CCLSameDst##type) \ 680 if (DataType::type == DataType::uint8) { \ 681 Threshold(g1_##type, g1_##type, 35, 255, ThresholdingType::BINARY); \ 682 ConnectedComponentsLabeling(g1_##type, g1_##type); \ 683 View<DataType::int32> out_v(g1_##type); \ 684 EXPECT_EQ(g1_##type.dims_, out_v.dims_); \ 685 EXPECT_EQ(g1_##type.colortype_, out_v.colortype_); \ 687 EXPECT_EQ(g1_##type.channels_, out_v.channels_); \ 688 EXPECT_TRUE(out_v({ 0,0,0 }) == 1); \ 690 Threshold(g2_##type, g2_##type, 35, 255, ThresholdingType::BINARY); \ 691 ConnectedComponentsLabeling(g2_##type, g2_##type); \ 693 EXPECT_EQ(g2_##type.dims_, out_v.dims_); \ 694 EXPECT_EQ(g2_##type.colortype_, out_v.colortype_); \ 696 EXPECT_EQ(g2_##type.channels_, out_v.channels_); \ 697 EXPECT_TRUE(out_v({ 0,0,0 }) == 1); EXPECT_TRUE(out_v({ 1,0,0 }) == 0); \ 698 EXPECT_TRUE(out_v({ 0,1,0 }) == 0); EXPECT_TRUE(out_v({ 1,1,0 }) == 1); \ 701 EXPECT_THROW(ConnectedComponentsLabeling(g1_##type, g1_##type), std::runtime_error); \ 705 TEST_F(Imgproc, Normalize##type) \ 707 constexpr double mean = 39.0; \ 708 constexpr double std = 17.5783958312469; \ 709 Normalize(g1_##type, out, mean, std); \ 710 View<DataType::type> out_v(out); \ 711 EXPECT_TRUE(out_v({ 0,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((g1_##type##_v({ 0,0,0 }) - mean) / std)); \ 713 Normalize(g2_##type, out, mean, std); \ 715 EXPECT_TRUE(out_v({ 0,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 0,0,0 }) - mean) / std)); \ 716 EXPECT_TRUE(out_v({ 1,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 1,0,0 }) - mean) / std)); \ 717 EXPECT_TRUE(out_v({ 0,1,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 0,1,0 }) - mean) / std)); \ 718 EXPECT_TRUE(out_v({ 1,1,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 1,1,0 }) - mean) / std)); \ 720 Normalize(rgb2_##type, out, mean, std); \ 722 EXPECT_TRUE(out_v({ 0,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,0,0 }) - mean) / std)); \ 723 EXPECT_TRUE(out_v({ 1,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,0,0 }) - mean) / std)); \ 724 EXPECT_TRUE(out_v({ 0,1,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,1,0 }) - mean) / std)); \ 725 EXPECT_TRUE(out_v({ 1,1,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,1,0 }) - mean) / std)); \ 726 EXPECT_TRUE(out_v({ 0,0,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,0,1 }) - mean) / std)); \ 727 EXPECT_TRUE(out_v({ 1,0,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,0,1 }) - mean) / std)); \ 728 EXPECT_TRUE(out_v({ 0,1,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,1,1 }) - mean) / std)); \ 729 EXPECT_TRUE(out_v({ 1,1,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,1,1 }) - mean) / std)); \ 730 EXPECT_TRUE(out_v({ 0,0,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,0,2 }) - mean) / std)); \ 731 EXPECT_TRUE(out_v({ 1,0,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,0,2 }) - mean) / std)); \ 732 EXPECT_TRUE(out_v({ 0,1,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,1,2 }) - mean) / std)); \ 733 EXPECT_TRUE(out_v({ 1,1,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,1,2 }) - mean) / std)); \ 735 TEST_F(Imgproc, NormalizeChannels##type) \ 737 const std::vector<double> mean = { 39.0, 38.0, 33.0 }; \ 738 const std::vector<double> std = { 17.5783958312469, 14.5783958312469, 23.5783958312469 }; \ 739 Normalize(rgb2_##type, out, mean, std); \ 740 View<DataType::type> out_v(out); \ 741 EXPECT_TRUE(out_v({ 0,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,0,0 }) - mean[0]) / std[0])); \ 742 EXPECT_TRUE(out_v({ 1,0,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,0,0 }) - mean[0]) / std[0])); \ 743 EXPECT_TRUE(out_v({ 0,1,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,1,0 }) - mean[0]) / std[0])); \ 744 EXPECT_TRUE(out_v({ 1,1,0 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,1,0 }) - mean[0]) / std[0])); \ 745 EXPECT_TRUE(out_v({ 0,0,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,0,1 }) - mean[1]) / std[1])); \ 746 EXPECT_TRUE(out_v({ 1,0,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,0,1 }) - mean[1]) / std[1])); \ 747 EXPECT_TRUE(out_v({ 0,1,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,1,1 }) - mean[1]) / std[1])); \ 748 EXPECT_TRUE(out_v({ 1,1,1 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,1,1 }) - mean[1]) / std[1])); \ 749 EXPECT_TRUE(out_v({ 0,0,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,0,2 }) - mean[2]) / std[2])); \ 750 EXPECT_TRUE(out_v({ 1,0,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,0,2 }) - mean[2]) / std[2])); \ 751 EXPECT_TRUE(out_v({ 0,1,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 0,1,2 }) - mean[2]) / std[2])); \ 752 EXPECT_TRUE(out_v({ 1,1,2 }) == saturate_cast<TypeInfo_t<DataType::type>>((rgb2_##type##_v({ 1,1,2 }) - mean[2]) / std[2])); \ 755 TEST_F(Imgproc, CenterCrop##type) \ 757 std::vector<int> size { 1,1 }; \ 758 CenterCrop(g1_##type, out, size); \ 759 View<DataType::type> out_v(out); \ 760 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 761 EXPECT_THAT(out.dims_, testing::ElementsAre(1, 1, 1)); \ 763 CenterCrop(g2_##type, out, size); \ 765 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 766 EXPECT_THAT(out.dims_, testing::ElementsAre(1, 1, 1)); \ 768 CenterCrop(rgb2_##type, out, size); \ 770 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); \ 771 EXPECT_TRUE(out_v({ 0,0,1 }) == 50); \ 772 EXPECT_TRUE(out_v({ 0,0,2 }) == 50); \ 773 EXPECT_THAT(out.dims_, testing::ElementsAre(1, 1, 3)); \ 776 TEST_F(Imgproc, ScaleTo_##type) \ 778 ScaleTo(g2_##type, out, 14, 60); \ 779 View<DataType::type> out_v(out); \ 780 EXPECT_TRUE(out_v({ 0,0,0 }) == 50); EXPECT_TRUE(out_v({ 1,0,0 }) == 32); \ 781 EXPECT_TRUE(out_v({ 0,1,0 }) == 14); EXPECT_TRUE(out_v({ 1,1,0 }) == 60); \ 782 ScaleTo(g2_##type, out, 0, 1); \ 784 EXPECT_TRUE(out_v({ 0,0,0 }) == static_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 0,0,0 }) * (1 / 46.) + (1 - ((1 / 46.) * 60))))); \ 785 EXPECT_TRUE(out_v({ 1,0,0 }) == static_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 1,0,0 }) * (1 / 46.) + (1 - ((1 / 46.) * 60))))); \ 786 EXPECT_TRUE(out_v({ 0,1,0 }) == static_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 0,1,0 }) * (1 / 46.) + (1 - ((1 / 46.) * 60))))); \ 787 EXPECT_TRUE(out_v({ 1,1,0 }) == static_cast<TypeInfo_t<DataType::type>>((g2_##type##_v({ 1,1,0 }) * (1 / 46.) + (1 - ((1 / 46.) * 60))))); \