There seems to be an issure regarding the dilation function:
Suppose I have to following input:
and dilate it with this mask:
The expected output is seen in the below figure on the left, which was calculated in python using the function scipy.ndimage.morphology.binary_dilation. However the same dilation using Arrayfire produces a different result, which is displayed on the right. (Note that both dilate functions reference the same Wikipedia article: Dilation Morphology)
This issue occurs with ArrayFire v3.3.2, 64-bit Windows, build f65dd97 and affects all three backends.
The relevant C++ Code to try it is the following:
using namespace af;
int inputData[10 * 10] =
{
0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1
};
array input(10, 10, inputData);
int maskData[3 * 3] =
{
1, 1, 1,
1, 0, 1,
1, 1, 1
};
array mask(3, 3, maskData);
array dilated = dilate(input.as(b8), mask.as(b8));
af_print(dilated); // "Arrayfire Dilation" in the output image