##### Contents

Miria Bernardino (mrafante)

# Foto do RA

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.

## 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.

```1 from ia870 import *
2
5 b = iaareaopen(a,200)
```

### 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.

```1 c = iacmp( uint8(0), '<=', b, '<=', uint8(140))
3 d = iaopen(c,iasedisk(2,'2D','OCTAGON'))
```

### 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.

```1 e1 = iadist(d, iasebox(),'EUCLIDEAN')
2 e2 = iagsurf(e1)
4 e3 = iaregmax(e1)
```

### Geodesic SKIZ

The watershed, constrained by the markers 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.

```1 f = ianeg(e1)
2 fs = iagsurf(f)
4 g = iacwatershed( f, e, iasebox())
```

### 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.

```1 adshow(iagshow(c,g))
2 h = iaintersec(c,ianeg(g))
```

### Final display

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

```1 j=iagradm(h)
```

### Counting centroids

Counting the number os centroids was found in the picture

```1 fr = ialabel(e)
4 n=iastats(fr,'max')
5 print 'n=',n
```
```n= 3
```

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.

## 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.

```1 from ia870 import *
2
6 b = iaareaopen(a,200)
```

### 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.

```1 c = iacmp( uint8(0), '<=', b, '<=', uint8(140))
3 d = iaopen(c,iasedisk(2,'2D','OCTAGON'))
```

### 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.

```1 e1 = iadist(d, iasebox(),'EUCLIDEAN')
2 e2 = iagsurf(e1)
4 e3 = iaregmax(e1)
```

### Geodesic SKIZ

The watershed, constrained by the markers 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.

```1 f = ianeg(e1)
2 fs = iagsurf(f)
4 g = iacwatershed( f, e, iasebox())
```

### 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.

```1 adshow(iagshow(c,g))
2 h = iaintersec(c,ianeg(g))
```

### Final display

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

```1 j=iagradm(h)
```

### Counting centroids

Counting the number os centroids was found in the picture

```1 fr = ialabel(e)
```n= 84