Skip to content

Commit 3912a70

Browse files
committed
analyzeRegions: add support for 3D images
1 parent df9c50a commit 3912a70

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

src/@Image/analyzeRegions.m

+34-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
11
function props = analyzeRegions(obj, varargin)
2-
%ANALYZEREGIONS Computes region properties on a label or binary image.
2+
% Compute region properties on a 2D/3D label or binary image.
33
%
4-
% PROPS = analyzeRegions(IMG)
4+
% TAB = analyzeRegions(IMG)
5+
% Returns a set of properties measured on each region of the input label
6+
% image IMG. The input image may be 2D or 3D.
7+
% The results is given as a table.
58
%
69
% Example
710
% % analyze regions on coins image
811
% I = Image.read('coins.png');
912
% bin = opening(I > 80, ones(3, 3));
10-
% lbl = labeling(bin);
11-
% props = analyzeRegions(lbl)
12-
% props =
13-
% 10x1 struct array with fields:
14-
% Area
15-
% Centroid
16-
% BoundingBox
13+
% lbl = componentLabeling(bin);
14+
% tab = analyzeRegions(lbl)
15+
% tab =
16+
% 10x3 table
17+
% Area Centroid BoundingBox
18+
% ____ ________________ ________________________________
19+
%
20+
% 2609 148.54 34.446 119.5 6.5 59 56
21+
% 1934 56.067 49.75 30.5 25.5 51 48
22+
% 2646 216.93 70.66 187.5 42.5 59 56
23+
% 1878 110.03 84.855 84.5 61.5 51 47
24+
% 2750 37.071 106.69 6.5 77.5 61 58
25+
% 1946 265.78 102.61 240.5 78.5 51 48
26+
% 2697 174.78 119.85 144.5 91.5 60 57
27+
% 2774 96.199 145.88 65.5 116.5 61 58
28+
% 1979 235.95 173.16 210.5 148.5 51 49
29+
% 2857 120.21 208.48 89.5 178.5 62 60
30+
%
1731
% % Display image with disc centroids overlaid (require MatGeom toolbox)
1832
% figure; show(I);
1933
% hold on;
20-
% drawPoint(reshape([props.Centroid]', [2 10])')
34+
% drawPoint(reshape([tab.Centroid]', [2 10])')
2135
%
2236
%
2337
% See also
24-
% regionprops
38+
% regionprops, regionCentroids, regionBoxes, regionEquivalentEllipses
2539
%
2640

2741
% ------
2842
% Author: David Legland
29-
% e-mail: david.legland@inra.fr
43+
% e-mail: david.legland@inrae.fr
3044
% Created: 2017-11-15, using Matlab 9.3.0.713579 (R2017b)
3145
% Copyright 2017 INRA - Cepia Software Platform.
3246

@@ -35,4 +49,11 @@
3549
end
3650

3751
buffer = getBuffer(obj);
38-
props = regionprops(buffer, varargin{:});
52+
nd = ndims(obj);
53+
if nd == 2
54+
props = regionprops('table', buffer, varargin{:});
55+
elseif nd == 3
56+
props = regionprops3(buffer, varargin{:});
57+
else
58+
error('Image:analyzeRegions', 'Can not manage images with dimension %d', nd);
59+
end

0 commit comments

Comments
 (0)