LocalFeatureOpponnentSift.cpp 1.1 KB

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