how to develop 2D images into 3D viewing.

조회 수: 3(최근 30일)
mohd akmal masud
mohd akmal masud 2021년 10월 8일
댓글: yanqi liu 2021년 10월 10일
hi all, I have code below. Anyone know how to develop it into viewing as 3D, let say I want add thickness of that images 2.332mm. So that I can develop it into 3D images viewing.
Because if still 2D images, it cannot develop as 3D viewing.
% 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);
end
% For origional images 2D (png format, each pixel have pixel count.)
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,'Image');
imds = imageDatastore(imageDir);
for k = 1:41
% subplot(6,7,i)
J = readimage(imds,k);
end
%for viewing as 3D images
p = patch(isosurface(J, I==1));
axis equal
set(p,'FaceColor','c','EdgeColor','none');
alpha(p,1)
hold
but have error
Error using isosurface (line 72)
Isovalue must be a scalar.
sorry I ask many times, because I'm newer in Matlab Language.

채택된 답변

yanqi liu
yanqi liu 2021년 10월 9일
편집: yanqi liu 2021년 10월 9일
sir,please check the follow code to get some information
% 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 origional images 2D (png format, each pixel have pixel count.)
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,'Image');
imds = imageDatastore(imageDir);
Js = [];
for k = 1:41
% subplot(6,7,i)
J = readimage(imds,k);
if ndims(J) == 3
J = rgb2gray(J);
end
% gray image
Js(:,:,k) = double(uint8(J).*uint8(Is{k}));
end
%for viewing as 3D images
Ds = smooth3(Js);
figure
hiso = patch(isosurface(Ds,5),...
'FaceColor',[1,.75,.65],...
'EdgeColor','none');
hcap = patch(isocaps(Js,5),...
'FaceColor','interp',...
'EdgeColor','none');
colormap copper
view(45,30)
axis tight
daspect([1,1,.8])
lightangle(45,30);
set(gcf,'Renderer','zbuffer'); lighting phong
isonormals(Ds,hiso)
set(hcap,'AmbientStrength',.6)
set(hiso,'SpecularColorReflectance',0,'SpecularExponent',50)
  댓글 수: 4
yanqi liu
yanqi liu 2021년 10월 10일
I think should use isosurface to get 3D structure

댓글을 달려면 로그인하십시오.

추가 답변(1개)

yanqi liu
yanqi liu 2021년 10월 9일
편집: yanqi liu 2021년 10월 9일
use matrix to smooth data
  댓글 수: 3
yanqi liu
yanqi liu 2021년 10월 10일
yes,use logical image to filter target

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by