JuliaImages / ImageSegmentation.jl

Partitioning images into meaningful regions
Other
47 stars 23 forks source link

3d watershed #35

Closed mschauer closed 4 years ago

mschauer commented 4 years ago

I am doing the watershed on a nxnx2 matrix and I am surprised that the segmentation of the first and the second layer are the same. Small example reproducing the behaviour.

A1 = [2 3 3 1 0
      1 3 3 3 2
      1 1 3 3 2
      0 1 3 3 2]

 A2 = [1 1 3 3 1
       1 2 3 3 2
       1 3 3 2 2
       1 3 3 2 2]

A = cat(A1, A2, dims=3)
seeds = zeros(Int, size(A))
is = findall(i -> i == 0, A)
seeds[is] .= 1:length(is)
seeds
S = watershed(A, seeds)
heatmap([S.image_indexmap[:,:,1]; S.image_indexmap[:, :, 2]])
Screenshot 2019-10-01 at 15 52 40
mschauer commented 4 years ago

I think I understand now why that is the case: the metric induced by the pixel neighbourhood makes points diagonally adjacent in different layer as close as direct neighbours.