MATLAB Answers

how to paste the coordinate value 1 binary images into 3D images.

3 views (last 30 days)
mohd akmal masud
mohd akmal masud on 10 Oct 2021
Answered: yanqi liu on 10 Oct 2021
hi all, I have code below. Anyone know how to insert the 3D arrays of binary images which have value 1 into my 3D images dicom?
so that only pixel on 3D images that have same coordinate with value 1 binary images appear
Anyone please help me?
% For binary images (png format, each pixel just have value 1 and 0.)
clc
clear all
dataSetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
imageDir = fullfile(dataSetDir,'bnwaftersegmentation');
imds = imageDatastore(imageDir);
for i = 1:41
% subplot(6,7,i)
I = readimage(imds,i);
% binary
Is{i} = logical(I);
end
% For 3D images spect
myFolder = ('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang\dcmoriextract');
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for K = 1 : length(theFiles)
baseFileName = theFiles(K).name;
fullFileName = fullfile(theFiles(K).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
P(:,:,K) = dicomread(fullFileName);
end
p = patch(isosurface(P, Is==1)); %% I STUCK HERE
axis equal
set(p,'FaceColor','c','EdgeColor','none');
alpha(p,1)
hold
% p = patch(isosurface(smooth3(P),pvmax));
% axis equal
% set(p,'FaceColor','m','EdgeColor','none');
for i=1:180
view(i-90,-15)
GG(i) = getframe(gcf);
end
mplay(GG)
movie2avi(GG,'spect01.avi')

Accepted Answer

yanqi liu
yanqi liu on 10 Oct 2021
sir, i think may be use logical matrix as mask,such as
im = im .* uint8(mask);
to get target

More Answers (0)

Community Treasure Hunt

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

Start Hunting!