tform.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:rasl 作者: welch 项目源码 文件源码
def imtransform(self, image, order=3, cval=0, *args, **kwargs):
        """tranform an image, with output image having same shape as input.

        This is implemented as an equivalent to MATLAB's
        imtransform(image, fliptform(tform)), to agree with the
        matrices generated by toolbox.parameters_to_projective_matrix.

        Note 1: It is *backwards* from the usual sense of tf.warp in skimage.

        Note 2: cval is not used during warping. boundaries are filled
        with NaN, and the transformed image has NaNs replaced with
        cval. This avoids made-up data at the expense of eroding
        boundaries.

        """
        # call warp with explicit matrix so we get the optimized behavior
        if not np.all(image == image):
            raise ValueError("NAN given to imtransform"+str(image))
        timage = tf.warp(image, self.params, order=order, mode='constant',
                         cval=np.nan, preserve_range=True,
                         output_shape=self.output_shape, *args, **kwargs)
        if cval == 0:
            timage = np.nan_to_num(timage)
        elif np.isfinite(cval):
            timage = np.where(np.isfinite(timage), timage, cval)
        return timage
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号