Function iacomb

namespace:ia636
page:iacomb

Synopse

Create a grid of impulses image.

  • g = iacomb(s, delta, offset)
    • g: Image.
    • s: Image. output image dimensions (1-D, 2-D or 3-D).
    • delta: Image. interval between the impulses in each dimension (1-D, 2-D or 3-D).
    • offset: Image. offset in each dimension (1-D, 2-D or 3-D).
01. from numpy import *
02. 
03. def iacomb(s, delta, offset):
04. 
05.     s = asarray(s)
06.     if product(s.shape) == 1:
07.         g = zeros(s)
08.         g[offset::delta] = 1
09.     elif s.size >= 2:
10.         g = zeros((s[0], s[1]))
11.         g[offset[0]::delta[0], offset[1]::delta[1]] = 1
12. 
13.     if s.size == 3:
14.         aux = zeros(s)
15.         for i in range(offset[2], s[2], delta[2]):
16.             aux[:,:,i] = g
17.         g = aux
18.     return g

Examples

Example 1

1. from ia636 import iacomb
2. 
3. u1 = iacomb(10, 3, 2)
4. print u1
[ 0.  0.  1.  0.  0.  1.  0.  0.  1.  0.]

Example 2

1. u2 = iacomb((7,9), (3,4), (3,2))
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.]]

Example 3

1. u3 = iacomb((7,9,4), (3,4,2), (2,2,1))
2. print u3[:,:,0]
3. print u3[:,:,1]
4. print u3[:,:,2]
5. print u3[:,:,3]
[[ 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.  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.]]
[[ 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.  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