def trapzWarp(pic, cx, cy, ismask=False):
 (Y, X) = pic.shape[:2]
 src = np.array([[0, 0], [X, 0], [X, Y], [0, Y]])
 dst = np.array([[(cx * X), (cy * Y)], [((1 - cx) * X), (cy * Y)], [X, Y], [0, Y]])
 tform = tf.ProjectiveTransform()
 tform.estimate(src, dst)
 im = tf.warp(pic, tform.inverse, output_shape=(Y, X))
 return (im if ismask else (im * 255).astype('uint8'))

def trapzWarp ( pic , cx , cy , ismask = False ) : ( Y , X ) = pic . shape [ : 2 ] src = np . array ( [ [ 0 , 0 ] , [ X , 0 ] , [ X , Y ] , [ 0 , Y ] ] ) dst = np . array ( [ [ ( cx * X ) , ( cy * Y ) ] , [ ( ( 1 - cx ) * X ) , ( cy * Y ) ] , [ X , Y ] , [ 0 , Y ] ] ) tform = tf . ProjectiveTransform ( ) tform . estimate ( src , dst ) im = tf . warp ( pic , tform . inverse , output_shape = ( Y , X ) ) return ( im if ismask else ( im * 255 ) . astype ( 'uint8' ) )
complicated function .