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)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by