Image Component Library (ICL)
ImgParams.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLCore/src/ICLCore/ImgParams.h **
10 ** Module : ICLCore **
11 ** Authors: Christof Elbrechter, Robert Haschke **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Point.h>
35 #include <ICLUtils/Size.h>
36 #include <ICLUtils/Rect.h>
37 #include <ICLCore/Types.h>
38 #include <ICLUtils/Exception.h>
39 #include <ICLUtils/Macros.h>
40 
41 
42 namespace icl{
43  namespace core{
45 
59  public:
61  static const ImgParams null;
62 
63 
65 
69  m_oSize(null.m_oSize), m_iChannels(null.m_iChannels),
70  m_eFormat(null.m_eFormat), m_oROI(null.m_oROI){}
71 
73 
74  ImgParams(const ImgParams &params):
75  m_oSize(params.m_oSize),m_iChannels(params.m_iChannels),
76  m_eFormat(params.m_eFormat),m_oROI(params.m_oROI){}
77 
79 
80  ImgParams(const utils::Size &size, int channels, const utils::Rect &roi = utils::Rect::null)
81  { setup(size,formatMatrix,channels,roi); }
82 
84 
85  ImgParams(const utils::Size &size, format fmt, const utils::Rect &roi = utils::Rect::null);
86 
88 
92  ImgParams(const utils::Size &size, int channels, format fmt, const utils::Rect& roi = utils::Rect::null)
93  { setup(size,fmt,channels,roi); }
94 
96 
99  ImgParams(int width, int height, format fmt,
100  int roiX=0, int roiY=0, int roiWidth = 0, int roiHeight = 0);
101 
103 
106  ImgParams(int width, int height, int channels,
107  int roiX=0, int roiY=0, int roiWidth = 0, int roiHeight = 0);
108 
109 
111 
115  ImgParams(int width, int height, int channels, format fmt,
116  int roiX=0, int roiY=0, int roiWidth=0, int roiHeight=0);
117 
119  bool isNull() const { return (*this)==null; }
120 
122  bool operator!=(const ImgParams &other) const{ return !((*this)==other); }
123 
125  bool operator==(const ImgParams &other) const;
126 
128  void setSize(const utils::Size &size);
129 
131  void setFormat(format fmt);
132 
134  void setChannels(int channels);
135 
137 
140  void setROIOffset(const utils::Point &offset);
141 
143 
146  void setROISize(const utils::Size &roisize);
147 
149 
152  void setROI(const utils::Point &offset, const utils::Size &roisize);
153 
155  void setROI(const utils::Rect &roi) { setROI (roi.ul(),roi.getSize()); }
156 
158  void setROIOffsetAdaptive(const utils::Point &offset);
159 
161  void setROISizeAdaptive(const utils::Size &size);
162 
164 
173  void setROIAdaptive(const utils::Rect &r);
174 
176 
177  utils::Rect& adaptROI(utils::Rect &roi) const;
178 
180  bool hasFullROI() const { return m_oROI.getSize() == m_oSize;}
181 
183  void setFullROI(){ setROI(utils::Point::null, getSize()); }
184 
186  const utils::Size& getSize() const { return m_oSize; }
187 
189  int getChannels() const { return m_iChannels; }
190 
192  format getFormat() const { return m_eFormat; }
193 
195  const utils::Rect& getROI() const { return m_oROI; }
196 
198  void getROI(utils::Point &offset, utils::Size &size) const {
199  offset=getROIOffset(); size = getROISize();
200  }
201 
203  const utils::Point getROIOffset() const { return m_oROI.ul(); }
204 
206  const utils::Size getROISize() const{ return m_oROI.getSize(); }
207 
209  int getWidth() const { return m_oSize.width; }
210 
212  int getHeight() const{ return m_oSize.height; }
213 
215  int getPixelOffset() const { return m_oROI.x+m_oROI.y*getWidth(); }
216 
218  int getROIWidth() const{ return m_oROI.width; }
219 
221  int getROIHeight() const{ return m_oROI.height; }
222 
224  int getROIXOffset() const{ return m_oROI.x; }
225 
227  int getROIYOffset() const { return m_oROI.y; }
228 
230  int getDim() const { return getSize().getDim(); }
231 
233  int getROIDim() const { return getROISize().getDim(); }
234 
235  private:
237 
273  void setup(const utils::Size &size, format fmt, int channels, const utils::Rect &roi);
274 
275 
278 
281 
284 
287 
288  };
289 
291  ICLCore_API std::ostream &operator<<(std::ostream &os, const ImgParams &p);
292 
294  ICLCore_API std::istream &operator>>(std::istream &is, ImgParams &p);
295 
296  } // namespace core
297 }
298 
int getROIDim() const
returns the count of ROI pixels ( ROI_width*ROI_height )
Definition: ImgParams.h:233
void getROI(utils::Point &offset, utils::Size &size) const
copies the roi parameters into the given structs offset and size
Definition: ImgParams.h:198
undocument this line if you encounter any issues!
Definition: Any.h:37
int getROIWidth() const
returns the ROI width of the object
Definition: ImgParams.h:218
const utils::Size getROISize() const
returns the objects ROI size
Definition: ImgParams.h:206
int getROIYOffset() const
returns the ROI Y-Offset of the object
Definition: ImgParams.h:227
ImgParams()
creates a null ImgParams object
Definition: ImgParams.h:68
ImgParams(const utils::Size &size, int channels, format fmt, const utils::Rect &roi=utils::Rect::null)
creates an ImgParams object with all given parameters
Definition: ImgParams.h:92
ICLCore_API std::istream & operator>>(std::istream &s, format &f)
puts a string representation of format into the given stream
ICLCore_API std::ostream & operator<<(std::ostream &s, const format &f)
puts a string representation of format into the given stream
int getDim() const
returns the count of image pixels (width*height)
Definition: ImgParams.h:230
int getPixelOffset() const
returns ROI-dependent pixel offset, to address the upper left ROI pixel
Definition: ImgParams.h:215
int getChannels() const
returns the objects channel count
Definition: ImgParams.h:189
ICLQt_API ImgROI roi(ImgQ &r)
creates a ROI-struct from an image
const utils::Rect & getROI() const
returns the objects ROI rect
Definition: ImgParams.h:195
ImgParams(const utils::Size &size, int channels, const utils::Rect &roi=utils::Rect::null)
creates an ImgParams object with specified size, channels, roi and formatMatrix
Definition: ImgParams.h:80
ImgParams(const ImgParams &params)
copy constructor
Definition: ImgParams.h:74
static const Rect null
null Rect is w=0, h=0, x=0, y=0
Definition: Rect.h:99
bool isNull() const
checks wether the object instance is null, i.e. all elements are zero
Definition: ImgParams.h:119
void setROI(const utils::Rect &roi)
sets the image ROI to the given rectangle
Definition: ImgParams.h:155
int getROIXOffset() const
returns the ROI X-Offset of the object
Definition: ImgParams.h:224
The ImgParams class stores all image parameters .
Definition: ImgParams.h:58
const utils::Size & getSize() const
returns the objects size
Definition: ImgParams.h:186
utils::Size m_oSize
image size
Definition: ImgParams.h:277
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
format getFormat() const
returns the object format
Definition: ImgParams.h:192
Size class of the ICL.
Definition: Size.h:61
int getROIHeight() const
returns the ROI height of the object
Definition: ImgParams.h:221
int m_iChannels
image channel count
Definition: ImgParams.h:280
int getWidth() const
returns the objects image width
Definition: ImgParams.h:209
const utils::Point getROIOffset() const
returns the objects ROI offset
Definition: ImgParams.h:203
utils::Rect m_oROI
image roi
Definition: ImgParams.h:286
bool hasFullROI() const
returns ROISize == ImageSize
Definition: ImgParams.h:180
void setFullROI()
sets the ROI to 0,0,image-width,image-height
Definition: ImgParams.h:183
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
static const Point null
null Point is x=0, y=0
Definition: Point.h:61
int getHeight() const
return the objects image height
Definition: ImgParams.h:212
bool operator!=(const ImgParams &other) const
returns !(*this==other)
Definition: ImgParams.h:122
format m_eFormat
image format (formatRGB, formatMatrix, ...)
Definition: ImgParams.h:283
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
#define ICLCore_API
Definition: CompatMacros.h:174
Definition: Types.h:77