def interleave_planes(ipixels, apixels, ipsize, apsize):
 itotal = len(ipixels)
 atotal = len(apixels)
 newtotal = (itotal + atotal)
 newpsize = (ipsize + apsize)
 out = array(ipixels.typecode)
 out.extend(ipixels)
 out.extend(apixels)
 for i in range(ipsize):
  out[i:newtotal:newpsize] = ipixels[i:itotal:ipsize]
 for i in range(apsize):
  out[(i + ipsize):newtotal:newpsize] = apixels[i:atotal:apsize]
 return out

def interleave_planes ( ipixels , apixels , ipsize , apsize ) : itotal = len ( ipixels ) atotal = len ( apixels ) newtotal = ( itotal + atotal ) newpsize = ( ipsize + apsize ) out = array ( ipixels . typecode ) out . extend ( ipixels ) out . extend ( apixels ) for i in range ( ipsize ) : out [ i : newtotal : newpsize ] = ipixels [ i : itotal : ipsize ] for i in range ( apsize ) : out [ ( i + ipsize ) : newtotal : newpsize ] = apixels [ i : atotal : apsize ] return out
interleave planes .