In [1]:
%matplotlib inline
from numpy import *
from scipy.misc import imsave
import matplotlib.pyplot as plt

In [6]:
nr = 500
nc = 500

# create a color image
a = zeros((nr,nc,3),dtype=uint8)
# for convenience, set up views into each color layer
red   = a[:,:,0]
green = a[:,:,1]
blue  = a[:,:,2]

# set a vertical strip to some color say red
red[:,30:50] = 155
blue[120:220,:] = 255
plt.imshow(a,interpolation='none');

In [8]:
nr = 500
nc = 500

# create a color image
a = zeros((nr,nc,3),dtype=uint8)
# for convenience, set up views into each color layer
red   = a[:,:,0]
green = a[:,:,1]
blue  = a[:,:,2]

# set a vertical strip to some color say red
red[:,30:50] = 155
blue[120:220,:] = 255

m = zeros((nr,nc,3),dtype=bool)
return m

plt.imshow(a,interpolation='none');

In [39]:
def mask(nr,nc):
m = zeros((nr,nc,3),dtype=bool)
for i in range(nr):
m[i,array(mod(i+arange(nc),2),dtype=bool)] = 1
return m

m = zeros((nr,nc,3),dtype=bool)
for i in range(nr):
m[i,array((i+arange(nc))//l % 2,dtype=bool),:] = 1
return m

#m[10,10,:] = True
plt.imshow(m,interpolation='none');

In [20]:
array(arange(10)%2,dtype=bool)

Out[20]:
array([False,  True, False,  True, False,  True, False,  True, False,  True], dtype=bool)
In [25]:
mod(3+arange(10),2)

Out[25]:
array([1, 0, 1, 0, 1, 0, 1, 0, 1, 0])
In [33]:
array(arange(10)//3 % 2,dtype=bool)

Out[33]:
array([False, False, False,  True,  True,  True, False, False, False,  True], dtype=bool)