Texture map for a 2D grid

前端 未结 4 576
名媛妹妹
名媛妹妹 2021-02-06 15:56

I have a set of points [x,y]=meshgrid(1:N,1:M) defined on a regular 2D, N x M grid. I have another set of points [u,v] that are some defor

4条回答
  •  再見小時候
    2021-02-06 16:28

    It seems that you can use tformfwd and tforminv with a small twist to get f.

    tformfwd transforms points from input space to output space. For example, to apply an affine transform to the point (u,v) = (5,3), you can do this:

    uv = [5 3];
    xy = tformfwd(tform, uv)
    

    This will out put the (x,y) coordinates given tform

    Similarly, tforminv transforms points from output space to input space. If we apply the inverse transformation to the point xy computed above, we should get back the original point.

    uvp = tforminv(tform, xy)
    uvp =
         5     3
    

    So, you can use this machinery to map points by the forward and inverse geometric transformation.

    If you are using R2013a and later, you can use the transformPointsForward and transformPointsInverse methods of the geometric transformation classes (e.g. affine2d, projective2d), and also consider imwarp.

提交回复
热议问题