2013-09-23 180 views
1

背景:打印圖像

我在MATLAB編程SIFT。我計算了高斯差分並將它們存儲在二維單元陣列中。第2列中的圖像是第1列的一半,依此類推。

問題。

現在,我已經將所有圖像存儲在我的2D單元格陣列中,我希望將它們全部打印在一個圖中。

我一直在瀏覽網頁的相當多,但我還沒有看到任何可以幫助。如果任何人都能指出我正確的方向或者提供一個例子,那麼它將會受到極大的關注。

乾杯

回答

0

如果你想要一個非常簡單的解決方案,那麼只需製作一幅合成圖像並用高斯金字塔中的圖像填充區域即可。我已經爲我的案例給出了一個示例代碼,但需要針對您的代碼進行調整。

代碼:

% Get total width and height  
width_total = 0;      
height_total = 0;    
for i = 0:3 % Cycle over scales - 4 total 
    width_total = width_total+size(obj.gaussianpyramid{i+1,1},2); 
    height_total = height_total+size(obj.gaussianpyramid{i+1,1},1); 
end 

% Form composite gaussian 
compositegaussian = zeros(width_total,height_total); 

ind_x = 0; 
for i = 0:3 % Cycle over octaves - 4 total     
    for j = 0:4 % Cycle over scales - 5 total 
     ind_y = j*size(obj.gaussianpyramid{i+1,j+1},1); 
     compositegaussian(ind_y+1:ind_y+size(obj.gaussianpyramid{i+1,j+1},1),ind_x+1:ind_x+size(obj.gaussianpyramid{i+1,j+1},2)) = obj.gaussianpyramid{i+1,j+1}; 
    end 
    ind_x = ind_x + size(obj.gaussianpyramid{i+1,1},2); 
end 

figure, imshow(compositegaussian,[]); 

輸出:

enter image description here

0

允許生成隨機5x2單元陣列,其中第一列包含10×10的圖像和所述第二 - 5×5的圖像:

c = cell(5,2); 
for k=1:5 
    c{k,1} = uint8(255 * rand(10)); 
    c{k,2} = uint8(255 * rand(5)); 
end 

下面的代碼說明它們:

figure; 
n = size(c, 1); 
for k = 1 : n 
    subplot(n, 2, k * 2 - 1); 
    image(c{k,1}); 
    subplot(n, 2, k * 2); 
    image(c{k,2});  
end 

如果圖像顛倒,在每次調用image()後使用set(gca,'YDir','normal');