How to calculate sphere area in subplot.

1 visualizzazione (ultimi 30 giorni)
Hi all,
I have 41 images. when I binarize it, then I plot 41 images in one figure as shown below. My coding as below. But only the last images its calculate the area of circle, that have one circle. Anyone can help me how to calculate the area for all the circle for all images in subplot.
%testimages
DATASetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
IMAGEDir = fullfile(DATASetDir,'Test');
IMDS = imageDatastore(IMAGEDir);
% IMDS = imageDatastore(IMAGEDir , ...
% 'FileExtensions', '.dcm','ReadFcn',@(x) dicomread(x));
% % volReader = @(x) dicomRead(x);
% voldsTest = imageDatastore(IMAGEDir , ...
% 'FileExtensions','.dcm','ReadFcn',volReader);
alldice=[]
acc=[]
for ii=1:41
subplot(6,7,ii)
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
B = labeloverlay(I,C);
outt2=C=="foreground";
st2=strel('disk',5);
outt22=imopen(outt2,st2);
title('input')
imshow(outt22)
end
T = regionprops('table', outt22,'Area','Centroid')
T =
1×2 table
Area Centroid
____ ________________
162 147.78 116.65

Risposta accettata

yanqi liu
yanqi liu il 28 Set 2021
sir,please check the follow code to get some information
%testimages
DATASetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
IMAGEDir = fullfile(DATASetDir,'Test');
IMDS = imageDatastore(IMAGEDir);
% IMDS = imageDatastore(IMAGEDir , ...
% 'FileExtensions', '.dcm','ReadFcn',@(x) dicomread(x));
% % volReader = @(x) dicomRead(x);
% voldsTest = imageDatastore(IMAGEDir , ...
% 'FileExtensions','.dcm','ReadFcn',volReader);
alldice=[]
acc=[]
for ii=1:41
subplot(6,7,ii)
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
B = labeloverlay(I,C);
outt2=C=="foreground";
st2=strel('disk',5);
outt22=imopen(outt2,st2);
title('input')
imshow(outt22)
fprintf('\nprocess %d image\n', ii);
T = regionprops('table', outt22,'Area','Centroid')
end
  1 Commento
mohd akmal masud
mohd akmal masud il 28 Set 2021
Modificato: mohd akmal masud il 28 Set 2021
yah..Its Work!! But its appear one by one table like below. What I suppose is its appear just one table, but sum all the area for every circle.
let say circle one have centroid 150 160, circle 2 have centroid 190, 210, circle three have centroid 210, 232
T =
3×3 table
Area Centroid
____ ________________
1560 150 160
850 190 210
501 210 232
process 1 image
T =
0×2 empty table
process 2 image
T =
1×2 table
Area Centroid
____ __________
1 149 129
process 3 image
T =
1×2 table
Area Centroid
____ ________________
4 149.25 130
process 4 image
T =
1×2 table
Area Centroid
____ ________________
12 149.92 129.25
process 5 image
T =
1×2 table
Area Centroid
____ ________________
9 149.44 129.22
process 6 image
T =
1×2 table
Area Centroid
____ ________________
9 150.78 127.67
process 7 image
T =
1×2 table
Area Centroid
____ ______________
4 147.5 128
process 8 image
T =
1×2 table
Area Centroid
____ ________________
6 148.83 129.5
process 9 image
T =
1×2 table
Area Centroid
____ ________________
4 149.25 129.5
process 10 image
T =
0×2 empty table
process 11 image
T =
2×2 table
Area Centroid
____ ______________
2 142.5 115
6 147 118
process 12 image
T =
1×2 table
Area Centroid
____ ________________
35 146.71 116.89
process 13 image
T =
1×2 table
Area Centroid
____ ________________
29 147.59 116.86
process 14 image
T =
1×2 table
Area Centroid
____ ________________
44 147.59 117.18
process 15 image
T =
1×2 table
Area Centroid
____ ________________
48 147.71 116.9
process 16 image
T =
2×2 table
Area Centroid
____ ________________
56 148.43 116.04
5 149 139
process 17 image
T =
3×2 table
Area Centroid
____ ________________
4 128.5 152
64 148.2 116.02
28 149.46 141.11
process 18 image
T =
3×2 table
Area Centroid
____ ________________
11 128.73 151.73
59 148.75 115.75
28 148.93 140.68
process 19 image
T =
4×2 table
Area Centroid
____ ________________
2 106 138.5
17 129.35 152.18
62 148.5 115.77
37 149.68 140.22
process 20 image
T =
5×2 table
Area Centroid
____ ________________
3 105.67 138.33
1 107 143
23 128.65 152.78
63 149.05 115.76
40 149.5 140
process 21 image
T =
4×2 table
Area Centroid
____ ________________
7 105.57 138.86
27 128.37 152.74
63 149.11 115.71
39 149.44 139.92
process 22 image
T =
4×2 table
Area Centroid
____ ________________
11 105.55 139.82
24 128.04 152.83
59 148.81 115.69
39 149.44 139.92
process 23 image
T =
4×2 table
Area Centroid
____ ________________
18 106.11 140.17
26 128 153.08
59 148.81 115.69
39 149.44 139.92
process 24 image
T =
4×2 table
Area Centroid
____ ________________
17 106.18 140.35
30 127.67 153.2
62 148.84 115.5
40 149.38 140
process 25 image
T =
4×2 table
Area Centroid
____ ________________
21 105.81 140.14
30 127.73 153.47
62 148.84 115.5
34 149.24 140.09
process 26 image
T =
4×2 table
Area Centroid
____ ________________
14 106.14 139.57
26 128.08 153.69
62 148.84 115.5
35 149.14 140.06
process 27 image
T =
4×2 table
Area Centroid
____ ________________
15 106.13 140.07
26 128.08 153.69
62 148.84 115.5
37 148.97 140.08
process 28 image
T =
4×2 table
Area Centroid
____ ________________
15 106.13 140.07
26 128.08 153.46
62 148.84 115.5
35 148.89 139.94
process 29 image
T =
4×2 table
Area Centroid
____ ________________
14 106.14 139.57
22 128.41 153.36
63 148.76 115.49
35 148.89 139.94
process 30 image
T =
4×2 table
Area Centroid
____ ________________
15 106.13 140.07
22 128.41 153.36
68 148.82 115.24
38 149.24 139.92
process 31 image
T =
4×2 table
Area Centroid
____ ________________
13 106.23 139.46
17 128.18 153.65
68 148.82 115.24
39 149.13 139.92
process 32 image
T =
4×2 table
Area Centroid
____ ________________
13 106.23 139.46
14 128.21 154
72 148.72 115.03
37 148.89 139.89
process 33 image
T =
4×2 table
Area Centroid
____ ________________
5 105.8 138.2
13 128.23 154.15
74 148.69 115.16
37 148.89 139.89
process 34 image
T =
3×2 table
Area Centroid
____ ________________
4 129 153.5
72 148.46 115.14
34 148.56 139.88
process 35 image
T =
2×2 table
Area Centroid
____ ________________
72 148.33 115.22
29 148.76 139.97
process 36 image
T =
2×2 table
Area Centroid
____ ________________
65 148.66 115.2
29 148.69 140.17
process 37 image
T =
2×2 table
Area Centroid
____ ________________
59 148.68 115.41
18 149 139.5
process 38 image
T =
2×2 table
Area Centroid
____ ________________
59 148.68 115.41
10 149 140.2
process 39 image
T =
2×2 table
Area Centroid
____ ________________
34 147.97 115.65
1 148 140
process 40 image
T =
1×2 table
Area Centroid
____ _______________
22 148.5 115.14
process 41 image
T =
1×2 table
Area Centroid
____ ________________
18 147.61 116.56

Accedi per commentare.

Più risposte (1)

yanqi liu
yanqi liu il 28 Set 2021
may be the filename should save?
clc; clear all; close all;
%testimages
DATASetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
IMAGEDir = fullfile(DATASetDir,'Test');
IMDS = imageDatastore(IMAGEDir);
% IMDS = imageDatastore(IMAGEDir , ...
% 'FileExtensions', '.dcm','ReadFcn',@(x) dicomread(x));
% % volReader = @(x) dicomRead(x);
% voldsTest = imageDatastore(IMAGEDir , ...
% 'FileExtensions','.dcm','ReadFcn',volReader);
alldice=[]
acc=[]
Ts = [];
Ts2 = [];
for ii=1:41
subplot(6,7,ii)
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
B = labeloverlay(I,C);
outt2=C=="foreground";
st2=strel('disk',5);
outt22=imopen(outt2,st2);
title('input')
imshow(outt22)
fprintf('\nprocess %d image\n', ii);
T = regionprops('table', outt22,'Area','Centroid');
Ts{ii} = T;
Ts2 = [Ts2; T];
end
disp(Ts2);
disp(Ts);

Community Treasure Hunt

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

Start Hunting!

Translated by