ntg*_*ntg 4 python rotation scikit-image
我正在尝试在 python 中使用 skimage 来旋转图像,在 opencv 中,似乎我可以这样做:
cv.GetRotationMatrix2D(center, angle, scale, mapMatrix)
Run Code Online (Sandbox Code Playgroud)
其中 center 是源图像中的旋转中心。
在 skimage 中,相应的转换似乎是skimage.transform.AffineTransform:
skimage.transform.AffineTransform(matrix=None, scale=None, rotation=None, shear=None, translation=None)
Run Code Online (Sandbox Code Playgroud)
但我无法如何定义旋转中心......是否可以在此定义旋转中心(或者也许还有另一种 skimage 方法?)
我检查了网络和手册,到目前为止没有发现任何信息......
目前可以通过组合以下转换来实现:
然而,单个参数将使这变得更容易!您能否在 GitHub 上提交问题以便我们实现此功能?
同时,代码:
from skimage import data
from skimage import transform
import numpy as np
import matplotlib.pyplot as plt
image = data.chelsea()
shift_y, shift_x = np.array(image.shape[:2]) / 2.
tf_rotate = transform.SimilarityTransform(rotation=np.deg2rad(30))
tf_shift = transform.SimilarityTransform(translation=[-shift_x, -shift_y])
tf_shift_inv = transform.SimilarityTransform(translation=[shift_x, shift_y])
image_rotated = transform.warp(image, (tf_shift + (tf_rotate + tf_shift_inv)).inverse)
plt.imshow(image_rotated)
plt.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9614 次 |
| 最近记录: |