Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 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_UPSCALING_ART_SCALE3X_HH 00027 # define MLN_UPSCALING_ART_SCALE3X_HH 00028 00032 00033 00034 # include <mln/core/concept/box.hh> 00035 # include <mln/core/concept/image.hh> 00036 # include <mln/core/alias/neighb2d.hh> 00037 # include <mln/core/alias/dpoint2d.hh> 00038 00039 # include <mln/extension/adjust_duplicate.hh> 00040 00041 00042 namespace mln 00043 { 00044 00045 namespace upscaling 00046 { 00047 00048 namespace art 00049 { 00050 00062 template <typename I> 00063 mln_concrete(I) 00064 scale3x(const Image<I>& input); 00065 00066 00067 # ifndef MLN_INCLUDE_ONLY 00068 00069 00070 template <typename I> 00071 mln_concrete(I) 00072 scale3x(const Image<I>& input_) 00073 { 00074 trace::entering("mln::upscaling::art::scale3x"); 00075 00076 const I& input = exact(input_); 00077 mln_precondition(input.is_valid()); 00078 mlc_is_a(mln_domain(I), Box)::check(); 00079 00080 extension::adjust_duplicate(input, 1); 00081 00082 mln_domain(I) ext_domain(input.domain().pmin() * 3, 00083 input.domain().pmax() * 3 00084 + 2 * mln::down_right); 00085 00086 mln_concrete(I) output(ext_domain); 00087 00088 00089 mln_piter(I) p(input.domain()); 00090 for_all(p) 00091 { 00092 00093 // A B C --\ 1 2 3 00094 // D E F > 4 5 6 00095 // G H I --/ 7 8 9 00096 mln_site(I) 00097 pA = p + mln::up_left, 00098 pB = p + mln::up, 00099 pC = p + mln::up_right, 00100 pD = p + mln::left, 00101 pE = p, 00102 pF = p + mln::right, 00103 pG = p + mln::down_left, 00104 pH = p + mln::down, 00105 pI = p + mln::down_right, 00106 pOut = p * 3 + mln::down_right; 00107 00108 // IF D==B AND D!=H AND B!=F => 1=D 00109 if (input(pD) == input(pB) 00110 && input(pD) != input(pH) 00111 && input(pB) != input(pF)) 00112 output(pOut + mln::up_left) = input(pD); 00113 else 00114 output(pOut + mln::up_left) = input(p); 00115 00116 // IF (D==B AND D!=H AND B!=F AND E!=C) OR (B==F AND B!=D 00117 // AND F!=H AND E!=A) 2=B 00118 if ((input(pD) == input(pB) 00119 && input(pD) != input(pH) 00120 && input(pB) != input(pF) 00121 && input(pE) != input(pC)) 00122 || (input(pB) == input(pF) 00123 && input(pB) != input(pD) 00124 && input(pF) != input(pH) 00125 && input(pE) != input(pA))) 00126 output(pOut + mln::up) = input(pB); 00127 else 00128 output(pOut + mln::up) = input(p); 00129 00130 // IF B==F AND B!=D AND F!=H => 3=F 00131 if (input(pB) == input(pF) 00132 && input(pB) != input(pD) 00133 && input(pF) != input(pH)) 00134 output(pOut + mln::up_right) = input(pF); 00135 else 00136 output(pOut + mln::up_right) = input(p); 00137 00138 // IF (H==D AND H!=F AND D!=B AND E!=A) OR (D==B AND D!=H 00139 // AND B!=F AND E!=G) 4=D 00140 if ((input(pH) == input(pD) 00141 && input(pH) != input(pF) 00142 && input(pD) != input(pB) 00143 && input(pE) != input(pA)) 00144 || (input(pD) == input(pB) 00145 && input(pD) != input(pH) 00146 && input(pB) != input(pF) 00147 && input(pE) != input(pG))) 00148 output(pOut + mln::left) = input(pD); 00149 else 00150 output(pOut + mln::left) = input(p); 00151 00152 // 5=E 00153 output(pOut) = input(p); 00154 00155 // IF (B==F AND B!=D AND F!=H AND E!=I) OR (F==H AND F!=B 00156 // AND H!=D AND E!=C) 6=F 00157 if ((input(pB) == input(pF) 00158 && input(pB) != input(pD) 00159 && input(pF) != input(pH) 00160 && input(pE) != input(pI)) 00161 || (input(pF) == input(pH) 00162 && input(pF) != input(pB) 00163 && input(pH) != input(pD) 00164 && input(pE) != input(pC))) 00165 output(pOut + mln::right) = input(pF); 00166 else 00167 output(pOut + mln::right) = input(p); 00168 00169 // IF H==D AND H!=F AND D!=B => 7=D 00170 if (input(pH) == input(pD) 00171 && input(pH) != input(pF) 00172 && input(pD) != input(pB)) 00173 output(pOut + mln::down_left) = input(pD); 00174 else 00175 output(pOut + mln::down_left) = input(p); 00176 00177 00178 // IF (F==H AND F!=B AND H!=D AND E!=G) OR (H==D AND H!=F 00179 // AND D!=B AND E!=I) 8=H 00180 if ((input(pF) == input(pH) 00181 && input(pF) != input(pB) 00182 && input(pH) != input(pD) 00183 && input(pE) != input(pG)) 00184 || (input(pH) == input(pD) 00185 && input(pH) != input(pF) 00186 && input(pD) != input(pB) 00187 && input(pE) != input(pI))) 00188 output(pOut + mln::down) = input(pH); 00189 else 00190 output(pOut + mln::down) = input(p); 00191 00192 00193 // IF F==H AND F!=B AND H!=D => 9=F 00194 if (input(pF) == input(pH) 00195 && input(pF) != input(pB) 00196 && input(pH) != input(pD)) 00197 output(pOut + mln::down_right) = input(pF); 00198 else 00199 output(pOut + mln::down_right) = input(p); 00200 00201 } 00202 00203 trace::exiting("mln::upscaling::art::scale3x"); 00204 return output; 00205 } 00206 00207 00208 # endif // ! MLN_INCLUDE_ONLY 00209 00210 00211 } // end of namespace mln::upscaling::art 00212 00213 } // end of namespace mln::upscaling 00214 00215 } // end of namespace mln 00216 00217 00218 #endif // ! MLN_UPSCALING_ART_SCALE3X_HH