RasterContrast.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21 \file RasterContrast.cpp
22 
23 \brief This class contains the parameters needed to apply dynamic contrast over a raster.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "RasterContrast.h"
29 
30 
32  : m_type(type),
33  m_nBands(nBands)
34 {
35  m_gain.resize(m_nBands, 1.);
36  m_offset1.resize(m_nBands, 0.);
37  m_offset2.resize(m_nBands, 0.);
38  m_min.resize(m_nBands, 0.);
39  m_max.resize(m_nBands, 0.);
40 }
41 
43  : m_type((te::map::RasterTransform::ContrastType)rhs.m_type),
44  m_nBands(rhs.m_nBands)
45 {
46  m_gain.reserve(rhs.m_nBands);
47  std::copy(rhs.m_gain.begin(), rhs.m_gain.end(), std::back_inserter(m_gain));
48 
49  m_offset1.reserve(rhs.m_nBands);
50  std::copy(rhs.m_offset1.begin(), rhs.m_offset1.end(), std::back_inserter(m_offset1));
51 
52  m_offset2.reserve(rhs.m_nBands);
53  std::copy(rhs.m_offset2.begin(), rhs.m_offset2.end(), std::back_inserter(m_offset2));
54 
55  m_min.reserve(rhs.m_nBands);
56  std::copy(rhs.m_min.begin(), rhs.m_min.end(), std::back_inserter(m_min));
57 
58  m_max.reserve(rhs.m_nBands);
59  std::copy(rhs.m_max.begin(), rhs.m_max.end(), std::back_inserter(m_max));
60 }
61 
63 {
64  m_gain.clear();
65  m_offset1.clear();
66  m_offset2.clear();
67  m_min.clear();
68  m_max.clear();
69 }
70 
72 {
73  return m_type;
74 }
75 
77 {
78  return m_nBands;
79 }
80 
81 void te::map::RasterContrast::setValues(const double& gain, const double& offset1, const double& offset2, const double& min, const double& max, const std::size_t& band)
82 {
83  if (band >= m_nBands)
84  throw;
85 
86  m_gain[band] = gain;
87  m_offset1[band] = offset1;
88  m_offset2[band] = offset2;
89  m_min[band] = min;
90  m_max[band] = max;
91 }
92 
93 void te::map::RasterContrast::getValues(std::vector<double>& gain, std::vector<double>& offset1, std::vector<double>& offset2, std::vector<double>& min, std::vector<double>& max)
94 {
95  gain = m_gain;
96  offset1 = m_offset1;
97  offset2 = m_offset2;
98  min = m_min;
99  max = m_max;
100 }
unsigned int band
void setValues(const double &gain, const double &offset1, const double &offset2, const double &min, const double &max, const std::size_t &band)
It set the transformation values for contranst of one band.
~RasterContrast()
Destructor.
const te::map::RasterTransform::ContrastType getType() const
It gets the contrast type.
te::map::RasterTransform::ContrastType m_type
The contrast type.
URI C++ Library.
Definition: Attributes.h:37
RasterContrast(const te::map::RasterTransform::ContrastType &type, const std::size_t &nBands)
It constructs a new RasterContrast instance.
This class contains the parameters needed to apply dynamic contrast over a raster.
This class contains the parameters needed to apply dynamic contrast over a raster.
std::size_t getNBands()
It gets the contrast number of bands.
std::vector< double > m_offset2
std::vector< double > m_max
std::vector< double > m_min
A Raster Transform is a class that defines functions to transform a styled raster.
void getValues(std::vector< double > &gain, std::vector< double > &offset1, std::vector< double > &offset2, std::vector< double > &min, std::vector< double > &max)
It get the contrast transformation values.
std::vector< double > m_gain
std::vector< double > m_offset1