MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / cppMorphImageTest

Function cppMorphImageTest

test/morph.cpp:408–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406
407template<typename T, bool isDilation, bool isColor>
408void 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
447TEST(Morph, Grayscale_CPP) {
448 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);

Callers

nothing calls this directly

Calls 8

readImageTestsFunction · 0.85
constantFunction · 0.85
loadImageFunction · 0.85
dilateFunction · 0.85
erodeFunction · 0.85
compareArraysRMSDFunction · 0.85
hostMethod · 0.80
elementsMethod · 0.45

Tested by

no test coverage detected