Home > Mobile >  Segmenting image of multiple cells and splitting into single cells
Segmenting image of multiple cells and splitting into single cells

Time:05-26

Say I have this image: Image of multiple cells

Which can be obtained via

from skimage.data import human_mitosis
image = human_mitosis()

I want to turn this image of multiple cells into multiple images for each individual cell through automatically cropping each single cell into its own image (ideally the size of the cropping is the same size/shape for each cell). So, for example, these would be some of the expected images:

enter image description here enter image description here

Although scikit has some code for segmenting cells, how do you use this segmentation (or some other potentially easier method) to separate single cells into their own images or objects?

Here is some code for segmenting the cells (taken from scikit's tutorial with this image enter image description here

CodePudding user response:

You can use skimage.measure.regionprops for this:

props = measure.regionprops(
        segmented_cells, intensity_image=image
        )

Now props[i].image_intensity will contain the image of the ith cell, and props[i].label will contain the label value in the segmented image of that cell. You can see other properties available in the regionprops docstring.

Edit: An earlier version of this answer said props[i].image contained the cropped image. It in fact contains only the boolean mask corresponding to the region.

  • Related