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