gpt4 book ai didi

python - 在 python 中倾斜或剪切图像

转载 作者:太空宇宙 更新时间:2023-11-03 12:33:05 30 4
gpt4 key购买 nike

我需要使用 python 剪切和倾斜一些图像。我遇到过this skimage module但我似乎无法准确理解我应该如何使用它。

我已经尝试了一些方法,但显然都出错了,因为后来我突然意识到,我并没有将我的图像传递给函数。然后我注意到该函数首先没有将我的图像作为输入参数。那么应该如何应用转换呢?还是为了倾斜或剪切图像,这甚至是正确的功能?

最佳答案

如果你想使用 skimage 模块,操作顺序是:

  • 加载图像或定义要使用的数据
  • 创建您想要的转换
  • 应用转换

工作流程可能如下所示:

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()

skimage 模块中的 AffineTransform 类接受 transformation matrix作为它的第一个参数(如果您改为使用其他参数,类将构造该参数)。

关于python - 在 python 中倾斜或剪切图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24191545/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com