[scikit-image] Memory consumption of measure.label (compared to matlab)
Martin Fleck
martin.fleck at uni-konstanz.de
Wed Jul 12 13:29:31 EDT 2017
Hello skimage users and devs,
in an image analysis of mine, I use skimage.measure.label and
skimage.morphology of skimage 0.13.0 .
My problem my analysis uses much more memory than I expect.
I attached output from the memory_profiler package, with which I tried
to keep track of the memory consumption of my analysis.
You can see that for an ~8MiB file that I used for testing,
skimage.measure.label needs to use 56MiB of memory, which surprised me.
My first question is: Am I doing something wrong here?
The memory consumption is skimage.morphology.remove_small_objects is
surprisingly high, too.
I want to be able to process images of several GiB on my machine.
I hope I can excuse the following comparison with matlab by pointing to
the similarity between skimage.measure.regionprops and matlabs regionprops:
With Matlab I don't run into any memory problems on the very same machine.
I would be very glad if I could continue using python for this analysis
and not have to rely on matlab.
Is there a way for me to reduce the memory consumption if I want to use
skimage.morphology.remove_small_objects() and
skimage.measure.regionprops() for which I need the label()?
Best Regards,
Martin
-------------- next part --------------
Line # Mem usage Increment Line Contents
================================================
154 102.523 MiB 0.000 MiB @profile
155 def run():
156 110.500 MiB 7.977 MiB image = data.imread(image_filename)
157 110.500 MiB 0.000 MiB image = color.rgb2gray(image)
158
159 # make binary image with threshold using Li's method
160 117.328 MiB 6.828 MiB bwSource = image<filters.threshold_minimum(image)
161
162 # Filter bwSource image -> remove small specks
163 131.715 MiB 14.387 MiB bwFiltered = morphology.remove_small_objects(bwSource, min_size=minSingleDislocationArea, connectivity=2)
164
165 # analyze regions:
166 187.551 MiB 55.836 MiB label_img = label(bwFiltered)
167 187.809 MiB 0.258 MiB regions = regionprops(label_img)
More information about the scikit-image
mailing list