How to use im2warp with displacement field

A manual of im2warp function says that
B = imwarp(A,D) transforms the input image A according to the displacement field defined by D.
So my goal is to warp A define dy
A = [1 0 0 0;0 0 0 0;0 0 0 0; 0 0 0 0];
The displacement is given by
uu = zeros(4,4,2);
uu(1,1,1) = 3;
uu(1,1,2) = 1;
I use the function
imwarp(A,uu,'nearest')
My expected result is
A_res = [0 0 0 0;0 0 0 0;0 0 0 0; 0 0 0 1];
However, the result is
>> imwarp(A,uu,'nearest')
ans =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
How to use imwarp with displacement?

Risposte (1)

Image Analyst
Image Analyst il 25 Dic 2015
Use imtranslate() - it's easier.

3 Commenti

Actually, my goal is to warp original region to another region. (Given by a displacement through optical flow estimation)
Even if I can translate a region, the warped region is very sparse. Although I use interpolation function, it doesn't work because in the outside of region, there is no displacement.
You're going to have to figure out how to warp the one arbitrarily-shaped region from image #1 into another arbitrarily-shaped region like in image #2. This might apply to the whole image but you're going to have to mask it to replace the pixels you didn't want to warp with the original pixels.
I just want to warp binary image representing the region in question. I have lost how to warp the binary region given a displacement defined only within region.
I tried using singed distance function, but it also doesn't work.
Thanks for your comment. I will think about it.

Accedi per commentare.

Categorie

Scopri di più su Read, Write, and Modify Image in Centro assistenza e File Exchange

Richiesto:

il 25 Dic 2015

Commentato:

il 26 Dic 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by