LocalFeatureOpponnentSift.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <iostream>
  2. #include "vislearning/features/localfeatures/sift.h"
  3. #include "vislearning/features/localfeatures/LocalFeatureOpponnentSift.h"
  4. using namespace OBJREC;
  5. using namespace std;
  6. using namespace NICE;
  7. LocalFeatureOpponnentSift::LocalFeatureOpponnentSift ( const Config *conf ) : LocalFeatureRGBSift ( conf )
  8. {
  9. }
  10. LocalFeatureOpponnentSift::~LocalFeatureOpponnentSift()
  11. {
  12. }
  13. int LocalFeatureOpponnentSift::getDescriptors ( const NICE::ColorImage & cimg,
  14. VVector & positions,
  15. VVector & descriptors ) const
  16. {
  17. NICE::ColorImage opimg ( cimg.width(), cimg.height() );
  18. for ( int y = 0; y < ( int ) cimg.height(); y++ )
  19. {
  20. for ( int x = 0; x < ( int ) cimg.width(); x++ )
  21. {
  22. // Farbkanaele auslesen
  23. int r = cimg.getPixel ( x, y, 0 );
  24. int g = cimg.getPixel ( x, y, 1 );
  25. int b = cimg.getPixel ( x, y, 2 );
  26. // Transformation in den Opponent Farbraum nach Van de Sande
  27. int o1 = ( int ) ( ( ( double ) ( r - g ) + 255.0 ) / 2.0 );
  28. int o2 = ( int ) ( ( ( double ) ( r + g - b ) + 510.0 ) / 4.0 );
  29. int o3 = ( int ) ( ( double ) ( r + g + b ) / 3.0 );
  30. opimg.setPixel ( x, y, o1, o2, o3 );
  31. }
  32. }
  33. return LocalFeatureRGBSift::getDescriptors ( opimg, positions, descriptors );
  34. }