GHough.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * NICE-Core - efficient algebra and computer vision methods
  3. * - libimage - An image/template for new NICE libraries
  4. * See file License for license information.
  5. */
  6. /*****************************************************************************/
  7. /*! \file GHough.h
  8. \brief GHough class declaration
  9. */
  10. /*****************************************************************************/
  11. /*
  12. * $Author: bajramov $
  13. * $Date: 2009/05/28 11:36:30 $
  14. * $Revision: 1.2 $
  15. */
  16. /*****************************************************************************/
  17. #ifndef _GHOUGH_IMAGE_H
  18. #define _GHOUGH_IMAGE_H
  19. #include <iostream>
  20. #include <core/image/ImageT.h>
  21. namespace NICE {
  22. /**
  23. * Hough transformation.
  24. */
  25. class GHough
  26. {
  27. public:
  28. //! pixel neighbors enumeration
  29. typedef enum {SINGLE_BIN, FOUR_NEIGHBORS, EIGHT_NEIGHBORS, HALF_OVERLAP} NeighborType;
  30. private:
  31. //! the Hough Transform space
  32. FloatImage houghmap;
  33. //! Size of the image space
  34. IppiSize imageSize;
  35. //! Size of the transform space
  36. IppiSize transformSize;
  37. //! indicates if the transform space has been allocated
  38. bool isInitialized;
  39. //! Which bins to increment during add operation
  40. NeighborType addMode;
  41. //! Checks if a point is within zero and the specified bounds
  42. inline bool boundsOkay(const Coord &pt, const IppiSize &bounds) const;
  43. public:
  44. //! Default constructor
  45. GHough();
  46. //! Constructor of optional argument with default-value
  47. /** @param imageSize size of the image
  48. * @param transformSize size of transformation area
  49. * @param addMode neighbor type
  50. */
  51. GHough(IppiSize imageSize, IppiSize transformSize, NeighborType addMode);
  52. //! Copy-Constructor
  53. /*! \param arg class to copy
  54. */
  55. GHough(const GHough& arg);
  56. //! Destructor of GHough
  57. virtual ~GHough(){}
  58. //! Cast operator to char*
  59. //operator char*();
  60. //! Assignment operator
  61. /*! \param ex class to copy
  62. * \return a reference to this class
  63. */
  64. GHough& operator=(const GHough& ex);
  65. //! Adds activation to a set/one Hough Transform bins
  66. /*!
  67. * \param pt location in the image space of the pixel point
  68. * \param activation value to add to the bin(s)
  69. **/
  70. void addPoint(const Coord &pt, float activation = 1.0);
  71. //! Adds activation to a set/one Hough Transform bins
  72. /*!
  73. * \param x x-coordinate in the image space of the pixel point
  74. * \param y y-coordinate in the image space of the pixel point
  75. * \param activation value to add to the bin(s)
  76. **/
  77. void addPoint(float x, float y, float activation = 1.0);
  78. //! Transforms a point from the image spage to the Hough Space giving top-left bin if overlap
  79. Coord transformPoint(const Coord &pt) const;
  80. //! Transforms a point from the image spage to the Hough Space giving best bin if overlap
  81. Coord nearestTransformPoint(const Coord &pt) const;
  82. //! Transforms a point from the Hough Space to the Image Space
  83. Coord invTransformPoint(const Coord &pt) const;
  84. //! allocates memory for the transform space
  85. /**
  86. * \param imageSize Size of the Image
  87. * \param transformSize Size of the Hough Transform space
  88. * \param addMode which bins to add activation to.
  89. * Possible options: SINGLE_BIN, FOUR_NEIGHBORS, EIGHT_NEIGHBORS
  90. **/
  91. void initialize(IppiSize imageSize,IppiSize transformSize, NeighborType addMode);
  92. //! allocates memory for the transform space
  93. /**
  94. * \param image an image
  95. * \param scalefactor transformSize
  96. * \param addMode which bins to add activation to.
  97. * Possible options: SINGLE_BIN, FOUR_NEIGHBORS, EIGHT_NEIGHBORS
  98. **/
  99. template<class IMAGE>
  100. void initialize(const IMAGE &image, float scalefactor, NeighborType addMode);
  101. //! allocates memory for the transform space
  102. /**
  103. * \param width width of the image
  104. * \param height height of the image
  105. * \param scalefactor transformSize
  106. * \param addMode which bins to add activation to.
  107. * Possible options: SINGLE_BIN, FOUR_NEIGHBORS, EIGHT_NEIGHBORS
  108. **/
  109. void initialize(int width, int height, float scalefactor, NeighborType addMode);
  110. //! Returns the Map as FloatImage
  111. const FloatImage &getMap() const;
  112. //! Finds the location with the maximum activation
  113. Coord getMaxLoc() const;
  114. //! Finds the value of the the maximum activation
  115. float getMax() const;
  116. //! Returns the activation value at any point
  117. float getVal(int x, int y) const;
  118. //! Returns the activation value at any point
  119. float getVal(const Coord &pt) const;
  120. //! Clears the transform space
  121. void clear();
  122. };
  123. }; // namespace NICE
  124. #endif /* _GHOUGH_IMAGE_H */
  125. /*****************************************************************************/
  126. /*
  127. * $Log: GHough.h,v $
  128. * Revision 1.2 2009/05/28 11:36:30 bajramov
  129. * renamed a few things for consistency
  130. *
  131. * Revision 1.1.1.1 2007/05/22 19:26:35 bajramov
  132. * limun2
  133. *
  134. * Revision 1.3 2007/02/07 19:09:42 zimmermann
  135. * * fixed documentation warnings
  136. *
  137. * Revision 1.2 2006/09/21 14:03:54 mattern
  138. * .
  139. *
  140. * Revision 1.1 2006/09/15 15:23:58 mattern
  141. * general hough transformation
  142. *
  143. */