You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.6 KiB

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