LocalFeatureRGBSift.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifdef NICE_USELIB_OPENMP
  2. #include <omp.h>
  3. #endif
  4. #include <vislearning/nice.h>
  5. #include <iostream>
  6. #include "vislearning/features/localfeatures/sift.h"
  7. #include "vislearning/features/localfeatures/LocalFeatureRGBSift.h"
  8. using namespace OBJREC;
  9. using namespace std;
  10. using namespace NICE;
  11. #undef DEBUG_show_one_picture_per_channel
  12. LocalFeatureRGBSift::LocalFeatureRGBSift( const Config *conf ):LocalFeatureSift(conf)
  13. {
  14. deletemode = false;
  15. }
  16. LocalFeatureRGBSift::~LocalFeatureRGBSift()
  17. {
  18. }
  19. int LocalFeatureRGBSift::getDescriptors ( const NICE::ColorImage & img,
  20. VVector & positions,
  21. VVector & descriptors ) const
  22. {
  23. sortPositions(positions);
  24. descriptors.clear();
  25. // Fuer jede Position wird ein leerer NICE::Vector in descriptors eingefuegt
  26. for(int i = 0; i < (int) positions.size(); i++)
  27. {
  28. NICE::Vector v;
  29. descriptors.push_back(v);
  30. }
  31. vector<VVector> desc( 3 );
  32. #ifndef DEBUG_show_one_picture_per_channel
  33. #pragma omp parallel for
  34. #endif
  35. // Descriptor fuer jeden der 3 Kanaele berechnen
  36. for(int i = 0; i < 3; i++)
  37. {
  38. NICE::Image tmp(img.width(), img.height());
  39. for(int y = 0; y < img.height(); y++)
  40. {
  41. for(int x = 0; x < img.width(); x++)
  42. {
  43. tmp.setPixel(x,y,img.getPixel(x,y,i));
  44. }
  45. }
  46. #ifdef DEBUG_show_one_picture_per_channel
  47. showImage( tmp );
  48. #endif
  49. VVector pos = positions;
  50. computeDesc(tmp, pos, desc[i]);
  51. }
  52. // ?
  53. //desc[0] = desc[2];
  54. for(int i = 0; i < 3; i++)
  55. {
  56. assert(desc[i].size() == descriptors.size());
  57. if(i == 0)
  58. {
  59. #ifndef DEBUG_show_one_picture_per_channel
  60. #pragma omp parallel for
  61. #endif
  62. for(int j = 0; j < (int)desc[i].size(); j++)
  63. {
  64. // kopiere den roten (1.)-Kanal in den Descriptorsvektor
  65. descriptors[j] = desc[i][j];
  66. }
  67. }
  68. else
  69. {
  70. #ifndef DEBUG_show_one_picture_per_channel
  71. #pragma omp parallel for
  72. #endif
  73. for(int j = 0; j < (int)desc[i].size(); j++)
  74. {
  75. descriptors[j].append(desc[i][j]);
  76. }
  77. }
  78. }
  79. return positions.size();
  80. }