0

I use the function regionprops in python for different sizes of 3D images (tiff images). However, when the size of my image is upper than 4Go, regionprops extracting always the same number of labels (32767). I run my code on Jupyter Notebook.

Can you help me to fix this (if it is possible) ?

Thank you in advance.

my code :

props = skimage.measure.regionprops(test) #test is np.array and contains my label image
#save to a file in csv format
name_file ="particles_position.txt" #change the file name
with open(name_file, "w") as csvfile:
    csv.register_dialect("custom", delimiter=" ", skipinitialspace=True)
    writer = csv.writer(csvfile, dialect="custom")
    writer.writerow(('label','centroid','area','equivalent_diameter'))
    for i in range(np.size(props)):
        writer.writerow((props[i]['label'], props[i]['centroid'], props[i]['area'],  props[i]['equivalent_diameter']))
Absynthe
  • 23
  • 5
  • We need more information to fix your problem, see https://stackoverflow.com/help/minimal-reproducible-example for details. In the meantime though, that max label happens to be the maximum value represented by an 16-bit signed integer (`np.iinfo(np.int16).max`), which is interesting. The 4GB limit is also interesting and I suggest making sure your Python/Anaconda/NumPy installation is 64-bit. You can check with `np.ones(5, dtype=np.intp).dtype`, that should evaluate to `np.int64`. – Juan Feb 02 '22 at 03:41
  • I know it's hard to share such a big dataset but you can make an example, for example, find `np.shape(test)` and `np.max(test)`, then instead of test use `np.random.randint(0, MAXVAL+1, size=SHAPE)` in your script. – Juan Feb 02 '22 at 03:42

1 Answers1

0

This looks like an overflow. I faced the same issue when applying skimage slic algorithm to a (very) large image, skimage doesn't deal with more than 2^15 labelled regions on an image.

You should try to slice your images in parts that countain less segments and give them separately to skimage.measure.regionprops.

endive1783
  • 827
  • 1
  • 8
  • 18