Open EmmanuelMess opened 3 years ago
Adding:
def clamp(n, smallest, largest):
return max(smallest, min(n, largest))
bkg_seed = (clamp(bkg_seed[0], 0, img_bin.shape[1] - 1), clamp(bkg_seed[1], 0, img_bin.shape[0] - 1))
to line 220 of background_marker.py fixes it.
This issue is probably caused by the inconsistent order of row and col in numpy and cv2. One simple fix is
replacing line 229 of background_marker.py
cv2.floodFill(img_floodfill, mask_, seedPoint=bkg_seed, newVal=lab_val)
with
cv2.floodFill(img_floodfill, mask_, seedPoint=(bkg_seed[1], bkg_seed[0]), newVal=lab_val)
Image: