MATLAB Answers

how to stack 3D images from 2D images after semantic function.

4 views (last 30 days)
mohd akmal masud
mohd akmal masud on 23 Sep 2021
Answered: yanqi liu on 26 Sep 2021
Hi all, I have 2D images. then I used semantic program that have network build from U-Net deep learning.
after I segment the volume, I wrote this coding below to view as 3D stack the binary images. but only first images appear. Anyone can help me?
filePattern = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256\testimages', '*.png');
IMDS = imageDatastore(filePattern);
fileList = dir(filePattern)
numFiles = length(fileList);
image3d = zeros(256, 256, numFiles, 'uint8');
for k = 16 : 35
fullFileName = fullfile(fileList(k).folder, fileList(k).name);
thisImage = imread(fullFileName);
image3d(:, :, k) = thisImage;
end
[C,scores] = semanticseg((image3d(:, :, k)),net1);
outt2=C=="foreground";
st2=strel('disk',0);
outt22=imopen(outt2,st2);
imshow3D( outt22);

More Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 23 Sep 2021
There is a small err in the code. Here is the corrected part of it:
for k = 1:numFiles % Starts at 1
fullFileName = fullfile(fileList(k).folder, fileList(k).name);
thisImage = imread(fullFileName);
image3d(:, :, k) = thisImage;
end

Community Treasure Hunt

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

Start Hunting!