I am standing in front of a huge problem. Using the python libraries NumPy and SciPy, I identified several features in large array. For this purpose, I created a 3×3 neighbor structure and used it for a connected component analysis –> see docs.
struct = scipy.ndimage.generate_binary_structure(2,2)
labeled_array, num_features = ndimage.label(array,struct)
My problem now is that I want to iterate through all identified features in a loop. Someone has an idea how to address individual features in the resulting NumPy array?
Here’s an example of handling features identified by ndimage.label. Whether this helps you or not depends on what you want to do with the features.
Here’s the image generated by the script: