0

I have a 3d image which I want to label. Typically I use from label from scipy.ndimage. I want to ask how do you handle anisotropy, the z-dimension is cut more coarsely than x and y.

My structuring element is like a ball:

from scipy.ndimage import label, generate_binary_structure
s = generate_binary_structure(3, 1)
labels, _ = label(img, structure=s)

I am looking at the plane above and below (apart from the current) to check for connecting elements

Aenaon
  • 3,169
  • 4
  • 32
  • 60
  • What's your current structuring element, if any? In other words, what are you passing as the `structure` argument to `label()`? https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.label.html – Nick ODell Jul 11 '23 at 21:10
  • Thanks, I just edited my post – Aenaon Jul 11 '23 at 21:20
  • `generate_binary_structure(3, 1)` should be fine. It just says that each pixel has 6 neighbors, two along each dimension. The anisotropy doesn't matter for this. Anisotropy matters if you were to compute distances and so on. But the labelling operation just wants to know what pixels are neighbors, not what distance they are at. – Cris Luengo Jul 11 '23 at 21:29
  • 2
    [DIPlib](https://diplib.org) handles anisotropy very well in most functions. You can add a pixel size to the image, and this pixel size is taken into account when doing certain quantitative operations such as distance transforms and size measurements. – Cris Luengo Jul 11 '23 at 21:32
  • ok, thanks so much Chris! – Aenaon Jul 11 '23 at 21:36

0 Answers0