Calculating Just A Specific Property In Regionprops Python
Answer : There seems to be a more direct way to do the same thing using regionprops with cache=False . I generated labels using skimage.segmentation.slic with n_segments=10000 . Then: rps = regionprops(labels, cache=False) [r.area for r in rps] My understanding of the regionprops documentation is that setting cache=False means that the attributes won't be calculated until they're called. According to %%time in Jupyter notebook, running the code above took 166ms with cache=False vs 247ms with cache=True , so it seems to work. I tried an equivalent of the other answer and found it much slower. %%time ard = np.empty(10000, dtype=int) for i in range(10000): ard[i] = size(np.where(labels==0)[1]) That took 34.3 seconds. Here's a full working example comparing the two methods using the skimage astronaut sample image and labels generated by slic segmentation: import numpy as np import skimage from skimage.segmentation import slic from skimage.data import a...