00001 /***************************************************************************\ 00002 * Copyright (C) by University Paris-Est - MISS team 00003 * ConvolutionExtremaSuppressorOperator.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__CONVOLUTIONEXTREMASUPPRESSOROPERATOR_HPP__ 00027 #define __OPENKN_IMAGE__CONVOLUTIONEXTREMASUPPRESSOROPERATOR_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 ConvolutionExtremaSuppressorOperator : public ConvolutionOperator { 00052 public: 00053 /* 00054 * Constructor & destructors 00055 */ 00059 inline ConvolutionExtremaSuppressorOperator(){ 00060 initialize(); 00061 } 00062 00066 inline ConvolutionExtremaSuppressorOperator(const ConvolutionExtremaSuppressorOperator& e) : ConvolutionOperator(e){ 00067 max = e.max; 00068 min = e.min; 00069 val = e.val; 00070 } 00074 inline ~ConvolutionExtremaSuppressorOperator(){} 00075 00076 protected: 00077 double min; 00078 double max; 00079 double val; 00080 00081 00082 public: 00086 inline void initialize(){ 00087 max = std::numeric_limits<double>::min(); 00088 min = std::numeric_limits<double>::max(); 00089 val = -1; 00090 } 00091 00096 inline double getResult() { 00097 if(val==-1) 00098 throw ImageException("kernel bad initialization"); 00099 return val<min?min:val>max?max:val; 00100 } 00101 00106 inline void operator()(double kernelValue, double imageValue){ 00107 if(kernelValue == 0.0){ 00108 max = std::max(max, imageValue); 00109 min = std::min(min, imageValue); 00110 }else if(kernelValue == 1.0){ 00111 val=imageValue; 00112 } 00113 } 00114 00118 inline ConvolutionExtremaSuppressorOperator* clone() const{ 00119 return new ConvolutionExtremaSuppressorOperator(*this); 00120 } 00121 }; 00122 00123 /* 00124 * End of Namespace 00125 */ 00126 } 00127 00128 /* 00129 * End of Anti-doublon 00130 */ 00131 #endif 00132
1.5.8