How to extract labels from a Binary Image in SimpleITK in python
<p>I would like to extract the labels from the 2D Binary image I get using the following code:</p>

<pre><code>image2DThresh = sitk.Threshold(image2D, lower=stats.GetMinimum(), upper=127.500)
cca = sitk.ConnectedComponentImageFilter()
cca_image = cca.Execute(2D_Slice)
# Get the shape statistics of the labels using
labelStats = sitk.LabelShapeStatisticsImageFilter()
</code></pre>

<p>The basic idea is to find the mean intensity, area of ROI and min/max indexes of the label in the main image. What I am trying to do is binarizing the image with Threshold Filter, then running CCA on this to get all the labels. Then I use the <code>LabelShapeStatisticsImageFilter()</code> to get the physical attributes of every label (except label 0 of course) and check if the label meets the conditions. The problem is i am not able to get the average intensity in the main image where the label is. That is why I suggest using <code>LabelIntensityStatisticsFilter</code>, which however for python 2.7, SimpleITK 0.10 isn't available. </p>