[iacrop] [Up] [iatile] | Image Information and Manipulation |
Implemented in Python.
g | Image. Gray-scale (uint8 or uint16) or binary image (logical). |
>>> f = Numeric.array([[0,1,2],[3,4,5]], Numeric.UnsignedInt8)
>>> print f
[[0 1 2] [3 4 5]]
>>> g1 = iapad(f)
>>> print g1
[[0 0 0 0 0] [0 0 1 2 0] [0 3 4 5 0] [0 0 0 0 0]]
>>> g2 = iapad(f, (1,3), 5)
>>> print g2
[[5 5 5 5 5 5 5 5 5] [5 5 5 0 1 2 5 5 5] [5 5 5 3 4 5 5 5 5] [5 5 5 5 5 5 5 5 5]]
def iapad(f, thick=[1,1], value=0): from Numeric import asarray, ones, array f, thick = asarray(f), asarray(thick) g = (value * ones(array(f.shape)+2*thick)).astype(f.typecode()) g[thick[0]:-thick[0], thick[1]:-thick[1]] = f return g
iacrop | Crop an image to find the minimum rectangle. |
[iacrop] [Up] [iatile] | |