[hofig1s1a] [Up] [hofig1s3] Chapter 1 - Binary Erosion and Dilation

hoeq1s1
Bound matrix format

Description

This example illustrates the bound matrix format the pixel coordinates.

Demo Script

A binary matrix is created

A binary image is created using the mmbinary function.

from morph import *
S = mmbinary([
   [0,0,0,0,0],
   [0,0,1,0,0],
   [0,0,1,1,0],
   [0,0,1,1,0],
   [0,0,0,0,0]])
print S
[[0 0 0 0 0]
 [0 0 1 0 0]
 [0 0 1 1 0]
 [0 0 1 1 0]
 [0 0 0 0 0]]
E = mmbinary([
   [0,1,0],
   [1,1,1],
   [0,1,0]])
print E
[[0 1 0]
 [1 1 1]
 [0 1 0]]

Pixel coordinates

The image origin, with coordinates (0,0) is at the center. The first coordinate is the row number from top to bottom and the second coordinate is the column number from left to right.

Si,Sv = mmmat2set(S)
print Si
[[-1  0]
 [ 0  0]
 [ 0  1]
 [ 1  0]
 [ 1  1]]
Ei,Ev = mmmat2set(E)
print Ei
[[-1  0]
 [ 0 -1]
 [ 0  0]
 [ 0  1]
 [ 1  0]]

[hofig1s1a] [Up] [hofig1s3] http://www.python.org