Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 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_APPROX_MEDIAN_HH 00027 # define MLN_DATA_APPROX_MEDIAN_HH 00028 00032 00033 # include <mln/data/median.hh> 00034 # include <mln/win/rectangle2d.hh> 00035 # include <mln/win/disk2d.hh> 00036 # include <mln/win/octagon2d.hh> 00037 # include <mln/win/hline2d.hh> 00038 # include <mln/win/vline2d.hh> 00039 # include <mln/win/diag2d.hh> 00040 # include <mln/win/backdiag2d.hh> 00041 00042 #include <time.h> 00043 00044 00045 namespace mln 00046 { 00047 00048 namespace data 00049 { 00050 00051 namespace approx 00052 { 00053 00065 template <typename I> 00066 mln_concrete(I) 00067 median(const Image<I>& input, const win::rectangle2d& win); 00068 00069 00081 template <typename I> 00082 mln_concrete(I) 00083 median(const Image<I>& input, const win::disk2d& win); 00084 00085 00097 template <typename I> 00098 mln_concrete(I) 00099 median(const Image<I>& input, const win::octagon2d& win); 00100 00101 00102 00103 # ifndef MLN_INCLUDE_ONLY 00104 00105 00106 // Facades. 00107 00108 00109 template <typename I> 00110 inline 00111 mln_concrete(I) 00112 median(const Image<I>& input, const win::rectangle2d& win) 00113 { 00114 trace::entering("data::approx::median"); 00115 00116 mln_concrete(I) output; 00117 00118 win::hline2d win1(win.width()); 00119 output = data::median(input, win1); 00120 00121 win::vline2d win2(win.height()); 00122 output = data::median(output, win2); 00123 00124 trace::exiting("data::approx::median"); 00125 return output; 00126 } 00127 00128 00129 template <typename I> 00130 inline 00131 mln_concrete(I) 00132 median(const Image<I>& input, const win::disk2d& win) 00133 { 00134 trace::entering("data::approx::median"); 00135 00136 const unsigned len = win.diameter() / 3 + 1; 00137 mln_concrete(I) output; 00138 00139 win::diag2d win1(len); 00140 output = data::median(input, win1); 00141 00142 win::backdiag2d win2(len); 00143 output = data::median(output, win2); 00144 00145 win::hline2d win3(len); 00146 output = data::median(input, win3); 00147 00148 win::vline2d win4(len); 00149 output = data::median(output, win4); 00150 00151 trace::exiting("data::approx::median"); 00152 return output; 00153 } 00154 00155 00156 template <typename I> 00157 inline 00158 mln_concrete(I) 00159 median(const Image<I>& input, const win::octagon2d& win) 00160 { 00161 return median(input, win::disk2d(win.length())); 00162 } 00163 00164 # endif // ! MLN_INCLUDE_ONLY 00165 00166 } // end of namespace mln::data::approx 00167 00168 } // end of namespace mln::data 00169 00170 } // end of namespace mln 00171 00172 00173 #endif // ! MLN_DATA_APPROX_MEDIAN_HH