33 #include <unordered_set>
35 #include <boost/core/typeinfo.hpp>
41 namespace manipulators {
43 class Slice :
public boost::static_visitor< MultiChannelMap::val_type >
46 Slice(
size_t left,
size_t right)
62 for(
int j=0; j<channel.
width(); j++)
64 ret[i-
m_left][j] = channel[i][j];
85 class SliceShallow :
public boost::static_visitor< MultiChannelMap::val_type >
102 boost::core::typeinfo
const & ti = BOOST_CORE_TYPEID(T);
104 boost::shared_array<T> shallow_ptr(
105 channel.
dataPtr().get() + offset,
123 class RandomSample :
public boost::static_visitor< MultiChannelMap::val_type >
128 ,
m_seed(
std::chrono::steady_clock::now().time_since_epoch().count())
141 std::vector<size_t> indices(channel.
numElements());
142 std::iota(indices.begin(), indices.end(), 0);
143 std::shuffle(indices.begin(), indices.end(), std::default_random_engine(
m_seed));
147 for(
size_t j=0; j<channel.
width(); j++)
149 res[i][j] = channel[indices[i]][j];
153 std::unordered_set<size_t> indices;
155 auto eng = std::default_random_engine(
m_seed);
156 std::uniform_int_distribution<> distr(0, channel.
numElements() - 1);
160 indices.insert(distr(eng));
164 for(
const size_t& index : indices)
166 for(
size_t j=0; j<channel.
width(); j++)
168 res[i][j] = channel[index][j];