I have a large numpy
array that I\'ve applied a filter over. I\'d like to identify the contiguous regions in this masked array. Here I\'m defining a region to be co
You're looking for scipy.ndimage.label
, more info here. label
returns an array the same shape as the input where each "unique feature has a unique value", so if you want the indices of the features you can do something like:
labels, numL = label(array)
label_indices = [(labels == i).nonzero() for i in xrange(1, numL+1)]