Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

FloatImage.h

Go to the documentation of this file.
00001 #ifndef FLOATIMAGE_H
00002 #define FLOATIMAGE_H
00003 
00004 #include <algorithm>
00005 #include <vector>
00006 
00007 namespace DualCoding {
00008   typedef unsigned char uchar;
00009   template<typename T> class Sketch;
00010 }
00011 
00012 namespace AprilTags {
00013 
00014 //! Represent an image as a vector of floats in [0,1]
00015 class FloatImage {
00016 private:
00017   int width;
00018   int height;
00019   std::vector<float> pixels;
00020 
00021 public:
00022 
00023   //! Default constructor
00024   FloatImage();
00025 
00026   //! Construct an empty image
00027   FloatImage(int widthArg, int heightArg);
00028 
00029   //! Constructor that copies pixels from an array
00030   FloatImage(int widthArg, int heightArg, const std::vector<float>& pArg);
00031 
00032   //! Constructor that copies pixels from a Sketch<uchar>
00033   explicit FloatImage(const DualCoding::Sketch<DualCoding::uchar>& sketch);
00034 
00035   FloatImage& operator=(const FloatImage& other);
00036 
00037   float get(int x, int y) const { return pixels[y*width + x]; }
00038   void set(int x, int y, float v) { pixels[y*width + x] = v; }
00039   
00040   int getWidth() const { return width; }
00041   int getHeight() const { return height; }
00042   int getNumFloatImagePixels() const { return width*height; }
00043   const std::vector<float>& getFloatImagePixels() const { return pixels; }
00044 
00045   static std::vector<float> sketchToFloats(const DualCoding::Sketch<DualCoding::uchar>& sketch);
00046 
00047   //! TODO: Fix decimateAvg function. DO NOT USE!
00048   void decimateAvg();
00049 
00050   //! Rescale all values so that they are between [0,1]
00051   void normalize();
00052 
00053   void filterFactoredCentered(const std::vector<float>& fhoriz, const std::vector<float>& fvert);
00054 
00055   template<typename T>
00056   void copyToSketch(DualCoding::Sketch<T>& sketch) {
00057     for (int i = 0; i < getNumFloatImagePixels(); i++)
00058       sketch[i] = (T)(255.0f * getFloatImagePixels()[i]);
00059   }
00060 
00061   void printMinMax() const;
00062 };
00063 
00064 } // namespace
00065 
00066 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:39 2016 by Doxygen 1.6.3