0
我想加載一個圖像,然後創建一個Matrix
與圖像的大小。 矩陣應該是透明的,只有一些備用值(點)。 然後我想在圖中顯示圖像並將矩陣放在頂部。Matlab透明覆蓋矩陣
至今代碼:
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
我的基質含有一些要點:
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
它:
A(200,300) = 1;
A(500,500) = 5;
A(580,200) = 3;
如果我現在通過這樣的矩陣中的每個值迭代會很慢。
所以我想要做的是創建一個透明矩陣,然後設置一些點,以便我可以在原始圖像上打印矩陣。
這可能嗎?我怎麼做?有沒有更好的方法來做到這一點?
密切相關的問題:http://stackoverflow.com/questions/3842195/how-to-show-points-on-image-in-matlab – paisanco 2014-11-02 13:59:02
看看''gscatter()'' – Nras 2014-11-02 14:45:17
我覺得這個傢伙演示如何做到這一點:[圖片覆蓋使用透明度](http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/) – bdecaf 2014-11-02 16:29:40