@@ -134,7 +134,7 @@ TYPED_TEST(Morph, Erode4x4x4) {
134134}
135135
136136template <typename T, bool isDilation, bool isColor>
137- void morphImageTest (string pTestFile) {
137+ void morphImageTest (string pTestFile, dim_t seLen ) {
138138 SUPPORTED_TYPE_CHECK (T);
139139 if (noImageIOTests ()) return ;
140140
@@ -148,23 +148,31 @@ void morphImageTest(string pTestFile) {
148148 size_t testCount = inDims.size ();
149149
150150 for (size_t testId = 0 ; testId < testCount; ++testId) {
151- af_array inArray = 0 ;
152- af_array maskArray = 0 ;
153- af_array outArray = 0 ;
154- af_array goldArray = 0 ;
155- dim_t nElems = 0 ;
151+ af_array _inArray = 0 ;
152+ af_array inArray = 0 ;
153+ af_array maskArray = 0 ;
154+ af_array outArray = 0 ;
155+ af_array _goldArray = 0 ;
156+ af_array goldArray = 0 ;
157+ dim_t nElems = 0 ;
156158
157159 inFiles[testId].insert (0 , string (TEST_DIR " /morph/" ));
158160 outFiles[testId].insert (0 , string (TEST_DIR " /morph/" ));
159161
160- dim4 mdims (3 , 3 , 1 , 1 );
162+ af_dtype targetType = static_cast <af_dtype>(dtype_traits<T>::af_type);
163+
164+ dim4 mdims (seLen, seLen, 1 , 1 );
161165 ASSERT_SUCCESS (af_constant (&maskArray, 1.0 , mdims.ndims (), mdims.get (),
162- (af_dtype)dtype_traits<T>::af_type ));
166+ targetType ));
163167
164168 ASSERT_SUCCESS (
165- af_load_image (&inArray, inFiles[testId].c_str (), isColor));
169+ af_load_image (&_inArray, inFiles[testId].c_str (), isColor));
170+ ASSERT_SUCCESS (af_cast (&inArray, _inArray, targetType));
171+
166172 ASSERT_SUCCESS (
167- af_load_image (&goldArray, outFiles[testId].c_str (), isColor));
173+ af_load_image (&_goldArray, outFiles[testId].c_str (), isColor));
174+ ASSERT_SUCCESS (af_cast (&goldArray, _goldArray, targetType));
175+
168176 ASSERT_SUCCESS (af_get_elements (&nElems, goldArray));
169177
170178 if (isDilation)
@@ -181,20 +189,44 @@ void morphImageTest(string pTestFile) {
181189 ASSERT_EQ (true , compareArraysRMSD (nElems, goldData.data (),
182190 outData.data (), 0 .018f ));
183191
192+ ASSERT_SUCCESS (af_release_array (_inArray));
184193 ASSERT_SUCCESS (af_release_array (inArray));
185194 ASSERT_SUCCESS (af_release_array (maskArray));
186195 ASSERT_SUCCESS (af_release_array (outArray));
196+ ASSERT_SUCCESS (af_release_array (_goldArray));
187197 ASSERT_SUCCESS (af_release_array (goldArray));
188198 }
189199}
190200
191- TEST (Morph, Grayscale) {
192- morphImageTest<float , true , false >(string (TEST_DIR " /morph/gray.test" ));
201+ TEST (Morph, GrayscaleDilation3x3StructuringElement) {
202+ morphImageTest<float , true , false >(string (TEST_DIR " /morph/gray.test" ), 3 );
203+ }
204+
205+ TEST (Morph, ColorImageErosion3x3StructuringElement) {
206+ morphImageTest<float , false , true >(string (TEST_DIR " /morph/color.test" ), 3 );
207+ }
208+
209+ TEST (Morph, BinaryImageDilationBy33x33Kernel) {
210+ morphImageTest<char , true , false >(
211+ string (TEST_DIR " /morph/zag_dilation.test" ), 33 );
212+ }
213+
214+ TEST (Morph, BinaryImageErosionBy33x33Kernel) {
215+ morphImageTest<char , false , false >(
216+ string (TEST_DIR " /morph/zag_erosion.test" ), 33 );
217+ }
218+
219+ #if defined(AF_CPU) // float image 33x33 morph ops
220+ TEST (Morph, DilationBy33x33Kernel) {
221+ morphImageTest<float , true , true >(
222+ string (TEST_DIR " /morph/baboon_dilation.test" ), 33 );
193223}
194224
195- TEST (Morph, ColorImage) {
196- morphImageTest<float , false , true >(string (TEST_DIR " /morph/color.test" ));
225+ TEST (Morph, ErosionBy33x33Kernel) {
226+ morphImageTest<float , false , true >(
227+ string (TEST_DIR " /morph/baboon_erosion.test" ), 33 );
197228}
229+ #endif // AF_CPU float image 33x33 morph ops
198230
199231template <typename T, bool isDilation>
200232void morphInputTest (void ) {
0 commit comments