I am doing a segmentation of ilium from MRI sequence using random walker algorithm. I segmented it from the easiest slice of the sequence and then I want to iterate over the sequence using previous bone segmentation (eroded and dilated) as inner and outer markers. I use the following code to label markers :
markers = np.zeros(bone_mark.shape) out_mark = np.invert(dilation(bone_mark, disk(10))) in_mark = erosion(bone_mark, disk(5)) markers[out_mark == True] = 1 markers[in_mark == True] = 2
bone_mark is the segmentation of ilium of previous slice. It works fine the first time, but when I run this in a loop, the second iteration fails to combine labels in marker array. Here you can see an example of marker image in first and second iterations :
in_mark in both iterations and they are fine, just like they should be. It looks mysterious to me and I have no idea how to fix this problem. Could you please share your thoughts on this problem?