OTB  6.7.0
Orfeo Toolbox
otbImage.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbImage_hxx
22 #define otbImage_hxx
23 
24 
25 #include "otbImage.h"
27 #include "itkMetaDataObject.h"
28 
29 namespace otb
30 {
31 
32 template <class TPixel, unsigned int VImageDimension>
34 {
35 }
36 
37 template <class TPixel, unsigned int VImageDimension>
39 {
40  return (this->GetMetaDataInterface()->GetProjectionRef());
41 }
42 
43 template <class TPixel, unsigned int VImageDimension>
44 void
46 {
47  itk::EncapsulateMetaData<std::string>(this->GetMetaDataDictionary(),MetaDataKey::ProjectionRefKey,kwl);
48 }
49 
50 template <class TPixel, unsigned int VImageDimension>
52 {
53  return (this->GetMetaDataInterface()->GetGCPProjection());
54 }
55 
56 template <class TPixel, unsigned int VImageDimension>
58 {
59  return (this->GetMetaDataInterface()->GetGCPCount());
60 }
61 
62 template <class TPixel, unsigned int VImageDimension>
64 {
65  return (this->GetMetaDataInterface()->GetGCPs(GCPnum));
66 }
67 
68 template <class TPixel, unsigned int VImageDimension>
69 const OTB_GCP& Image<TPixel, VImageDimension>::GetGCPs(unsigned int GCPnum) const
70 {
71  return (this->GetMetaDataInterface()->GetGCPs(GCPnum));
72 }
73 
74 template <class TPixel, unsigned int VImageDimension>
75 std::string Image<TPixel, VImageDimension>::GetGCPId(unsigned int GCPnum) const
76 {
77  return (this->GetMetaDataInterface()->GetGCPId(GCPnum));
78 }
79 
80 template <class TPixel, unsigned int VImageDimension>
81 std::string Image<TPixel, VImageDimension>::GetGCPInfo(unsigned int GCPnum) const
82 {
83  return (this->GetMetaDataInterface()->GetGCPInfo(GCPnum));
84 }
85 
86 template <class TPixel, unsigned int VImageDimension>
87 double Image<TPixel, VImageDimension>::GetGCPRow(unsigned int GCPnum) const
88 {
89  return (this->GetMetaDataInterface()->GetGCPRow(GCPnum));
90 }
91 
92 template <class TPixel, unsigned int VImageDimension>
93 double Image<TPixel, VImageDimension>::GetGCPCol(unsigned int GCPnum) const
94 {
95  return (this->GetMetaDataInterface()->GetGCPCol(GCPnum));
96 }
97 
98 template <class TPixel, unsigned int VImageDimension>
99 double Image<TPixel, VImageDimension>::GetGCPX(unsigned int GCPnum) const
100 {
101  return (this->GetMetaDataInterface()->GetGCPX(GCPnum));
102 }
103 
104 template <class TPixel, unsigned int VImageDimension>
105 double Image<TPixel, VImageDimension>::GetGCPY(unsigned int GCPnum) const
106 {
107  return (this->GetMetaDataInterface()->GetGCPY(GCPnum));
108 }
109 
110 template <class TPixel, unsigned int VImageDimension>
111 double Image<TPixel, VImageDimension>::GetGCPZ(unsigned int GCPnum) const
112 {
113  return (this->GetMetaDataInterface()->GetGCPZ(GCPnum));
114 }
115 
116 template <class TPixel, unsigned int VImageDimension>
119 {
120  return (this->GetMetaDataInterface()->GetGeoTransform());
121 }
122 
123 template <class TPixel, unsigned int VImageDimension>
126 {
127  return (this->GetMetaDataInterface()->GetUpperLeftCorner());
128 }
129 
130 template <class TPixel, unsigned int VImageDimension>
133 {
134  return (this->GetMetaDataInterface()->GetUpperRightCorner());
135 }
136 
137 template <class TPixel, unsigned int VImageDimension>
140 {
141  return (this->GetMetaDataInterface()->GetLowerLeftCorner());
142 }
143 
144 template <class TPixel, unsigned int VImageDimension>
147 {
148  return (this->GetMetaDataInterface()->GetLowerRightCorner());
149 }
150 
151 template <class TPixel, unsigned int VImageDimension>
154 {
155  auto spacing = this->GetSpacing();
156  for ( unsigned int i = 0; i < Image::ImageDimension; ++i )
157  {
158  if (this->m_Direction[i][i] < 0 )
159  spacing[i] = - spacing[i];
160  }
161  return spacing;
162 }
163 
164 template <class TPixel, unsigned int VImageDimension>
167 {
168 
169  for ( unsigned int i = 0; i < VImageDimension; i++ )
170  {
171  if ( spacing[i] < 0.0 )
172  {
173  if ( this->m_Direction[i][i] > 0 )
174  {
175  for ( unsigned j = 0; j < VImageDimension; ++j )
176  {
177  this->m_Direction[j][i] = - this->m_Direction[j][i];
178  }
179  }
180  spacing[i] = - spacing[i];
181  }
182  }
183  this->SetSpacing(spacing);
184  this->ComputeIndexToPhysicalPointMatrices();
185  this->Modified();
186 }
187 
188 template <class TPixel, unsigned int VImageDimension>
190 ::SetSignedSpacing( double spacing[ VImageDimension ])
191 {
192  SpacingType s(spacing);
193  this->SetSignedSpacing(s);
194 }
195 
196 template <class TPixel, unsigned int VImageDimension>
199 {
201 
202  itk::ExposeMetaData<ImageKeywordlistType>(this->GetMetaDataDictionary(),
204  kwl);
205  return kwl;
206 }
207 
208 template <class TPixel, unsigned int VImageDimension>
209 void
211 {
212  itk::EncapsulateMetaData<ImageKeywordlistType>(this->GetMetaDataDictionary(),MetaDataKey::OSSIMKeywordlistKey,kwl);
213 }
214 
215 
216 template <class TPixel, unsigned int VImageDimension>
219 {
221 
222  itk::ExposeMetaData<ImageKeywordlistType>(this->GetMetaDataDictionary(),
224  kwl);
225  return kwl;
226 }
227 
228 template <class TPixel, unsigned int VImageDimension>
229 void
232 {
233  Superclass::CopyInformation(data);
235 }
236 
237 template <class TPixel, unsigned int VImageDimension>
241 {
242  if (m_ImageMetadataInterface.IsNull())
243  m_ImageMetadataInterface = ImageMetadataInterfaceFactory::CreateIMI(this->GetMetaDataDictionary());
244  return m_ImageMetadataInterface;
245 }
246 
247 template <class TPixel, unsigned int VImageDimension>
248 void
250 {
251  Superclass::PrintSelf(os, indent);
252  this->GetMetaDataInterface()->PrintMetadata(os, indent, this->GetMetaDataDictionary());
253 }
254 
255 } // end namespace otb
256 #endif
virtual VectorType GetUpperLeftCorner(void) const
Definition: otbImage.hxx:125
virtual std::string GetGCPId(unsigned int GCPnum) const
Definition: otbImage.hxx:75
void SetMetaDataDictionary(const MetaDataDictionary &rhs)
Storage and conversion for OSSIM metadata.
static ImageMetadataInterfaceBasePointerType CreateIMI(const MetaDataDictionaryType &dict)
SpacingType GetSignedSpacing() const
Definition: otbImage.hxx:153
This OTB_GCP class is used to manage the GCP parameters in OTB.
void SetSignedSpacing(InputImage *input, SpacingType spacing)
Definition: otbImage.h:53
static const unsigned int ImageDimension
Definition: otbImage.h:137
OTBOSSIMAdapters_EXPORT char const * ProjectionRefKey
virtual double GetGCPY(unsigned int GCPnum) const
Definition: otbImage.hxx:105
virtual VectorType GetGeoTransform(void) const
Definition: otbImage.hxx:118
virtual std::string GetProjectionRef(void) const
Definition: otbImage.hxx:38
MetaDataDictionary & GetMetaDataDictionary()
virtual VectorType GetLowerRightCorner(void) const
Definition: otbImage.hxx:146
virtual double GetGCPCol(unsigned int GCPnum) const
Definition: otbImage.hxx:93
virtual void SetProjectionRef(const std::string &wkt)
Definition: otbImage.hxx:45
virtual std::string GetGCPInfo(unsigned int GCPnum) const
Definition: otbImage.hxx:81
virtual void SetImageKeywordList(const ImageKeywordlistType &kwl)
Definition: otbImage.hxx:210
virtual VectorType GetUpperRightCorner(void) const
Definition: otbImage.hxx:132
void CopyInformation(const itk::DataObject *) override
Copy metadata from a DataObject.
Definition: otbImage.hxx:231
virtual double GetGCPX(unsigned int GCPnum) const
Definition: otbImage.hxx:99
virtual unsigned int GetGCPCount(void) const
Definition: otbImage.hxx:57
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbImage.hxx:249
virtual ImageKeywordlistType GetImageKeywordlist(void)
Definition: otbImage.hxx:198
ImageMetadataInterfacePointerType GetMetaDataInterface() const
Definition: otbImage.hxx:240
ImageMetadataInterfaceBase::VectorType VectorType
Definition: otbImage.h:99
virtual VectorType GetLowerLeftCorner(void) const
Definition: otbImage.hxx:139
virtual double GetGCPZ(unsigned int GCPnum) const
Definition: otbImage.hxx:111
virtual void SetSignedSpacing(SpacingType spacing)
Definition: otbImage.hxx:166
virtual OTB_GCP & GetGCPs(unsigned int GCPnum)
Definition: otbImage.hxx:63
virtual std::string GetGCPProjection(void) const
Definition: otbImage.hxx:51
virtual double GetGCPRow(unsigned int GCPnum) const
Definition: otbImage.hxx:87
OTBOSSIMAdapters_EXPORT char const * OSSIMKeywordlistKey