ColorToGrayOperator.h
Go to the documentation of this file.
00001 #ifndef Col2Gvi_H
00002 #define Col2Gvi_H
00003 
00004 #include "ImageToImageOperator.h"
00005 #include "ColorImageRGB8.h"
00006 #include "GrayLevelImage8.h"
00007 
00008 namespace puma2 {
00009 
00014 template <class C, class G>
00015 class ColorToGrayOperator  : 
00016         public ImageToImageOperator<C,G>
00017 {
00018   public:
00019 
00023     ColorToGrayOperator();
00024 
00028         ColorToGrayOperator(const C & iImg, G & oImg)
00029         {
00030               // NB: we can call this method only here, after
00031                   // complete construction of the base class
00032                   // i.e., we may not call this function in a base class
00033                   // constructor as virtual function tables are not 
00034                   // set up properly there!
00035               this->operator()(iImg,oImg); // will call virtual functions
00036         }
00037 
00041     virtual ~ColorToGrayOperator();
00042 
00044         virtual void apply(const C & iImg, G & oImg);
00045 };
00046 
00047 template <class C, class G>
00048 ColorToGrayOperator<C,G>::ColorToGrayOperator() 
00049 {
00050 }
00051 
00052 template <class C, class G>
00053 ColorToGrayOperator<C,G>::~ColorToGrayOperator() 
00054 { 
00055   
00056 };
00057 
00058 template <class C, class G>
00059 void ColorToGrayOperator<C,G>::apply(const C & iImg, G & oImg)
00060 {
00061         for (int i = iImg.getHeight() - 1 ; i >= 0; --i) {
00062           const typename C::PixelType *rowPtr = iImg[i];
00063           for (int j = iImg.getWidth() - 1 ; j >= 0; --j) {
00064                 oImg[i][j] = 
00065                    ((3 * int(rowPtr[j][0]) +
00066                      6 * int(rowPtr[j][1]) +
00067                          int(rowPtr[j][2])) / 10);
00068           }
00069         }
00070 }
00071 
00072 }
00073 
00074 #endif


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43