I’m translating a matlab script into python and I’m having troubles with this section:
% MATLAB
CC = bwconncomp(volume, 26); % connectivity = 26; volume is a binary 3d matrix
properties = {'Volume','SurfaceArea'};
stats = regionprops3(CC, properties);
bwconncomp returns the number of connected components and a ‘1-by-NumObjects cell array where the k-th element in the cell array is a vector containing the linear indices of the pixels in the k-th connected component’ (bwconncomp doc. Regionprops3 then calculates the volume and surface area of each component (regionprops3 doc.
I tried this in python:
from scikit import measure
CC = measure.label(volume, return_num=True, connectivity=3)
stats = measure.regionprops(CC[0])
where CC is a tuple with the labeled image (all positions of the same components have the same value) and the number of objects
(scikit docs.
What I’m struggling to understand is which properties, of the many the function measure.regionprops returns, are the equivalent of volume and surfaceArea in matlab.
From matlab docs:
Volume is calculated as ‘Count of the actual number of on voxels in the region, returned as a scalar. Volume represents the metric or measure of the number of voxels in the regions within the volumetric binary image.’ and
SurfaceArea as ‘Distance around the boundary of the region, returned as a scalar.’
I read that the scikit package was initially for 2D images and only later the 3D processing was implemented: this might be part of the problem maybe (??). Nevertheless I couldn’t find better solutions.
Do you guys know which properties should I focus on or if there are better implementations? Thanks