degate  0.1.2
IPMedianFilter.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 __IPMEDIANFILTER_H__
00023 #define __IPMEDIANFILTER_H__
00024 
00025 #include <string>
00026 #include <ImageProcessorBase.h>
00027 #include <MedianFilter.h>
00028 
00029 namespace degate {
00030 
00031   /**
00032    * Processor: Median filter a single channel image.
00033    */
00034 
00035   template<typename ImageTypeIn, typename ImageTypeOut>
00036   class IPMedianFilter : public ImageProcessorBase {
00037 
00038   private:
00039 
00040     unsigned int median_filter_width;
00041 
00042   public:
00043 
00044     /**
00045      * The constructor.
00046      */
00047 
00048     IPMedianFilter(unsigned int _median_filter_width = 3) :
00049       ImageProcessorBase("IPNormalize",
00050                          "Normalize an image.",
00051                          false,
00052                          typeid(typename ImageTypeIn::pixel_type),
00053                          typeid(typename ImageTypeOut::pixel_type)),
00054       median_filter_width(_median_filter_width) { }
00055 
00056 
00057     virtual ImageBase_shptr run(ImageBase_shptr _in) {
00058 
00059       assert(_in != NULL);
00060 
00061       std::shared_ptr<ImageTypeIn> img_in =
00062         std::dynamic_pointer_cast<ImageTypeIn>(_in);
00063 
00064       std::shared_ptr<ImageTypeOut>
00065         img_out(new ImageTypeOut(_in->get_width(), _in->get_height()));
00066 
00067       assert(img_in != NULL);
00068       assert(img_out != NULL);
00069 
00070       median_filter<ImageTypeOut, ImageTypeIn>(img_out, img_in, median_filter_width);
00071 
00072       return img_out;
00073     }
00074 
00075 
00076   };
00077 
00078 }
00079 
00080 #endif
00081