Last active
August 29, 2015 13:56
-
-
Save jeanpat/8819895 to your computer and use it in GitHub Desktop.
A python function relying on scipy.ndimage to extract region of interest in an image or in a stack of images with a a label image, spurious pixels are removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def extractParticles(greyIm, LabIm): | |
| locations = nd.find_objects(LabIm) | |
| i=1 | |
| extracted_images=[] | |
| for loc in locations: | |
| lab_image = np.copy(LabIm[loc]) | |
| grey_image = np.copy(greyIm[loc]) | |
| lab_image[lab_image<>i]=0 | |
| grey_image[lab_image <>i]=0 | |
| extracted_images.append(grey_image) | |
| i=i+1 | |
| return extracted_images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment