我想結合matlab中的圖像數量。組合圖像的數量最多爲四個。我希望它們根據圖層的概念(如在Photoshop中)進行組合,而不是連接在一起。這意味着結果圖像的大小將與每個組合圖像的大小相同。有沒有一個matlab函數能夠正確執行這個任務?結合使用matlab的圖像數量
回答
試試這個:
img1 = imread...
img2 = imread...
img3 = imread...
img4 = imread...
combined_img(:,1) = img1;
combined_img(:,2) = img2;
combined_img(:,3) = img3;
combined_img(:,4) = img4;
現在你有,你可以通過combined_img的第三索引來訪問一個4分層圖像。 下面的命令將顯示第1圖像:
imshow(combined_img(:,1));
非常感謝您的幫助。我會嘗試代碼。希望能得到我想要的結果。 –
我假設圖像是灰度圖像。所以我的意思是他們只有兩個維度。也許你應該提供一些關於你想使用的圖像的信息。 –
是的圖像是灰色的,我試過了代碼,但沒有奏效。 –
這確實像你描述:
function imgLayers
% initialize figure
figure(1), clf, hold on
% just some random image (included with Matlab) to server
% as the background
img{1,1} = imresize(imread('westconcordaerial.png'), 4);
img{1,2} = [0 0];
% rotate the image and discolor it to create another image
img{2,1} = uint8(imresize(imrotate(img{1}, +12), 0.3)/2.5);
img{2,2} = [150 20];
% and another image
img{3,1} = uint8(imresize(imrotate(img{1}, -15), 0.5)*2.5);
img{3,2} = [450 80];
% show the stacked image
imshow(stack_image(img));
%% create new image, based on several layers
function newImg = stack_image(imgs)
% every image contained at a cell index (ii) is placed
% on top of all the previous ones (0:ii-1)
rows = cellfun(@(x)size(x,1),imgs(:,1));
cols = cellfun(@(x)size(x,2),imgs(:,1));
% initialize new image
newImg = zeros(max(rows(:)), max(cols(:)), 3, 'uint8');
% traverse the stack
for ii = 1:size(imgs,1)
layer = imgs{ii,1};
offset = imgs{ii,2};
newImg(offset(1)+(1:rows(ii)), offset(2)+(1:cols(ii)), :) = layer;
end
end
end
小心,雖然 - 沒有足夠的約束檢查等,所以你必須做有點發展自己。但它應該足以讓你開始:)
感謝您理解我描述的想法。我將嘗試理解上面的代碼並使其適用於我的情況。 –
- 1. Matlab適合圖形圖像
- 2. 將Matlab與Matlab結合使用
- 3. 使用向量係數的Matlab圖像過濾
- 4. Matlab imwarp,圖像不適合
- 5. 將圖像與PHP結合使用GD
- 6. 使用matlab編程數學圖像
- 7. Matlab - 圖像動量計算
- 8. 使用MATLAB比較圖像
- 9. 如何兩幅圖像的低頻和高頻結合在Matlab
- 10. 結合EXR圖像
- 11. Matlab圖像量化不起作用
- 12. jQuery - 結合變量和圖像src來替換圖像attr
- 13. 使用Fisher法matlab結合P值?
- 14. 如何將圖像滑塊與縮放圖像結合使用?
- 15. MATLAB:顯示擬合圖像的RGB值
- 16. matlab中兩幅圖像的融合
- 17. angular2 onError的圖像結合
- 18. 使用matlab將圖像轉換爲avi的奇怪結果
- 19. C#結合了大量的圖像 - WPF成像類
- 20. 將三幅灰度圖像與MATLAB結合爲RGB
- 21. 如何在一個窗口上結合兩個圖像matlab?
- 22. 通過使用Matlab讀取每幀圖像並使用Matlab顯示圖像
- 23. Matlab圖像 - 如何計算白色像素的數量
- 24. 使用ImageResizer結合使用圖像的安全服務
- 25. 如何使用MATLAB內插圖像上的矢量座標?
- 26. 使用MATLAB來計算連續圖像之間的偏移量
- 27. MATLAB:結合陣列
- 28. 量化matlab中的灰度圖像
- 29. 使用Matlab的圖像旋轉
- 30. 使用Matlab的壓縮率(圖像)
圖層就是這樣,圖層。如果所有圖像的大小相同,則在組合圖像中看到的只是最上層(即最後一張圖像),以防沒有透明度。現在,我假設你想要通過乘,加,減或其他類似操作來合併它們?如果是,具體哪個操作? –
其實我正在考慮這個想法來幫助我分割醫療組織圖像。 這個想法與flash(或photoshop)中圖層的概念類似。例如,您首先在單獨的圖層上添加背景圖像(例如海圖像),在此圖層上添加包含對象(例如船隻)的另一圖層,並在這兩層之上添加另一個包含星號的圖層作爲示例。最終結果(具有swf文件時)是包含所有對象的單個圖像,因爲它們位於不同位置(不應用透明度),所以這些對象都是可見的。 –