Image.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DATASTRUCTURES_IMAGE_H
17 #define SURGSIM_DATASTRUCTURES_IMAGE_H
18 
19 #include <array>
20 #include <memory>
21 
22 #include <Eigen/Core>
23 
24 namespace SurgSim
25 {
26 
27 namespace DataStructures
28 {
29 
33 template<class T>
34 class Image
35 {
36 public:
38  Image();
39 
44  Image(size_t width, size_t height, size_t channels);
45 
51  Image(size_t width, size_t height, size_t channels, const T* const data);
52 
55  Image(const Image<T>& other);
56 
59  Image(Image<T>&& other);
60 
62  virtual ~Image();
63 
67  Image<T>& operator=(const Image<T>& other);
68 
72  Image<T>& operator=(Image<T>&& other);
73 
76  size_t getWidth() const;
77 
80  size_t getHeight() const;
81 
84  std::array<size_t, 3> getSize() const;
85 
88  size_t getNumChannels() const;
89 
91  typedef Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>, 0, Eigen::InnerStride<>> ChannelType;
92 
96  ChannelType getChannel(size_t channel);
97 
100  T* const getData();
101 
104  const T* const getData() const;
105 
106 private:
107  size_t m_width;
108  size_t m_height;
109  size_t m_channels;
110  std::unique_ptr<T[]> m_data;
111 };
112 
114 
115 }
116 }
117 
119 
120 #endif //SURGSIM_DATASTRUCTURES_IMAGE_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
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
size_t getWidth() const
Get the Image width.
Definition: Image-inl.h:111
Image< float > Imagef
Definition: Image.h:113
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