Orfeo Toolbox  3.16
otbImageLayer.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 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbImageLayer_h
19 #define __otbImageLayer_h
20 
21 #include "otbImageLayerBase.h"
24 
25 #include "itkExtractImageFilter.h"
26 #include "itkListSample.h"
28 
30 #include "otbGenericRSTransform.h"
31 
32 #include "otbCoordinateToName.h"
33 
35 
36 namespace otb
37 {
47 template <class TImage, class TOutputImage>
49  : public ImageLayerBase<TOutputImage>
50 {
51 public:
53  typedef ImageLayer Self;
57 
59  itkNewMacro(Self);
60 
62  itkTypeMacro(ImageLayer, ImageLayerBase);
63 
65  typedef TImage ImageType;
66  typedef typename ImageType::Pointer ImagePointerType;
67  typedef typename ImageType::PixelType PixelType;
68  typedef typename itk::NumericTraits<PixelType>::ValueType ScalarType;
72  typedef typename ImageType::RegionType RegionType;
73  typedef typename ImageType::IndexType IndexType;
74  typedef typename IndexType::IndexValueType IndexValueType;
75 
82  typedef TOutputImage OutputImageType;
83  typedef typename OutputImageType::PixelType OutputPixelType;
84 
90 
93  typename itk::NumericTraits<ScalarType>::RealType, 1,
98 
100 
108 
110  virtual void SetImage(ImageType * img)
111  {
112  if (this->m_Image != img)
113  {
114  this->m_Image = img;
115  this->m_ExtractFilter->SetInput(m_Image);
116  this->m_ScaledExtractFilter->SetInput(m_Image);
117  }
118  }
119  itkGetObjectMacro(Image, ImageType);
120 
122  virtual void SetQuicklook(ImageType * ql)
123  {
124  if (this->m_Quicklook != ql)
125  {
126  this->m_Quicklook = ql;
127  this->m_QuicklookRenderingFilter->SetInput(m_Quicklook);
128  }
129 
130  }
131  itkGetObjectMacro(Quicklook, ImageType);
132 
135  {
136  //FIXME Update condition?
137  return m_RenderingFunction->GetHistogramList();
138  }
139 
142  {
143  m_RenderingFunction = function;
144  m_RenderingFunction->SetListSample(this->GetListSample());
145  m_QuicklookRenderingFilter->SetRenderingFunction(m_RenderingFunction);
146  m_ExtractRenderingFilter->SetRenderingFunction(m_RenderingFunction);
148  }
149  itkGetObjectMacro(RenderingFunction, RenderingFunctionType);
150 
152  virtual void SetExtractRegion(const RegionType& region)
153  {
154  // This check should be done in the itk::ExtractImageFilter
155  if (this->GetExtractRegion() != region)
156  {
158  // SetExtractionRegion throws an exception in case of empty region
159  if (region.GetNumberOfPixels() > 0)
160  {
161  m_ExtractFilter->SetExtractionRegion(region);
162  }
163  }
164  }
165 
167  virtual void SetScaledExtractRegion(const RegionType& region)
168  {
169  // This check should be done in the itk::ExtractImageFilter
170  if (this->GetScaledExtractRegion() != region)
171  {
173  // SetExtractionRegion throws an exception in case of empty region
174  if (region.GetNumberOfPixels() > 0)
175  {
176  m_ScaledExtractFilter->SetExtractionRegion(region);
177  }
178  }
179  }
180 
182  virtual void Render();
183 
185  virtual std::string GetPixelDescription(const IndexType& index, bool getPlaceName = true);
186 
188  virtual PointType GetPixelLocation(const IndexType& index);
189 
192  {
193 // this->UpdateListSample(); //FIXME condition to IsModified
194  return m_ListSample;
195  }
196 
198  virtual void SetListSample(ListSamplePointerType listSample)
199  {
200  m_ListSample = listSample;
201  m_ListSampleProvided = true;
202  m_RenderingFunction->SetListSample(m_ListSample);
203  }
204 
205  virtual LayerValueType GetValueAtIndex(const IndexType& index);
206 
207  itkSetMacro(ComputeHistoOnFullResolution, bool);
208  itkSetMacro(ComputeHistoOnZoomResolution, bool);
209  itkSetMacro(UpdateHisto, bool);
210 
211 protected:
213  ImageLayer();
215  virtual ~ImageLayer();
217  void PrintSelf(std::ostream& os, itk::Indent indent) const;
218 
220  virtual void UpdateListSample();
221 
223  virtual void RenderImages();
224 
225  virtual void InitTransform();
226 
227  virtual void ComputeApproximativeGroundSpacing();
229  unsigned int PixelSize(ImagePointerType image, ScalarType* v) const;
230  unsigned int PixelSize(ImagePointerType image, VectorPixelType* v) const;
231  unsigned int PixelSize(ImagePointerType image, RGBPixelType* v) const;
232  unsigned int PixelSize(ImagePointerType image, RGBAPixelType* v) const;
233 
234  itkGetMacro(ApproxGroundSpacing, FloatType);
235  itkGetObjectMacro(Transform, TransformType);
236 
237 private:
238  ImageLayer(const Self&); // purposely not implemented
239  void operator =(const Self&); // purposely not implemented
240 
243 
246 
249  bool m_ListSampleProvided; //To remember if the list sample was provided manually by the user
250  bool m_ComputeHistoOnFullResolution; //to compute histogram on full image, even if quicklook is available.
251  bool m_ComputeHistoOnZoomResolution; //to compute histogram on zoom image, even if quicklook is available.
252  bool m_UpdateHisto; //boolean to force histogram computation.
253 
256 
261 
265 
269 
271  std::string m_PlaceName; //FIXME the call should be done by a more general method outside of the layer
272  std::string m_CountryName; //which would also handle the dependance to curl
273 
275  typename GroundSpacingImageType::Pointer m_GroundSpacing; //FIXME the call should be done by a more general method outside of the layer
277 
278 }; // end class
279 } // end namespace otb
280 
281 #ifndef OTB_MANUAL_INSTANTIATION
282 #include "otbImageLayer.txx"
283 #endif
284 
285 #endif

Generated at Sun Feb 3 2013 00:26:23 for Orfeo Toolbox with doxygen 1.8.1.1