Superimposing a Quiver plot over an Image
34 次查看(过去 30 天)
显示 更早的评论
Hello, I have an Quiver plot I want to superimpose over a color mapped image. i.e. The image was developed with the use of the ind2rgb so it is a nxmx3 matrix. Any suggestions?? Thanks in advance!
2 个评论
Gautam Mohan
2016-6-2
Hi,
A technique you could use would be to plot the image on a fixed axis, and then plot the quiver on the same axis afterwards, ensuring that hold is on (using the command 'hold on') to plot the quiver on top of the image.
Here is an example:
(I have taken an arbitrary quiver plot from a doc example and plotted it over a default image in MATLAB. This example should generalize to whatever quiver plot and image data is required.)
im = imread('autumn.tif');
[x,y] = meshgrid(-2:.2:2,-1:.15:1);
z = x .* exp(-x.^2 - y.^2); [px,py] = gradient(z,.2,.15);
quiver(x,y,px,py); axis image %plot the quiver to see the dimensions of the plot
hax = gca; %get the axis handle
image(hax.XLim,hax.YLim,im); %plot the image within the axis limits
hold on; %enable plotting overwrite
quiver(x,y,px,py) %plot the quiver on top of the image (same axis limits)
Note that if you already know the axis limits beforehand, you can set them and omit the first quiver plot. The only reason I plotted quiver first was to obtain the limits (which can sometimes be slightly greater than normal to account for the space the arrows take up).
Hope this helps!
Marco A. Acevedo Z.
2021-4-6
First, use imshow(img) and then hold on and use quiver(X, Y, U, V). Remember to set axis(equal). The xlim are automatically set afaik. Cheers,
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!