Toolbox ia870 | List of Figures | Fig. 7.1 | Fig. 7.4

Figure 7.2 - Segmentation by watershed

Description

The literature has devoted many complex methods to deal with this segmentation problem. The watershed approach is a simple yet powerful tool to solve this type of segmentation. Figure 7.2 illustrates the beef segmentation based on the watershed transform (with details to be subsequently explained). For this example, we use the watershed from markers.This watershed requires a set of markers. Each marker must be placed on a sample region of the object to be segmented. In this case, we use two markers: one for the lean meat (inner marker) and the other for the fat (outer marker). These two markers are illustrated in Fig. 7.2(a), overlaid on the morphological gradient. Marker design in watershed-based segmentation is one of the most crucial steps for a successful solution. We have discussed in Chapter 6 several techniques to extract markers from images and we will use them in this chapter to illustrate different approaches for watershed-based segmentation.

As a motivation, we show in Fig. 7.2 a solution for the beef segmentation using the watershed from markers: (a) the gradient image overlaid by two markers, one inside and another outside of the object to segment, (b) the watershed line, and (c) the watershed line overlaid on the input image to illustrate the quality of the segmentation.

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 
 4 a = np.transpose(adreadgray('beef.tif'))
 5 c  = MT.iathreshad(a,uint8(10))
 6 d  = MT.iaareaclose(c,200)
 7 e  = MT.iagradm(d,MT.iasecross(1),MT.iasebox(9))
 8 f  = MT.iaero(d,MT.iasecross(95))
 9 g  = MT.iaunion(e,f)
10 h  = MT.iagradm(MT.iaclose(a))
11 ws = MT.iacwatershed(h,g);
12 
13 fig_a = MT.iaunion(MT.iagray(g),h)
14 fig_c = MT.iaintersec(MT.iagray(MT.ianeg(MT.iadil(ws))),a)
15 
16 adshow(MT.iapad(MT.ianeg(fig_a)), '(a) Inner and outer marker overlaid of gradient')
17 adshow(MT.iapad(MT.ianeg(ws)), '(b) Watershed line')
18 adshow(fig_c, '(c) Illustration of the watershed line')

(a) Inner and outer marker overlaid of gradient

(b) Watershed line

(c) Illustration of the watershed line