How to plot surf for 3D images.

17 views (last 30 days)
mohd akmal masud
mohd akmal masud on 27 Jun 2022
Answered: KSSV on 27 Jun 2022
Dear all, I have 3D image as attached. How to plot it using surf fucntion? so that i can get the graph as below.
>> h = dicomread('h.dcm');
>> h = squeeze(h);
>> surf(h);
Error using matlab.graphics.chart.primitive.Surface
Value must be a scalar, vector or array of numeric type.
Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});

Accepted Answer

KSSV
KSSV on 27 Jun 2022
dicom will be a 3D matrix..you cannot use surf straight away.
h = dicomread('h.dcm');
[m,n,p] = size(h) ;
figure
hold on
for i = 1:p
surf(h(:,:,i))
end
Have a look on slice

More Answers (1)

Voss
Voss on 27 Jun 2022
unzip('h.zip')
h = dicomread('./h/h.dcm');
whos h
Name Size Bytes Class Attributes h 130x130x1x74 2501200 uint16
h = squeeze(h);
whos h
Name Size Bytes Class Attributes h 130x130x74 2501200 uint16
figure();
surf(h(:,:,1))
title('First Slice')
colormap(jet());
colorbar();
figure();
surf(h(:,:,end))
title('Last Slice')
colormap(jet());
colorbar();
figure();
surf(sum(h,3));
title('Sum of All Slices')
colormap(jet());
colorbar();

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!