def upsample_filt(size):
 factor = ((size + 1) // 2)
 if ((size % 2) == 1):
  center = (factor - 1)
 else:
  center = (factor - 0.5)
 og = np.ogrid[:size, :size]
 return ((1 - (abs((og[0] - center)) / factor)) * (1 - (abs((og[1] - center)) / factor)))

def upsample_filt ( size ) : factor = ( ( size + 1 ) // 2 ) if ( ( size % 2 ) == 1 ) : center = ( factor - 1 ) else : center = ( factor - 0.5 ) og = np . ogrid [ : size , : size ] return ( ( 1 - ( abs ( ( og [ 0 ] - center ) ) / factor ) ) * ( 1 - ( abs ( ( og [ 1 ] - center ) ) / factor ) ) )
make a 2d bilinear kernel suitable for upsampling of the given size .