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 : ICLFilter/src/ICLFilter/OpROIHandler.h ** 00010 ** Module : ICLFilter ** 00011 ** Authors: Christof Elbrechter ** 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 <ICLCore/ImgBase.h> 00034 00035 namespace icl { 00036 namespace filter{ 00038 00077 class OpROIHandler { 00078 public: 00080 virtual ~OpROIHandler(){} 00081 00082 00083 private: 00084 friend class UnaryOp; 00085 friend class BinaryOp; 00087 void setClipToROI (bool bClipToROI) {this->m_bClipToROI = bClipToROI;} 00088 void setCheckOnly (bool bCheckOnly) {this->m_bCheckOnly = bCheckOnly;} 00089 00090 bool getClipToROI() const { return m_bClipToROI; } 00091 bool getCheckOnly() const { return m_bCheckOnly; } 00092 00094 OpROIHandler() : m_bClipToROI (true), m_bCheckOnly (false) {} 00095 00098 bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, 00099 core::format eFormat, int nChannels, const utils::Rect& roi, 00100 utils::Time timestamp=utils::Time::null); 00101 00103 virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) { 00104 // ensure that the checkOnly flag is set to TRUE, if source and destination images are the same pointers, 00105 // this can not lead to problems, because *ppoDst is reallocated only if its depth differs from 00106 // the source images depth (which is not true if poSrc==*ppoDst 00107 //ICLASSERT_RETURN_VAL( !(ppoDst && (*ppoDst==poSrc) && !getCheckOnly() ), false); 00108 return prepare (ppoDst, poSrc->getDepth(), chooseSize (poSrc), 00109 poSrc->getFormat(), poSrc->getChannels (), chooseROI (poSrc), 00110 poSrc->getTime()); 00111 } 00112 00115 virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth) { 00116 // ensure that the checkOnly flag is set to TRUE, if source and destination images are the same pointers, 00117 // this can not lead to problems, because *ppoDst is reallocated only if its depth differs from 00118 // the source images depth (which is not true if poSrc==*ppoDst 00119 // ICLASSERT_RETURN_VAL( !(ppoDst && (*ppoDst==poSrc) && !getCheckOnly() ), false); 00120 return prepare (ppoDst, eDepth, chooseSize (poSrc), 00121 poSrc->getFormat(), poSrc->getChannels (), chooseROI (poSrc), 00122 poSrc->getTime()); 00123 } 00125 const utils::Size chooseSize (const core::ImgBase *poSrc) { 00126 return m_bClipToROI ? poSrc->getROISize () : poSrc->getSize (); 00127 } 00129 const utils::Rect chooseROI (const core::ImgBase *poSrc) { 00130 return m_bClipToROI ? utils::Rect (utils::Point::null, poSrc->getROISize ()) 00131 : poSrc->getROI(); 00132 } 00133 00134 bool m_bClipToROI, m_bCheckOnly; 00135 }; 00136 } // namespace filter 00137 }