Figure 1.1 - Probing an image
The basic idea, arising out of stereology, is to probe an image with a structuring element and to quantify the manner in which the structuring element fits (or does not fit) within the image. In Fig. 1.1 we see a binary image and a square structuring element (probe). The structuring element is placed in two different positions. In one location it fits; in the other it does not fit. By marking the locations at which the structuring element fits within the image, we derive structural information concerning the image.
1 import numpy as np 2 import ia870 as MT 3 from handson.lib import draw_se_axis 4 5 F = adreadgray('MVBook/blob_1.png') > 0 6 7 B = MT.iasebox(25) 8 Z = MT.iasubm(F,F) 9 Z[ 80,120] = 1 10 Z[160,240] = 1 11 T = MT.iasymdif(MT.iadil(Z, B), MT.iadil(Z)) 12 G = MT.iasymdif(F, MT.iagradm(T)) 13 14 Z = MT.iasubm(F,F) 15 Z[80,120] =255 16 Z[160,240]=255 17 Z1 = MT.iadil(Z) 18 Z2 = MT.iadil(Z,B) 19 20 T = MT.iasymdif(Z2,Z1) 21 E = MT.iagradm(T) 22 23 G = MT.iasymdif(F,E) 24 adshow(MT.ianeg(G), '(a) Probing an image') 25 26 se = MT.iaseshow(B) 27 se = draw_se_axis(se) 28 adshow(MT.ianeg(se), title='(b) square probe.')