Measure variance
SciPy measurement functions allow you to tailor measurements to specific sets of pixels:
- Specifying
labels
restricts the mask to non-zero pixels. - Specifying
index
value(s) returns a measure for each label value.
For this exercise, calculate the intensity variance of vol
with respect to different pixel sets. We have provided the 3D segmented image as labels
: label 1 is the left ventricle and label 2 is a circular sample of tissue.
After printing the variances, select the true statement from the answers below.
Diese Übung ist Teil des Kurses
Biomedical Image Analysis in Python
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Variance for all pixels
var_all = ndi.variance(vol, labels=None, index=None)
print('All pixels:', var_all)
# Variance for labeled pixels
var_labels = ndi.variance(____, _____, ____)
print('Labeled pixels:', ____)
# Variance for each object
var_objects = ____
print('Left ventricle:', var_objects[0])
print('Other tissue:', ____)