All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Contrast.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 terralib/rp/Contrast.cpp
22  \brief Contrast enhancement.
23 */
24 
25 #include "Contrast.h"
26 
27 #include "Functions.h"
28 
29 #include "../raster/Raster.h"
30 #include "../raster/Band.h"
31 #include "../raster/BandIterator.h"
32 #include "../raster/BandProperty.h"
33 #include "../raster/RasterProperty.h"
34 #include "../raster/RasterSummaryManager.h"
35 #include "../raster/RasterFactory.h"
36 #include "../common/progress/TaskProgress.h"
37 #include "Macros.h"
38 
39 #include "float.h"
40 #include <boost/concept_check.hpp>
41 #include <terralib/raster/Grid.h>
42 
43 namespace te
44 {
45  namespace rp
46  {
48  {
49  reset();
50  }
51 
53  {
54  reset();
55  }
56 
57  void Contrast::InputParameters::reset() throw( te::rp::Exception )
58  {
60  m_lCMinInput.clear();
61  m_lCMaxInput.clear();
62  m_hECMaxInput.clear();
63  m_sMASCMeanInput.clear();
64  m_sMASCStdInput.clear();
65 
66  m_inRasterPtr = 0;
67  m_inRasterBands.clear();
68  m_enableProgress = false;
69  }
70 
72  const Contrast::InputParameters& params )
73  {
74  reset();
75 
76  m_type = params.m_type;
77  m_lCMinInput = params.m_lCMinInput;
78  m_lCMaxInput = params.m_lCMaxInput;
79  m_hECMaxInput = params.m_hECMaxInput;
80  m_sMASCMeanInput = params.m_sMASCMeanInput;
81  m_sMASCStdInput = params.m_sMASCStdInput;
82 
83  m_inRasterPtr = params.m_inRasterPtr;
84  m_inRasterBands = params.m_inRasterBands;
85  m_enableProgress = params.m_enableProgress;
86 
87  return *this;
88  }
89 
91  {
92  return new InputParameters( *this );
93  }
94 
96  {
97  reset();
98  }
99 
101  {
102  reset();
103  operator=( other );
104  }
105 
107  {
108  reset();
109  }
110 
111  void Contrast::OutputParameters::reset() throw( te::rp::Exception )
112  {
113  m_outRasterPtr = 0;
114  m_createdOutRasterPtr.reset();
115  m_outRasterBands.clear();
116  m_createdOutRasterDSType.clear();
117  m_createdOutRasterInfo.clear();
118  }
119 
121  const Contrast::OutputParameters& params )
122  {
123  reset();
124 
125  m_outRasterPtr = params.m_outRasterPtr;
126  m_outRasterBands = params.m_outRasterBands;
127  m_createdOutRasterDSType = params.m_createdOutRasterDSType;
128  m_createdOutRasterInfo = params.m_createdOutRasterInfo;
129 
130  return *this;
131  }
132 
134  {
135  return new OutputParameters( *this );
136  }
137 
139  {
140  reset();
141  }
142 
144  {
145  }
146 
148  throw( te::rp::Exception )
149  {
150  TERP_TRUE_OR_RETURN_FALSE( m_isInitialized, "Algoritm not initialized" );
151 
152  // Initializing the output raster
153 
154  m_outputParametersPtr = dynamic_cast<
155  Contrast::OutputParameters* >( &outputParams );
156  TERP_TRUE_OR_RETURN_FALSE( m_outputParametersPtr, "Invalid parameters" );
157 
159  {
161 
162  std::vector< te::rst::BandProperty* > bandsProperties;
163  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
164  m_inputParameters.m_inRasterBands.size() ; ++inRasterBandsIdx )
165  {
166  assert( m_inputParameters.m_inRasterBands[ inRasterBandsIdx ] <
168 
169  bandsProperties.push_back( new te::rst::BandProperty(
172  inRasterBandsIdx ] )->getProperty() ) ) );
173 
174  m_outputParametersPtr->m_outRasterBands.push_back( inRasterBandsIdx );
175  }
176 
181  bandsProperties,
183  0,
184  0 ) );
186  "Output raster creation error" );
187 
190  }
191  else
192  {
198  {
199  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
200  m_inputParameters.m_inRasterBands.size() ; ++inRasterBandsIdx )
201  {
203  m_outputParametersPtr->m_outRasterBands[ inRasterBandsIdx ] <
205  "Invalid output raster band" )
206  }
207  }
208  else
209  {
210  TERP_LOG_AND_RETURN_FALSE( "Invalid output raster" );
211  }
212  }
213 
214  // Executing the contrast on the selected bands
215 
216  switch( m_inputParameters.m_type )
217  {
219  {
220  return execLinearContrast();
221  break;
222  }
224  {
226  break;
227  }
229  {
230  return execSetMeanAndStdContrast();
231  break;
232  }
233  default :
234  {
235  TERP_LOG_AND_THROW( "Invalid contrast type" );
236  break;
237  }
238  }
239  }
240 
241  void Contrast::reset() throw( te::rp::Exception )
242  {
245  m_isInitialized = false;
246  }
247 
249  throw( te::rp::Exception )
250  {
251  reset();
252 
253  Contrast::InputParameters const* inputParamsPtr = dynamic_cast<
254  Contrast::InputParameters const* >( &inputParams );
255  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr, "Invalid parameters" );
256 
257  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_inRasterPtr,
258  "Invalid raster pointer" );
261  "Invalid raster" );
262 
263  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_inRasterBands.size() > 0,
264  "Invalid bands number" );
265 
266  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
267  inputParamsPtr->m_inRasterBands.size() ; ++inRasterBandsIdx )
268  {
270  inputParamsPtr->m_inRasterBands[ inRasterBandsIdx ] <
271  inputParamsPtr->m_inRasterPtr->getNumberOfBands(),
272  "Invalid input raster band" );
273  }
274 
275  // Checking contrast specifi parameters
276 
277  switch( inputParamsPtr->m_type )
278  {
280  {
281  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_lCMinInput.size() ==
282  inputParamsPtr->m_inRasterBands.size(),
283  "Invalid parameter m_lCMinInput" );
284  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_lCMaxInput.size() ==
285  inputParamsPtr->m_inRasterBands.size(),
286  "Invalid parameter m_lCMaxInput" );
287 
288  break;
289  }
291  {
292  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_hECMaxInput.size() ==
293  inputParamsPtr->m_inRasterBands.size(),
294  "Invalid parameter m_hECMaxInput" );
295 
296  break;
297  }
299  {
300  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_sMASCMeanInput.size() ==
301  inputParamsPtr->m_inRasterBands.size(),
302  "Invalid parameter m_sMASCMeanInput" );
303  TERP_TRUE_OR_RETURN_FALSE( inputParamsPtr->m_sMASCStdInput.size() ==
304  inputParamsPtr->m_inRasterBands.size(),
305  "Invalid parameter m_sMASCStdInput" );
306  break;
307  }
308  default :
309  {
310  TERP_LOG_AND_THROW( "Invalid contrast type" );
311  break;
312  }
313  }
314 
315  m_inputParameters = *inputParamsPtr;
316  m_isInitialized = true;
317 
318  return true;
319  }
320 
322  {
323  return m_isInitialized;
324  }
325 
327  {
330 
331  const bool enableGlobalProgress = m_inputParameters.m_enableProgress &&
332  ( m_inputParameters.m_inRasterBands.size() > 1 );
333  std::auto_ptr< te::common::TaskProgress > progressPtr;
334  if( enableGlobalProgress )
335  {
336  progressPtr.reset( new te::common::TaskProgress );
337  progressPtr->setMessage( "Contrast" );
338  progressPtr->setTotalSteps( m_inputParameters.m_inRasterBands.size() );
339  }
340 
341  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
342  m_inputParameters.m_inRasterBands.size() ; ++inRasterBandsIdx )
343  {
344  te::rst::Band const* inRasterBandPtr = m_inputParameters.m_inRasterPtr->getBand(
345  m_inputParameters.m_inRasterBands[ inRasterBandsIdx ] );
347  m_outputParametersPtr->m_outRasterBands[ inRasterBandsIdx ] );
348 
349  double outRangeMin = 0.0;
350  double outRangeMax = 0.0;
351  GetDataTypeRange( outRasterBandPtr->getProperty()->getType(),
352  outRangeMin, outRangeMax );
353  const double outRasterRange = outRangeMax - outRangeMin;
354 
355  const double inRasterRange = m_inputParameters.m_lCMaxInput[ inRasterBandsIdx ] -
356  m_inputParameters.m_lCMinInput[ inRasterBandsIdx ];
357 
358  if( ( outRasterRange != 0.0 ) && ( inRasterRange != 0.0 ) )
359  {
360  m_offSetGainRemap_gain = outRasterRange / inRasterRange;
361  m_offSetGainRemap_offset = outRangeMin - m_inputParameters.m_lCMinInput[ inRasterBandsIdx ];
362  }
363 
364  if( ! remapBandLevels( *inRasterBandPtr, *outRasterBandPtr,
366  (!enableGlobalProgress) ) )
367  {
368  return false;
369  }
370 
371  if( enableGlobalProgress )
372  {
373  progressPtr->pulse();
374  if( ! progressPtr->isActive() ) return false;
375  }
376  }
377 
378  return true;
379  }
380 
382  {
385 
386  const te::rst::RasterSummary* rsummary =
389 
390  double value;
391  double newvalue;
392  unsigned int N = m_inputParameters.m_inRasterPtr->getNumberOfRows() *
394 
395  std::auto_ptr< te::common::TaskProgress > progressPtr;
397  {
398  progressPtr.reset( new te::common::TaskProgress );
399  progressPtr->setMessage( "Contrast" );
400  progressPtr->setTotalSteps( m_inputParameters.m_inRasterBands.size() );
401  }
402 
403  for( unsigned int b = 0 ; b < m_inputParameters.m_inRasterBands.size() ; b++ )
404  {
405  const double lutfactor =
406  m_inputParameters.m_hECMaxInput[ b ] / (double) N;
407 
408  unsigned int niband = m_inputParameters.m_inRasterBands[b];
409  unsigned int noband = m_outputParametersPtr->m_outRasterBands[b];
410 
411  const te::rst::Band* iband = m_inputParameters.m_inRasterPtr->getBand(niband);
413 
414  double outRangeMin = 0.0;
415  double outRangeMax = 0.0;
416  GetDataTypeRange( oband->getProperty()->getType(),
417  outRangeMin, outRangeMax );
418 
423 
424  std::map<double, double> lut;
425  const double minp = rsummary->at(niband).m_minVal->real();
426  const double maxp = rsummary->at(niband).m_maxVal->real();
427  for (double pixel = minp; pixel <= maxp; pixel++)
428  {
429  newvalue = 0.0;
430  for (double nj = minp; nj <= pixel; nj++)
431  newvalue += rsummary->at(niband).m_histogramR->operator[](nj);
432  lut[pixel] = lutfactor * newvalue;
433  }
434 
435  while (ibandit != ibanditend)
436  {
437  value = lut[ *ibandit ];
438  value = std::max( outRangeMin, value );
439  value = std::min( outRangeMax, value );
440  oband->setValue(ibandit.getColumn(), ibandit.getRow(), value);
441  ++ibandit;
442  }
443 
445  {
446  progressPtr->pulse();
447  if( ! progressPtr->isActive() ) return false;
448  }
449  }
450 
451  return true;
452  }
453 
455  {
458 
459  const te::rst::RasterSummary* rsummary =
463 
464  std::auto_ptr< te::common::TaskProgress > progressPtr;
466  {
467  progressPtr.reset( new te::common::TaskProgress );
468  progressPtr->setMessage( "Contrast" );
469  progressPtr->setTotalSteps( m_inputParameters.m_inRasterBands.size() *
471  }
472 
473  for( unsigned int b = 0 ; b < m_inputParameters.m_inRasterBands.size() ; b++ )
474  {
475  unsigned int niband = m_inputParameters.m_inRasterBands[b];
476  unsigned int noband = m_outputParametersPtr->m_outRasterBands[b];
477 
478  const te::rst::Band* iband = m_inputParameters.m_inRasterPtr->getBand(niband);
480 
481  double outRangeMin = 0.0;
482  double outRangeMax = 0.0;
483  GetDataTypeRange( oband->getProperty()->getType(),
484  outRangeMin, outRangeMax );
485 
490 
491  const double meanp = rsummary->at(niband).m_meanVal->real();
492  const double stdp = rsummary->at(niband).m_stdVal->real();
493  const double offset = m_inputParameters.m_sMASCMeanInput[ b ] /
495  const double c1 = m_inputParameters.m_sMASCStdInput[ b ] / stdp;
496  const double c2 = offset * m_inputParameters.m_sMASCStdInput[ b ];
497 
498  double value;
499  double newvalue;
500 
501  for (unsigned r = 0; r < iband->getRaster()->getNumberOfRows(); r++)
502  {
503  for (unsigned c = 0; c < iband->getRaster()->getNumberOfColumns(); c++)
504  {
505  iband->getValue(c, r, value);
506  newvalue = (value - meanp) * c1 + c2;
507  newvalue = std::max( outRangeMin, newvalue );
508  newvalue = std::min( outRangeMax, newvalue );
509  oband->setValue(c, r, newvalue);
510  }
511 
513  {
514  progressPtr->pulse();
515  if( ! progressPtr->isActive() ) return false;
516  }
517  }
518  }
519 
520  return true;
521  }
522 
523  bool Contrast::remapBandLevels( const te::rst::Band& inRasterBand,
524  te::rst::Band& outRasterBand, RemapFuncPtrT remapFuncPtr,
525  const bool enableProgress )
526  {
527  const unsigned int inBlkWidthPixels = inRasterBand.getProperty()->m_blkw;
528  const unsigned int inBlkHeightPixels = inRasterBand.getProperty()->m_blkh;
529  const unsigned int outBlkWidthPixels = outRasterBand.getProperty()->m_blkw;
530  const unsigned int outBlkHeightPixels = outRasterBand.getProperty()->m_blkh;
531  double outRangeMin = 0.0;
532  double outRangeMax = 0.0;
533  GetDataTypeRange( outRasterBand.getProperty()->getType(),
534  outRangeMin, outRangeMax );
535 
536  std::auto_ptr< te::common::TaskProgress > progressPtr;
537  if( enableProgress )
538  {
539  progressPtr.reset( new te::common::TaskProgress );
540  progressPtr->setMessage( "Contrast" );
541  }
542 
543  if( ( inBlkWidthPixels == outBlkWidthPixels ) &&
544  ( inBlkHeightPixels == outBlkHeightPixels ) )
545  { // block version
546  const unsigned int blockSizePixels = inBlkWidthPixels *
547  inBlkHeightPixels;
548  const unsigned int xBlocksNmb = inRasterBand.getProperty()->m_nblocksx;
549  const unsigned int yBlocksNmb = inRasterBand.getProperty()->m_nblocksy;
550  unsigned char* inputBuffer = new unsigned char[ inRasterBand.getBlockSize() ];
551  unsigned char* outputBuffer = new unsigned char[ outRasterBand.getBlockSize() ];
552  double* inDoublesBuffer = new double[ blockSizePixels ];
553  double* outDoublesBuffer = new double[ blockSizePixels ];
554  const int inputVectorDataType = inRasterBand.getProperty()->getType();
555  const int outputVectorDataType = outRasterBand.getProperty()->getType();
556  unsigned int blockXIndex = 0;
557  unsigned int blockOffset = 0;
558  double outValue = 0;
559 
560  if( enableProgress ) progressPtr->setTotalSteps( yBlocksNmb * xBlocksNmb );
561 
562  for( unsigned int blockYIndex = 0 ; blockYIndex < yBlocksNmb ;
563  ++blockYIndex )
564  {
565  for( blockXIndex = 0 ; blockXIndex < xBlocksNmb ;
566  ++blockXIndex )
567  {
568  inRasterBand.read( blockXIndex, blockYIndex, inputBuffer );
569 
570  Convert2DoublesVector( inputBuffer, inputVectorDataType,
571  blockSizePixels, inDoublesBuffer );
572 
573  for( blockOffset = 0 ; blockOffset < blockSizePixels ; ++blockOffset )
574  {
575  (this->*remapFuncPtr)( inDoublesBuffer[blockOffset],
576  outValue);
577  outDoublesBuffer[blockOffset] = std::max( outRangeMin, std::min(
578  outRangeMax, outValue ) );
579  }
580 
581  ConvertDoublesVector( outDoublesBuffer, blockSizePixels,
582  outputVectorDataType, outputBuffer );
583 
584  outRasterBand.write( blockXIndex, blockYIndex, outputBuffer );
585 
586  if( enableProgress )
587  {
588  progressPtr->pulse();
589  if( ! progressPtr->isActive() ) return false;
590  }
591  }
592  }
593 
594  delete[] inputBuffer;
595  delete[] outputBuffer;
596  delete[] inDoublesBuffer;
597  delete[] outDoublesBuffer;
598  }
599  else
600  { // pixel by pixel version
601  const unsigned int linesNumber = m_inputParameters.m_inRasterPtr->getNumberOfRows();
602  const unsigned int columnsNumber = m_inputParameters.m_inRasterPtr->getNumberOfColumns();
603 
604  if( enableProgress ) progressPtr->setTotalSteps( linesNumber );
605 
606  unsigned int col = 0;
607  double inputValue = 0;
608  double outputValue = 0;
609 
610  for( unsigned int line = 0 ; line < linesNumber ; ++line )
611  {
612  for( col = 0 ; col < columnsNumber ; ++col )
613  {
614  inRasterBand.getValue( col, line, inputValue );
615  (this->*remapFuncPtr)( inputValue, outputValue );
616  outRasterBand.setValue( col, line, std::max( outRangeMin, std::min(
617  outRangeMax, outputValue ) ) );
618  }
619 
620  if( enableProgress )
621  {
622  progressPtr->pulse();
623  if( ! progressPtr->isActive() ) return false;
624  }
625  }
626  }
627 
628  return true;
629  }
630 
631  } // end namespace rp
632 } // end namespace te
633 
Calculate the standard deviation value.
Definition: Enums.h:42
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
Definition: RasterSummary.h:44
std::vector< unsigned int > m_outRasterBands
Bands to be processed from the output raster.
Definition: Contrast.h:126
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Definition: Contrast.cpp:147
#define TERP_LOG_AND_RETURN_FALSE(message)
Logs a warning message will and return false.
Definition: Macros.h:236
te::rst::Raster * m_outRasterPtr
A pointer to a valid initiated raster instance where the result must be written, leave NULL to create...
Definition: Contrast.h:122
int getType() const
It returns the data type of the elements in the band.
Definition: BandProperty.h:113
void(Contrast::* RemapFuncPtrT)(const double &inValue, double &outValue)
Type definition for a remapping function pointer.
Definition: Contrast.h:168
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: Contrast.cpp:133
Raster Processing functions.
const OutputParameters & operator=(const OutputParameters &params)
Definition: Contrast.cpp:120
double m_offSetGainRemap_gain
Definition: Contrast.h:208
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
Contrast output parameters.
Definition: Contrast.h:118
static Raster * make()
It creates and returns an empty raster with default raster driver.
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
Contrast::InputParameters m_inputParameters
Contrast input execution parameters.
Definition: Contrast.h:171
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
std::vector< unsigned int > m_inRasterBands
Bands to be processed from the input raster.
Definition: Contrast.h:91
void Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements.
Definition: Functions.cpp:286
std::vector< double > m_lCMaxInput
The contrast maximum input greyscale value of each band.
Definition: Contrast.h:81
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::map< std::string, std::string > m_createdOutRasterInfo
The necessary information to create the raster (as described in te::raster::RasterFactory), leave empty if the result must be written to the raster pointed m_outRasterPtr.
Definition: Contrast.h:130
A rectified grid is the spatial support for raster data.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: Contrast.cpp:111
std::string m_createdOutRasterDSType
Output raster data source type (as described in te::raster::RasterFactory ), leave empty if the resul...
Definition: Contrast.h:128
te::rst::Raster const * m_inRasterPtr
Input raster.
Definition: Contrast.h:89
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
Definition: Macros.h:183
bool m_isInitialized
Tells if this instance is initialized.
Definition: Contrast.h:174
Abstract parameters base interface.
A raster band description.
Definition: Band.h:63
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
const InputParameters & operator=(const InputParameters &params)
Definition: Contrast.cpp:71
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
std::vector< double > m_lCMinInput
The contrast minimum input greyscale value of each band.
Definition: Contrast.h:79
virtual Raster * getRaster() const =0
Returns the associated raster.
ContrastType m_type
The contrast type to be applied.
Definition: Contrast.h:77
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: Contrast.h:93
Contrast input parameters.
Definition: Contrast.h:64
void offSetGainRemap(const double &inValue, double &outValue)
Remap on gray level using an offset (Contrast::m_offSetGainRemap_offset) and a gain value (Contrast::...
Definition: Contrast.h:217
std::auto_ptr< te::rst::Raster > m_createdOutRasterPtr
A pointer to the created output raster instance, or an empty pointer empty if the result must be writ...
Definition: Contrast.h:124
bool execLinearContrast()
Execute a linear contrast following the internal parameters.
Definition: Contrast.cpp:326
std::vector< double > m_hECMaxInput
The contrast maximum input greyscale value of each band.
Definition: Contrast.h:83
virtual int getBlockSize() const
It returns the number of bytes ocuppied by a data block.
Definition: Band.cpp:490
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
const Algorithm & operator=(const Algorithm &)
Definition: Algorithm.cpp:43
This class implements an iterator to &quot;navigate&quot; over a single band (const).
Definition: BandIterator.h:211
Calculate the histogram for the real part.
Definition: Enums.h:44
A raster band description.
Definition: BandProperty.h:61
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
Definition: Contrast.cpp:241
bool execHistogramEqualizationContrast()
Execute the histogram equalization contrast following the internal parameters.
Definition: Contrast.cpp:381
void GetDataTypeRange(const int dataType, double &min, double &max)
Returns the real data type range (all values that can be represented by the given data type)...
Definition: Functions.cpp:228
static ConstBandIterator begin(const Band *b)
Returns an iterator referring to the first value of the band.
Definition: BandIterator.h:592
Raster Processing algorithm output parameters base interface.
virtual void write(int x, int y, void *buffer)=0
It writes a data block from the specified buffer.
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:370
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
std::vector< double > m_sMASCMeanInput
The mean greyscale to be applied in each band.
Definition: Contrast.h:85
#define TERP_LOG_AND_THROW(message)
Logs a error message and throws.
Definition: Macros.h:138
std::vector< double > m_sMASCStdInput
The standard deviation to be applied in each band.
Definition: Contrast.h:87
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
void ConvertDoublesVector(double *inputVector, unsigned int inputVectorSize, const int outputVectorDataType, void *outputVector)
Convert a doubles vector.
Definition: Functions.cpp:398
SummaryTypes
Types for the BandSummary.
Definition: Enums.h:38
bool execSetMeanAndStdContrast()
Execute the histogram equalization contrast following the internal parameters.
Definition: Contrast.cpp:454
static ConstBandIterator end(const Band *b)
Returns an iterator referring to after the end of the iterator.
Definition: BandIterator.h:597
virtual void read(int x, int y, void *buffer) const =0
It reads a data block to the specified buffer.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: Contrast.cpp:57
Calculate the mean value.
Definition: Enums.h:43
Contrast::OutputParameters * m_outputParametersPtr
Contrast input execution parameters.
Definition: Contrast.h:172
Contrast enhancement.
double m_offSetGainRemap_offset
Definition: Contrast.h:207
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
Definition: Contrast.cpp:321
bool remapBandLevels(const te::rst::Band &inRasterBand, te::rst::Band &outRasterBand, RemapFuncPtrT remapFuncPtr, const bool enableProgress)
Band gray levels remap using a remap function.
Definition: Contrast.cpp:523
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Definition: Contrast.cpp:248
Raster Processing algorithm input parameters base interface.
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: Contrast.cpp:90