Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_DATA_SATURATE_HH 00027 # define MLN_DATA_SATURATE_HH 00028 00032 00033 # include <mln/fun/v2v/saturate.hh> 00034 # include <mln/data/apply.hh> 00035 # include <mln/data/transform.hh> 00036 00037 00038 namespace mln 00039 { 00040 00041 namespace data 00042 { 00043 00044 00054 template <typename V, typename I> 00055 mln_ch_value(I, V) 00056 saturate(V v, const Image<I>& input); 00057 00058 00065 template <typename I, typename V> 00066 mln_ch_value(I, V) 00067 saturate(const Image<I>& input, 00068 const V& min, const V& max); 00069 00070 00077 template <typename I> 00078 void saturate_inplace(Image<I>& input, 00079 const mln_value(I)& min, const mln_value(I)& max); 00080 00081 00082 # ifndef MLN_INCLUDE_ONLY 00083 00084 template <typename V, typename I> 00085 inline 00086 mln_ch_value(I, V) 00087 saturate(V, const Image<I>& input) 00088 { 00089 trace::entering("data::saturate"); 00090 00091 mln_precondition(exact(input).is_valid()); 00092 00093 fun::v2v::saturate<V> f; 00094 mln_ch_value(I, V) output = data::transform(input, f); 00095 00096 trace::exiting("data::saturate"); 00097 return output; 00098 } 00099 00100 template <typename I, typename V> 00101 inline 00102 mln_ch_value(I, V) 00103 saturate(const Image<I>& input, 00104 const V& min, const V& max) 00105 { 00106 trace::entering("data::saturate"); 00107 00108 mln_precondition(exact(input).is_valid()); 00109 00110 fun::v2v::saturate<V> f(min, max); 00111 mln_ch_value(I, V) output = data::transform(input, f); 00112 00113 trace::exiting("data::saturate"); 00114 return output; 00115 } 00116 00117 template <typename I> 00118 inline 00119 void saturate_inplace(Image<I>& input, 00120 const mln_value(I)& min, const mln_value(I)& max) 00121 { 00122 trace::entering("data::saturate_inplace"); 00123 00124 mln_precondition(exact(input).is_valid()); 00125 00126 fun::v2v::saturate<mln_value(I)> f(min, max); 00127 data::apply(input, f); 00128 00129 trace::exiting("data::saturate_inplace"); 00130 } 00131 00132 # endif // ! MLN_INCLUDE_ONLY 00133 00134 } // end of namespace mln::data 00135 00136 } // end of namespace mln 00137 00138 00139 #endif // ! MLN_DATA_SATURATE_HH