IniziaInizia gratis

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.

Labeled Volume


After printing the variances, select the true statement from the answers below.

Questo esercizio fa parte del corso

Biomedical Image Analysis in Python

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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:', ____)
Modifica ed esegui il codice