All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IHSFusion.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 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;
73  m_interpMethod = te::rst::NearestNeighbor;
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  const double gain = ( ( rasterVariance == 0.0 ) ? 0.0 :
587  std::sqrt( (double)intensityVariance ) / std::sqrt( rasterVariance ) );
588  float* intensityRow = 0;
589 
590  for( row = 0 ; row < nRows ; ++row )
591  {
592  intensityRow = intensityData[ row ];
593 
594  for( col = 0 ; col < nCols ; ++col )
595  {
596  band.getValue( col, row, value );
597  intensityRow[ col ] = (float)std::min( 1.0, std::max( 0.0, ( ( value - rasterMean ) * gain ) + ((double)intensityMean) ) );
598  }
599  }
600 
601  return true;
602  }
603 
604  bool IHSFusion::saveIHSData( const double& rgbMin, const double rgbMax, const te::rp::Matrix< float >& intensityData,
605  const te::rp::Matrix< float >& hueData, const te::rp::Matrix< float >& saturationData,
606  const std::string& rType, const std::map< std::string, std::string >& rInfo,
607  std::auto_ptr< te::rst::Raster >& outputRasterPtr ) const
608  {
610  assert( intensityData.getLinesNumber() == m_inputParameters.m_highResRasterPtr->getNumberOfRows() );
611  assert( intensityData.getColumnsNumber() == hueData.getColumnsNumber() );
612  assert( intensityData.getColumnsNumber() == saturationData.getColumnsNumber() );
613  assert( intensityData.getLinesNumber() == hueData.getLinesNumber() );
614  assert( intensityData.getLinesNumber() == saturationData.getLinesNumber() );
615 
616  const unsigned int nRows = intensityData.getLinesNumber();
617  const unsigned int nCols = intensityData.getColumnsNumber();
618 
619  std::vector< te::rst::BandProperty* > outRasterBandsProperties;
620  outRasterBandsProperties.push_back( new te::rst::BandProperty(
623  outRasterBandsProperties[ 0 ]->m_blkw = nCols;
624  outRasterBandsProperties[ 0 ]->m_blkh = 1;
625  outRasterBandsProperties[ 0 ]->m_nblocksx = 1;
626  outRasterBandsProperties[ 0 ]->m_nblocksy = nRows;
627  outRasterBandsProperties.push_back( new te::rst::BandProperty(
630  outRasterBandsProperties[ 1 ]->m_blkw = nCols;
631  outRasterBandsProperties[ 1 ]->m_blkh = 1;
632  outRasterBandsProperties[ 1 ]->m_nblocksx = 1;
633  outRasterBandsProperties[ 1 ]->m_nblocksy = nRows;
634  outRasterBandsProperties.push_back( new te::rst::BandProperty(
637  outRasterBandsProperties[ 2 ]->m_blkw = nCols;
638  outRasterBandsProperties[ 2 ]->m_blkh = 1;
639  outRasterBandsProperties[ 2 ]->m_nblocksx = 1;
640  outRasterBandsProperties[ 2 ]->m_nblocksy = nRows;
641 
643 
644  outputRasterPtr.reset(
646  rType,
647  gridPtr,
648  outRasterBandsProperties,
649  rInfo,
650  0,
651  0 ) );
652  TERP_TRUE_OR_RETURN_FALSE( outputRasterPtr.get(),
653  "Output raster creation error" );
654 
655  const double rgbNormFac = ( rgbMax == rgbMin ) ? 0.0 :
656  ( rgbMax - rgbMin );
657  const double pi3 = M_PI / 3.0; // 60
658  const double twoPi3 = 2.0 * M_PI / 3.0; // 120
659  const double fourPi3 = 4.0 * M_PI / 3.0; // 240
660  unsigned int row = 0;
661  unsigned int col = 0;
662  double hue = 0;
663  double lig = 0;
664  double sat = 0;
665  double red = 0;
666  double green = 0;
667  double blue = 0;
668  te::rst::Band& redBand = *outputRasterPtr->getBand( 0 );
669  te::rst::Band& greenBand = *outputRasterPtr->getBand( 1 );
670  te::rst::Band& blueBand = *outputRasterPtr->getBand( 2 );
671 
672  for( row = 0 ; row < nRows ; ++row )
673  {
674  for( col = 0 ; col < nCols ; ++col )
675  {
676  hue = hueData[ row ][ col ];
677  lig = intensityData[ row ][ col ];
678  sat = saturationData[ row ][ col ];
679 
680  if( ( hue == 0.0 ) && ( sat == 0.0 ) )
681  { // Gray scale case
682  red = green = blue = ( lig * rgbNormFac );
683  }
684  else
685  { // color case
686  /* Hue inside RG sector */
687  if( hue < twoPi3 )
688  {
689  blue = lig * ( 1.0 - sat );
690  red = lig * ( 1.0 + ( sat * std::cos( hue ) /
691  std::cos( pi3 - hue ) ) );
692  green = ( 3.0 * lig ) - ( red + blue );
693  }
694  else if( hue < fourPi3 )
695  { /* Hue inside GB sector */
696 
697  hue -= twoPi3;
698 
699  red = lig * ( 1.0 - sat );
700  green = lig * ( 1.0 + ( sat * std::cos( hue ) /
701  std::cos( pi3 - hue ) ) );
702  blue = ( 3.0 * lig ) - ( red + green );
703  }
704  else
705  { /* Hue inside BR sector */
706 
707  hue -= fourPi3;
708 
709  green = lig * ( 1.0 - sat );
710  blue = lig * ( 1.0 + ( sat * std::cos( hue ) /
711  std::cos( pi3 - hue ) ) );
712  red = ( 3.0 * lig ) - ( green + blue );
713  }
714 
715  red = ( red * rgbNormFac ) + rgbMin;
716  green = ( green * rgbNormFac ) + rgbMin;
717  blue = ( blue * rgbNormFac ) + rgbMin;
718  }
719 
720  red = MIN( red, rgbMax );
721  green = MIN( green, rgbMax );
722  blue = MIN( blue, rgbMax );
723 
724  red = MAX( red, rgbMin );
725  green = MAX( green, rgbMin );
726  blue = MAX( blue, rgbMin );
727 
728  redBand.setValue( col, row, red );
729  greenBand.setValue( col, row, green );
730  blueBand.setValue( col, row, blue );
731  }
732  }
733 
734  return true;
735  }
736 
737  }
738 } // end namespace te
739 
Near neighborhood interpolation method.
Definition: Enums.h:95
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:114
Creation of skeleton imagems.
double m_RGBMin
The used RGB minimum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:84
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: IHSFusion.h:112
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition: IHSFusion.h:116
A raster band description.
Definition: BandProperty.h:61
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: IHSFusion.cpp:136
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
IHSFusion output parameters.
Definition: IHSFusion.h:108
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
Definition: Interpolator.h:55
IHSFusion input parameters.
Definition: IHSFusion.h:64
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
Raster Processing algorithm output parameters base interface.
#define MIN(a, b)
Macro that returns min between two values.
unsigned int m_lowResRasterRedBandIndex
The low-resolution raster red band index (default:0).
Definition: IHSFusion.h:70
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:92
bool getRGBRange(double &rgbMin, double &rgbMax) const
Get the minimum and maximum values from the RGB input image.
Definition: IHSFusion.cpp:303
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
Definition: BandProperty.h:136
#define MAX(a, b)
Macro that returns max between two values.
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
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: IHSFusion.h:78
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: IHSFusion.cpp:64
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Definition: IHSFusion.cpp:150
double m_RGBMax
The used RGB maximum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:86
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
unsigned int getColumnsNumber() const
The number of current matrix columns.
Definition: Matrix.h:678
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:428
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:604
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
InputParameters m_inputParameters
Input execution parameters.
Definition: IHSFusion.h:152
#define M_PI
Definition: IHSFusion.cpp:40
unsigned int m_lowResRasterBlueBandIndex
The low-resolution raster blue band index (default:2).
Definition: IHSFusion.h:74
A raster band description.
Definition: Band.h:63
const InputParameters & operator=(const InputParameters &params)
Definition: IHSFusion.cpp:78
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: IHSFusion.h:80
void reset()
Reset (clear) the active instance data.
Definition: Matrix.h:480
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
const OutputParameters & operator=(const OutputParameters &params)
Definition: IHSFusion.cpp:125
Abstract parameters base interface.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: IHSFusion.cpp:118
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 swapIntensity(te::rp::Matrix< float > &intensityData)
Swap the intensity data by the high resolution image data.
Definition: IHSFusion.cpp:537
A generic template matrix.
Definition: Matrix.h:51
static Raster * make()
It creates and returns an empty raster with default raster driver.
Raster Processing algorithm input parameters base interface.
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
Definition: IHSFusion.cpp:298
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: IHSFusion.cpp:97
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
Definition: IHSFusion.cpp:235
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition: IHSFusion.h:76
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: IHSFusion.h:68
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
bool getStatistics(const te::rp::Matrix< float > &matrix, float &mean, float &variance) const
Get statistics from the given matrix.
Definition: IHSFusion.cpp:494
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Definition: IHSFusion.cpp:241
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: IHSFusion.h:82
unsigned int m_lowResRasterGreenBandIndex
The low-resolution raster green band index (default:1).
Definition: IHSFusion.h:72
unsigned int getLinesNumber() const
The number of current matrix lines.
Definition: Matrix.h:671
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:149
bool m_isInitialized
Tells if this instance is initialized.
Definition: IHSFusion.h:154