torch / image

An Image toolbox for Torch.
Other
209 stars 141 forks source link

Flow field for warp function? #144

Open dasguptar opened 8 years ago

dasguptar commented 8 years ago

With respect to the flow parameter that has to be passed to the warp function, is there any proper way to obtain the flow field if I have an affine transformation matrix in mind? Basically, if I know the translation, rotation and scale parameters, how could I compute the flow field before passing it to the warp function? The test_warp.lua file is not clear in terms of how it arrives at the flow it uses.

dasguptar commented 8 years ago

@soumith @jonathantompson Any comments? Tagging you since you have commits on the image.warp function!

soumith commented 8 years ago

i always thought test_warp gave a pretty good example. These lines take a rotation matrix and apply it to an identity flowfield. Seems simple...: https://github.com/torch/image/blob/master/test/test_warp.lua#L103-L106

Similarly, i think you can matmul an affine transform matrix.

dasguptar commented 8 years ago

From what I could decipher, two things are being done:

My doubt/question is this: Why are two separate types of identity flowfields required for scaling/translation and rotation? The code uses flow_scale which varies from 0 to image dimension and flow_rot which is centered.

If I simply use one of these identity flowfields and do a matmul using an affine transform matrix, the results are incorrect. How is the flowfield supposed to be initialised in that case for a generic case?

chsasank commented 8 years ago

@dasguptar affinetransform is now added as a function. You can check its source to find out how to generate field for a given affine matrix.