我有這些系列的二維CT圖像,我已經能夠使用「imread」將它們讀入Matlab中。然而,問題是我需要將圖像讀入爲單個3D矩陣,而不是一堆2D矩陣。我已經意識到可以將第二維圖層的數量作爲第三維來存儲,但我不知道如何做到這一點,因爲我仍然是學習者。 代碼我有用於在2D堆棧閱讀如下:如何在Matlab中將二維矩陣序列存儲到三維數組中?
a = dir('*.tif');
for i = 1: numel(a)
b = imread(a(i).name); %read in the image
b_threshold = graythresh(b); %apply threshold
b_binary = im2bw(b, b_threshold); %binarize image
[m, n] = size(b); %compute the size of the matrix
phi(i) = ((m*n) - sum((b_binary(:))))/(m*n); %compute the fraction of pore pixels in the image
phi(:,i) = phi(i); %store each of the above result
end
我添加只是一個單一的圖像,儘管這些中的一些是必要的。儘管如此,人們可以輕鬆地複製圖像以創建一堆2D圖像。要使代碼正常工作,重要的是按數字順序對它們進行重命名。 pore_image 歡迎任何幫助/建議/想法。謝謝!
我要記住(因爲你是新的),您可以接受的答案之一。所以請做到這一點,如果你欣賞他們 – Leos313