Orfeo Toolbox  3.16
otbLabelImageToLabelMapWithAdjacencyFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Some parts of this code are derived from ITK. See ITKCopyright.txt
13  for details.
14 
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notices for more information.
19 
20 =========================================================================*/
21 #ifndef __otbLabelImageToLabelMapWithAdjacencyFilter_h
22 #define __otbLabelImageToLabelMapWithAdjacencyFilter_h
23 
24 #include "itkImageToImageFilter.h"
26 #include "itkLabelObject.h"
27 
28 namespace otb {
29 
34 template<class TInputImage, class TOutputImage=otb::LabelMapWithAdjacency< itk::LabelObject< typename TInputImage::PixelType, TInputImage::ImageDimension > > >
36  public itk::ImageToImageFilter<TInputImage, TOutputImage>
37 {
38 public:
45 
47  typedef TInputImage InputImageType;
48  typedef TOutputImage OutputImageType;
49  typedef typename InputImageType::Pointer InputImagePointer;
50  typedef typename InputImageType::ConstPointer InputImageConstPointer;
51  typedef typename InputImageType::RegionType InputImageRegionType;
52  typedef typename InputImageType::PixelType InputImagePixelType;
53  typedef typename InputImageType::IndexType IndexType;
54 
55  typedef typename OutputImageType::Pointer OutputImagePointer;
56  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
57  typedef typename OutputImageType::RegionType OutputImageRegionType;
58  typedef typename OutputImageType::PixelType OutputImagePixelType;
59  typedef typename OutputImageType::LabelObjectType LabelObjectType;
60  typedef typename OutputImageType::AdjacencyMapType AdjacencyMapType;
61  typedef typename OutputImageType::AdjacentLabelsContainerType AdjacentLabelsContainerType;
62  typedef typename OutputImageType::LabelType LabelType;
63 
65  itkStaticConstMacro(InputImageDimension, unsigned int,
66  TInputImage::ImageDimension);
67  itkStaticConstMacro(OutputImageDimension, unsigned int,
68  TOutputImage::ImageDimension);
69 
71  itkNewMacro(Self);
72 
75  ImageToImageFilter);
76 
81  itkSetMacro(BackgroundValue, OutputImagePixelType);
82  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
83 
84 protected:
90  void PrintSelf(std::ostream& os, itk::Indent indent) const;
91 
92  // class to store a RLE
93  class RLE
94  {
95  public:
96  // Location
98  // Length
99  long unsigned int length;
100  // Label
101  unsigned long int label;
102  // Constructor
103  RLE(const IndexType & w, long unsigned int l, unsigned long int la)
104  {
105  where = w;
106  length = l;
107  label = la;
108  }
109 
110  }; // end class RLE
111 
112  // RLE Vector
113  typedef std::vector<RLE> RLEVectorType;
114 
118  void GenerateInputRequestedRegion();
119 
121  void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
122 
123  virtual void BeforeThreadedGenerateData();
124 
125  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId);
126 
127  virtual void AfterThreadedGenerateData();
128 
130  void AddAdjacency(LabelType label1, LabelType label2, int threadId);
131 
133  void ParseLine(const RLEVectorType & line, int threadId);
134 
136  void ParseConsecutiveLines(const RLEVectorType& line1, const RLEVectorType& line2, int threadId);
137 
138 
139 private:
140  LabelImageToLabelMapWithAdjacencyFilter(const Self&); //purposely not implemented
141  void operator=(const Self&); //purposely not implemented
142 
144 
145  typename std::vector< OutputImagePointer > m_TemporaryImages;
146  typename std::vector<AdjacencyMapType> m_TemporaryAdjacencyMaps;
147 
148 }; // end of class
149 
150 } // end namespace otb
151 
152 #ifndef OTB_MANUAL_INSTANTIATION
154 #endif
155 
156 #endif
157 
158 

Generated at Sun Feb 3 2013 00:32:34 for Orfeo Toolbox with doxygen 1.8.1.1