skewing or shearing an image in python

前端 未结 1 565
生来不讨喜
生来不讨喜 2021-02-06 15:06

I need to shear and skew some images using python. I\'ve come across this skimage module but I don\'t seem able to understand exactly how I\'m supposed to use this.

I\'v

相关标签:
1条回答
  • 2021-02-06 15:32

    If you want to use the skimage module the order of operations are:

    • Load image or define data to work with
    • Create the transformation you want
    • Apply the transformatioin

    A work flow might look like the following:

    from skimage import io
    from skimage import transform as tf
    
    # Load the image as a matrix
    image = io.imread("/path/to/your/image.jpg")
    
    # Create Afine transform
    afine_tf = tf.AffineTransform(shear=0.2)
    
    # Apply transform to image data
    modified = tf.warp(image, inverse_map=afine_tf)
    
    # Display the result
    io.imshow(modified)
    io.show()
    

    The AffineTransform class from the skimage module accepts a transformation matrix as its first parameter (which the class constructs if you instead use the other parameters).

    0 讨论(0)
提交回复
热议问题