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 : ICLCV/src/ICLCV/ImageRegion.h ** 00010 ** Module : ICLCV ** 00011 ** Authors: Christof Elbrechter, Erik Weitnauer ** 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 00032 #pragma once 00033 00034 #include <ICLUtils/ShallowCopyable.h> 00035 #include <ICLCore/Img.h> 00036 #include <ICLCV/RegionPCAInfo.h> 00037 #include <ICLCV/LineSegment.h> 00038 #include <ICLUtils/Any.h> 00039 00040 namespace icl{ 00041 namespace cv{ 00043 struct ImageRegionPart; 00044 struct ImageRegionData; 00048 00049 00098 struct ImageRegion { 00099 00101 ImageRegionData *m_data; 00102 00104 template<class T> void calculateBoundaryIntern(const core::Img<T> &image) const; 00105 00107 void calculateThinnedBoundaryIntern() const; 00108 00110 utils::Point getUpperLeftPixel()const; 00111 00112 public: 00113 00115 ImageRegion(ImageRegionData *data=0): 00116 m_data(data){} 00117 00119 friend class RegionDetector; 00120 00122 00123 inline operator bool() const { return m_data; } 00124 00126 ImageRegionData *data() { return m_data; } 00127 00129 const ImageRegionData *data() const { return m_data; } 00130 00132 void sample(core::ImgBase *image, int color); 00133 00135 void sample(core::ImgBase *image, const std::vector<int> &channelColors); 00136 00138 int getSize() const; 00139 00141 int getVal() const; 00142 00144 int getID() const; 00145 00147 utils::Point32f getCOG() const; 00148 00150 const std::vector<LineSegment> &getLineSegments() const; 00151 00153 const utils::Rect &getBoundingBox() const; 00154 00156 const RegionPCAInfo &getPCAInfo() const; 00157 00159 const std::vector<utils::Point> &getBoundary(bool thinned=true) const; 00160 00162 int getBoundaryPointCount(bool thinned) const; 00163 00165 00171 float getBoundaryLength() const; 00172 00174 00178 const std::vector<utils::Point32f> &getBoundaryCorners() const; 00179 00180 00182 00195 float getFormFactor() const; 00196 00198 00200 const std::vector<utils::Point> &getPixels() const; 00201 00203 void drawTo(const core::ImgBase *image, icl64f val) const; 00204 00206 00207 void drawToColor(const core::ImgBase *image, const icl64f *color) const; 00208 00210 00219 const std::vector<ImageRegion> &getSubRegions(bool directOnly=true) const throw (utils::ICLException); 00220 00222 00223 const ImageRegion &getParentRegion() const throw (utils::ICLException); 00224 00226 00229 const std::vector<ImageRegion> &getParentTree() const throw (utils::ICLException); 00230 00232 00233 const std::vector<ImageRegion> &getNeighbours() const throw (utils::ICLException); 00234 00236 bool isBorderRegion() const throw (utils::ICLException); 00237 00239 bool contains(const utils::Point &p) const; 00240 00242 void showTree() const; 00243 00245 00252 void setMetaData(const utils::Any &any) const; 00253 00255 const utils::Any &getMetaData() const; 00256 }; 00257 00258 } // namespace cv 00259 } 00260