I want to implement Connected-Component Labeling but I’m not sure if I should do it in a 4-connected manner or 8-connected. I’ve read about 3 materials on it but none of them explains their choice of graph connectivity. One of them chose 8, the other two 4 and one of those two said that he chose 4 for a shorter program trace (noting that extending his pseudocode to 8 should be trivial). So, what are the merits of one over the other?
Share
The only real difference is how the algorithms handle diagonal configurations. With a diamond neighborhood, diagonal "in" elements will not be connected. With the square neighborhood, they will.
You might want to treat this as an ambiguous case instead of just always doing one or the other. Some existing strategies will look at the actual values before binarization and interpolate a value between the diagonal elements. This value is binarized and when it too is in, the diagonal elements are connected. Otherwise, they are not.