ImageToImageOperator.h
Go to the documentation of this file.
00001 #ifndef ImageToImageOperator_H
00002 #define ImageToImageOperator_H
00003 
00004 #include <iostream>
00005 #include "ImageOperator.h"
00006 
00007 namespace puma2 {
00008 
00014 template <class I, class O > class ImageToImageOperator 
00015         : public ImageOperator
00016 {
00017 public:
00018 
00022     ImageToImageOperator();
00023 
00027     virtual ~ImageToImageOperator();
00028 
00030         virtual void operator() (const I & iImg, O & oImg);
00031 
00032 protected:
00034         virtual void apply(const I & iImg, O & oImg) = 0;
00035 
00051         virtual void checkArgument(const I & iImg, O & oImg);
00052 public:
00053         static  void checkImageArgument(const I & iImg, O & oImg);
00054 };
00055 
00056 
00057 template <class I, class O> 
00058    ImageToImageOperator<I,O>::ImageToImageOperator() 
00059 {
00060 }
00061 
00062 template <class I, class O> 
00063    ImageToImageOperator<I,O>::~ImageToImageOperator() 
00064 { 
00065 };
00066 
00067 template <class I, class O> 
00068    void ImageToImageOperator<I,O>::operator() 
00069         (const I & iImg, O & oImg)
00070 {
00071         checkArgument(iImg,oImg);   // virtual - can be overwritten
00072         apply(iImg,oImg);       // virtual - must be overwritten
00073 }
00074 
00075 
00076 template <class I, class O> 
00077    void ImageToImageOperator<I,O>::checkArgument
00078         (const I & iImg, O & oImg)
00079 {
00080         checkImageArgument(iImg,oImg);
00081 }
00082 
00083 template <class I, class O> 
00084    void ImageToImageOperator<I,O>::checkImageArgument
00085         (const I & iImg, O & oImg)
00086 {
00087         if (oImg.getWidth() != 0) {
00088           if ((oImg.getWidth() != iImg.getWidth() )  ||
00089               (oImg.getHeight() != iImg.getHeight() ))
00090                                 throw "Image size missmatch";
00091         } else {
00092             if (reinterpret_cast<const void*>(&iImg) == reinterpret_cast<const void*>(&oImg)) 
00093                                 throw "Inplace operation of image operator not possible";
00094                 oImg.resize(iImg.getWidth(),iImg.getHeight());
00095         }
00096 }
00097 
00098 } // Namespace
00099 
00100 #endif


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