OTB  6.7.0
Orfeo Toolbox
otbWrapperCastImage.h
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 otbWrapperCastimage_h
22 #define otbWrapperCastimage_h
23 
24 
25 #include "otbClampImageFilter.h"
26 
27 #include "OTBApplicationEngineExport.h"
28 
29 #include "otbWrapperTypes.h"
30 
31 
32 namespace otb
33 {
34 namespace Wrapper
35 {
36 namespace details
37 {
38 
45 template <typename TOutputImage, typename TInputImage>
46 struct OTBApplicationEngine_EXPORT_TEMPLATE CastImage
47 {
50 
53 
54 
56  CastImage(TInputImage* in) : icif(InputClampImageFilter::New()), ocif(OutputClampImageFilter::New()), out(ocif->GetOutput())
57  {
58  assert(in);
59 
60  icif->SetInput(in);
61 
62  ocif->SetInput(icif->GetOutput());
63  }
64 
67 
70 
72  TOutputImage* out;
73 };
74 
75 
82 template <typename TOutputImage>
83 struct OTBApplicationEngine_EXPORT_TEMPLATE CastImage<TOutputImage, DoubleVectorImageType>
84 {
87 
88 
90  CastImage(DoubleVectorImageType* in) : ocif(OutputClampImageFilter::New()), out(ocif->GetOutput())
91  {
92  assert(in);
93 
94  ocif->SetInput(in);
95  }
96 
99 
102 
104  TOutputImage* out;
105 };
106 
107 
114 template <typename T>
115 struct OTBApplicationEngine_EXPORT_TEMPLATE CastImage<T, T>
116 {
117  CastImage(T* in) : out(in)
118  {
119  assert(in);
120  }
121 
124  T* out;
125 };
126 
127 
134 template <>
135 struct OTBApplicationEngine_EXPORT_TEMPLATE CastImage<DoubleVectorImageType, DoubleVectorImageType>
136 {
138  {
139  assert(in);
140  }
141 
145 };
146 
147 } // namespace details.
148 
149 } // namespace Wrapper
150 
151 } // namespace otb
152 
153 #endif
Creation of an "otb" vector image which contains metadata.
Helper class (private) which casts and clamps input-image type into output-image type.
InputClampImageFilter::Pointer icif
Clamp image values to be below, over, or between threhold values.
OutputClampImageFilter::Pointer ocif