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/ImgIterator.h ** 00010 ** Module : ICLCore ** 00011 ** Authors: Christof Elbrechter, Michael Goetting, 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 <ICLCore/CoreFunctions.h> 00034 #include <ICLMath/MatrixSubRectIterator.h> 00035 00036 namespace icl{ 00037 namespace core{ 00039 00240 template <typename Type> 00241 class ImgIterator : public math::MatrixSubRectIterator<Type>{ 00242 public: 00243 00244 static inline const ImgIterator<Type> create_end_roi_iterator(const Type *data, 00245 int width, 00246 const utils::Rect &roi){ 00247 ImgIterator<Type> i(const_cast<Type*>(data),width,roi); 00248 i.m_dataCurr = i.m_dataEnd - roi.width + width; 00249 i.m_currLineEnd = i.m_dataCurr + roi.width; 00250 return i; 00251 } 00252 00254 00255 inline ImgIterator(){} 00256 00262 inline ImgIterator(Type *data,int imageWidth,const utils::Rect &roi): 00263 math::MatrixSubRectIterator<Type>(data,imageWidth,roi.x,roi.y,roi.width,roi.height){} 00264 00266 00275 inline ImgIterator(const ImgIterator<Type> &origin, const utils::Size &s, const utils::Point &a){ 00276 ImgIterator<Type>::m_matrixWidth=origin.m_matrixWidth; 00277 ImgIterator<Type>::m_subRectWidth=s.width; 00278 ImgIterator<Type>::m_subRectHeight=s.height; 00279 ImgIterator<Type>::m_dataOrigin=origin.m_dataOrigin; 00280 ImgIterator<Type>::m_dataCurr=origin.m_dataCurr - a.x - a.y * origin.m_matrixWidth; 00281 ImgIterator<Type>::init(); 00282 } 00283 00285 00289 inline bool inRegionSubROI() const{ 00290 return ImgIterator<Type>::inSubRect(); 00291 } 00292 00294 inline ImgIterator<Type> &operator=(const math::MatrixSubRectIterator<Type> &other){ 00295 math::MatrixSubRectIterator<Type>::operator=(other); 00296 return *this; 00297 } 00298 00300 inline const ImgIterator<Type> &operator=(const math::MatrixSubRectIterator<Type> &other) const{ 00301 math::MatrixSubRectIterator<Type>::operator=(other); 00302 return *this; 00303 } 00304 00306 int getROIWidth() const { 00307 return math::MatrixSubRectIterator<Type>::getSubRectWidth(); 00308 } 00309 00311 int getROIHeight() const { 00312 return math::MatrixSubRectIterator<Type>::getSubRectHeight(); 00313 } 00314 }; 00315 } // namespace core 00316 } // namespace icl