フィルターのクリア

Cropping 3D image and save into mat files

1 回表示 (過去 30 日間)
Fadhurrahman
Fadhurrahman 2022 年 1 月 17 日
コメント済み: Fadhurrahman 2022 年 1 月 18 日
Greetings,
So i want to crop a 3D images with 5x5x8 and save every single 5x5x8 into a mat files. the output has a 5x5x8 in it.
is there any reference to do it?
here is my code
Thank you very much for helping.
clear
close all
clc
R1 = geotiffread('1.tif');
R2 = geotiffread('2.tif');
R3 = geotiffread('3.tif');
R4 = geotiffread('4.tif');
R5 = geotiffread('5.tif');
R6 = geotiffread('6.tif');
R7 = geotiffread('7.tif');
R8 = geotiffread('8.tif');
stackb = cat(3,R1, R2, R3, R4, R5, R6, R7,R8)
% stackc=cat(3,R1, R2, R3, R4, R5, R6, R7)
c = images.spatialref.Cuboid([1,5],[1,5],[1,8]);
croppedVolume = imcrop3(stackc,c);
[rows, columns, numberOfColorChannels] = size(stackb);
N = rows;
for i = 1:N
Icropped{i} = imcrop3(stackb,c);
end
save(name, 'Icropped')
  4 件のコメント
KSSV
KSSV 2022 年 1 月 18 日
They are in a cell, you can extract them by using {}.
Icroped{1}, Icropped{2},..etc.
Fadhurrahman
Fadhurrahman 2022 年 1 月 18 日
@KSSV thank you. i have a new problem for saving it
so i want to save these "DCrop" for every iteration. but in the end it only save a single file
here's the code
N = 1000;
name=sprintf('a_%3d')
for i = 1:N
stackc = squeeze(stackc);
targetSize = [5 5 7];
win = randomCropWindow3d(size(stackc),targetSize);
Dcrop = imcrop3(stackc,win);
i=i+1
end
save(name,"Dcrop")

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeAgriculture についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by