15inline void Ensemble::heightheight(
const T& f,
const M& fmask)
17 using mask_type =
typename M::value_type;
19 static_assert(std::is_integral<mask_type>::value,
"Integral mask required.");
22 GOOSEEYE_ASSERT(f.dimension() == m_shape_orig.size(), std::out_of_range);
23 GOOSEEYE_ASSERT(xt::all(xt::equal(fmask, 0) || xt::equal(fmask, 1)), std::out_of_range);
24 GOOSEEYE_ASSERT(m_stat == Type::heightheight || m_stat == Type::Unset, std::out_of_range);
27 m_stat = Type::heightheight;
30 xt::pad_mode pad_mode = xt::pad_mode::constant;
35 pad_mode = xt::pad_mode::periodic;
42 xt::pad(xt::atleast_3d(fmask), m_pad, xt::pad_mode::constant, mask_value);
44 xt::pad(xt::atleast_3d(fmask), m_pad, xt::pad_mode::constant, mask_value);
47 for (
size_t h = m_pad[0][0]; h < F.shape(0) - m_pad[0][1]; ++h) {
48 for (
size_t i = m_pad[1][0]; i < F.shape(1) - m_pad[1][1]; ++i) {
49 for (
size_t j = m_pad[2][0]; j < F.shape(2) - m_pad[2][1]; ++j) {
57 xt::range(h - m_pad[0][0], h + m_pad[0][1] + 1),
58 xt::range(i - m_pad[1][0], i + m_pad[1][1] + 1),
59 xt::range(j - m_pad[2][0], j + m_pad[2][1] + 1));
61 auto Fmii = 1.0 - xt::view(
63 xt::range(h - m_pad[0][0], h + m_pad[0][1] + 1),
64 xt::range(i - m_pad[1][0], i + m_pad[1][1] + 1),
65 xt::range(j - m_pad[2][0], j + m_pad[2][1] + 1));
67 m_first += xt::pow(Fi - F(h, i, j), 2.0) * Fmii;
70 m_second += xt::pow(Fi - F(h, i, j), 4.0) * Fmii;