All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IHSFusion.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/IHSFusion.cpp
22  \brief Creation of skeleton imagems.
23 */
24 
25 #include "IHSFusion.h"
26 #include "Macros.h"
27 #include "Functions.h"
28 
29 #include "../raster/BandProperty.h"
30 #include "../raster/RasterFactory.h"
31 #include "../raster/Band.h"
32 #include "../raster/Grid.h"
33 #include "../geometry/Envelope.h"
34 #include "../common/progress/TaskProgress.h"
35 
36 #include <cmath>
37 #include <limits>
38 
39 #ifndef M_PI
40  #define M_PI 3.14159265358979323846
41 #endif
42 
43 namespace te
44 {
45  namespace rp
46  {
47 
49  {
50  reset();
51  }
52 
54  {
55  reset();
56  operator=( other );
57  }
58 
60  {
61  reset();
62  }
63 
64  void IHSFusion::InputParameters::reset() throw( te::rp::Exception )
65  {
66  m_lowResRasterPtr = 0;
67  m_lowResRasterRedBandIndex = 0;
68  m_lowResRasterGreenBandIndex = 1;
69  m_lowResRasterBlueBandIndex = 2;
70  m_highResRasterPtr = 0;
71  m_highResRasterBand = 0;
72  m_enableProgress = false;
74  m_RGBMin = 0.0;
75  m_RGBMax = 0.0;
76  }
77 
79  const IHSFusion::InputParameters& params )
80  {
81  reset();
82 
83  m_lowResRasterPtr = params.m_lowResRasterPtr;
84  m_lowResRasterRedBandIndex = params.m_lowResRasterRedBandIndex;
85  m_lowResRasterGreenBandIndex = params.m_lowResRasterGreenBandIndex;
86  m_lowResRasterBlueBandIndex = params.m_lowResRasterBlueBandIndex;
87  m_highResRasterPtr = params.m_highResRasterPtr;
88  m_highResRasterBand = params.m_highResRasterBand;
89  m_enableProgress = params.m_enableProgress;
90  m_interpMethod = params.m_interpMethod;
91  m_RGBMin = params.m_RGBMin;
92  m_RGBMax = params.m_RGBMax;
93 
94  return *this;
95  }
96 
98  {
99  return new InputParameters( *this );
100  }
101 
103  {
104  reset();
105  }
106 
108  {
109  reset();
110  operator=( other );
111  }
112 
114  {
115  reset();
116  }
117 
118  void IHSFusion::OutputParameters::reset() throw( te::rp::Exception )
119  {
120  m_rType.clear();
121  m_rInfo.clear();
122  m_outputRasterPtr.reset();
123  }
124 
126  const IHSFusion::OutputParameters& params )
127  {
128  reset();
129 
130  m_rType = params.m_rType;
131  m_rInfo = params.m_rInfo;
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  if( ! m_isInitialized ) return false;
154 
155  IHSFusion::OutputParameters* outParamsPtr = dynamic_cast<
156  IHSFusion::OutputParameters* >( &outputParams );
157  TERP_TRUE_OR_THROW( outParamsPtr, "Invalid paramters" );
158 
159  // progress
160 
161  std::auto_ptr< te::common::TaskProgress > progressPtr;
163  {
164  progressPtr.reset( new te::common::TaskProgress );
165 
166  progressPtr->setTotalSteps( 4 );
167 
168  progressPtr->setMessage( "Fusing images" );
169  }
170 
171  // Getting RGB range
172 
173  double rgbMin = 0.0;
174  double rgbMax = 0.0;
175  TERP_TRUE_OR_RETURN_FALSE( getRGBRange( rgbMin, rgbMax ),
176  "Unable to get RGB range" );
177 
179  {
180  progressPtr->pulse();
181  if( ! progressPtr->isActive() ) return false;
182  }
183 
184  // Loading IHS data
185 
186  te::rp::Matrix< float > intensityData;
188  te::rp::Matrix< float > hueData;
190  te::rp::Matrix< float > saturationData;
191  saturationData.reset( te::rp::Matrix< float >::AutoMemPol );
192 
193  TERP_TRUE_OR_RETURN_FALSE( loadIHSData( rgbMin, rgbMax, intensityData,
194  hueData, saturationData ), "Error loading IHS data" );
195 
197  {
198  progressPtr->pulse();
199  if( ! progressPtr->isActive() ) return false;
200  }
201 
202 // CreateRasterFileFromMatrix( intensityData, true, "intensityData.tif" );
203 // CreateRasterFileFromMatrix( hueData, true, "hueData.tif" );
204 // CreateRasterFileFromMatrix( saturationData, true, "saturationData.tif" );
205 
206  // Swapping Itensity
207 
208  TERP_TRUE_OR_RETURN_FALSE( swapIntensity( intensityData ),
209  "Intensity channel swap error" );
210 
211 // CreateRasterFileFromMatrix( intensityData, true, "swappedintensityData.tif" );
212 
214  {
215  progressPtr->pulse();
216  if( ! progressPtr->isActive() ) return false;
217  }
218 
219  // Saving RGB data
220 
221  TERP_TRUE_OR_RETURN_FALSE( saveIHSData( rgbMin, rgbMax, intensityData,
222  hueData, saturationData, outParamsPtr->m_rType, outParamsPtr->m_rInfo,
223  outParamsPtr->m_outputRasterPtr),
224  "RGB raster creation error" );
225 
227  {
228  progressPtr->pulse();
229  if( ! progressPtr->isActive() ) return false;
230  }
231 
232  return true;
233  }
234 
235  void IHSFusion::reset() throw( te::rp::Exception )
236  {
238  m_isInitialized = false;
239  }
240 
242  throw( te::rp::Exception )
243  {
244  reset();
245 
246  IHSFusion::InputParameters const* inputParamsPtr = dynamic_cast<
247  IHSFusion::InputParameters const* >( &inputParams );
248  TERP_TRUE_OR_THROW( inputParamsPtr, "Invalid paramters pointer" );
249 
250  m_inputParameters = *inputParamsPtr;
251 
252  // Checking the m_lowResRasterPtr and m_lowResRasterBands
253 
255  "Invalid low Resolution Raster Pointer" )
256 
259  "Invalid raster" );
260 
264  "Invalid raster band" );
265 
269  "Invalid raster band" );
270 
274  "Invalid raster band" );
275 
276  // Checking the m_highResRasterPtr and m_highResRasterBand
277 
279  "Invalid high resolution Raster Pointer" )
280 
283  "Invalid raster" );
284 
288  "Invalid raster band" );
289 
291  m_inputParameters.m_RGBMax, "Invalid RGB channel ranges" );
292 
293  m_isInitialized = true;
294 
295  return true;
296  }
297 
299  {
300  return m_isInitialized;
301  }
302 
303  bool IHSFusion::getRGBRange( double& rgbMin, double& rgbMax ) const
304  {
305  if( ( m_inputParameters.m_RGBMax == 0.0 ) &&
306  ( m_inputParameters.m_RGBMin == 0.0 ) )
307  {
308 
309  const unsigned int nCols = m_inputParameters.m_lowResRasterPtr->getNumberOfColumns();
310  const unsigned int nRows = m_inputParameters.m_lowResRasterPtr->getNumberOfRows();
317  const double redNoData = redBand.getProperty()->m_noDataValue;
318  const double greenNoData = greenBand.getProperty()->m_noDataValue;
319  const double blueNoData = blueBand.getProperty()->m_noDataValue;
320 
321  rgbMin = std::numeric_limits<double>::max();
322  rgbMax = -1.0 * std::numeric_limits<double>::max();
323 
324  unsigned int row = 0;
325  unsigned int col = 0;
326  double redValue = 0;
327  double greenValue = 0;
328  double blueValue = 0;
329 
330  for( row = 0 ; row < nRows ; ++row )
331  {
332  for( col = 0 ; col < nCols ; ++col )
333  {
334  redBand.getValue( col, row, redValue );
335  greenBand.getValue( col, row, greenValue );
336  blueBand.getValue( col, row, blueValue );
337 
338  if( ( redValue != redNoData ) && ( greenValue != greenNoData ) &&
339  ( blueValue != blueNoData ) )
340  {
341  if( redValue > rgbMax ) rgbMax = redValue;
342  if( greenValue > rgbMax ) rgbMax = greenValue;
343  if( blueValue > rgbMax ) rgbMax = blueValue;
344 
345  if( redValue < rgbMin ) rgbMin = redValue;
346  if( greenValue < rgbMin ) rgbMin = greenValue;
347  if( blueValue < rgbMin ) rgbMin = blueValue;
348  }
349  }
350  }
351  }
352  else
353  {
354  rgbMin = m_inputParameters.m_RGBMin;
355  rgbMax = m_inputParameters.m_RGBMax;
356  }
357 
358  return true;
359  }
360 
361  bool IHSFusion::loadIHSData( const double& rgbMin, const double rgbMax,
362  te::rp::Matrix< float >& intensityData,
363  te::rp::Matrix< float >& hueData, te::rp::Matrix< float >& saturationData ) const
364  {
365  const unsigned int outNCols = m_inputParameters.m_highResRasterPtr->getNumberOfColumns();
366  const unsigned int outNRows = m_inputParameters.m_highResRasterPtr->getNumberOfRows();
367  const double colsRescaleFactor =
369  ((double)outNCols);
370  const double rowsRescaleFactor =
372  ((double)outNRows);
373  const unsigned int redBandIdx = m_inputParameters.m_lowResRasterRedBandIndex;
374  const unsigned int greenBandIdx = m_inputParameters.m_lowResRasterGreenBandIndex;
375  const unsigned int blueBandIdx = m_inputParameters.m_lowResRasterBlueBandIndex;
376  const double redNoData = m_inputParameters.m_lowResRasterPtr->getBand(
377  redBandIdx )->getProperty()->m_noDataValue;
378  const double greenNoData = m_inputParameters.m_lowResRasterPtr->getBand(
379  greenBandIdx )->getProperty()->m_noDataValue;
380  const double blueNoData = m_inputParameters.m_lowResRasterPtr->getBand(
381  blueBandIdx )->getProperty()->m_noDataValue;
382 
383  if( ! intensityData.reset( outNRows, outNCols ) ) return false;
384  if( ! hueData.reset( outNRows, outNCols ) ) return false;
385  if( ! saturationData.reset( outNRows, outNCols ) ) return false;
386 
389  unsigned int outRow = 0;
390  unsigned int outCol = 0;
391  double inRow = 0;
392  double inCol = 0;
393  std::complex< double > redC = 0;
394  std::complex< double > greenC = 0;
395  std::complex< double > blueC = 0;
396  float* intensityRow = 0;
397  float* hueRow = 0;
398  float* saturationRow = 0;
399 
400  double teta = 0;
401  double redNorm = 0, greenNorm = 0, blueNorm = 0;
402  double rMinusG = 0, rMinusB = 0;
403  double rgbSum = 0;
404  double cosValue = 0;
405  const double twoPi = 2.0 * ((double)M_PI);
406  const double pi2 = ((double)M_PI) / 2.0;
407  const double rgbNormFac = ( rgbMax == rgbMin ) ? 0.0 :
408  ( 1.0 / ( rgbMax - rgbMin ) );
409 
410  for( outRow = 0 ; outRow < outNRows ; ++outRow )
411  {
412  inRow = ((double)outRow) * rowsRescaleFactor;
413  intensityRow = intensityData[ outRow ];
414  hueRow = hueData[ outRow ];
415  saturationRow = saturationData[ outRow ];
416 
417  for( outCol = 0 ; outCol < outNCols ; ++outCol )
418  {
419  inCol = ((double)outCol) * colsRescaleFactor;
420 
421  interpol.getValue( inCol, inRow, redC, redBandIdx );
422  interpol.getValue( inCol, inRow, greenC, greenBandIdx );
423  interpol.getValue( inCol, inRow, blueC, blueBandIdx );
424 
425  if( ( redC.real() == redNoData ) || ( greenC.real() == greenNoData ) ||
426  ( blueC.real() == blueNoData ) )
427  {
428  intensityRow[ outCol ] = 0.0;
429  hueRow[ outCol ] = 0.0;
430  saturationRow[ outCol ] = 0.0;
431  }
432  else
433  {
434  if( ( redC.real() == greenC.real() ) && ( greenC.real() == blueC.real() ) )
435  { // Gray scale case
436  // From Wikipedia:
437  // h = 0 is used for grays though the hue has no geometric
438  // meaning there, where the saturation s = 0. Similarly,
439  // the choice of 0 as the value for s when l is equal to 0 or 1
440  // is arbitrary.
441 
442  hueRow[ outCol ] = 0.0;
443  saturationRow[ outCol ] = 0.0;
444  intensityRow[ outCol ] = (float)( redC.real() * rgbNormFac ); // or green or blue since they all are the same.
445  }
446  else
447  { // Color case
448  redNorm = ( redC.real() - rgbMin ) * rgbNormFac;
449  greenNorm = ( greenC.real() - rgbMin ) * rgbNormFac;
450  blueNorm = ( blueC.real() - rgbMin ) * rgbNormFac;
451 
452  rMinusG = redNorm - greenNorm;
453  rMinusB = redNorm - blueNorm;
454 
455  cosValue = sqrt( ( rMinusG * rMinusG ) + ( rMinusB *
456  ( greenNorm - blueNorm ) ) );
457 
458  if( cosValue == 0.0 )
459  {
460  teta = pi2;
461  }
462  else
463  {
464  cosValue = ( 0.5 * ( rMinusG + rMinusB ) ) /
465  cosValue;
466  teta = std::acos( cosValue );
467  }
468 
469  assert( ( cosValue >= (-1.0) ) && ( cosValue <= (1.0) ) );
470 
471  if( blueNorm > greenNorm )
472  {
473  hueRow[ outCol ] = (float)( twoPi - teta );
474  }
475  else
476  {
477  hueRow[ outCol ] = (float)teta;
478  }
479 
480  rgbSum = ( redNorm + greenNorm + blueNorm );
481 
482  saturationRow[ outCol ] = (float)( 1.0 - ( 3 * std::min( std::min( redNorm, greenNorm ), blueNorm ) /
483  rgbSum ) );
484 
485  intensityRow[ outCol ] = (float)( rgbSum / 3.0 );
486  }
487  }
488  }
489  }
490 
491  return true;
492  }
493 
494  bool IHSFusion::getStatistics( const te::rp::Matrix< float >& matrix, float& mean,
495  float& variance ) const
496  {
497  const unsigned int nRows = matrix.getLinesNumber();
498  const unsigned int nCols = matrix.getColumnsNumber();
499 
500  if( ( nRows == 0 ) || ( nCols == 0 ) ) return false;
501 
502  unsigned int col = 0;
503  unsigned int row = 0;
504  float const * rowPtr = 0;
505 
506  mean = 0.0;
507 
508  for( row = 0 ; row < nRows ; ++row )
509  {
510  rowPtr = matrix[ row ];
511 
512  for( col = 0 ; col < nCols ; ++col )
513  {
514  mean += rowPtr[ col ];
515  }
516  }
517 
518  mean /= (float)( nCols * nRows );
519 
520  float diff = 0.0;
521  variance = 0.0;
522 
523  for( row = 0 ; row < nRows ; ++row )
524  {
525  rowPtr = matrix[ row ];
526 
527  for( col = 0 ; col < nCols ; ++col )
528  {
529  diff = rowPtr[ col ] - mean;
530  variance += ( diff * diff );
531  }
532  }
533 
534  return true;
535  }
536 
538  {
539  const unsigned int nRows = intensityData.getLinesNumber();
540  const unsigned int nCols = intensityData.getColumnsNumber();
541 
542  if( ( nRows == 0 ) || ( nCols == 0 ) ) return false;
543 
546 
547  // intensity statistics
548 
549  float intensityMean = 0.0;
550  float intensityVariance = 0.0;
551  getStatistics( intensityData, intensityMean, intensityVariance );
552 
553  // high resolution raster statistics
554 
555  double rasterMean = 0;
556  double rasterVariance = 0;
557 
558  unsigned int col = 0;
559  unsigned int row = 0;
560  double value = 0;
563  double diff = 0;
564 
565  for( row = 0 ; row < nRows ; ++row )
566  {
567  for( col = 0 ; col < nCols ; ++col )
568  {
569  band.getValue( col, row, value );
570  rasterMean += value;
571  }
572  }
573 
574  rasterMean /= (double)( nCols * nRows );
575 
576  for( row = 0 ; row < nRows ; ++row )
577  {
578  for( col = 0 ; col < nCols ; ++col )
579  {
580  band.getValue( col, row, value );
581  diff = value - rasterMean;
582  rasterVariance += ( diff * diff );
583  }
584  }
585 
586  double gain = ( ( rasterVariance == 0.0 ) ? 0.0 :
587  sqrt( intensityVariance / rasterVariance ) );
588  double offset = intensityMean - ( gain * rasterMean );
589  float* intensityRow = 0;
590 
591  for( row = 0 ; row < nRows ; ++row )
592  {
593  intensityRow = intensityData[ row ];
594 
595  for( col = 0 ; col < nCols ; ++col )
596  {
597  band.getValue( col, row, value );
598  intensityRow[ col ] = (float)std::min( 1.0, std::max( 0.0, ( ( value * gain ) - offset ) ) );
599  }
600  }
601 
602  return true;
603  }
604 
605  bool IHSFusion::saveIHSData( const double& rgbMin, const double rgbMax, const te::rp::Matrix< float >& intensityData,
606  const te::rp::Matrix< float >& hueData, const te::rp::Matrix< float >& saturationData,
607  const std::string& rType, const std::map< std::string, std::string >& rInfo,
608  std::auto_ptr< te::rst::Raster >& outputRasterPtr ) const
609  {
611  assert( intensityData.getLinesNumber() == m_inputParameters.m_highResRasterPtr->getNumberOfRows() );
612  assert( intensityData.getColumnsNumber() == hueData.getColumnsNumber() );
613  assert( intensityData.getColumnsNumber() == saturationData.getColumnsNumber() );
614  assert( intensityData.getLinesNumber() == hueData.getLinesNumber() );
615  assert( intensityData.getLinesNumber() == saturationData.getLinesNumber() );
616 
617  const unsigned int nRows = intensityData.getLinesNumber();
618  const unsigned int nCols = intensityData.getColumnsNumber();
619 
620  std::vector< te::rst::BandProperty* > outRasterBandsProperties;
621  outRasterBandsProperties.push_back( new te::rst::BandProperty(
624  outRasterBandsProperties.push_back( new te::rst::BandProperty(
627  outRasterBandsProperties.push_back( new te::rst::BandProperty(
630 
631  te::rst::Grid* gridPtr = new te::rst::Grid( nCols, nRows,
634 
635  outputRasterPtr.reset(
637  rType,
638  gridPtr,
639  outRasterBandsProperties,
640  rInfo,
641  0,
642  0 ) );
643  TERP_TRUE_OR_RETURN_FALSE( outputRasterPtr.get(),
644  "Output raster creation error" );
645 
646  const double rgbNormFac = ( rgbMax == rgbMin ) ? 0.0 :
647  ( rgbMax - rgbMin );
648  const double pi3 = M_PI / 3.0; // 60
649  const double twoPi3 = 2.0 * M_PI / 3.0; // 120
650  const double fourPi3 = 4.0 * M_PI / 3.0; // 240
651  unsigned int row = 0;
652  unsigned int col = 0;
653  double hue = 0;
654  double lig = 0;
655  double sat = 0;
656  double red = 0;
657  double green = 0;
658  double blue = 0;
659  te::rst::Band& redBand = *outputRasterPtr->getBand( 0 );
660  te::rst::Band& greenBand = *outputRasterPtr->getBand( 1 );
661  te::rst::Band& blueBand = *outputRasterPtr->getBand( 2 );
662 
663  for( row = 0 ; row < nRows ; ++row )
664  {
665  for( col = 0 ; col < nCols ; ++col )
666  {
667  hue = hueData[ row ][ col ];
668  lig = intensityData[ row ][ col ];
669  sat = saturationData[ row ][ col ];
670 
671  if( ( hue == 0.0 ) && ( sat == 0.0 ) )
672  { // Gray scale case
673  red = green = blue = ( lig * rgbNormFac );
674  }
675  else
676  { // color case
677  /* Hue inside RG sector */
678  if( hue < twoPi3 )
679  {
680  blue = lig * ( 1.0 - sat );
681  red = lig * ( 1.0 + ( sat * std::cos( hue ) /
682  std::cos( pi3 - hue ) ) );
683  green = ( 3.0 * lig ) - ( red + blue );
684  }
685  else if( hue < fourPi3 )
686  { /* Hue inside GB sector */
687 
688  hue -= twoPi3;
689 
690  red = lig * ( 1.0 - sat );
691  green = lig * ( 1.0 + ( sat * std::cos( hue ) /
692  std::cos( pi3 - hue ) ) );
693  blue = ( 3.0 * lig ) - ( red + green );
694  }
695  else
696  { /* Hue inside BR sector */
697 
698  hue -= fourPi3;
699 
700  green = lig * ( 1.0 - sat );
701  blue = lig * ( 1.0 + ( sat * std::cos( hue ) /
702  std::cos( pi3 - hue ) ) );
703  red = ( 3.0 * lig ) - ( green + blue );
704  }
705 
706  red = ( red * rgbNormFac ) + rgbMin;
707  green = ( green * rgbNormFac ) + rgbMin;
708  blue = ( blue * rgbNormFac ) + rgbMin;
709  }
710 
711  red = MIN( red, rgbMax );
712  green = MIN( green, rgbMax );
713  blue = MIN( blue, rgbMax );
714 
715  red = MAX( red, rgbMin );
716  green = MAX( green, rgbMin );
717  blue = MAX( blue, rgbMin );
718 
719  redBand.setValue( col, row, red );
720  greenBand.setValue( col, row, green );
721  blueBand.setValue( col, row, blue );
722  }
723  }
724 
725  return true;
726  }
727 
728  }
729 } // end namespace te
730 
const InputParameters & operator=(const InputParameters &params)
Definition: IHSFusion.cpp:78
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
Raster Processing functions.
bool swapIntensity(te::rp::Matrix< float > &intensityData)
Swap the intensity data by the high resolution image data.
Definition: IHSFusion.cpp:537
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: IHSFusion.cpp:118
static Raster * make()
It creates and returns an empty raster with default raster driver.
unsigned int getLinesNumber() const
The number of current matrix lines.
Definition: Matrix.h:665
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
unsigned int m_lowResRasterRedBandIndex
The low-resolution raster red band index (default:0).
Definition: IHSFusion.h:68
void getValue(const double &c, const double &r, std::complex< double > &v, const std::size_t &b)
Get the interpolated value at specific band.
Definition: Interpolator.h:84
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
Definition: Interpolator.h:51
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: IHSFusion.h:78
#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
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition: IHSFusion.h:114
Abstract parameters base interface.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
A raster band description.
Definition: Band.h:63
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: IHSFusion.cpp:97
bool getRGBRange(double &rgbMin, double &rgbMax) const
Get the minimum and maximum values from the RGB input image.
Definition: IHSFusion.cpp:303
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
bool saveIHSData(const double &rgbMin, const double rgbMax, const te::rp::Matrix< float > &intensityData, const te::rp::Matrix< float > &hueData, const te::rp::Matrix< float > &saturationData, const std::string &rType, const std::map< std::string, std::string > &rInfo, std::auto_ptr< te::rst::Raster > &outputRasterPtr) const
Save resampled IHS data as RGB data to the output image.
Definition: IHSFusion.cpp:605
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
Definition: Grid.cpp:276
double m_RGBMax
The used RGB maximum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:84
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Definition: IHSFusion.cpp:150
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: IHSFusion.h:110
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: IHSFusion.h:66
Creation of skeleton imagems.
IHSFusion input parameters.
Definition: IHSFusion.h:62
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: IHSFusion.cpp:136
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: IHSFusion.h:112
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
const Algorithm & operator=(const Algorithm &)
Definition: Algorithm.cpp:43
bool loadIHSData(const double &rgbMin, const double rgbMax, te::rp::Matrix< float > &intensityData, te::rp::Matrix< float > &hueData, te::rp::Matrix< float > &saturationData) const
Load resampled IHS data from the input image.
Definition: IHSFusion.cpp:361
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Definition: IHSFusion.cpp:241
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: IHSFusion.cpp:64
InputParameters m_inputParameters
Input execution parameters.
Definition: IHSFusion.h:150
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
Definition: IHSFusion.cpp:235
A raster band description.
Definition: BandProperty.h:61
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits&lt;double&gt;::max().
Definition: BandProperty.h:136
#define MIN(a, b)
Macro that returns min between two values.
A generic template matrix.
Definition: Matrix.h:50
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:149
unsigned int m_lowResRasterGreenBandIndex
The low-resolution raster green band index (default:1).
Definition: IHSFusion.h:70
unsigned int getColumnsNumber() const
The number of current matrix columns.
Definition: Matrix.h:672
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
Definition: IHSFusion.cpp:298
Raster Processing algorithm output parameters base interface.
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: IHSFusion.h:76
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: IHSFusion.h:80
void reset()
Reset (clear) the active instance data.
Definition: Matrix.h:474
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
int getSRID() const
Returns the grid spatial reference system identifier.
Definition: Grid.cpp:266
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition: IHSFusion.h:74
IHSFusion output parameters.
Definition: IHSFusion.h:106
bool getStatistics(const te::rp::Matrix< float > &matrix, float &mean, float &variance) const
Get statistics from the given matrix.
Definition: IHSFusion.cpp:494
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
#define M_PI
Definition: IHSFusion.cpp:40
const OutputParameters & operator=(const OutputParameters &params)
Definition: IHSFusion.cpp:125
Near neighborhood interpolation method.
Definition: Interpolator.h:60
#define MAX(a, b)
Macro that returns max between two values.
bool m_isInitialized
Tells if this instance is initialized.
Definition: IHSFusion.h:152
double m_RGBMin
The used RGB minimum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:82
unsigned int m_lowResRasterBlueBandIndex
The low-resolution raster blue band index (default:2).
Definition: IHSFusion.h:72
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
Raster Processing algorithm input parameters base interface.