Demo iadflatzone

Flat-zone image simplification by connected filtering.


This experiment illustrates the flat zone extension property of connected filters. The flat zones of an image is the set of the largest connected components with identical intensity values. The main property of the connected filter is that every flat zone of the input image is included in a flat zone of the output image. This example was kindly provided by Prof. Jose Crespo from Facultad de Informatica of Universidad Politecnica de Madrid and adapted from [CSS98].



The input image is read.

1. a = adreadgray('cameraman.tif')
2. adshow(a)

Flat zone computation

Obtain the flat zones (8-connectivity) and compute its number. The number of flat zones is determined by the maximum labeling value (starting from flat zone one).

1. import ia870 as MT
3. b = MT.ialabelflat(a,MT.iasebox())
4. nfz = b.max()
5. print 'regions=',nfz
6. adshow(a)
7. adshow(MT.iaglblshow(b))
regions= 43268

Flat zone extension using connected filter

Apply the alternating sequential filter by reconstruction with increasing sizes. They constitute a connected pyramid.

1. t = time.time()
2. c=MT.iaasfrec(a,'CO',MT.iasebox(),MT.iasebox(),2)
3. print 'time:',time.time()-t,'seconds'
4. adshow(c)
time: 3.22969317436 seconds

1. t = time.time()
2. d=MT.iaasfrec(a,'CO',MT.iasebox(),MT.iasebox(),4)
3. print 'time:',time.time()-t,'seconds'
4. adshow(d)
time: 5.5480530262 seconds

1. t = time.time()
2. e=MT.iaasfrec(a,'CO',MT.iasebox(),MT.iasebox(),16)
3. print 'time:',time.time()-t,'seconds'
4. adshow(e)
time: 23.5272181034 seconds

Flat zone visualization and counting

These figures show the image simplification in a connected pyramid. Notice how the shapes are well preserved along the scale space. The number of flat zones at each level of the pyramid are computed to illustrate the flat zone number reduction.

1. c_lab=MT.ialabelflat(c,MT.iasebox())
2. d_lab=MT.ialabelflat(d,MT.iasebox())
3. e_lab=MT.ialabelflat(e,MT.iasebox())
4. print c_lab.max()
5. print d_lab.max()
6. print e_lab.max()
7. adshow(MT.iaglblshow(c_lab))
8. adshow(MT.iaglblshow(d_lab))
9. adshow(MT.iaglblshow(e_lab))

Flat zone inclusion property

In this experiment we select a particular flat zone, the flat zone to which the pixel (90,60) belongs, and display it at each level of the connected pyramid. Notice the flat zone inclusion property.

1. from ia870 import iagshow
3. c_v=c_lab[89,59]
4. c_flat = (c_lab == c_v)
5. d_v = d_lab[89,59]
6. d_flat = (d_lab == d_v)
7. e_v = e_lab[89,59]
8. e_flat = (e_lab == e_v)
9. adshow(MT.iagshow(a,e_flat,d_flat,c_flat))

See Also


  • [CSS98] J. Crespo and R. Schafer and J. Serra and C. Gratin and F. Meyer. The flat zone approach: A general low-level region merging segmentation method. Signal Processing; 62:37-60, 1998.