16 #ifndef SURGSIM_DATASTRUCTURES_IMAGEBASE_INL_H
17 #define SURGSIM_DATASTRUCTURES_IMAGEBASE_INL_H
24 namespace DataStructures
35 SURGSIM_ASSERT(x < m_width) <<
"x is larger than the image width (" << x <<
" >= " << m_width <<
")";
36 SURGSIM_ASSERT(y < m_height) <<
"y is larger than the image height (" << y <<
" >= " << m_height <<
")";
37 return Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>>
38 (getData() + m_channels * (x + y * m_width), m_channels);
44 SURGSIM_ASSERT(x < m_width) <<
"x is larger than the image width (" << x <<
" >= " << m_width <<
")";
45 SURGSIM_ASSERT(y < m_height) <<
"y is larger than the image height (" << y <<
" >= " << m_height <<
")";
46 return Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>>
47 (getData() + m_channels * (x + y * m_width), m_channels);
51 Eigen::Map<typename ImageBase<T>::ChannelType, Eigen::Unaligned, Eigen::Stride<-1, -1>>
54 SURGSIM_ASSERT(index < m_channels) <<
"Channel number is larger than the number of channels";
55 Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> stride(m_width*m_channels, m_channels);
56 return Eigen::Map<
ChannelType, Eigen::Unaligned, Eigen::Stride<-1, -1>>
57 (getData() + index, m_width, m_height, stride);
61 Eigen::Map<const typename ImageBase<T>::ChannelType, Eigen::Unaligned, Eigen::Stride<-1, -1>>
64 SURGSIM_ASSERT(index < m_channels) <<
"Channel number is larger than the number of channels";
65 Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> stride(m_width*m_channels, m_channels);
66 return Eigen::Map<
const ChannelType, Eigen::Unaligned, Eigen::Stride<-1, -1>>
67 (getData() + index, m_width, m_height, stride);
73 auto myChannel = getChannel(index);
74 SURGSIM_ASSERT(myChannel.rows() == data.rows() && myChannel.cols() == data.cols())
75 <<
"Channel data must be of size " << myChannel.rows() <<
"x" << myChannel.cols() <<
". "
76 << data.rows() <<
"x" << data.cols() <<
" data was provided.";
83 return Eigen::Map<VectorType, Eigen::Unaligned>(getData(), m_width * m_height * m_channels);
89 return Eigen::Map<const VectorType, Eigen::Unaligned>(getData(), m_width * m_height * m_channels);
95 auto myVector = getAsVector();
96 SURGSIM_ASSERT(myVector.rows() == data.rows() && myVector.cols() == data.cols())
97 <<
"Vector must be of size " << myVector.rows() <<
"x" << myVector.cols() <<
". "
98 <<
"A " << data.rows() <<
"x" << data.cols() <<
" vector was provided.";
117 std::array<size_t, 3> size = {m_width, m_height, m_channels};
132 m_channels = channels;
138 #endif //SURGSIM_DATASTRUCTURES_IMAGEBASE_INL_H