working hit-or-miss implementation
I need an implementation of hit-or-miss transform done in OpenCV. Searching the internet, all I found is this program on opencv-code.com. The implementation, however, is broken. As an example, take the kernel
0 0 0
0 1 0
0 0 0
That is, a one in the middle and don't-cares everywhere else. The expected behaviour would be to simply copy the input image and that's what the MATLAB function bwhitmiss
does. The provided snippet, however, zeros a few values.
Original:
[0, 0, 0, 0, 0, 0, 0, 0;
0, 1, 1, 1, 0, 0, 0, 0;
0, 1 , 0, *1*, 0, 0, 0, 1;
0, 1, *1*, 1, 0, 1, 0, 0;
0, 0 , 1, 0, 0, 0, 0, 0;
0, 0, 1, 0, 0, 1, 1, 0;
0, 1, 0, *1*, 0, 0,*1*, 0;
0, 1, *1*, 1, 0, 0, 0, 0]
Hit-and-miss result:
[0, 0, 0, 0, 0, 0, 0, 0;
0, 1, 1, 1, 0, 0, 0, 0;
0, 1, 0, *0*, 0, 0, 0, 1;
0, 1, *0*, 1, 0, 1, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 1, 0, 0, 1, 1, 0;
0, 1, 0, *0*, 0, 0,*0*, 0;
0, 1, *0*, 1, 0, 0, 0, 0]
Does someone have an idea for a fix?