我有一张背景图片和一个带有每个向量的单独颜色信息的向量场,我想将其绘制在背景图片上:
% Random background image
Image = rand(100,200);
% Random colors
color1 = rand(30,30);
color2 = rand(30,30);
color3 = rand(30,30);
% Positions
x = 31:60;
y = 31:60;
[X,Y] = meshgrid(x,y);
% Random vectors
DX = 10 * rand(30,30);
DY = 20 * rand(30,30);
% The vector at (X(i,j),Y(i,j)) is supposed
% to have the RGB color [color1(i,j) color2(i,j) color3(i,j)]
% Uniformly colored vector field - works fine
imshow(Image);
hold on;
quiver(X,Y,DX,DY,'color',[0.5 0.75 1]);
% What I would like - does not work
imshow(Image);
hold on;
quiver(X(:),Y(:),DX(:),DY(:),'color',[color1(:) color2(:) color3(:)]);
一个简单的for循环会导致背景图像被擦除,如在此处所述,至少对于Matlab版本R2012b (8.0.0.783)是如此。
有什么想法吗?
refresh(gcf)
来刷新图形... - beesleep