], ... [0, 0, 0, 7], ... [9, 3, 0, 0]]) >>> from scipy import ndimage >>> ndimage.variance(a) 7.609375 Features to process can be specified using `labels` and `index`: >>> lbl, nlbl = ndimage.label(a) >>> ndimage.variance(a, lbl, index=np.arange(1, nlbl+1)) array([ 2.1875, 2.25 , 9. ]) If no index is given, all non-zero `labels` are processed: >>> ndimage.variance(a, lbl) 6.1875 T)