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 Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::array< size_t, 3 > getSize() const
Get the Image size.
Definition: ImageBase-inl.h:115
size_t getHeight() const
Get the Image height.
Definition: ImageBase-inl.h:109
void setChannel(size_t index, const Eigen::Ref< const ChannelType > &data)
Set the image data in the channel.
Definition: ImageBase-inl.h:71
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > ChannelType
2D Channel Type;
Definition: ImageBase.h:67
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, 1 > > operator()(size_t x, size_t y)
Get the pixel value at (x, y)
Definition: ImageBase-inl.h:33
Eigen::Map< ChannelType, Eigen::Unaligned, Eigen::Stride<-1, -1 > > getChannel(size_t index)
Get the 2D image channel data.
Definition: ImageBase-inl.h:52
void setSize(size_t width, size_t height, size_t channels)
Set the Image size.
Definition: ImageBase-inl.h:128
The header that provides the assertion API.
size_t getWidth() const
Get the Image width.
Definition: ImageBase-inl.h:103
Eigen::Map< VectorType, Eigen::Unaligned > getAsVector()
Get the data as a 1D Vector.
Definition: ImageBase-inl.h:81
void setAsVector(const Eigen::Ref< const VectorType > &data)
Set the image data as a 1D Vector.
Definition: ImageBase-inl.h:93
virtual ~ImageBase()
Destructor.
Definition: ImageBase-inl.h:28
size_t getNumChannels() const
Get the number of channels in this Image.
Definition: ImageBase-inl.h:122