How to add annotation/label in figure?

10 views (last 30 days)
mohd akmal masud
mohd akmal masud on 11 Mar 2025
Answered: Cris LaPierre on 14 Mar 2025
Dear all,
Then anyone know how to add a label /annotation the value of 'Volume' near the segment (as example in picture). The value is in unit mm3 and multiply by 10.
clc
clear all
close all
[spect map]=dicomread('I-131sphere10nisbah1');
info = dicominfo('I-131sphere10nisbah1');
%gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
aa=size(spect);aa=aa(3);
%% set the thresh FOR sphere 1, max count 3189
PVmax = max(max(max(spect)));
PVmin = PVmax*0.42;
RZ01=spect;
RZ01(RZ01<PVmin)=0;
RZ01(RZ01>PVmax)=0;
RZ01(RZ01~=0)=1;
BW = imbinarize(RZ01);
figure, imshow3D(BW)
data = regionprops3(BW,spect,'Volume','VoxelValues', 'Centroid')% Result in table form
%% 3D fusing
% from CT files reading
% Get a list of all files in the folder with the desired file name pattern.
myFolder = ('dicomCTPhantom');
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for L = 1 : length(theFiles)
baseFileName = theFiles(L).name;
fullFileName = fullfile(theFiles(L).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()
CT(:,:,L) = dicomread(fullFileName);
end
CT=double(CT);
[N M L]=size(CT);
rats=size(CT)./size(spect);
[x,y,z]=meshgrid(rats(1):rats(1):M,rats(2):rats(2):N,rats(3):rats(3):L);
CT=interp3(CT,x,y,z);
CT = flip(CT,3);
e=10000;%isovalue, air at 0 (Faceskin800, air1250)
figure
whitebg('black')
colordef none
axis off
pause
fprintf('\nFull Reconstruction. Please wait...\n');
% for e=min(min(min(RZ))):1000:max(max(max(RZ)))
% plot3(0.5,0.5,0.5);
% hold;
q = patch(isosurface(CT,e));
axis equal
set(q,'FaceColor','w','EdgeColor','none');
alpha(q,0.2)
material shiny
hold
camlight('headlight')
% title([num2str(e)]);
view([-22 -4])
% end
p = patch(isosurface(smooth3(BW)));
axis equal
set(p,'FaceColor','c','EdgeColor','none');
alpha(p,1)
hold
% %
Volume Centroid VoxelValues
______ __________________________ ______________
359 75.88 58.415 44.552 {359×1 uint16}
47 75.766 70.234 44.277 { 47×1 uint16}

Answers (1)

Cris LaPierre
Cris LaPierre on 14 Mar 2025

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!