How to 'aggregate' a stack of images (picture 1) in matlab as in attached picture 2

1 回表示 (過去 30 日間)
BA
BA 2022 年 8 月 7 日
編集済み: Image Analyst 2022 年 8 月 9 日
I tried to use loop as below
for i = 1 : 10
imshow(df(:,:,i)) % Problem because df is the structure, not the 3-D array dff.
end
but it did not work.

採用された回答

Image Analyst
Image Analyst 2022 年 8 月 7 日
編集済み: Image Analyst 2022 年 8 月 9 日
% Take 10 fields of your structure called "df",
% and put into slices of a new 3-D image array called "dff":
[rows, columns] = size(df.x1);
% Preallocate space for the 3-D array dff
dff = zeros(rows, columns, 10, class(df.x1));
% Get fields of structure and put them into correspondingly-named slices of dff.
dff(:, :, 1) = df.x1; % Put the x1 image into slice1.
dff(:, :, 2) = df.x2; % Put the x2 image into slice2.
dff(:, :, 3) = df.x3; % Put the x3 image into slice3.
dff(:, :, 4) = df.x4; % Put the x4 image into slice4.
dff(:, :, 5) = df.x5; % Put the x5 image into slice5.
dff(:, :, 6) = df.x6; % Put the x6 image into slice6.
dff(:, :, 7) = df.x7; % Put the x7 image into slice7.
dff(:, :, 8) = df.x8; % Put the x8 image into slice8.
dff(:, :, 9) = df.x9; % Put the x9 image into slice9.
dff(:, :, 10) = df.x10; % Put the x10 image into slice10.
  2 件のコメント
BA
BA 2022 年 8 月 7 日
I did not get this. Could you please explain it?
Image Analyst
Image Analyst 2022 年 8 月 9 日
@Bilal Alsharif, see edits above. I've used your exact variable names (instead of general names) and added a lot more comments.

サインインしてコメントする。

その他の回答 (1 件)

yanqi liu
yanqi liu 2022 年 8 月 9 日
yes,sir,may be use eval and for loop to make the structer,such as
for i = 1:10
figure(i);
imshow(eval(sprintf('df.x%d', i)), [])
end

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by