|
1 | 1 | 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. |
3 | 3 | %
|
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. |
5 | 8 | %
|
6 | 9 | % Example
|
7 | 10 | % % analyze regions on coins image
|
8 | 11 | % I = Image.read('coins.png');
|
9 | 12 | % 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 | +% |
17 | 31 | % % Display image with disc centroids overlaid (require MatGeom toolbox)
|
18 | 32 | % figure; show(I);
|
19 | 33 | % hold on;
|
20 |
| -% drawPoint(reshape([props.Centroid]', [2 10])') |
| 34 | +% drawPoint(reshape([tab.Centroid]', [2 10])') |
21 | 35 | %
|
22 | 36 | %
|
23 | 37 | % See also
|
24 |
| -% regionprops |
| 38 | +% regionprops, regionCentroids, regionBoxes, regionEquivalentEllipses |
25 | 39 | %
|
26 | 40 |
|
27 | 41 | % ------
|
28 | 42 | % Author: David Legland
|
29 |
| -% e-mail: david.legland@inra.fr |
| 43 | +% e-mail: david.legland@inrae.fr |
30 | 44 | % Created: 2017-11-15, using Matlab 9.3.0.713579 (R2017b)
|
31 | 45 | % Copyright 2017 INRA - Cepia Software Platform.
|
32 | 46 |
|
|
35 | 49 | end
|
36 | 50 |
|
37 | 51 | 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