00001 /***************************************************************************\ 00002 * Copyright (C) by University Paris-Est - MISS team 00003 * ConvolutionMaxOperator.hpp created in 10 2008. 00004 * Mail : biri@univ-mlv.fr 00005 * 00006 * This file is part of the OpenKraken-image. 00007 * 00008 * The OpenKraken-image is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation; either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * The OpenKraken-image is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * 00021 \***************************************************************************/ 00022 00023 /* 00024 * Anti-doublon 00025 */ 00026 #ifndef __OPENKN_IMAGE__CONVOLUTIONMAXOPERATOR_HPP__ 00027 #define __OPENKN_IMAGE__CONVOLUTIONMAXOPERATOR_HPP__ 00028 00029 00030 /* 00031 * External Includes 00032 */ 00033 #include<limits> 00034 00035 /* 00036 * Internal Includes 00037 */ 00038 #include "ImageException.hpp" 00039 #include "ConvolutionOperator.hpp" 00040 00041 /* 00042 * Namespace 00043 */ 00044 namespace kn{ 00045 /* 00046 * Class definition 00047 */ 00051 class ConvolutionMaxOperator : public ConvolutionOperator { 00052 public: 00053 /* 00054 * Constructor & destructors 00055 */ 00059 inline ConvolutionMaxOperator(){ 00060 initialize(); 00061 } 00062 00066 inline ConvolutionMaxOperator(const ConvolutionMaxOperator& e) : ConvolutionOperator(e){ 00067 max = e.max; 00068 kernelSum = e.kernelSum; 00069 } 00073 inline ~ConvolutionMaxOperator(){} 00074 00075 protected: 00076 double max; 00077 double kernelSum; 00078 00079 00080 public: 00084 inline void initialize(){ 00085 max = std::numeric_limits<double>::min(); 00086 kernelSum = 0.0; 00087 } 00088 00093 inline double getResult() { 00094 if(kernelSum == 0) 00095 throw ImageException("kernel sum null"); 00096 return max; 00097 } 00098 00103 inline void operator()(double kernelValue, double imageValue){ 00104 max = std::max(max, imageValue*kernelValue); 00105 kernelSum+=kernelValue; 00106 } 00107 00111 inline ConvolutionMaxOperator* clone() const{ 00112 return new ConvolutionMaxOperator(*this); 00113 } 00114 }; 00115 00116 /* 00117 * End of Namespace 00118 */ 00119 } 00120 00121 /* 00122 * End of Anti-doublon 00123 */ 00124 #endif 00125
1.5.8