root / vision / cvblobs8.3 / BlobProperties.cpp @ 53f28116
History | View | Annotate | Download (1.62 KB)
1 |
#include "BlobProperties.h" |
---|---|
2 |
|
3 |
|
4 |
/**
|
5 |
- FUNCI?: GetPerimeter
|
6 |
- FUNCIONALITAT: Get perimeter from chain code. Diagonals sum sqrt(2) and horizontal and vertical codes 1
|
7 |
- PAR?METRES:
|
8 |
-
|
9 |
- RESULTAT:
|
10 |
-
|
11 |
- RESTRICCIONS:
|
12 |
-
|
13 |
- AUTOR: rborras
|
14 |
- DATA DE CREACI?: 2008/04/30
|
15 |
- MODIFICACI?: Data. Autor. Descripci?.
|
16 |
- NOTA: Algorithm derived from "Methods to estimate area and perimeters of blob-like objects: A comparison", L.Yang
|
17 |
*/
|
18 |
#define SQRT2 1.414213562 |
19 |
|
20 |
/**
|
21 |
- FUNCI?: GetPerimeter
|
22 |
- FUNCIONALITAT: Get blob area, ie. external contour area minus internal contours area
|
23 |
- PAR?METRES:
|
24 |
-
|
25 |
- RESULTAT:
|
26 |
-
|
27 |
- RESTRICCIONS:
|
28 |
-
|
29 |
- AUTOR: rborras
|
30 |
- DATA DE CREACI?: 2008/04/30
|
31 |
- MODIFICACI?: Data. Autor. Descripci?.
|
32 |
*/
|
33 |
|
34 |
double CBlobProperties::GetArea()
|
35 |
{ |
36 |
double area;
|
37 |
t_contourList::iterator itContour; |
38 |
|
39 |
area = m_externalContour.GetArea(); |
40 |
|
41 |
itContour = m_internalContours.begin(); |
42 |
|
43 |
while (itContour != m_internalContours.end() )
|
44 |
{ |
45 |
area += (*itContour).GetArea(); |
46 |
itContour++; |
47 |
} |
48 |
return area;
|
49 |
} |
50 |
|
51 |
/**
|
52 |
- FUNCI?: GetPerimeter
|
53 |
- FUNCIONALITAT: Get blob perimeter, ie. sum of the lenght of all the contours
|
54 |
- PAR?METRES:
|
55 |
-
|
56 |
- RESULTAT:
|
57 |
-
|
58 |
- RESTRICCIONS:
|
59 |
-
|
60 |
- AUTOR: rborras
|
61 |
- DATA DE CREACI?: 2008/04/30
|
62 |
- MODIFICACI?: Data. Autor. Descripci?.
|
63 |
*/
|
64 |
double CBlobProperties::GetPerimeter()
|
65 |
{ |
66 |
double perimeter;
|
67 |
t_contourList::iterator itContour; |
68 |
|
69 |
perimeter = m_externalContour.GetPerimeter(); |
70 |
|
71 |
itContour = m_internalContours.begin(); |
72 |
|
73 |
while (itContour != m_internalContours.end() )
|
74 |
{ |
75 |
perimeter += (*itContour).GetPerimeter(); |
76 |
itContour++; |
77 |
} |
78 |
return perimeter;
|
79 |
} |
80 |
|
81 |
|