Image_tools.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * @file Image_tools.h
  3. * @author Alexander Freytag
  4. * @date 18/11/2010
  5. * @brief Contains tools for Image_Processing
  6. */
  7. #ifndef _NICE_OBJREC_IMAGETOOLS
  8. #define _NICE_OBJREC_IMAGETOOLS
  9. #include "core/image/ImageT.h"
  10. #include "core/image/ColorImageT.h"
  11. #include <utility>
  12. namespace OBJREC {
  13. class Image_tools
  14. {
  15. protected:
  16. public:
  17. /** simple constructor */
  18. Image_tools();
  19. /** simple destructor */
  20. ~Image_tools();
  21. /**
  22. * @author Alexander Freytag
  23. * @brief Calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing
  24. */
  25. void calculateGradients(
  26. const NICE::Image & origImage,
  27. NICE::ImageT<float> & grad_x_Image,
  28. NICE::ImageT<float> & grad_y_Image );
  29. /**
  30. * @author Alexander Freytag
  31. * @brief Calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing, considering the chanel with the greatest magnitude als resulting gradient
  32. */
  33. void calculateGradients(
  34. NICE::ColorImage origColorImage,
  35. NICE::ImageT<float> & grad_x_Image,
  36. NICE::ImageT<float> & grad_y_Image );
  37. /**
  38. * @author Alexander Freytag
  39. * @brief Calculate gradient-orientations
  40. */
  41. void calculateGradientOrientations(
  42. const NICE::ImageT<float> & grad_x_Image,
  43. const NICE::ImageT<float> & grad_y_Image,
  44. const int & number_Of_Bins,
  45. NICE::Image & gradient_orientations,
  46. const bool unsignedBins=true );
  47. void calculateGradientOrientations(
  48. const NICE::GrayImage16s & grad_x_Image,
  49. const NICE::GrayImage16s & grad_y_Image,
  50. const int & number_Of_Bins,
  51. NICE::Image & gradient_orientations,
  52. const bool unsignedBins=true );
  53. /**
  54. *@author Alexander Freytag
  55. *@brief Calculate gradient-magnitudes
  56. */
  57. void calculateGradientMagnitudes(
  58. const NICE::ImageT<float> & grad_x_Image,
  59. const NICE::ImageT<float> & grad_y_Image,
  60. NICE::ImageT<float> & gradient_magnitudes );
  61. /**
  62. *@author Alexander Freytag
  63. *@brief Normalizes the descriptor-vector of the specified block, using L2-norm
  64. */
  65. std::vector<float> normalizeBlockDescriptor(
  66. const std::vector<float> & orig_Block_Descriptor,
  67. const float epsilon = 0.01 );
  68. /**
  69. *author Alexander Freytag
  70. *@brief Calculates the resulting HoG-Features for an image by normalizing spatial blocks und storing the resulting normalized histograms in a vector - not implemented up to now
  71. */
  72. std::vector< std::vector<float> > calculateResultingHogFeatures(
  73. const NICE::Image & gradient_orientations,
  74. const NICE::ImageT<float> & gradient_magnitudes,
  75. const int & blocksize = 2,
  76. const int & cellsize = 8 );
  77. };
  78. }
  79. #endif