[ialog] [Up] [iarectangle] Image Creation

iacomb
Create a grid of impulses image.

Synopsis

g = iacomb( s, delta, offset )

Implemented in Python.

Input

s Image. Gray-scale (uint8 or uint16) or binary image (logical).

output image dimensions (1-D, 2-D or 3-D).

delta Image. Gray-scale (uint8 or uint16) or binary image (logical).

interval between the impulses in each dimension (1-D, 2-D or 3-D).

offset Image. Gray-scale (uint8 or uint16) or binary image (logical).

offset in each dimension (1-D, 2-D or 3-D).

Output

g Image. Gray-scale (uint8 or uint16) or binary image (logical).

Examples


>>> u1 = iacomb(10, 3, 2)

              
>>> print u1
[0 0 1 0 0 1 0 0 1 0]

>>> u2 = iacomb((7,9), (3,4), (3,2))

              
>>> print u2
[[0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 1 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 1 0 0]]

>>> u3 = iacomb((7,9,4), (3,4,2), (2,2,1))

              
>>> print u3[:,:,0]
[[0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]]
>>> print u3[:,:,1]
[[0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 1 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 1 0 0]
 [0 0 0 0 0 0 0 0 0]]
>>> print u3[:,:,2]
[[0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]]
>>> print u3[:,:,3]
[[0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 1 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 1 0 0 0 1 0 0]
 [0 0 0 0 0 0 0 0 0]]

Equation

1-D
Multidimensional

Source Code

def iacomb(s, delta, offset):
    from Numeric import asarray, product, zeros
    s = asarray(s)
    if product(s.shape) == 1:
        g = zeros(s) 
        g[offset::delta] = 1
    elif len(s) >= 2:
        g = zeros((s[0], s[1]))
        g[offset[0]::delta[0], offset[1]::delta[1]] = 1
    if len(s) == 3:
        aux = zeros(s)
        for i in range(offset[2], s[2], delta[2]):
            aux[:,:,i] = g
        g = aux
    return g
    

See also

iaptrans Periodic translation.
[ialog] [Up] [iarectangle] http://www.python.org