26 #ifndef MLN_FUN_X2V_TRILINEAR_HH
27 # define MLN_FUN_X2V_TRILINEAR_HH
29 # include <mln/core/image/image2d.hh>
30 # include <mln/core/concept/function.hh>
31 # include <mln/fun/internal/selector.hh>
32 # include <mln/convert/to.hh>
33 # include <mln/algebra/vec.hh>
52 template <
typename I >
54 :
public fun::internal::selector_<const algebra::vec<3,float>,
56 mln_value(I), trilinear<I> >::ret
58 typedef mln_value(I) result;
64 operator()(
const algebra::vec<3,T>& v)
const;
70 # ifndef MLN_INCLUDE_ONLY
75 mlc_bool(I::psite::dim == 3)::check();
82 trilinear<I>::operator()(const algebra::vec<3,T>& v)
const
84 typedef mln_sum(mln_value(I)) vsum;
90 math::round<
double> f;
91 unsigned x1 = f(std::floor(x));
92 unsigned x2 = f(std::floor(x) + 1);
93 unsigned y1 = f(std::floor(y));
94 unsigned y2 = f(std::floor(y) + 1);
95 unsigned z1 = f(std::floor(z));
96 unsigned z2 = f(std::floor(z) + 1);
104 vsum i1 = ima(
point3d(z1,x1,y1)) * (1 - zd)
107 vsum i2 = ima(
point3d(z1,x1,y2)) * (1 - zd)
110 vsum j1 = ima(
point3d(z1,x2,y1)) * (1 - zd)
113 vsum j2 = ima(
point3d(z1,x2,y2)) * (1 - zd)
117 vsum w1 = i1 * (1 - yd) + i2 * yd;
118 vsum w2 = j1 * (1 - yd) + j2 * yd;
121 vsum res = w1 * (1 - xd) + w2 * xd;
123 return convert::to<mln_value(I)>(res);
127 # endif // ! MLN_INCLUDE_ONLY
136 #endif // ! MLN_FUN_X2V_TRILINEAR_HH