| 406 | |
| 407 | template<typename T, bool isDilation, bool isColor> |
| 408 | void cppMorphImageTest(string pTestFile) { |
| 409 | SUPPORTED_TYPE_CHECK(T); |
| 410 | IMAGEIO_ENABLED_CHECK(); |
| 411 | |
| 412 | vector<dim4> inDims; |
| 413 | vector<string> inFiles; |
| 414 | vector<dim_t> outSizes; |
| 415 | vector<string> outFiles; |
| 416 | |
| 417 | readImageTests(pTestFile, inDims, inFiles, outSizes, outFiles); |
| 418 | |
| 419 | size_t testCount = inDims.size(); |
| 420 | |
| 421 | for (size_t testId = 0; testId < testCount; ++testId) { |
| 422 | inFiles[testId].insert(0, string(TEST_DIR "/morph/")); |
| 423 | outFiles[testId].insert(0, string(TEST_DIR "/morph/")); |
| 424 | |
| 425 | array mask = constant(1.0, 3, 3); |
| 426 | array img = loadImage(inFiles[testId].c_str(), isColor); |
| 427 | array gold = loadImage(outFiles[testId].c_str(), isColor); |
| 428 | dim_t nElems = gold.elements(); |
| 429 | array output; |
| 430 | |
| 431 | if (isDilation) |
| 432 | output = dilate(img, mask); |
| 433 | else |
| 434 | output = erode(img, mask); |
| 435 | |
| 436 | vector<T> outData(nElems); |
| 437 | output.host((void*)outData.data()); |
| 438 | |
| 439 | vector<T> goldData(nElems); |
| 440 | gold.host((void*)goldData.data()); |
| 441 | |
| 442 | ASSERT_EQ(true, compareArraysRMSD(nElems, goldData.data(), |
| 443 | outData.data(), 0.018f)); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | TEST(Morph, Grayscale_CPP) { |
| 448 | UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI); |
nothing calls this directly
no test coverage detected