ImagePairToImageOperator.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  ImagePairToImageOperator.h
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:
00008  *  $Id: ImagePairToImageOperator.h 44313 2011-04-06 22:46:28Z agas $
00009  *******************************************************************************/
00010 
00011 #ifndef ImagePairToImageOperator_H
00012 #define ImagePairToImageOperator_H
00013 
00014 #include <iostream>
00015 #include "ImageOperator.h"
00016 
00017 namespace puma2 {
00018 
00025 template <class I1, class I2, class O > class ImagePairToImageOperator
00026         : public ImageOperator
00027 {
00028 public:
00029 
00033     ImagePairToImageOperator();
00034 
00038     virtual ~ImagePairToImageOperator();
00039 
00041         virtual void operator() (const I1 & iImg1, const I2 & iImg2, O & oImg);
00042 
00043 protected:
00045         virtual void apply(const I1 & iImg1, const I2 & iImg2, O & oImg) = 0;
00046 
00062         virtual void checkArgument(const I1 & iImg1, const I2 & iImg2, O & oImg);
00063 public:
00064         static  void checkImageArgument(const I1 & iImg1, const I2 & iImg2, O & oImg);
00065 };
00066 
00067 
00068 template <class I1, class I2, class O>
00069    ImagePairToImageOperator<I1,I2,O>::ImagePairToImageOperator()
00070 {
00071 }
00072 
00073 template <class I1, class I2, class O>
00074    ImagePairToImageOperator<I1,I2,O>::~ImagePairToImageOperator()
00075 {
00076 };
00077 
00078 template <class I1, class I2, class O>
00079    void ImagePairToImageOperator<I1,I2,O>::operator()
00080         (const I1 & iImg1, const I2 & iImg2, O & oImg)
00081 {
00082         checkArgument(iImg1, iImg2, oImg);   // virtual - can be overwritten
00083         apply(iImg1, iImg2, oImg);       // virtual - must be overwritten
00084 }
00085 
00086 
00087 template <class I1, class I2, class O>
00088    void ImagePairToImageOperator<I1,I2,O>::checkArgument
00089         (const I1 & iImg1, const I2 & iImg2, O & oImg)
00090 {
00091         checkImageArgument(iImg1, iImg2, oImg);
00092 }
00093 
00094 template <class I1, class I2, class O>
00095    void ImagePairToImageOperator<I1,I2,O>::checkImageArgument
00096         (const I1 & iImg1, const I2 & iImg2, O & oImg)
00097 {
00098         if (oImg.getWidth() != 0) {
00099           if (    (oImg.getWidth() != iImg1.getWidth() )  || (oImg.getHeight() != iImg1.getHeight() ) ||
00100             (oImg.getWidth() != iImg2.getWidth() )  || (oImg.getHeight() != iImg2.getHeight() ) )
00101     {
00102                                 throw "Image size missmatch";
00103     }
00104         } else {
00105     if ( (reinterpret_cast<const void*>(&iImg1) == reinterpret_cast<const void*>(&oImg)) ||
00106          (reinterpret_cast<const void*>(&iImg2) == reinterpret_cast<const void*>(&oImg)) )
00107     {
00108                                 throw "Inplace operation of image operator not possible";
00109     }
00110                 oImg.resize(iImg1.getWidth(),iImg1.getHeight());
00111         }
00112 }
00113 
00114 } // Namespace
00115 
00116 #endif


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