Hi Stuart
On Tue, Apr 2, 2013 at 7:04 PM, Stuart Mumford
I am using your (amazingly fast) label image routines and regionprops to extract the coordinates of the regions in two images. I need to filter these objects out if they do not overlap in both the images, then renumber all the remaining regions. At the moment I am doing something unspeakable with nested loops and sets which is pretty damn slow; I was hoping someone here would have a really clever idea on how to solve this. Failing that does anyone know how I can find the number of coordinates (output from regionprops) that overlap in two numpy arrays?
You can use join_segmentations to find an intersection of your two label maps. Then, walk through the newly formed regions and check at each point whether the object exists in both images (that way, you don't have so many comparisons to do). http://scikit-image.org/docs/dev/auto_examples/plot_join_segmentations.html If that's not exactly what you had in mind, you can use this code to find all the connected regions in an image: https://github.com/stefanv/lulu/blob/master/lulu/base.pyx#L21 These regions are encoded sparsely, and testing their intersection is very fast (see the algorithm section of this paper: https://scholar.sun.ac.za/handle/10019.1/4883). I hope that helps! Stéfan