how to calculated the total volume

1 visualización (últimos 30 días)
mohd akmal masud
mohd akmal masud el 12 de Oct. de 2021
Comentada: mohd akmal masud el 30 de Oct. de 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?

Respuesta aceptada

yanqi liu
yanqi liu el 12 de Oct. de 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 comentarios
mohd akmal masud
mohd akmal masud el 14 de Oct. de 2021
yah..its work..Thank you very much sir
mohd akmal masud
mohd akmal masud el 30 de Oct. de 2021
Hi sir, I used this below code for 23 images that all images have 4 circle. Its work.
%% 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
vol = [];
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(i)=m1*m2*(v1/2)
end
ss=sprintf('the volume %d is %6f,%d is %6f,%d is %6f,%d is %6f',1,vol(1),2,vol(2),3,vol(3),4,vol(4));
msgbox(ss)
end
But, when I apply it into 23 images, that certain image have only 1 circle, 2 circle, 3 circle, and 4 circle, have got error.
Index in position 1 exceeds array bounds (must not exceed 2).
can you help me?

Iniciar sesión para comentar.

Más respuestas (1)

yanqi liu
yanqi liu el 12 de Oct. de 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)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by