# mmdcornea
Cornea cells marking.

## Description

This procedure creates a maker for each cell in a very poor quality microscopic image of a cornea. The composition of an opening with the regional maximum is used to create the markers.

## Demo Script

### Reading and topographic view

The gray-scale image of the cornea is read and displayed. A topographic model is also displayed. We can notice that the cells are formed by small hills in the topographic model. We can also notice that the image is very noisy.

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

    >>> mmshow(a);

    >>> b = mmsurf(a);

    >>> mmshow(b);

a | b |

### Filtering and cell detection

The image is filtered by an alternating sequential filtering with size 2. This filter is composed by openings and closings, removing small peaks and valleys. Next, the regional maxima are detected. For illustrative purpose, they are displayed overlayed on the topographic image view. These regional maxima are the markers for each cell. If anything goes wrong in this step, the error will be propagated throughout the process.

    >>> c = mmasf(a,'oc',mmsecross(),2);

    >>> d = mmregmax( c);

    >>> mmshow(mmsurf(c));

    >>> mmshow(mmsurf(c), d);

mmsurf(c) | mmsurf(c), d |

### Find the background marker

Following the paradigm of segmentation by watershed, the background marker is detected by applying the constrained watershed on the negation of the cells image using the markers detected in the last step. These watershed lines partition the image in regions of influence of each cell. For illustrative display, the negative of the cell image is displayed overlayed by the markers on the left, and also overlayed by the watershed lines on the right.

    >>> e = mmneg(a);

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

    >>> mmshow(e,d);

    >>> mmshow(e,f,d);

e,d | e,f,d |

### Labeling the markers and gradient

As the internal and external markers can be touching, we combine the external marker with value 1 with the labeling of the internal markers added by 1. The labeled marker image is shown on the left. The final watershed will be applied on the gradient of the original image, which is shown on the right.

    >>> g = mmgray(f, 'uint16', 1);

    >>> h1 = mmaddm(mmlabel(d), uint16(1));

    >>> h = mmintersec(mmgray(d,'uint16'), h1);

    >>> i = mmunion( g, h);

    >>> mmlblshow(i);

    >>> j = mmgradm( a);

    >>> mmshow(j);

i | j |

### Constrained watershed of the gradient from markers

Apply the constrained watershed on the gradient from the labeled internal and external markers. Show the watershed lines on the left and the results overlayed on the original image, on the right.

    >>> k = mmcwatershed(j, i);

    >>> mmshow( k);

    >>> mmshow(a, k, k);

k | a, k, k |

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