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.LGPL ** 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/CompatMacros.h> 00034 #include <ICLUtils/Point.h> 00035 #include <ICLUtils/Size.h> 00036 #include <ICLUtils/Rect.h> 00037 #include <ICLCore/Types.h> 00038 #include <ICLUtils/Exception.h> 00039 #include <ICLUtils/Macros.h> 00040 00041 00042 namespace icl{ 00043 namespace core{ 00045 00058 class ICLCore_API ImgParams{ 00059 public: 00061 static const ImgParams null; 00062 00063 00065 00068 ImgParams() : 00069 m_oSize(null.m_oSize), m_iChannels(null.m_iChannels), 00070 m_eFormat(null.m_eFormat), m_oROI(null.m_oROI){} 00071 00073 00074 ImgParams(const ImgParams ¶ms): 00075 m_oSize(params.m_oSize),m_iChannels(params.m_iChannels), 00076 m_eFormat(params.m_eFormat),m_oROI(params.m_oROI){} 00077 00079 00080 ImgParams(const utils::Size &size, int channels, const utils::Rect &roi = utils::Rect::null) 00081 { setup(size,formatMatrix,channels,roi); } 00082 00084 00085 ImgParams(const utils::Size &size, format fmt, const utils::Rect &roi = utils::Rect::null); 00086 00088 00092 ImgParams(const utils::Size &size, int channels, format fmt, const utils::Rect& roi = utils::Rect::null) 00093 { setup(size,fmt,channels,roi); } 00094 00096 00099 ImgParams(int width, int height, format fmt, 00100 int roiX=0, int roiY=0, int roiWidth = 0, int roiHeight = 0); 00101 00103 00106 ImgParams(int width, int height, int channels, 00107 int roiX=0, int roiY=0, int roiWidth = 0, int roiHeight = 0); 00108 00109 00111 00115 ImgParams(int width, int height, int channels, format fmt, 00116 int roiX=0, int roiY=0, int roiWidth=0, int roiHeight=0); 00117 00119 bool isNull() const { return (*this)==null; } 00120 00122 bool operator!=(const ImgParams &other) const{ return !((*this)==other); } 00123 00125 bool operator==(const ImgParams &other) const; 00126 00128 void setSize(const utils::Size &size); 00129 00131 void setFormat(format fmt); 00132 00134 void setChannels(int channels); 00135 00137 00140 void setROIOffset(const utils::Point &offset); 00141 00143 00146 void setROISize(const utils::Size &roisize); 00147 00149 00152 void setROI(const utils::Point &offset, const utils::Size &roisize); 00153 00155 void setROI(const utils::Rect &roi) { setROI (roi.ul(),roi.getSize()); } 00156 00158 void setROIOffsetAdaptive(const utils::Point &offset); 00159 00161 void setROISizeAdaptive(const utils::Size &size); 00162 00164 00173 void setROIAdaptive(const utils::Rect &r); 00174 00176 00177 utils::Rect& adaptROI(utils::Rect &roi) const; 00178 00180 bool hasFullROI() const { return m_oROI.getSize() == m_oSize;} 00181 00183 void setFullROI(){ setROI(utils::Point::null, getSize()); } 00184 00186 const utils::Size& getSize() const { return m_oSize; } 00187 00189 int getChannels() const { return m_iChannels; } 00190 00192 format getFormat() const { return m_eFormat; } 00193 00195 const utils::Rect& getROI() const { return m_oROI; } 00196 00198 void getROI(utils::Point &offset, utils::Size &size) const { 00199 offset=getROIOffset(); size = getROISize(); 00200 } 00201 00203 const utils::Point getROIOffset() const { return m_oROI.ul(); } 00204 00206 const utils::Size getROISize() const{ return m_oROI.getSize(); } 00207 00209 int getWidth() const { return m_oSize.width; } 00210 00212 int getHeight() const{ return m_oSize.height; } 00213 00215 int getPixelOffset() const { return m_oROI.x+m_oROI.y*getWidth(); } 00216 00218 int getROIWidth() const{ return m_oROI.width; } 00219 00221 int getROIHeight() const{ return m_oROI.height; } 00222 00224 int getROIXOffset() const{ return m_oROI.x; } 00225 00227 int getROIYOffset() const { return m_oROI.y; } 00228 00230 int getDim() const { return getSize().getDim(); } 00231 00233 int getROIDim() const { return getROISize().getDim(); } 00234 00235 private: 00237 00273 void setup(const utils::Size &size, format fmt, int channels, const utils::Rect &roi); 00274 00275 00277 utils::Size m_oSize; 00278 00280 int m_iChannels; 00281 00283 format m_eFormat; 00284 00286 utils::Rect m_oROI; 00287 00288 }; 00289 00291 ICLCore_API std::ostream &operator<<(std::ostream &os, const ImgParams &p); 00292 00294 ICLCore_API std::istream &operator>>(std::istream &is, ImgParams &p); 00295 00296 } // namespace core 00297 } 00298