Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scikit图像中的Shift图像[Python]_Python_Image Processing_Scikit Image - Fatal编程技术网

Scikit图像中的Shift图像[Python]

Scikit图像中的Shift图像[Python],python,image-processing,scikit-image,Python,Image Processing,Scikit Image,我想让函数执行此操作,但它不存在: from skimage.transform import shift shifted = shift(image, translation=(15.2, 35.7), mode='wrap', preserve_range=True) 你能帮我用skimage.transform.AffineTransform编写一个函数吗? from skimage.transform import AffineTransform d

我想让函数执行此操作,但它不存在:

from skimage.transform import shift

shifted = shift(image, translation=(15.2, 35.7),
                mode='wrap', preserve_range=True)
你能帮我用skimage.transform.AffineTransform编写一个函数吗?

from skimage.transform import AffineTransform

def shift(image, translation):
    transform = AffineTransform(translation=translation)
    # How to do it???
    shifted = transform(image)   # Does not work, documentation for usage present
                                 # of this class is not present...
    return shifted

然而,函数
scipy.ndimage.interpolation.shift
实现了我想要的功能,速度非常慢,甚至比旋转慢10-20倍
numpy.roll
也不支持,因为它不支持分数翻译


文档有点吝啬:

这似乎有效。然而,如果有人知道更简单更快的方法,请告诉我

from skimage.transform import AffineTransform, warp

def shift(image, vector):
    transform = AffineTransform(translation=vector)
    shifted = warp(image, transform, mode='wrap', preserve_range=True)

    shifted = shifted.astype(image.dtype)