how to calculated the total volume

1 回表示 (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 10 月 12 日
コメント済み: mohd akmal masud 2021 年 10 月 30 日
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?

採用された回答

yanqi liu
yanqi liu 2021 年 10 月 12 日
%% 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 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 10 月 14 日
yah..its work..Thank you very much sir
mohd akmal masud
mohd akmal masud 2021 年 10 月 30 日
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?

サインインしてコメントする。

その他の回答 (1 件)

yanqi liu
yanqi liu 2021 年 10 月 12 日
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)
  1 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 10 月 12 日
but only one volume appear

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by