In [93]:
import numpy as np
import matplotlib.pyplot as plt

In [102]:
def put(T,b,offset=(0,0)):
ny,nx = b.shape
i,j = offset
T[i:i+ny,j:j+nx] = b

In [103]:
nx,ny = 10, 20
T = np.zeros( (ny,nx),dtype=np.int)
b = np.array([ [1,0],[1,0],[1,0],[1,1] ],dtype=np.int)

In [104]:
put(T,b,(0,2))
put(T,b,(ny-1-3,1))
put(T,b.T,(ny-1-3,5))
put(T,b.T[::-1,:],(ny-1-2,3))

In [130]:
plt.imshow(T)

Out[130]:
<matplotlib.image.AxesImage at 0x122e904e0>
In [153]:
np.sum(np.cumsum(T[10::-1,:],axis=0)>0,axis=0)

Out[153]:
array([0, 0, 4, 4, 0, 0, 0, 0, 0, 0])
In [152]:
np.max(np.sum(np.cumsum(T[10:,:],axis=0)>0,axis=0)+\
np.sum(np.cumsum(T[10::-1,:],axis=0)>0,axis=0))

Out[152]:
6
In [147]:
plt.imshow(np.cumsum(T[10::-1,:],axis=0)>0,extent=[0,nx,0,10])

Out[147]:
<matplotlib.image.AxesImage at 0x1236e4710>
In [143]:
plt.imshow(np.cumsum(T[10:,:],axis=0)>0,extent=[0,nx,0,10])

Out[143]:
<matplotlib.image.AxesImage at 0x1239213c8>
In [124]:
plt.imshow(np.cumsum(b[::,:],axis=0)>0)

Out[124]:
<matplotlib.image.AxesImage at 0x122980320>
In [ ]:


In [ ]:


In [ ]:


In [ ]: