degate  0.1.2
IPConvolve.h
Go to the documentation of this file.
00001 /* -*-c++-*-
00002 
00003  This file is part of the IC reverse engineering tool degate.
00004 
00005  Copyright 2008, 2009, 2010 by Martin Schobert
00006 
00007  Degate is free software: you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation, either version 3 of the License, or
00010  any later version.
00011 
00012  Degate is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with degate. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __IPCONVOLVE_H__
00023 #define __IPCONVOLVE_H__
00024 
00025 #include <string>
00026 #include <ImageProcessorBase.h>
00027 #include <FilterKernel.h>
00028 
00029 namespace degate {
00030 
00031   /**
00032    * Processor: Convolve an image.
00033    */
00034 
00035   template<typename ImageTypeIn, typename ImageTypeOut>
00036   class IPConvolve : public ImageProcessorBase {
00037 
00038   private:
00039     FilterKernel_shptr kernel;
00040 
00041   public:
00042 
00043     /**
00044      * The constructor.
00045      */
00046 
00047     IPConvolve(FilterKernel_shptr _kernel) :
00048       ImageProcessorBase("IPConvolve",
00049                          "Convolve an image.",
00050                          false,
00051                          typeid(typename ImageTypeIn::pixel_type),
00052                          typeid(typename ImageTypeOut::pixel_type)),
00053         kernel(_kernel) { }
00054 
00055     /**
00056      * The destructor.
00057      */
00058 
00059     virtual ~IPConvolve() {}
00060 
00061 
00062     virtual ImageBase_shptr run(ImageBase_shptr _in) {
00063 
00064       assert(_in != NULL);
00065 
00066       std::shared_ptr<ImageTypeIn> img_in =
00067         std::dynamic_pointer_cast<ImageTypeIn>(_in);
00068 
00069       std::shared_ptr<ImageTypeOut>
00070         img_out(new ImageTypeOut(_in->get_width(), _in->get_height()));
00071 
00072       assert(img_in != NULL);
00073       assert(img_out != NULL);
00074 
00075       convolve<ImageTypeOut, ImageTypeIn>(img_out, img_in, kernel);
00076 
00077       return img_out;
00078     }
00079 
00080 
00081   };
00082 
00083 }
00084 
00085 #endif
00086