当前位置:   article > 正文

python transformat_python:skimage.transform.AffineTransform旋转中心

tf similaritytransform旋转点

Stefan答案中的图像中心似乎不正确,下面是他的代码的正确版本from skimage import transform

import numpy as np

import matplotlib.pyplot as plt

image = np.zeros([21, 21])

image[10,:] = 1

image[10,10] = 5

image[7, 10] = 1

shift_y, shift_x = (np.array(image.shape)-1) / 2.

tf_rotate = transform.SimilarityTransform(rotation=np.deg2rad(60))

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, order = 3)

plt.subplot(121)

plt.imshow(image)

plt.subplot(122)

plt.imshow(image_rotated)

plt.show()

print "original image maximum at: ", np.unravel_index(np.argmax(image), image.shape)

print "rotated image maximum at : ", np.unravel_index(np.argmax(image_rotated), image_rotated.shape)

原始图像最大值为:(10,10)

旋转图像的最大值为:(10,10)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/86798
推荐阅读
相关标签
  

闽ICP备14008679号