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

Function testImage

test/confidence_connected.cpp:45–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template<typename T>
45void testImage(const std::string pTestFile, const size_t numSeeds,
46 const unsigned *seedx, const unsigned *seedy,
47 const int multiplier, const unsigned neighborhood_radius,
48 const int iter) {
49 SUPPORTED_TYPE_CHECK(T);
50 IMAGEIO_ENABLED_CHECK();
51
52 vector<af::dim4> inDims;
53 vector<string> inFiles;
54 vector<dim_t> outSizes;
55 vector<string> outFiles;
56
57 readImageTests(std::string(TEST_DIR) + "/confidence_cc/" + pTestFile,
58 inDims, inFiles, outSizes, outFiles);
59
60 size_t testCount = inDims.size();
61
62 af_array seedxArr = 0, seedyArr = 0;
63 dim4 seedDims(numSeeds);
64 ASSERT_SUCCESS(af_create_array(&seedxArr, seedx, seedDims.ndims(),
65 seedDims.get(), u32));
66 ASSERT_SUCCESS(af_create_array(&seedyArr, seedy, seedDims.ndims(),
67 seedDims.get(), u32));
68
69 for (size_t testId = 0; testId < testCount; ++testId) {
70 af_array _inArray = 0;
71 af_array inArray = 0;
72 af_array outArray = 0;
73 af_array _goldArray = 0;
74 af_array goldArray = 0;
75
76 inFiles[testId].insert(0, string(TEST_DIR "/confidence_cc/"));
77 outFiles[testId].insert(0, string(TEST_DIR "/confidence_cc/"));
78
79 ASSERT_SUCCESS(
80 af_load_image(&_inArray, inFiles[testId].c_str(), false));
81 ASSERT_SUCCESS(
82 af_load_image(&_goldArray, outFiles[testId].c_str(), false));
83
84 // af_load_image always returns float array, so convert to output type
85 ASSERT_SUCCESS(conv_image<T>(&inArray, _inArray));
86 ASSERT_SUCCESS(conv_image<T>(&goldArray, _goldArray));
87
88 CCCTestParams params;
89 params.prefix = "Image";
90 params.radius = neighborhood_radius;
91 params.multiplier = multiplier;
92 params.iterations = iter;
93 params.replace = 255.0;
94
95 ASSERT_SUCCESS(af_confidence_cc(&outArray, inArray, seedxArr, seedyArr,
96 params.radius, params.multiplier,
97 params.iterations, params.replace));
98 int device = 0;
99 ASSERT_SUCCESS(af_get_device(&device));
100 ASSERT_SUCCESS(af_sync(device));
101
102 ASSERT_ARRAYS_EQ(outArray, goldArray);

Callers

nothing calls this directly

Calls 9

readImageTestsFunction · 0.85
af_create_arrayFunction · 0.50
af_load_imageFunction · 0.50
af_confidence_ccFunction · 0.50
af_get_deviceFunction · 0.50
af_syncFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected