I have a background image and a vectorfield with an individual color information for each vector which I want to plot over the background image:
% 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(:)]);
A simple for-loop leads to an erasure of the background image as noted in: Image gradually erased when overlayed with lines, at least for Matlab version R2012b (8.0.0.783).
Any ideas?