# mmdcells
Extract blood cells and separate them.

## Description

A microscopic gray-scale image containing blood cells is segmented and further processed for the separation of superposed cells. The segmentation procedure is based on gray-scale connected filtering and threshold, while the separation procedure is based on the classical watershed approach.

## Demo Script

### Reading and elimination of white pores

First, the blood cells image is read. Then, the gray-scale area open operator is applied for removing small white pores over the cells.

    >>> a = mmreadgray('bloodcells.tif');

    >>> mmshow(a);

    >>> b = mmareaopen(a, 200);

    >>> mmshow(b);

a | b |

### Threshold and shape smoothing

The threshold of dark areas produces the segmented image (i.e., the region where there are cells). Then the opening by a small disk performs smoothing of the cells borders.

    >>> c = mmcmp( uint8(0), '<=', b, '<=', uint8(140));

    Warning: Converting input image from int32 to uint16.
    Warning: Converting input image from int32 to uint16.

    >>> mmshow(c);

    >>> d = mmopen(c,mmsedisk(2,'2D','OCTAGON'));

    >>> mmshow(d);

c | d |

### Marking

A marker for each cell is obtained by dilating the regional maximum of the distance transform. For visualization illustration, the distance transform is viewed as a topographic surface shading on the left and the dilated regional maximum is displayed in read overlayed on the surface view.

    >>> e1 = mmdist(d, mmsebox(),'EUCLIDEAN');

    >>> e2 = mmsurf(e1);

    >>> mmshow( e2);

    >>> e3 = mmregmax(e1);

    >>> e  = mmdil(e3);

    >>> mmshow( e2, e);

e2 | e2, e |

### Geodesic SKIZ

The watershed, constrained by the makers image, is applied to the negation of the distance function. The result of this procedure is also called geodesic SKIZ. For visualization, on the left the negate distance function is displayed as a topographic surface, and on the right this surface is superposed by the markers and the detected watershed lines.

    >>> f = mmneg(e1);

    >>> fs = mmsurf(f);

    >>> mmshow(fs);

    >>> g = mmcwatershed( f, e, mmsebox());

    >>> mmshow(fs, g, e);

fs | fs, g, e |

### Cell separation

The geodesic SKIZ (i.e., watershed division lines) is subtracted from the segmented image, separating the cells. On the left the detected watershed lines is overlayed on the cells binary image, and on the right, the cells image separated using the watershed lines.

    >>> mmshow(c,g);

    >>> h = mmintersec(c,mmneg(g));

    >>> mmshow(h);

c,g | h |

### Edge off

The cells that touch the frame of the image are removed.

    >>> i = mmedgeoff(h);

    >>> mmshow(i);

i |

### Final display

Superposition of the contour of the detected cells on the original image.

    >>> j=mmgradm(i);

    >>> mmshow(a,j);

a,j |

[`mmdcalc`] [Up] [`mmdchickparts`] |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center.