23 #ifndef MODULES_REMOTE_MOSAIC_INCLUDE_OTBMOSAICFUNCTORS_H_
24 #define MODULES_REMOTE_MOSAIC_INCLUDE_OTBMOSAICFUNCTORS_H_
28 #include "vnl/vnl_matrix.h"
29 #include "vcl_legacy_aliases.h"
30 #include "vcl_compiler.h"
44 template <
class TInput,
class TOutput>
64 D1[0][0] = 1.0 / vcl_sqrt(3.0);
65 D1[1][1] = 1.0 / vcl_sqrt(6.0);
66 D1[2][2] = 1.0 / vcl_sqrt(2.0);
86 return !(*
this != other);
94 if (A[0] == 0 && A[1] == 0 && A[2] == 0)
101 vnl_matrix<double> rgb(3, 1);
107 vnl_matrix<double> lms(3, 1);
111 const double log10 = vcl_log(10);
112 lms[0][0] = vcl_log(lms[0][0]) / log10;
113 lms[1][0] = vcl_log(lms[1][0]) / log10;
114 lms[2][0] = vcl_log(lms[2][0]) / log10;
117 vnl_matrix<double> lab(3, 1);
118 lab =
D1 * (
D2 * lms);
120 output[0] = lab[0][0];
121 output[1] = lab[1][0];
122 output[2] = lab[2][0];
133 vnl_matrix<double>
M;
134 vnl_matrix<double>
D1;
135 vnl_matrix<double>
D2;
146 template <
class TInput,
class TOutput>
166 D1[0][0] = 1.0 / vcl_sqrt(3.0);
167 D1[1][1] = 1.0 / vcl_sqrt(6.0);
168 D1[2][2] = 1.0 / vcl_sqrt(2.0);
188 return !(*
this != other);
197 if (A[0] == 0 && A[1] == 0 && A[2] == 0)
203 vnl_matrix<double> lab(3, 1);
209 vnl_matrix<double> lms(3, 1);
210 lms =
D2 * (
D1 * lab);
211 lms[0][0] = vcl_pow(10.0, lms[0][0]);
212 lms[1][0] = vcl_pow(10.0, lms[1][0]);
213 lms[2][0] = vcl_pow(10.0, lms[2][0]);
216 vnl_matrix<double> rgb(3, 1);
219 output[0] = rgb[0][0];
220 output[1] = rgb[1][0];
221 output[2] = rgb[2][0];
232 vnl_matrix<double>
M;
233 vnl_matrix<double>
D1;
234 vnl_matrix<double>
D2;
246 template <
class TInput,
class TOutput>
250 IsNoData(
const typename TInput::ValueType input_nodata = 0):
nodata(input_nodata){};
256 for (
unsigned int i = 0; i < A.Size(); i++)
258 if (!std::isnan(A[i]) && A[i] !=
nodata)
IsNoData(const typename TInput::ValueType input_nodata=0)
TOutput operator()(const TInput &A) const
Base class for converting LAB into RGB color space (Ruderman et al.)
vcl_size_t OutputSize(const std::array< vcl_size_t, 1 > &) const
bool operator!=(const LAB2RGB &) const
bool operator==(const LAB2RGB &other) const
TOutput operator()(const TInput &A) const
Base class for converting RGB into LAB color space (Ruderman et al.)
vcl_size_t OutputSize(const std::array< vcl_size_t, 1 > &) const
bool operator!=(const RGB2LAB &) const
TOutput operator()(const TInput &A) const
bool operator==(const RGB2LAB &other) const
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.