2
TerraLib - a library for developing GIS applications.
3
Copyright 2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
5
This code is part of the TerraLib library.
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
You should have received a copy of the GNU Lesser General Public
12
License along with this library.
14
The authors reassure the license terms regarding the warranties.
15
They specifically disclaim any warranties, including, but not limited to,
16
the implied warranties of merchantability and fitness for a particular
17
purpose. The library provided hereunder is on an "as is" basis, and the
18
authors have no obligation to provide maintenance, support, updates,
19
enhancements, or modifications.
20
In no event shall INPE be held liable to any party
21
for direct, indirect, special, incidental, or consequential damages arising
22
out of the use of this library and its documentation.
25
#ifndef TEPDICONTRAST_HPP
26
#define TEPDICONTRAST_HPP
28
#include "TePDIAlgorithm.hpp"
29
#include "TePDIRgbPalette.hpp"
30
#include "TePDITypes.hpp"
32
#include "TePDISharedPtr.cpp"
35
* This is the class for contrast image processing algorithms.
37
class TePDIContrast : public TePDIAlgorithm{
39
typedef TePDISharedPtr< TePDIContrast > pointer;
40
typedef const TePDISharedPtr< TePDIContrast > const_pointer;
43
* Allowed contrast types.
45
enum TePDIContrastType{
46
TePDIContrastMinMax = 1,
47
TePDIContrastLinear = 2,
48
TePDIContrastSquareRoot = 3,
49
TePDIContrastSquare = 4,
51
TePDIContrastNegative = 6,
52
TePDIContrastHistEqualizer = 7,
53
TePDIContrastSimpleSlicer = 8
57
* Alternative Constructor.
59
* The general required parameters by any contrast type:
61
* contrast_type (TePDIContrastType),
62
* input_image (TePDITypes::TePDIRasterPtrType),
63
* output_image (TePDITypes::TePDIRasterPtrType),
64
* histo_levels (int) - Number of interpolated histogram levels.
66
* The specific required parameters ( by parameter type ):
68
* channels (std::vector<int>) - Band(s) to process. For
69
* TePDIContrastSimpleSlicer just one band is allowed.
71
* min_level (double) - Minimal level for Linear Luts
72
* Required by: TePDIContrastLinear, TePDIContrastSquareRoot,
73
* TePDIContrastSquare, TePDIContrastLog, TePDIContrastNegative,
74
* TePDIContrastSimpleSlicer
76
* max_level (double) - Minimal level for Linear Luts
77
* Required by: TePDIContrastLinear, TePDIContrastSquareRoot,
78
* TePDIContrastSquare, TePDIContrastLog, TePDIContrastNegative,
79
* TePDIContrastSimpleSlicer
81
* rgb_palette (TePDIRgbPalette::pointer) -
82
* Reference RGB palette.
83
* Required by: TePDIContrastSimpleSlicer
85
* @param params Algoritm parameters.
87
TePDIContrast( const TePDIParameters& params );
90
* Default Constructor.
101
* Checks if the supplied parameters fits the requirements of each
102
* PDI algorithm implementation.
104
* Error log messages must be generated. No exceptions generated.
106
* @param parameters The parameters to be checked.
107
* @return true if the parameters are OK. false if not.
109
bool CheckParameters( const TePDIParameters& parameters );
113
* A cache of level ordered histograms to avoid rebuilding
114
* histograms all the times.
116
TePDITypes::TePDIHistogramsMapType histo_cache_;
119
* Runs the current algorithm implementation.
121
* @return true if OK. false on error.
123
bool RunImplementation();
126
* Reset the internal state to the initial state.
131
* Build level ordered histograms from the required raster channels.
133
* The result histograms will remain inside the protected
134
* object histo_cache_
136
* @param inRaster The input Raster.
137
* @param histo_levels Number of histogram interpolated levels.
138
* @param channels Channels to use for histogram generation.
139
* @param force Force histogram regeneratin even if already in cache.
141
void BuildHistograms(
142
TePDITypes::TePDIRasterPtrType& inRaster,
143
unsigned int histo_levels,
144
std::vector< int >& channels,
145
bool force = false );
148
* Do level remapping from one raster to another.
150
* @param inRaster The input Raster.
151
* @param outRaster The Output Raster.
152
* @param lut The look-up table.
153
* @param in_channel in_raster channel to remap.
154
* @param out_channel out_raster channel to write on.
157
TePDITypes::TePDIRasterPtrType& inRaster,
158
TePDITypes::TePDILutType& lut,
161
TePDITypes::TePDIRasterPtrType& outRaster );
164
* Get the maximum histogram level.
166
* Only for histograms with levels equal or greater than zero.
168
* @param hist The input LEVEL ORDERED histogram.
169
* @return the maximum level.
171
double GetHistMax( TePDITypes::TePDIHistogramType& hist );
174
* Get the minimum histogram level.
176
* Only for histograms with levels equal or greater than zero.
178
* @param hist The input LEVEL ORDERED histogram.
179
* @return the minimum level.
181
double GetHistMin( TePDITypes::TePDIHistogramType& hist );
184
* Build a min-max look-up table.
186
* @param hist Base histogram.
187
* @return The look-up table.
189
TePDITypes::TePDILutType GetMinMaxLut(
190
TePDITypes::TePDIHistogramType& hist );
193
* Build a Linear look-up table.
195
* @param min Minimal level value.
196
* @param max Maximum level value.
197
* @param hist Base histogram.
198
* @return The look-up table.
200
TePDITypes::TePDILutType GetLinearLut(
201
TePDITypes::TePDIHistogramType& hist,
202
double min, double max );
205
* Build a Square Root look-up table.
207
* @param min Minimal level value.
208
* @param max Maximum level value.
209
* @param hist Base histogram.
210
* @return The look-up table.
212
TePDITypes::TePDILutType GetSquareRootLut(
213
TePDITypes::TePDIHistogramType& hist,
214
double min, double max );
217
* Build a Square look-up table.
219
* @param min Minimal level value.
220
* @param max Maximum level value.
221
* @param hist Base histogram.
222
* @return The look-up table.
224
TePDITypes::TePDILutType GetSquareLut(
225
TePDITypes::TePDIHistogramType& hist,
226
double min, double max );
229
* Build a Log look-up table.
231
* @param min Minimal level value.
232
* @param max Maximum level value.
233
* @param hist Base histogram.
234
* @return The look-up table.
236
TePDITypes::TePDILutType GetLogLut(
237
TePDITypes::TePDIHistogramType& hist,
238
double min, double max );
241
* Build a Negative look-up table.
243
* @param min Minimal level value.
244
* @param max Maximum level value.
245
* @param hist Base histogram.
246
* @return The look-up table.
248
TePDITypes::TePDILutType GetNegativeLut(
249
TePDITypes::TePDIHistogramType& hist,
250
double min, double max );
253
* Build a Histogram equalizer look-up table.
255
* @param hist A LEVEL-ORDERED Base histogram.
256
* @return The look-up table.
258
TePDITypes::TePDILutType GetHistEqualizerLut(
259
TePDITypes::TePDIHistogramType& hist );
262
* Builds a Simple slicer look-up table.
264
* @param hist A LEVEL-ORDERED Base histogram.
265
* @param in_palette The reference RGB palette.
266
* @param min Minimal level value.
267
* @param max Maximum level value.
268
* @param out_lut The look-up table.
270
void GetSimpleSlicerLut(
271
TePDITypes::TePDIHistogramType& hist,
272
TePDIRgbPalette::pointer in_palette,
275
TePDITypes::TePDILutType& out_lut );
278
#endif //TEPDICONTRAST_HPP