Hi guys,
Please remove me from this mailing list.

On Apr 3, 2017 5:18 PM, "Serge Shakhov via scikit-image" <
scikit-image@python.org> wrote:

> Hi Stefan,
>
> Thanks for your reply.
> My experience with scikit-image just started with this script, I'm not
> experienced at all.
> Here is the test script:
>
> import skimage.transform
> import matplotlib.pyplot as plt
> from PIL import Image
> from skimage import data
> from skimage.transform import resize
> from skimage.transform import rescale
> import numpy as np
> import os
> from skimage import io
>
> srcIm = data.checkerboard()
> src = np.array([[(0,0),(100,0),(110,0)],[(0,110),(100,110),(110,110)]])
> dst = np.array([[(0,0),(50,0),(70,0)],[(0,20),(60,50),(100,100)]])
>
> src = src.astype(float)
> dst = dst.astype(float)
>
> #revert to 1D list
> src = src.reshape(((src.shape[0]*src.shape[1]),2), order='F')
> dst = dst.reshape(((dst.shape[0]*dst.shape[1]),2), order='F')
>
> #Perform transform
> piecewiseAffine = skimage.transform.PiecewiseAffineTransform()
> piecewiseAffine.estimate(src,dst)
> dstArr = skimage.transform.warp(srcIm, piecewiseAffine, order=1, 
> mode='constant', cval=0, clip=False, preserve_range=False)
>
> #Visualise result
> dstArr = np.array(dstArr * 255., dtype=np.uint8)
>
> dstIm = Image.fromarray(dstArr)
> dstIm.show()
>
> Could you help me and point to what I have to modify here?
>
> If I reverse the piecewiseAffine.estimate(src,dst)
> -->> piecewiseAffine.estimate(dst, src)
> I can get the opposite transformation and it's not cropped, but not the
> one I need.
>
> Thanks.
>
>
> Best regards,
> Serge Shakhov.
>
>
> On Tuesday, 4 April 2017, 3:56, Stefan van der Walt <stef...@berkeley.edu>
> wrote:
>
>
> 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([[0, 0],
>                     [0, r],
>                     [c, 0],
>                     [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).inversepano0_warped = warp(image, 
> shifted_transform, order=3,
>                     output_shape=output_shape, cval=-1)
>
>
> Let us know how that goes!
>
> Stéfan
>
>
> _______________________________________________
> scikit-image mailing list
> scikit-image@python.org
> https://mail.python.org/mailman/listinfo/scikit-image
>
>
>
>
> _______________________________________________
> scikit-image mailing list
> scikit-image@python.org
> https://mail.python.org/mailman/listinfo/scikit-image
>
>
_______________________________________________
scikit-image mailing list
scikit-image@python.org
https://mail.python.org/mailman/listinfo/scikit-image

Reply via email to