def diamond(radius, dtype=np.uint8):
 L = np.arange(0, ((radius * 2) + 1))
 (I, J) = np.meshgrid(L, L)
 return np.array(((np.abs((I - radius)) + np.abs((J - radius))) <= radius), dtype=dtype)

def diamond ( radius , dtype = np . uint8 ) : L = np . arange ( 0 , ( ( radius * 2 ) + 1 ) ) ( I , J ) = np . meshgrid ( L , L ) return np . array ( ( ( np . abs ( ( I - radius ) ) + np . abs ( ( J - radius ) ) ) <= radius ) , dtype = dtype )
generates a flat .