Demo iadarea

Remove objects with small areas in binary images.

Description

In this example, the image of an electric circuit diagram is processed. The circuit diagram image is composed of two kinds of objects: the circuit itself, that has a large area, and the letters, that have small areas. Eliminating all the objects that have area less than 200, we get the image that contains only the circuit diagram.

Script

Reading

The binary image to be processed is read.

1. a = adreadgray('circuit_bw.tif') > 0
2. adshow(a)

Filtering

The procedure areaopen removes the objects with area less than the specified parameter (i.e., 200).

1. from ia870 import iaareaopen
2. 
3. b = iaareaopen(a,200)
4. adshow(b)

Final display

For displaying purposes the filtered image is superposed over the original image.

1. from ia870 import iagshow
2. adshow(iagshow(a,b))