2014-02-15 18 views
0

我有一個形象的標記像素和我選擇,我希望把一個標記上他們10個像素狀況做了一個形象

rasterpoints = xlsread('coordinates_sat3.xlsx'); %# 10 pair of coordinates of pixels on my image 

diff_win_spr %# 10x1 vector with positive and negative values 

現在我想不同的一種標誌物在我的形象插入根據在diff_win_spr的cellvalue是正或負

marker1 = 'o'; 
marker2 = '+'; 

for ii=1:10 
    if diff_win_spr(ii)<0; 
     for ii=1:10; 
     rastermarkers=insertMarker(a,rasterpoints(ii,:),marker1,'size', 10);%%% if diff_win_spr is negative I want marker1 in the rasterpoint position on the image a 
     end 
    else diff_win_spr(ii)>0; 
     for ii=1:10; 
     rastermarkers=insertMarker(a,rasterpoints(ii,:),marker2,'size', 10);%%% if diff_win_spr is positive I want marker2 in the rasterpoint position on the image a 
     end 
    end 
end 

我的輸出圖像只顯示我的第10個標記(用正確的符號bytheway)

c=imshow(rastermarkers) 
%imwrite(b,'sat_mark.tif','WriteMode','append'); 

回答

1

您在每次迭代時重寫rastermarkers,使用與輸入相同的未修改圖像。你的代碼更改爲:現在

marker1 = 'o'; 
marker2 = '+'; 

for ii=1:10 
    if diff_win_spr(ii)<0; 
     a=insertMarker(a,rasterpoints(ii,:),marker1,'size', 10); 
    else diff_win_spr(ii)>0; 
     a=insertMarker(a,rasterpoints(ii,:),marker2,'size', 10); 
    end 
end 

你的輸出a

+0

感謝...這是一個此症,但現在我的輸出圖像是10 MARKER1 10 MARKER2 overwrited。你懷疑爲什麼? 它看起來像條件​​不起作用。 – rochinha44

+0

@ rochinha44:我看到第一個錯誤,並沒有完成讀取你的代碼,假設只有一個。你有兩個嵌套循環,都使用相同的迭代器'ii'。這是不對的。我會更新我的答案。 – Daniel

相關問題