I want use IMG_erode_bin function in imglib, but I don't understand what this function do. When I refer to the description of this function in sprc264 , it shows:
---------------------------------------------------------------------------------------------------------------
Algorithm
result = 1;
if (mask[0][0] != DONT_CARE) result &= input[y + 0][x + 0];
if (mask[0][1] != DONT_CARE) result &= input[y + 1][x + 1];
if (mask[0][2] != DONT_CARE) result &= input[y + 2][x + 2];
if (mask[1][0] != DONT_CARE) result &= input[y + 0][x + 0];
if (mask[1][1] != DONT_CARE) result &= input[y + 1][x + 1];
if (mask[1][2] != DONT_CARE) result &= input[y + 2][x + 2];
if (mask[2][0] != DONT_CARE) result &= input[y + 0][x + 0];
if (mask[2][1] != DONT_CARE) result &= input[y + 1][x + 1];
if (mask[2][2] != DONT_CARE) result &= input[y + 2][x + 2];
output [ y ] [x] = result;
For this code, DONT_CARE is specified by a negative value in the input mask.
Non-negative values in the mask cause the corresponding pixel to be included in the
erosion operation.
---------------------------------------------------------------------------------------------------------------
I don't understand why this alg always AND among in diagonal direction of input image array. For example:
Input ( unsigned char input[24] ) image array:
0 1 1 1 0 0 0 1
0 1 1 0 1 1 1 1
0 1 0 1 0 0 0 1
Mask (In my opinion, everything will not be effected if every value of this Mask is positive.)
0 0 0
1 1 1
0 0 0
IMG_erode_bin(input,output,(*mask)[3],8); // unsigned char output[24]
The result is:
All of values in "output" is zero, As the alg description above, I believe that at least one value of output array should be "1".
Please look at the bold and italic number in "input" array(here x = 1, y = 0). From alg description, "result" variant is 1,
result &= input[y + 0][x + 0]; // 1 & = 1;
result &= input[y + 1][x + 1]; // 1 & = 1;
result &= input[y + 2][x + 2]; // 1 & = 1;
Where is wrong? I can not get "1" in output array.
By the way:
As I know, the erosion theory in image processing is not like the alg description.
Thanks.