[scikit-image] How to see full image after transformation not the cropped one
Stefan van der Walt
stefanv at berkeley.edu
Mon Apr 3 11:55:55 EDT 2017
Hi Serge
On Sun, Apr 2, 2017, at 15:30, Serge Shakhov via scikit-image wrote:
> But I didn't find an answer.
> I'm doing 2D piecewise affine transformation with
> skimage.transform.PiecewiseAffineTransform
> Result image is heavily cropped.
> I tried to play with output_shape, mode and clip parameters but
> without any effect, image is still cropped.
> Could anyone point me what am I doing wrong?
I thought we had this implemented, but I guess not yet. You can
see how here:
https://github.com/scikit-image/skimage-tutorials/blob/master/lectures/adv3_panorama-stitching.ipynb
Specifically:
*from* *skimage.transform* *import* SimilarityTransform
*# Shape of middle image, our registration target* r, c = image.shape
*# Note that transformations take coordinates in (x, y) format,* *# not
(row, column), in order to be consistent with most literature* corners =
np.array([[, ], [, r], [c, ], [c, r]])
*# Warp the image corners to their new positions* warped_corners =
my_tf(corners)
*# The overall output shape will be max - min* corner_min =
np.min(corners, axis=0) corner_max = np.max(corners, axis=0)
output_shape = (corner_max - corner_min)
*# Ensure integer shape with np.ceil and dtype conversion* output_shape
= np.ceil(output_shape[::-1]).astype(int)
That calculates the shape you want. You now need to modify the
transform to output an image inside of this shape:
*from* *skimage.transform* *import* warp *
# This in-plane offset is the only necessary transformation for the
# middle image*
offset = SimilarityTransform(translation=-corner_min)
shifted_transform = (my_tf + offset).inverse pano0_warped = warp(image,
shifted_transform, order=3, output_shape=output_shape, cval=-1)
Let us know how that goes!
Stéfan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20170403/ef421789/attachment-0001.html>
More information about the scikit-image
mailing list