Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ImgIterator.h
Go to the documentation of this file.
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.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 <ICLCore/CoreFunctions.h>
00035 #include <ICLMath/MatrixSubRectIterator.h>
00036 
00037 namespace icl{
00038   namespace core{
00040 
00241     template <typename Type>
00242     class ImgIterator : public math::MatrixSubRectIterator<Type>{
00243       public:
00244       
00245       static inline const ImgIterator<Type> create_end_roi_iterator(const Type *data,
00246                                                                     int width,
00247                                                                     const utils::Rect &roi){
00248         ImgIterator<Type> i(const_cast<Type*>(data),width,roi);
00249         i.m_dataCurr = i.m_dataEnd - roi.width + width;
00250         i.m_currLineEnd = i.m_dataCurr + roi.width;
00251         return i;
00252       }
00253 
00255 
00256       inline ImgIterator(){}
00257 
00263       inline ImgIterator(Type *data,int imageWidth,const utils::Rect &roi):
00264       math::MatrixSubRectIterator<Type>(data,imageWidth,roi.x,roi.y,roi.width,roi.height){}
00265 
00267 
00276       inline ImgIterator(const ImgIterator<Type> &origin, const utils::Size &s, const utils::Point &a){
00277         ImgIterator<Type>::m_matrixWidth=origin.m_matrixWidth;
00278         ImgIterator<Type>::m_subRectWidth=s.width;
00279         ImgIterator<Type>::m_subRectHeight=s.height;
00280         ImgIterator<Type>::m_dataOrigin=origin.m_dataOrigin;
00281         ImgIterator<Type>::m_dataCurr=origin.m_dataCurr - a.x - a.y * origin.m_matrixWidth;
00282         ImgIterator<Type>::init();
00283       }
00284 
00286 
00290       inline bool inRegionSubROI() const{
00291         return ImgIterator<Type>::inSubRect();
00292       }
00293 
00295       inline ImgIterator<Type> &operator=(const math::MatrixSubRectIterator<Type> &other){
00296         math::MatrixSubRectIterator<Type>::operator=(other);
00297         return *this;
00298       }
00299     
00301       inline const ImgIterator<Type> &operator=(const math::MatrixSubRectIterator<Type> &other) const{
00302         math::MatrixSubRectIterator<Type>::operator=(other);
00303         return *this;
00304       }
00305 
00307       int getROIWidth() const {
00308         return math::MatrixSubRectIterator<Type>::getSubRectWidth();
00309       }
00310 
00312       int getROIHeight() const {
00313         return math::MatrixSubRectIterator<Type>::getSubRectHeight();
00314       }
00315     };
00316   } // namespace core
00317 } // namespace icl
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines