Image Component Library (ICL)
ImageRegionData.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLCV/src/ICLCV/ImageRegionData.h **
10 ** Module : ICLCV **
11 ** Authors: Christof Elbrechter, Erik Weitnauer **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/StackTimer.h>
35 #include <ICLUtils/Any.h>
36 #include <ICLCore/Img.h>
37 #include <ICLCV/ImageRegionPart.h>
38 #include <ICLCV/ImageRegion.h>
39 #include <ICLCV/RegionPCAInfo.h>
41 
42 #include <set>
43 
44 namespace icl{
45  namespace cv{
46 
48 
51  private:
53  public:
54  friend class RegionDetector;
55  friend struct ImageRegion;
56  friend bool region_search_border(std::set<IRD*>&,IRD*);
57  friend void collect_subregions_recursive(std::set<IRD*>&,IRD*);
58  friend bool is_region_contained(IRD*,IRD*);
59  friend bool region_search_outer_bb(const utils::Rect&,std::set<IRD*>&,IRD*);
60 
61  private:
63  int value;
64 
66  int id;
67 
69  mutable int size;
70 
73 
75  std::vector<LineSegment> segments;
76 
79 
83  RegionGraphInfo():isBorder(false),parent(0){}
84 
86  bool isBorder;
87 
88  // region graph information
89  std::set<ImageRegionData*> neighbours;
90 
91  // child regions
92  std::vector<ImageRegionData*> children;
93 
96  } *graph;
97 
98  // structure for representing simple region information
101  boundingBox(0),cog(0),pcainfo(0),
102  boundaryLength(0),boundary(0),
103  thinned_boundary(0),pixels(0){}
105  if(boundingBox) delete boundingBox;
106  if(cog) delete cog;
107  if(pcainfo) delete pcainfo;
108  if(boundary) delete boundary;
109  if(thinned_boundary) delete thinned_boundary;
110  if(pixels) delete pixels;
111  }
116 
117  std::vector<utils::Point> *boundary;
118  std::vector<utils::Point> *thinned_boundary;
119  std::vector<utils::Point> *pixels;
120 
121  } *simple;
122 
123  struct CSSParams{
125  float rc_coeff;
126  float sigma;
129  std::vector<utils::Point32f> resultBuffer;
130 
131  bool isOk(CornerDetectorCSS *css) const{
132  return css->getAngleThreshold() == angle_thresh &&
133  css->getRCCoeff() == rc_coeff &&
134  css->getSigma() == sigma &&
135  css->getCurvatureCutoff() == curvature_cutoff &&
136  css->getStraightLineThreshold() == straight_line_thresh;
137  }
138 
140  angle_thresh = css->getAngleThreshold();
141  rc_coeff = css->getRCCoeff();
142  sigma = css->getSigma();
143  curvature_cutoff = css->getCurvatureCutoff();
144  straight_line_thresh = css->getStraightLineThreshold();
145  }
146  };
147 
151  directSubRegions(0),allSubRegions(0),parent(0),
152  parentTree(0),publicNeighbours(0),cssParams(0){}
154  if(directSubRegions) delete directSubRegions;
155  if(allSubRegions) delete allSubRegions;
156  if(parent) delete parent;
157  if(parentTree) delete parentTree;
158  if(publicNeighbours) delete publicNeighbours;
159  if(cssParams) delete cssParams;
160  }
161  std::vector<ImageRegion> *directSubRegions;
162  std::vector<ImageRegion> *allSubRegions;
164  std::vector<ImageRegion> *parentTree;
165  std::vector<ImageRegion> *publicNeighbours;
167  } *complex;
168 
169 
171 
173  static ImageRegionData *createInstance(CornerDetectorCSS *css, ImageRegionPart *topRegionPart, int id, bool createGraphInfo, const core::ImgBase *image);
174 
176  inline ImageRegionData(CornerDetectorCSS *css, int value, int id, unsigned int segmentSize, bool createGraph,const core::ImgBase *image):
177  value(value),id(id),size(0),image(image),segments(segmentSize),graph(createGraph ? new RegionGraphInfo : 0),
178  simple(0),complex(0),css(css){}
179 
182  if(graph) delete graph;
183  if(simple) delete simple;
184  if(complex) delete complex;
185  }
186 
187  // utility function (only if linkTable is not given)
188  inline void link(ImageRegionData *a){
189  if(this != a){
190  if(a->graph->neighbours.size() < graph->neighbours.size()){
191  if(a->graph->neighbours.insert(this).second){
192  graph->neighbours.insert(a);
193  }
194  }else{
195  if(graph->neighbours.insert(a).second){
196  a->graph->neighbours.insert(this);
197  }
198  }
199  }
200  }
201 
203  inline void addChild(ImageRegionData *a){
204  graph->children.push_back(a);
205  a->graph->parent = this;
206  }
207 
209  void showTree(int indent=0) const;
210 
212  void showWithNeighbours() const;
213 
216  if(!complex) complex = new ComplexInformation;
217  return complex;
218  }
219 
222  if(!simple) simple = new SimpleInformation;
223  return simple;
224  }
225  };
226 
227  } // namespace cv
228 }
229 
Definition: ImageRegionData.h:99
utils::Any meta
meta data, that can be associated with a region structure
Definition: ImageRegionData.h:78
undocument this line if you encounter any issues!
Definition: Any.h:37
ImageRegionData IRD
Definition: ImageRegionData.h:52
const core::ImgBase * image
underlying image
Definition: ImageRegionData.h:72
std::vector< ImageRegion > * directSubRegions
directly contained regions
Definition: ImageRegionData.h:161
ImageRegionData * parent
parent region
Definition: ImageRegionData.h:95
std::vector< utils::Point > * thinned_boundary
thinned boundary pixels
Definition: ImageRegionData.h:118
utils::Rect * boundingBox
bounding rectangle
Definition: ImageRegionData.h:112
float getAngleThreshold() const
Definition: CornerDetectorCSS.h:172
Curvature Corner Detector.
Definition: CornerDetectorCSS.h:89
std::vector< utils::Point > * pixels
all pixels
Definition: ImageRegionData.h:119
CornerDetectorCSS * css
for corner detection
Definition: ImageRegionData.h:170
int value
image pixle value
Definition: ImageRegionData.h:63
float getSigma() const
Definition: CornerDetectorCSS.h:174
contains complex information,
Definition: ImageRegionData.h:149
bool isBorder
is the region connected to the border
Definition: ImageRegionData.h:86
struct icl::cv::ImageRegionData::RegionGraphInfo * graph
optional information about the region graph
SimpleInformation()
Definition: ImageRegionData.h:100
~ImageRegionData()
Destructor.
Definition: ImageRegionData.h:181
float straight_line_thresh
Definition: ImageRegionData.h:128
void setFrom(CornerDetectorCSS *css)
Definition: ImageRegionData.h:139
int size
pixel-count
Definition: ImageRegionData.h:69
~SimpleInformation()
Definition: ImageRegionData.h:104
#define ICLCV_API
Definition: CompatMacros.h:177
std::vector< LineSegment > segments
list of line segments
Definition: ImageRegionData.h:75
ImageRegionData(CornerDetectorCSS *css, int value, int id, unsigned int segmentSize, bool createGraph, const core::ImgBase *image)
Constructor.
Definition: ImageRegionData.h:176
Definition: ImageRegionData.h:123
float getCurvatureCutoff() const
Definition: CornerDetectorCSS.h:175
ImageRegion * parent
adjacent surrounding region
Definition: ImageRegionData.h:163
CSSParams * cssParams
Definition: ImageRegionData.h:166
float angle_thresh
Definition: ImageRegionData.h:124
float curvature_cutoff
Definition: ImageRegionData.h:127
ImageRegion Structure providing region feature information.
Definition: ImageRegion.h:99
std::vector< ImageRegion > * allSubRegions
(even indirectly) contained regions
Definition: ImageRegionData.h:162
~ComplexInformation()
Definition: ImageRegionData.h:153
int id
Region-ID.
Definition: ImageRegionData.h:66
std::vector< utils::Point > * boundary
all boundary pixels
Definition: ImageRegionData.h:117
std::vector< ImageRegionData * > children
Definition: ImageRegionData.h:92
SimpleInformation * ensureSimple()
utility function
Definition: ImageRegionData.h:221
std::set< ImageRegionData * > neighbours
Definition: ImageRegionData.h:89
Complex utility class for detection of connected image components.
Definition: RegionDetector.h:179
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
int boundaryLength
length of the region boundary
Definition: ImageRegionData.h:115
utils::Point32f * cog
center of gravity
Definition: ImageRegionData.h:113
std::vector< ImageRegion > * parentTree
surround regions
Definition: ImageRegionData.h:164
void link(ImageRegionData *a)
Definition: ImageRegionData.h:188
Utility class for shallow copied data of image region class.
Definition: ImageRegionData.h:50
void addChild(ImageRegionData *a)
adds a new child region
Definition: ImageRegionData.h:203
structure for representing region-graph information
Definition: ImageRegionData.h:81
float sigma
Definition: ImageRegionData.h:126
std::vector< ImageRegion > * publicNeighbours
adjacent regions
Definition: ImageRegionData.h:165
RegionGraphInfo()
Constructor.
Definition: ImageRegionData.h:83
The ImageRegionPart represents a intermediate region part for the connected component analysis.
Definition: ImageRegionPart.h:42
ComplexInformation * ensureComplex()
utility function
Definition: ImageRegionData.h:215
float getRCCoeff() const
Definition: CornerDetectorCSS.h:173
std::vector< utils::Point32f > resultBuffer
Definition: ImageRegionData.h:129
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
Simple generic data type implementation that uses a string based data representation.
Definition: Any.h:109
float getStraightLineThreshold() const
Definition: CornerDetectorCSS.h:176
float rc_coeff
Definition: ImageRegionData.h:125
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
data-struct to represent local PCA information
Definition: RegionPCAInfo.h:39
RegionPCAInfo * pcainfo
spacial PCA information
Definition: ImageRegionData.h:114
bool isOk(CornerDetectorCSS *css) const
Definition: ImageRegionData.h:131
ComplexInformation()
Definition: ImageRegionData.h:150