Applying a vector field to image in matlab

谁都会走 提交于 2021-01-28 04:07:29

问题


How do I apply a vector field obtained via quiver, to an image which causes the pixels to displace in the direction of the vectors (image is warped)?

Also, if the vector field I have is 3 dimensional, how would I do this? Think of it as laying down a flat 2 dimensional image over a 3 dimensional terrain. How would I go about viewing this in matlab?

Thank you for your time

EDIT: I have to warp the image not just in the Z axis, but along the X and Y axes as well.


回答1:


Laying down a flat 2 dimensional image over a 3 dimensional terrain:

It's not very clear the way the axes are oriented but this is an image of a clown mapped on the peaks function. Exact steps are described in the documentation of surface in the example 'Display image along surface plot.'

load clown
C = flipud(X);
figure
surface(XD,YD,ZD,C,...
    'FaceColor','texturemap',...
    'EdgeColor','none',...
    'CDataMapping','direct')
colormap(map)
view(-35,45)

Essentially, you create your surface with CData as the image you want to be displayed and set an appropriate colormap for the axes.




回答2:


Use the imwarp function in the Image Processing Toolbox.



来源:https://stackoverflow.com/questions/34551379/applying-a-vector-field-to-image-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!