How to plot individually colored vectors over a background image in matlab? -


i have background image , vectorfield individual color information each vector want plot on 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); % vector @ (x(i,j),y(i,j)) supposed % have 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]);  % - not work imshow(image); hold on; quiver(x(:),y(:),dx(:),dy(:),'color',[color1(:) color2(:) color3(:)]); 

a simple for-loop leads erasure of background image noted in: image gradually erased when overlayed lines, @ least matlab version r2012b (8.0.0.783).

any ideas?

the first problem have code is

color1 = rand(30,30); color2 = rand(30,30); color3 = rand(30,30); (...) quiver(x,y,dx,dy,'color',[color1 color2 color3]); 

even assuming quiver can take multiple colors (more on below) last argument passing 30x90 array. don't see how expect matlab guess how breaks 3 30x30 arrays (red, green, blue). usually, way pass color data rgb matrix give nx3 vector n points.

more point though, not expect quiver able accept multiple color arguments. (i cannot test right now.) see properties page, in particular "color" tab, , compare same scatter properties' "cdata".

i fail see proper fix problem, since @ bottom there apparent inability in matlab plot vectors of different colors same call. if plotting vectors in uniform color , adding scatter of various colors @ starting points of them enough you, go it... otherwise have @ source code of this: not doing want, maybe can adapted.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -