Saturday 15 September 2012

image - Matlab transparent overlay matrix -



image - Matlab transparent overlay matrix -

i want load image , create matrix size of image. matrix should transparent spare values (points). want show image in figure , set matrix on top.

the code far:

world = imread('map1.jpg'); % import image of location [x_world,y_world] = size(world); % size of image = zeros(x_world,y_world); % create matrix dimension of image imshow(world); % display image axis image; % label axis

my matrix contains points:

a(200,300) = 1; a(500,500) = 5; a(580,200) = 3;

if iterate through each value in matrix that:

for = 1:x_world j = 1:y_world if(a(i,j) == 1) plot(i,j,'r.','markersize',20); % plot single point elseif(a(i,j) == 2) plot(i,j,'y.','markersize',20); % plot single point elseif(a(i,j) == 3) plot(i,j,'m.','markersize',20); % plot single point elseif(a(i,j) == 4) plot(i,j,'g.','markersize',20); % plot single point elseif(a(i,j) == 5) plot(i,j,'b.','markersize',20); % plot single point elseif(a(i,j) == 6) plot(i,j,'w.','markersize',20); % plot single point end end end

it slow.

so want create transparent matrix , set points, can print matrix on original image.

is possible? how do that? there maybe improve way that?

as start, avoid looping on of theese rows , columns looping on 6 groups. code blow should give same result:

markers = {'r.', 'y.', 'm.', 'g.', 'b.', 'w.'}; % // define markers figure hold on grouping = 1:6 [i, j] = ind2sub(size(a), find(a==group)); % // find indices of current grouping plot(i, j, markers{group}, 'markersize', 20) % // plot them marker end

if speed issue, maybe can have @ gscatter() , or sparse().

image matlab matrix transparent

No comments:

Post a Comment