29 #include "../raster.h"
30 #include "../raster/RasterProperty.h"
31 #include "../se/RasterSymbolizer.h"
57 m_categorizeMap.clear();
58 m_interpolateMap.clear();
65 m_rgbMap[RED_CHANNEL] = -1;
66 m_rgbMap[GREEN_CHANNEL] = -1;
67 m_rgbMap[BLUE_CHANNEL] = -1;
69 std::map<RGBChannels,short>::iterator it = m_rgbMap.begin();
70 while (it != m_rgbMap.end())
72 if (it->first == RED_CHANNEL)
73 m_rgbMap[RED_CHANNEL] = it->second;
75 else if (it->first == GREEN_CHANNEL)
76 m_rgbMap[GREEN_CHANNEL] = it->second;
78 else if (it->first == BLUE_CHANNEL)
79 m_rgbMap[BLUE_CHANNEL] = it->second;
97 m_gain = (double)(rmax-rmin)/(vmax-vmin);
98 m_offset = -1*m_gain*vmin+rmin;
104 if (m_transfFuncPtr == 0 || m_RGBAFuncPtr)
111 return MONO2THREE_TRANSF;
116 return EXTRACT2RGB_TRANSF;
121 return RED2THREE_TRANSF;
126 return GREEN2THREE_TRANSF;
131 return BLUE2THREE_TRANSF;
136 return CATEGORIZE_TRANSF;
141 return INTERPOLATE_TRANSF;
145 return BAND2BAND_TRANSF;
155 if (func == MONO2THREE_TRANSF)
160 else if (func == EXTRACT2RGB_TRANSF)
165 else if (func == RED2THREE_TRANSF)
170 else if (func == GREEN2THREE_TRANSF)
175 else if (func == BLUE2THREE_TRANSF)
180 else if (func == CATEGORIZE_TRANSF)
185 else if (func == INTERPOLATE_TRANSF)
190 else if (func == BAND2BAND_TRANSF)
206 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_monoBand);
208 if(checkNoValue(val, m_monoBand) ==
false)
210 val = (val * m_gain + m_offset) * m_mContrast;
214 std::vector<double> vecValues;
215 vecValues.resize(3, val);
217 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
225 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_monoBand);
227 if(checkNoValue(val, m_monoBand) ==
false)
229 val = (val * m_gain + m_offset) * m_mContrast;
233 te::color::RGBAColor c(static_cast<int>(val), static_cast<int>(val), static_cast<int>(val), static_cast<int>(m_transp));
243 double valR, valG, valB;
245 m_rasterIn->getValue((
int)icol, (
int)ilin, valR, m_rgbMap[RED_CHANNEL]);
246 m_rasterIn->getValue((
int)icol, (
int)ilin, valG, m_rgbMap[GREEN_CHANNEL]);
247 m_rasterIn->getValue((
int)icol, (
int)ilin, valB, m_rgbMap[BLUE_CHANNEL]);
249 if(checkNoValue(valR, m_rgbMap[RED_CHANNEL]) ==
false ||
250 checkNoValue(valG, m_rgbMap[GREEN_CHANNEL]) ==
false ||
251 checkNoValue(valB, m_rgbMap[BLUE_CHANNEL]) ==
false)
253 std::vector<double> vecValues;
255 valR = (valR * m_gain + m_offset) * m_rContrast;
257 vecValues.push_back(valR);
259 valG = (valG * m_gain + m_offset) * m_gContrast;
261 vecValues.push_back(valG);
263 valB = (valB * m_gain + m_offset) * m_bContrast;
265 vecValues.push_back(valB);
267 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
273 double valR, valG, valB;
275 m_rasterIn->getValue((
int)icol, (
int)ilin, valR, m_rgbMap[RED_CHANNEL]);
276 m_rasterIn->getValue((
int)icol, (
int)ilin, valG, m_rgbMap[GREEN_CHANNEL]);
277 m_rasterIn->getValue((
int)icol, (
int)ilin, valB, m_rgbMap[BLUE_CHANNEL]);
279 if(checkNoValue(valR, m_rgbMap[RED_CHANNEL]) ==
false ||
280 checkNoValue(valG, m_rgbMap[GREEN_CHANNEL]) ==
false ||
281 checkNoValue(valB, m_rgbMap[BLUE_CHANNEL]) ==
false)
283 valR = (valR * m_gain + m_offset) * m_rContrast;
286 valG = (valG * m_gain + m_offset) * m_gContrast;
289 valB = (valB * m_gain + m_offset) * m_bContrast;
292 te::color::RGBAColor c(static_cast<int>(valR), static_cast<int>(valG), static_cast<int>(valB), static_cast<int>(m_transp));
304 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_rgbMap[RED_CHANNEL]);
306 if(checkNoValue(val, m_rgbMap[RED_CHANNEL]) ==
false)
308 val = (val * m_gain + m_offset) * m_rContrast;
312 std::vector<double> vecValues;
313 vecValues.push_back(val);
314 vecValues.push_back(0.);
315 vecValues.push_back(0.);
317 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
325 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_rgbMap[RED_CHANNEL]);
327 if(checkNoValue(val, m_rgbMap[RED_CHANNEL]) ==
false)
329 val = (val * m_gain + m_offset) * m_rContrast;
333 te::color::RGBAColor c(static_cast<int>(val), static_cast<int>(0.), static_cast<int>(0.), static_cast<int>(m_transp));
346 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_rgbMap[GREEN_CHANNEL]);
348 if(checkNoValue(val, m_rgbMap[GREEN_CHANNEL]) ==
false)
350 val = (val * m_gain + m_offset) * m_gContrast;
354 std::vector<double> vecValues;
355 vecValues.push_back(0.);
356 vecValues.push_back(val);
357 vecValues.push_back(0.);
359 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
367 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_rgbMap[GREEN_CHANNEL]);
369 if(checkNoValue(val, m_rgbMap[GREEN_CHANNEL]) ==
false)
371 val = (val * m_gain + m_offset) * m_gContrast;
375 te::color::RGBAColor c(static_cast<int>(0.), static_cast<int>(val), static_cast<int>(0.), static_cast<int>(m_transp));
388 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_rgbMap[BLUE_CHANNEL]);
390 if(checkNoValue(val, m_rgbMap[BLUE_CHANNEL]) ==
false)
392 val = (val * m_gain + m_offset) * m_bContrast;
396 std::vector<double> vecValues;
397 vecValues.push_back(0.);
398 vecValues.push_back(0.);
399 vecValues.push_back(val);
401 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
409 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_rgbMap[BLUE_CHANNEL]);
411 if(checkNoValue(val, m_rgbMap[BLUE_CHANNEL]) ==
false)
413 val = (val * m_gain + m_offset) * m_bContrast;
417 te::color::RGBAColor c(static_cast<int>(0.), static_cast<int>(0.), static_cast<int>(val), static_cast<int>(m_transp));
430 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_monoBand);
434 std::vector<double> vecValues;
435 vecValues.push_back(c.
getRed());
437 vecValues.push_back(c.
getBlue());
439 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
446 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_monoBand);
448 return getCategorizedColor(val);
455 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_monoBand);
459 std::vector<double> vecValues;
460 vecValues.push_back(c.
getRed());
462 vecValues.push_back(c.
getBlue());
464 m_rasterOut->setValues((
int)ocol, (
int)olin, vecValues);
471 m_rasterIn->getValue((
int)icol, (
int)ilin, val, m_monoBand);
473 return getInterpolatedColor(val);
480 for(std::size_t t = 0; t < m_rasterIn->getNumberOfBands(); ++t)
482 m_rasterIn->getValue((
int)icol, (
int)ilin, val, t);
484 if(checkNoValue(val, t) ==
false)
486 val = (val * m_gain + m_offset);
490 m_rasterOut->setValue((
int)ocol, (
int)olin, val, t);
497 if (value < m_rstMinValue)
499 value = m_rstMinValue;
501 else if (value > m_rstMaxValue)
503 value = m_rstMaxValue;
509 if(m_rasterIn->getBand(band)->getProperty()->m_noDataValue == value)
519 InterpolatedMap::iterator it = m_interpolateMap.begin();
521 while(it != m_interpolateMap.end())
525 if(rt.first<= value && rt.second > value)
527 int distance = int(value - it->first.first);
533 else if(distance >= (
int)it->second.getColorBar().size())
535 distance = it->second.getColorBar().size() - 1;
538 return it->second.getColorBar()[distance];
549 CategorizedMap::iterator it = m_categorizeMap.begin();
551 while(it != m_categorizeMap.end())
555 if(rt.first<= value && rt.second > value)
void setRed2ThreeBand(double icol, double ilin, double ocol, double olin)
double m_rstMinValue
Min value from input raster.
void fixValue(double &value)
void setBand2Band(double icol, double ilin, double ocol, double olin)
RasterTransform(te::rst::Raster *input, te::rst::Raster *output)
Constructor.
void setTransfFunction(RasterTransfFunctions func)
te::color::RGBAColor getCategorizedColor(double value)
double m_rstMaxValue
Max value from input raster.
#define TE_SE_DEFAULT_GAMMA_VALUE
It specifies the default gamma value.
te::color::RGBAColor getInterpolatedColor(double value)
int getGreen() const
It returns the green component color value (a value from 0 to 255).
te::color::RGBAColor getRed2ThreeBand(double icol, double ilin)
void setMono2ThreeBand(double icol, double ilin, double ocol, double olin)
~RasterTransform()
Destructor.
void setRGBMap(std::map< RGBChannels, short > &rgbMap)
Sets the rgb map values.
std::pair< double, double > RasterThreshold
RasterTransfFunctions getTransfFunction()
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void setBlue2ThreeBand(double icol, double ilin, double ocol, double olin)
void setLinearTransfParameters(double vmin, double vmax, double rmin, double rmax)
Set parameters of linear transformation.
void setExtractRGB(double icol, double ilin, double ocol, double olin)
te::color::RGBAColor getCategorize(double icol, double ilin)
te::color::RGBAColor getBlue2ThreeBand(double icol, double ilin)
te::color::RGBAColor getMono2ThreeBand(double icol, double ilin)
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
void setGreen2ThreeBand(double icol, double ilin, double ocol, double olin)
te::color::RGBAColor getInterpolate(double icol, double ilin)
bool checkNoValue(double &value, int band)
Function used to check if value is or not a valid value.
void setInterpolate(double icol, double ilin, double ocol, double olin)
A Raster Transform is a class that defines functions to transform a styled raster.
An abstract class for raster data strucutures.
void setCategorize(double icol, double ilin, double ocol, double olin)
A Raster Transform is a class that defines functions to transform a styled raster.
te::color::RGBAColor getGreen2ThreeBand(double icol, double ilin)
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
te::color::RGBAColor getExtractRGB(double icol, double ilin)
int getRed() const
It returns the red component color value (a value from 0 to 255).