17 #ifndef SURGSIM_DATASTRUCTURES_IMAGE_INL_H
18 #define SURGSIM_DATASTRUCTURES_IMAGE_INL_H
24 namespace DataStructures
29 m_width(0), m_height(0), m_channels(0)
36 m_width(width), m_height(height), m_channels(channels), m_data(new T[m_width * m_height * m_channels])
41 Image<T>::Image(
size_t width,
size_t height,
size_t channels,
const T*
const data) :
42 m_width(width), m_height(height), m_channels(channels), m_data(new T[m_width * m_height * m_channels])
44 std::copy(data, data + width * height * channels,
m_data.get());
49 m_width(other.getWidth()), m_height(other.getHeight()), m_channels(other.getNumChannels()),
50 m_data(new T[m_width * m_height * m_channels])
59 *
this = std::move(other);
68 size_t oldDataSize = getWidth() * getHeight() * getNumChannels();
69 if (newDataSize != oldDataSize)
71 m_data.reset(
new T[newDataSize]);
76 std::copy(other.
m_data.get(), other.
m_data.get() + newDataSize, m_data.get());
86 m_data = std::move(other.m_data);
87 m_width = other.getWidth();
88 m_height = other.getHeight();
89 m_channels = other.getNumChannels();
106 SURGSIM_ASSERT(channel < m_channels) <<
"channel number is larger than the number of channels";
107 return ChannelType(m_data.get() + channel, m_width, m_height, Eigen::InnerStride<>(m_channels));
125 std::array<size_t, 3> size = {m_width, m_height, m_channels};
126 return std::move(size);
150 #endif //SURGSIM_DATASTRUCTURES_IMAGE_INL_H
Definition: DriveElementFromInputBehavior.cpp:27
std::unique_ptr< T[]> m_data
Definition: Image.h:110
A templated Image class.
Definition: Image.h:34
size_t getHeight() const
Get the Image height.
Definition: Image-inl.h:117
size_t m_width
Definition: Image.h:107
std::array< size_t, 3 > getSize() const
Get the Image size.
Definition: Image-inl.h:123
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >, 0, Eigen::InnerStride<> > ChannelType
Type of the channel returned by getChannel.
Definition: Image.h:91
Image< T > & operator=(const Image< T > &other)
Assignment Operator.
Definition: Image-inl.h:63
size_t m_height
Definition: Image.h:108
Image()
Default Constructor.
Definition: Image-inl.h:28
size_t m_channels
Definition: Image.h:109
The header that provides the assertion API.
size_t getWidth() const
Get the Image width.
Definition: Image-inl.h:111
virtual ~Image()
Destructor.
Definition: Image-inl.h:99
T *const getData()
Get the pointer to the data.
Definition: Image-inl.h:136
ChannelType getChannel(size_t channel)
Get the data in the channel as an eigen matrix.
Definition: Image-inl.h:104
size_t getNumChannels() const
Get the number of channels in this Image.
Definition: Image-inl.h:130