Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLCore/src/ICLCore/ImgParams.h ** 00010 ** Module : ICLCore ** 00011 ** Authors: Christof Elbrechter, Robert Haschke ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.GPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLUtils/Point.h> 00034 #include <ICLUtils/Size.h> 00035 #include <ICLUtils/Rect.h> 00036 #include <ICLCore/Types.h> 00037 #include <ICLUtils/Exception.h> 00038 #include <ICLUtils/Macros.h> 00039 00040 00041 namespace icl{ 00042 namespace core{ 00044 00057 class ImgParams{ 00058 public: 00060 static const ImgParams null; 00061 00062 00064 00067 ImgParams(const ImgParams ¶ms=null): 00068 m_oSize(params.m_oSize),m_iChannels(params.m_iChannels), 00069 m_eFormat(params.m_eFormat),m_oROI(params.m_oROI){} 00070 00072 00073 ImgParams(const utils::Size &size, int channels, const utils::Rect &roi = utils::Rect::null) 00074 { setup(size,formatMatrix,channels,roi); } 00075 00077 00078 ImgParams(const utils::Size &size, format fmt, const utils::Rect &roi = utils::Rect::null); 00079 00081 00085 ImgParams(const utils::Size &size, int channels, format fmt, const utils::Rect& roi = utils::Rect::null) 00086 { setup(size,fmt,channels,roi); } 00087 00089 00092 ImgParams(int width, int height, format fmt, 00093 int roiX=0, int roiY=0, int roiWidth = 0, int roiHeight = 0); 00094 00096 00099 ImgParams(int width, int height, int channels, 00100 int roiX=0, int roiY=0, int roiWidth = 0, int roiHeight = 0); 00101 00102 00104 00108 ImgParams(int width, int height, int channels, format fmt, 00109 int roiX=0, int roiY=0, int roiWidth=0, int roiHeight=0); 00110 00112 bool isNull() const { return (*this)==null; } 00113 00115 bool operator!=(const ImgParams &other) const{ return !((*this)==other); } 00116 00118 bool operator==(const ImgParams &other) const; 00119 00121 void setSize(const utils::Size &size); 00122 00124 void setFormat(format fmt); 00125 00127 void setChannels(int channels); 00128 00130 00133 void setROIOffset(const utils::Point &offset); 00134 00136 00139 void setROISize(const utils::Size &roisize); 00140 00142 00145 void setROI(const utils::Point &offset, const utils::Size &roisize); 00146 00148 void setROI(const utils::Rect &roi) { setROI (roi.ul(),roi.getSize()); } 00149 00151 void setROIOffsetAdaptive(const utils::Point &offset); 00152 00154 void setROISizeAdaptive(const utils::Size &size); 00155 00157 00166 void setROIAdaptive(const utils::Rect &r); 00167 00169 00170 utils::Rect& adaptROI(utils::Rect &roi) const; 00171 00173 bool hasFullROI() const { return m_oROI.getSize() == m_oSize;} 00174 00176 void setFullROI(){ setROI(utils::Point::null, getSize()); } 00177 00179 const utils::Size& getSize() const { return m_oSize; } 00180 00182 int getChannels() const { return m_iChannels; } 00183 00185 format getFormat() const { return m_eFormat; } 00186 00188 const utils::Rect& getROI() const { return m_oROI; } 00189 00191 void getROI(utils::Point &offset, utils::Size &size) const { 00192 offset=getROIOffset(); size = getROISize(); 00193 } 00194 00196 const utils::Point getROIOffset() const { return m_oROI.ul(); } 00197 00199 const utils::Size getROISize() const{ return m_oROI.getSize(); } 00200 00202 int getWidth() const { return m_oSize.width; } 00203 00205 int getHeight() const{ return m_oSize.height; } 00206 00208 int getPixelOffset() const { return m_oROI.x+m_oROI.y*getWidth(); } 00209 00211 int getROIWidth() const{ return m_oROI.width; } 00212 00214 int getROIHeight() const{ return m_oROI.height; } 00215 00217 int getROIXOffset() const{ return m_oROI.x; } 00218 00220 int getROIYOffset() const { return m_oROI.y; } 00221 00223 int getDim() const { return getSize().getDim(); } 00224 00226 int getROIDim() const { return getROISize().getDim(); } 00227 00228 private: 00230 00266 void setup(const utils::Size &size, format fmt, int channels, const utils::Rect &roi); 00267 00268 00270 utils::Size m_oSize; 00271 00273 int m_iChannels; 00274 00276 format m_eFormat; 00277 00279 utils::Rect m_oROI; 00280 00281 }; 00282 00284 std::ostream &operator<<(std::ostream &os, const ImgParams &p); 00285 00287 std::istream &operator>>(std::istream &is, ImgParams &p); 00288 00289 } // namespace core 00290 } 00291