I'm working with watershed algorithm in scikit (skimage) to segmentate my image and then I detect the segmented objects by using function find_objects from ndimage library. The returned type is a tuple of slices as this: (slice(0L, 45L, None), slice(460L, 519L, None)). I need to make a white color in the central point of the region segmented by wathershed, so how do I find it from the slice object? Is there an easier way to find this point?
rect = (slice(0L, 45L, None), slice(460L, 519L, None))
# Find the midpoint of the rectangle:
x,y = [(side.start+side.stop)/2. for side in rect]
In your example, you get x = 22.5
and y = 489.5
.