2014-11-02 3 views
0

이미지를로드 한 다음 이미지 크기를 Matrix으로 만들고 싶습니다. 매트릭스는 일부 예비 값 (포인트)만으로 투명해야합니다. 그런 다음 이미지를 그림으로 표시하고 매트릭스를 맨 위에 놓기를 원합니다.Matlab 투명 오버레이 매트릭스

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; 

:

지금까지의 코드는 :

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 

내 매트릭스는 몇 가지 포인트를 포함 정말 느릴 것입니다.

그래서 내가하고 싶은 것은 투명한 매트릭스를 만든 다음 몇 가지 포인트를 설정하여 원래 이미지 위에 매트릭스를 인쇄 할 수 있도록하는 것입니다.

그럴 수 있습니까? 어떻게해야합니까? 거기에 더 좋은 방법이 있을까요?

+0

자세히 관련 질문 : http://stackoverflow.com/questions/3842195/how-to-show-points-on-image-in-matlab – paisanco

+0

"gscatter()"를 살펴보십시오 – Nras

+0

나는 이것을 생각합니다. 사람이 이것을하는 방법을 보여줍니다 : [투명도를 사용하는 이미지 오버레이] (http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/) – bdecaf

답변

0

처음에는 6 개의 그룹을 반복하여 모든 행과 열을 반복하지 않아도됩니다. 속도가 문제가

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

경우, 당신은 아마 gscatter() 및 또는 sparse()에 모습을 가질 수 있습니다 코드 타격이 같은 결과를 제공해야합니다.