27 #ifndef MLN_FUN_X2V_TRILINEAR_HH
28 # define MLN_FUN_X2V_TRILINEAR_HH
30 # include <mln/core/image/image2d.hh>
31 # include <mln/core/concept/function.hh>
32 # include <mln/fun/internal/selector.hh>
33 # include <mln/convert/to.hh>
34 # include <mln/algebra/vec.hh>
53 template <
typename I >
57 mln_value(I), trilinear<I> >
::ret
65 operator()(const algebra::vec<3,
T>& v) const;
71 # ifndef MLN_INCLUDE_ONLY
76 mlc_bool(I::psite::dim == 3)::check();
83 trilinear<I>::operator()(const algebra::vec<3,
T>& v)
const
85 typedef mln_sum(mln_value(I)) vsum;
91 unsigned x1 = math::
round<
double>(std::floor(x));
92 unsigned x2 = math::
round<
double>(std::floor(x) + 1);
93 unsigned y1 = math::
round<
double>(std::floor(y));
94 unsigned y2 = math::
round<
double>(std::floor(y) + 1);
95 unsigned z1 = math::
round<
double>(std::floor(z));
96 unsigned z2 = math::
round<
double>(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