I’m working on segmentation at the moment and I want to proof my results with openCV.
When I’m working with different connectivity type the result is the same.
Is this a bug in openCV?
My minimal example with connectivity=4:
test = np.zeros((5, 5)).astype(np.uint8)
test[1:3, 1:3] = 255
test[3:5, 3:5] = 255
num_labels, labels, stats, centroids = cv2.connectedComponentsWithStats(test, 4, cv2.CV_32S)
test, labels
is:
(array([[ 0, 0, 0, 0, 0],
[ 0, 255, 255, 0, 0],
[ 0, 255, 255, 0, 0],
[ 0, 0, 0, 255, 255],
[ 0, 0, 0, 255, 255]], dtype=uint8),
array([[0, 0, 0, 0, 0],
[0, 1, 1, 0, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 1, 1],
[0, 0, 0, 1, 1]], dtype=int32))
and thats wrong, because a 4-way-connectivity only connects elements when
[[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]
is true.
Or am I wrong?
Thanks for your responds.
Regards Marc