how to calculated the total volume
1 view (last 30 days)
Show older comments
mohd akmal masud
on 12 Oct 2021
Commented: mohd akmal masud
on 30 Oct 2021
Hi all, I have code below, to put the rectangle on the circle of binary images.
%% TO GET THE VOLUME SEGMENTATION AFTER DEEP LEARNING PERFORM(blob all the sphere binary)
alldice=[]
acc=[]
Ts = [];
Ts2 = [];
for ii=1:7
subplot(3,3,ii)
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
outt2=C=="foreground";
st2=strel('disk',5);
outt22=imerode(outt2,st2);
% outt22(:,:,ii) = imerode(outt2,st2);
title('output')
imshow(outt22)
% imshow(outt22(:,:,ii))
allbb=[];
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',1);
allbb=[allbb; BB];
end
end
then I got this picture below
then I used code below to get the total area each circle
for i=1:4
zz=imcrop(outt22,allbb(i,:))
stats = regionprops('table',zz,'Centroid',...
'MajorAxisLength','MinorAxisLength')
T = regionprops('table', outt22,'Area','Centroid')
m1=stats.MajorAxisLength
m2=stats.MinorAxisLength
v1=stats.MinorAxisLength
vol=m1*m2*(v1/2)
ss=sprintf('the volume is %6f',vol)
msgbox(ss)
end
but its only calculated one of the images, how calculate all the sphere for all the images?
0 Comments
Accepted Answer
yanqi liu
on 12 Oct 2021
%% TO GET THE VOLUME SEGMENTATION AFTER DEEP LEARNING PERFORM(blob all the sphere binary)
alldice=[]
acc=[]
Ts = [];
Ts2 = [];
for ii=1:7
subplot(3,3,ii)
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
outt2=C=="foreground";
st2=strel('disk',5);
outt22=imerode(outt2,st2);
% outt22(:,:,ii) = imerode(outt2,st2);
title('output')
imshow(outt22)
% imshow(outt22(:,:,ii))
allbb=[];
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',1);
allbb=[allbb; BB];
end
for i=1:4
zz=imcrop(outt22,allbb(i,:))
stats = regionprops('table',zz,'Centroid',...
'MajorAxisLength','MinorAxisLength')
T = regionprops('table', outt22,'Area','Centroid')
m1=stats.MajorAxisLength
m2=stats.MinorAxisLength
v1=stats.MinorAxisLength
vol=m1*m2*(v1/2)
ss=sprintf('the volume is %6f',vol)
msgbox(ss)
end
end
4 Comments
More Answers (1)
yanqi liu
on 12 Oct 2021
vols = 0;
for i=1:4
zz=imcrop(outt22,allbb(i,:))
stats = regionprops('table',zz,'Centroid',...
'MajorAxisLength','MinorAxisLength')
T = regionprops('table', outt22,'Area','Centroid')
m1=stats.MajorAxisLength
m2=stats.MinorAxisLength
v1=stats.MinorAxisLength
vol=m1*m2*(v1/2)
vols = vols + vol;
end
ss=sprintf('the volume is %6f',vols)
msgbox(ss)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!