【发布时间】:2014-11-02 13:48:41
【问题描述】:
我想加载一张图片,然后用图片的大小创建一个Matrix。
矩阵应该是透明的,只有一些备用值(点)。
然后我想在图中显示图像并将矩阵放在顶部。
到目前为止的代码:
world = imread('map1.jpg'); % import image of location
[x_world,y_world] = size(world); % get the size of the image
A = zeros(x_world,y_world); % create matrix with dimension of image
imshow(world); % display image
axis image; % label the axis
我的矩阵包含一些点:
A(200,300) = 1;
A(500,500) = 5;
A(580,200) = 3;
如果我现在像这样遍历矩阵中的每个值:
for i = 1:x_world
for j = 1:y_world
if(A(i,j) == 1)
plot(i,j,'r.','MarkerSize',20); % plot a single point
elseif(A(i,j) == 2)
plot(i,j,'y.','MarkerSize',20); % plot a single point
elseif(A(i,j) == 3)
plot(i,j,'m.','MarkerSize',20); % plot a single point
elseif(A(i,j) == 4)
plot(i,j,'g.','MarkerSize',20); % plot a single point
elseif(A(i,j) == 5)
plot(i,j,'b.','MarkerSize',20); % plot a single point
elseif(A(i,j) == 6)
plot(i,j,'w.','MarkerSize',20); % plot a single point
end
end
end
真的很慢。
所以我想做的是创建一个透明的矩阵,然后设置一些点,这样我就可以在原始图像上打印矩阵。
这可能吗?我怎么做?还有其他更好的方法吗?
【问题讨论】:
-
看看
gscatter() -
我认为这个人展示了如何做到这一点:Image overlay using transparency
标签: image matlab matrix transparent