All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
WisperFusion.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/WisperFusion.cpp
22  \brief Creation of skeleton imagems.
23 */
24 
25 #include "WisperFusion.h"
27 #include "Macros.h"
28 #include "Functions.h"
29 #include "Matrix.h"
30 #include "../raster/BandProperty.h"
31 #include "../raster/RasterFactory.h"
32 #include "../raster/Band.h"
33 #include "../raster/Grid.h"
34 #include "../raster/Utils.h"
35 #include "../geometry/Envelope.h"
36 #include "../common/progress/TaskProgress.h"
37 #include "../memory/ExpansibleRaster.h"
38 
39 #include <cmath>
40 #include <limits>
41 
42 namespace te
43 {
44  namespace rp
45  {
46 
48  {
49  reset();
50  }
51 
53  {
54  reset();
55  operator=( other );
56  }
57 
59  {
60  reset();
61  }
62 
63  void WisperFusion::InputParameters::reset() throw( te::rp::Exception )
64  {
65  m_lowResRasterPtr = 0;
66  m_lowResRasterBands.clear();
67  m_lowResRasterBandSensors.clear();
68  m_lowResRasterBandsSRFs.clear();
69  m_highResRasterPtr = 0;
70  m_highResRasterBand = 0;
71  m_hiResRasterBandSensor = te::rp::srf::InvalidSensor;
72  m_hiResRasterBandsSRFs.clear();
73  m_hiResRasterWaveletLevels = 0;
74  m_enableProgress = false;
75  m_interpMethod = te::rst::NearestNeighbor;
76  m_waveletFilterType = te::rp::TriangleWAFilter;
77  m_userWaveletFilterPtr = 0;
78  m_enableMultiThread = true;
79  }
80 
82  const WisperFusion::InputParameters& params )
83  {
84  reset();
85 
86  m_lowResRasterPtr = params.m_lowResRasterPtr;
87  m_lowResRasterBands = params.m_lowResRasterBands;
88  m_lowResRasterBandSensors = params.m_lowResRasterBandSensors;
89  m_lowResRasterBandsSRFs = params.m_lowResRasterBandsSRFs;
90  m_highResRasterPtr = params.m_highResRasterPtr;
91  m_highResRasterBand = params.m_highResRasterBand;
92  m_hiResRasterBandSensor = params.m_hiResRasterBandSensor;
93  m_hiResRasterBandsSRFs = params.m_hiResRasterBandsSRFs;
94  m_hiResRasterWaveletLevels = params.m_hiResRasterWaveletLevels;
95  m_enableProgress = params.m_enableProgress;
96  m_interpMethod = params.m_interpMethod;
97  m_waveletFilterType = params.m_waveletFilterType;
98  m_userWaveletFilterPtr = params.m_userWaveletFilterPtr;
99  m_enableMultiThread = params.m_enableMultiThread;
100 
101  return *this;
102  }
103 
105  {
106  return new InputParameters( *this );
107  }
108 
110  {
111  reset();
112  }
113 
115  {
116  reset();
117  operator=( other );
118  }
119 
121  {
122  reset();
123  }
124 
125  void WisperFusion::OutputParameters::reset() throw( te::rp::Exception )
126  {
127  m_rType.clear();
128  m_rInfo.clear();
129  m_outputRasterPtr.reset();
130  }
131 
133  const WisperFusion::OutputParameters& params )
134  {
135  reset();
136 
137  m_rType = params.m_rType;
138  m_rInfo = params.m_rInfo;
139 
140  return *this;
141  }
142 
144  {
145  return new OutputParameters( *this );
146  }
147 
149  {
150  reset();
151  }
152 
154  {
155  }
156 
158  throw( te::rp::Exception )
159  {
160  if( ! m_isInitialized ) return false;
161 
162  WisperFusion::OutputParameters* outParamsPtr = dynamic_cast<
163  WisperFusion::OutputParameters* >( &outputParams );
164  TERP_TRUE_OR_THROW( outParamsPtr, "Invalid paramters" );
165 
166  // progress
167 
168  std::auto_ptr< te::common::TaskProgress > progressPtr;
170  {
171  progressPtr.reset( new te::common::TaskProgress );
172 
173  progressPtr->setTotalSteps( 3 );
174 
175  progressPtr->setMessage( "Fusing images" );
176  }
177 
178  // defining the wavelet filter
179 
180  boost::numeric::ublas::matrix< double > waveletFilter;
181 
183  {
184  waveletFilter = *( m_inputParameters.m_userWaveletFilterPtr );
185  }
186  else
187  {
188  waveletFilter = te::rp::CreateWaveletAtrousFilter(
190  }
191 
192  // loading the SRFs
193 
194  std::vector< std::map< double, double > > lowResSRFs;
195  std::map< double, double > highResSRFs;
196 
197  {
199  {
200  std::map< double, double > auxMap;
201 
202  for( unsigned int sensorIdx = 0 ; sensorIdx <
203  m_inputParameters.m_lowResRasterBandSensors.size() ; ++sensorIdx )
204  {
205  auxMap.clear();
207  auxMap );
208  lowResSRFs.push_back( auxMap );
209  }
210  }
211  else
212  {
214  }
215 
217  {
219  highResSRFs );
220  }
221  else
222  {
224  }
225  }
226 
227  // Computing the the intersetion of the area covered by each low resolution band pair
228  // and with the high resolution band
229 
230  te::rp::Matrix< double > lRBandXlRBandSRFIntersectionAreas; // the LRxLR bands intersection areas.
231  std::vector< unsigned int > lRInterceptedBandIndex; // the index of the band intercepted by another.
232  std::vector< double > lowResBandsSRFAreas;
233  std::vector< double > lRBandXHRBandIntersectionAreas;
234  double lRBandsXHRBandTotalExclusiveIntersectionSRFArea = 0.0; // The LRxLR bands overlap is taken into account.
235  const double hiResBandSRFArea = te::rp::srf::getSRFArea( highResSRFs );
236 
237  {
238  unsigned int lowResBandIdx1 = 0;
239  unsigned int lowResBandIdx2 = 0;
240  const unsigned int nLowResBands = m_inputParameters.m_lowResRasterBands.size();
241 
242  // low resolution
243 
244  std::map< double, double > lRBandsXHRBandTotalExclusiveIntersectionSRF;
245 
246  lRBandXlRBandSRFIntersectionAreas.reset( nLowResBands, nLowResBands );
247  lowResBandsSRFAreas.resize( nLowResBands, 0.0 );
248  lRBandXHRBandIntersectionAreas.resize( nLowResBands, 0.0 );
249  for( lowResBandIdx1 = 0 ; lowResBandIdx1 < nLowResBands ; ++lowResBandIdx1 )
250  {
251  for( lowResBandIdx2 = lowResBandIdx1 ; lowResBandIdx2 < nLowResBands ;
252  ++lowResBandIdx2 )
253  {
254  if( lowResBandIdx1 != lowResBandIdx2 )
255  {
256  std::map< double, double > lRXLRIntersectionSRF;
257  te::rp::srf::getIntersectionSRF( lowResSRFs[ lowResBandIdx1 ],
258  lowResSRFs[ lowResBandIdx2 ], lRXLRIntersectionSRF );
259 
260  lRBandXlRBandSRFIntersectionAreas[ lowResBandIdx1 ][ lowResBandIdx2 ] =
261  te::rp::srf::getSRFArea( lRXLRIntersectionSRF );
262  lRBandXlRBandSRFIntersectionAreas[ lowResBandIdx2 ][ lowResBandIdx1 ] =
263  lRBandXlRBandSRFIntersectionAreas[ lowResBandIdx1 ][ lowResBandIdx2 ];
264  }
265  else
266  {
267  lRBandXlRBandSRFIntersectionAreas[ lowResBandIdx1 ][ lowResBandIdx2 ] = 0.0;
268  }
269  }
270 
271  lowResBandsSRFAreas[ lowResBandIdx1 ] = te::rp::srf::getSRFArea( lowResSRFs[ lowResBandIdx1 ] );
272  TERP_TRUE_OR_RETURN_FALSE( lowResBandsSRFAreas[ lowResBandIdx1 ] > 0.0,
273  "One low resolution band SRF is invalid" );
274 
275  std::map< double, double > lRXHRIntersectionSRF;
276  te::rp::srf::getIntersectionSRF( lowResSRFs[ lowResBandIdx1 ], highResSRFs, lRXHRIntersectionSRF );
277 
278  lRBandXHRBandIntersectionAreas[ lowResBandIdx1 ] = te::rp::srf::getSRFArea( lRXHRIntersectionSRF );
279  TERP_TRUE_OR_RETURN_FALSE( lRBandXHRBandIntersectionAreas[ lowResBandIdx1 ] > 0.0,
280  "One low resolution band SRF does not intersects the high resolution band SRF" );
281 
282  std::map< double, double > auxUnionSRF;
283  te::rp::srf::getUnionSRF( lRXHRIntersectionSRF, lRBandsXHRBandTotalExclusiveIntersectionSRF, auxUnionSRF );
284  lRBandsXHRBandTotalExclusiveIntersectionSRF = auxUnionSRF;
285  }
286 
287  lRBandsXHRBandTotalExclusiveIntersectionSRFArea = te::rp::srf::getSRFArea(
288  lRBandsXHRBandTotalExclusiveIntersectionSRF );
289 
290  std::multimap< double, unsigned int > centralFrequency2BandIdxMap;
291  for( lowResBandIdx1 = 0 ; lowResBandIdx1 < nLowResBands ; ++lowResBandIdx1 )
292  {
293  std::map< double, double >::const_iterator lowResSRFsIt =
294  lowResSRFs[ lowResBandIdx1 ].begin();
295  std::map< double, double >::const_iterator lowResSRFsItEnd =
296  lowResSRFs[ lowResBandIdx1 ].end();
297  double highestResponse = -1.0 * std::numeric_limits< double >::max();
298  double highestResponseFrequency = 0;
299 
300  while( lowResSRFsIt != lowResSRFsItEnd )
301  {
302  if( highestResponse < lowResSRFsIt->second )
303  {
304  highestResponse = lowResSRFsIt->second;
305  highestResponseFrequency = lowResSRFsIt->first;
306  }
307 
308  ++lowResSRFsIt;
309  }
310 
311  centralFrequency2BandIdxMap.insert( std::pair< double, unsigned int>(
312  highestResponseFrequency, lowResBandIdx1 ) );
313  }
314 
315  lRInterceptedBandIndex.resize( nLowResBands, nLowResBands + 1 );
316  std::multimap< double, unsigned int >::iterator centralFrequency2BandIdxMapIt =
317  centralFrequency2BandIdxMap.begin();
318  std::multimap< double, unsigned int >::iterator centralFrequency2BandIdxMapItPrev;
319  std::multimap< double, unsigned int >::iterator centralFrequency2BandIdxMapItEnd =
320  centralFrequency2BandIdxMap.end();
321  while( centralFrequency2BandIdxMapIt != centralFrequency2BandIdxMapItEnd )
322  {
323  if( centralFrequency2BandIdxMapIt == centralFrequency2BandIdxMap.begin() )
324  {
325  lRInterceptedBandIndex[ centralFrequency2BandIdxMapIt->second ] =
326  centralFrequency2BandIdxMapIt->second;
327  centralFrequency2BandIdxMapItPrev = centralFrequency2BandIdxMapIt;
328  }
329  else
330  {
331  lRInterceptedBandIndex[ centralFrequency2BandIdxMapIt->second ] =
332  centralFrequency2BandIdxMapItPrev->second;
333 
334  ++centralFrequency2BandIdxMapItPrev;
335  }
336 
337  ++centralFrequency2BandIdxMapIt;
338  }
339  }
340 
341  // The wavelet decomposition levels
342 
343  const unsigned int highResWaveletLevels = (unsigned int)
346  :
347  (
348  0.5
349  +
350  std::max(
351  (
352  std::log(
353  (double)
354  (
356  )
357  /
358  (double)
359  (
361  )
362  )
363  /
364  std::log( 2.0 )
365  )
366  ,
367  (
368  std::log(
369  (double)
370  (
372  )
373  /
374  (double)
375  (
377  )
378  )
379  /
380  std::log( 2.0 )
381  )
382  )
383  );
384  TERP_TRUE_OR_RETURN_FALSE( highResWaveletLevels > 0,
385  "Minimal number of wavelet decompositions not reached" );
386 
387  // creating the ressampled input raster
388 
389  std::auto_ptr< te::rst::Raster > resampledLlowResRasterPtr;
390 
391  {
392  std::map< std::string, std::string > rinfo;
393  rinfo["MAXMEMPERCENTUSED"] = "30";
394 
399  0,
400  0,
405  rinfo,
406  "EXPANSIBLE",
407  resampledLlowResRasterPtr ),
408  "Low resolution raster resample error" );
409  }
410 
411 // TERP_TRUE_OR_THROW( te::rp::Copy2DiskRaster( *resampledLlowResRasterPtr,
412 // "resampledLlowResRaster.tif" ), "" );
413 
415  {
416  progressPtr->pulse();
417  if( ! progressPtr->isActive() ) return false;
418  }
419 
420 
421  // creating the high resolution raster wavelets
422 
423  std::auto_ptr< te::rst::Raster > highResWaveletsRasterPtr;
424 
425  {
426  std::map<std::string, std::string> auxRasterInfo;
427 
428  std::vector< te::rst::BandProperty * > bandProps;
429 
430  for( unsigned int levelIdx = 0 ; levelIdx < highResWaveletLevels ;
431  ++levelIdx )
432  {
433  bandProps.push_back( new te::rst::BandProperty(
436  bandProps.back()->m_blkh = 1;
437  bandProps.back()->m_blkw = m_inputParameters.m_highResRasterPtr->getNumberOfColumns();
438  bandProps.back()->m_nblocksx = 1;
439  bandProps.back()->m_nblocksy = m_inputParameters.m_highResRasterPtr->getNumberOfRows();
440  bandProps.back()->m_type = te::dt::DOUBLE_TYPE;
441 
442  bandProps.push_back( new te::rst::BandProperty(
445  bandProps.back()->m_blkh = 1;
446  bandProps.back()->m_blkw = m_inputParameters.m_highResRasterPtr->getNumberOfColumns();
447  bandProps.back()->m_nblocksx = 1;
448  bandProps.back()->m_nblocksy = m_inputParameters.m_highResRasterPtr->getNumberOfRows();
449  bandProps.back()->m_type = te::dt::DOUBLE_TYPE;
450  }
451 
452  std::vector< unsigned int > rasterBands;
453  rasterBands.push_back( m_inputParameters.m_highResRasterBand );
454 
455  highResWaveletsRasterPtr.reset( new te::mem::ExpansibleRaster(
456  60,
458  bandProps ) );
459  TERP_TRUE_OR_RETURN_FALSE( highResWaveletsRasterPtr.get(), "Raster allocation error" );
460 
463  rasterBands,
464  *highResWaveletsRasterPtr,
465  highResWaveletLevels,
466  waveletFilter ),
467  "Low resolution raster wavelets creation error" );
468  }
469 
470 /* TERP_TRUE_OR_THROW( te::rp::Copy2DiskRaster( *highResWaveletsRasterPtr,
471  "highResWaveletsRaster.tif" ), "" ); */
472 
474  {
475  progressPtr->pulse();
476  if( ! progressPtr->isActive() ) return false;
477  }
478 
479  // Creating the output raster
480 
481  {
483 
484  std::vector< te::rst::BandProperty * > bandProperties;
485  std::vector< unsigned int > outputRasterBands;
486 
487  for( unsigned int bandIdx = 0 ; bandIdx <
488  resampledLlowResRasterPtr->getNumberOfBands() ; ++bandIdx )
489  {
490  bandProperties.push_back( new te::rst::BandProperty(
491  *resampledLlowResRasterPtr->getBand( bandIdx )->getProperty() ) );
492 
493  outputRasterBands.push_back( bandIdx );
494  }
495 
496  outParamsPtr->m_outputRasterPtr.reset(
498  outParamsPtr->m_rType,
499  gridPtr,
500  bandProperties,
501  outParamsPtr->m_rInfo,
502  0,
503  0 ) );
504  TERP_TRUE_OR_RETURN_FALSE( outParamsPtr->m_outputRasterPtr.get(),
505  "Output raster creation error" );
506  }
507 
508  // Recomposing levels for each band
509 
510  {
511  const unsigned int nRows = outParamsPtr->m_outputRasterPtr->getNumberOfRows();
512  const unsigned int nCols = outParamsPtr->m_outputRasterPtr->getNumberOfColumns();
513  const unsigned int nBands = outParamsPtr->m_outputRasterPtr->getNumberOfBands();
514  te::rst::Raster& resampledLlowResRaster = *resampledLlowResRasterPtr;
515  te::rst::Raster& outputRaster = *(outParamsPtr->m_outputRasterPtr);
516  te::rst::Raster& highResWaveletsRaster = *highResWaveletsRasterPtr;
517  const unsigned int highResWaveletsRasterBands = highResWaveletsRaster.getNumberOfBands();
518  unsigned int row = 0;
519  unsigned int col = 0;
520  unsigned int bandIdx = 0;
521  std::vector< double > resLRRasterValues( nBands );
522  unsigned int waveletBandIdx = 0;
523  double outputRasterValue = 0;
524  double resampledLlowResRasterValue = 0;
525  double wisperTerm = 0;
526  double highResWaveletsValue = 0.0;
527  std::vector< double > ropi( nBands );
528  double ropiMean = 0;
529 
530  std::vector< double > outBandsMinValue( nBands );
531  std::vector< double > outBandsMaxValue( nBands );
532  std::vector< double > resampledLlowResBandsGains( nBands );
533  for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
534  {
536  outParamsPtr->m_outputRasterPtr->getBandDataType( bandIdx ),
537  outBandsMinValue[ bandIdx ], outBandsMaxValue[ bandIdx ] );
538  }
539 
540  for( row = 0 ; row < nRows ; ++row )
541  {
542  for( col = 0 ; col < nCols ; ++col )
543  {
544  ropiMean = 0.0;
545  for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
546  {
547  resampledLlowResRaster.getValue( col, row, resampledLlowResRasterValue, bandIdx );
548 
549  resLRRasterValues[ bandIdx ] = resampledLlowResRasterValue;
550 
551  assert( lRBandXHRBandIntersectionAreas[ bandIdx ] > 0.0 );
552  ropi[ bandIdx ] =
553  (
554  (
555  lRBandXHRBandIntersectionAreas[ bandIdx ]
556  *
557  lRBandXHRBandIntersectionAreas[ bandIdx ]
558  *
559  resLRRasterValues[ bandIdx ]
560  )
561  /
562  lowResBandsSRFAreas[ bandIdx ]
563  );
564 
565  ropiMean += ropi[ bandIdx ];
566  }
567  ropiMean /= ((double)nBands);
568 
569  for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
570  {
571  wisperTerm =
572  (
573  // Si
574  (
575  ropi[ bandIdx ]
576  /
577  ropiMean
578  )
579  *
580  (
581  // alpha
582  (
583  lRBandsXHRBandTotalExclusiveIntersectionSRFArea
584  /
585  hiResBandSRFArea
586  )
587  *
588  // P( mi | pm )
589  (
590  lRBandXHRBandIntersectionAreas[ bandIdx ]
591  /
592  lRBandsXHRBandTotalExclusiveIntersectionSRFArea
593  )
594  /
595  // P( pm | mi )
596  (
597  lRBandXHRBandIntersectionAreas[ bandIdx ]
598  /
599  lowResBandsSRFAreas[ bandIdx ]
600  )
601  )
602  *
603  (
604  1.0
605  -
606  (
607  (
608  // beta
609  lRBandXlRBandSRFIntersectionAreas[ bandIdx ][ lRInterceptedBandIndex[ bandIdx ] ]
610  /
611  lRBandXHRBandIntersectionAreas[ bandIdx ]
612  )
613  /
614  2.0
615  )
616  )
617  );
618 
619  outputRasterValue = resLRRasterValues[ bandIdx ];
620 
621  for( waveletBandIdx = 1 ; waveletBandIdx < highResWaveletsRasterBands ;
622  waveletBandIdx += 2 )
623  {
624  highResWaveletsRaster.getValue( col, row, highResWaveletsValue,
625  waveletBandIdx );
626  outputRasterValue += ( wisperTerm * highResWaveletsValue );
627  }
628 
629  outputRasterValue = std::max( outBandsMinValue[ bandIdx ],
630  outputRasterValue );
631  outputRasterValue = std::min( outBandsMaxValue[ bandIdx ],
632  outputRasterValue );
633 
634  outputRaster.setValue( col, row, outputRasterValue, bandIdx );
635  }
636  }
637  }
638 
639  }
640 
642  {
643  progressPtr->pulse();
644  if( ! progressPtr->isActive() ) return false;
645  }
646 
647  return true;
648  }
649 
650  void WisperFusion::reset() throw( te::rp::Exception )
651  {
653  m_isInitialized = false;
654  }
655 
657  throw( te::rp::Exception )
658  {
659  reset();
660 
661  WisperFusion::InputParameters const* inputParamsPtr = dynamic_cast<
662  WisperFusion::InputParameters const* >( &inputParams );
663  TERP_TRUE_OR_THROW( inputParamsPtr, "Invalid paramters pointer" );
664 
665  m_inputParameters = *inputParamsPtr;
666 
667  // Checking the low Resolution related parameters
668 
670  "Invalid low Resolution Raster Pointer" )
671 
674  "Invalid raster" );
675 
676  for( unsigned int lowResRasterBandsIdx = 0; lowResRasterBandsIdx <
678  ++lowResRasterBandsIdx )
679  {
681  m_inputParameters.m_lowResRasterBands[ lowResRasterBandsIdx ] <
683  "Invalid low resolution raster band" );
684  }
685 
687  {
690  "Invalid low resolution bands sensors" );
691 
692  for( unsigned int idx = 0 ; idx < m_inputParameters.m_lowResRasterBandSensors.size() ;
693  ++idx )
694  {
696  te::rp::srf::InvalidSensor, "Invalid low resolution sensor" );
697  }
698  }
699  else
700  {
703  "Missing low resolution bands SRFs" );
704 
705  for( unsigned int idx = 0 ; idx < m_inputParameters.m_lowResRasterBandsSRFs.size() ;
706  ++idx )
707  {
709  "Invalid low resolution SRF" );
710  }
711  }
712 
713  // Checking the m_highResRasterPtr and m_highResRasterBand
714 
716  "Invalid high resolution Raster Pointer" )
717 
720  "Invalid raster" );
721 
725  "Invalid raster band" );
726 
728  {
730  te::rp::srf::InvalidSensor, "Invalid high resolution sensor" );
731  }
732 
733  // others
734 
736  {
738  ( m_inputParameters.m_userWaveletFilterPtr->size1() > 2 ) &&
741  "Invalid user filter" );
742  }
743 
744  m_isInitialized = true;
745 
746  return true;
747  }
748 
750  {
751  return m_isInitialized;
752  }
753 
754  }
755 } // end namespace te
756 
bool m_isInitialized
Tells if this instance is initialized.
Definition: WisperFusion.h:163
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell.
Definition: Raster.cpp:233
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition: WisperFusion.h:125
Near neighborhood interpolation method.
Definition: Enums.h:95
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: WisperFusion.h:87
void getSRF(const SensorType &sensor, ContainerT &container)
Returns a Spectral Response Function from the given sensor.
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: WisperFusion.h:69
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
AbstractParameters * clone() const
Create a clone copy of this instance.
A raster band description.
Definition: BandProperty.h:61
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.
Triangle filter type.
Definition: Functions.h:78
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:180
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
Raster Processing algorithm output parameters base interface.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Spectral Response Functions.
unsigned int m_hiResRasterWaveletLevels
The number of wavelet decomposition levels to use (0-automatically found, default:0).
Definition: WisperFusion.h:85
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
WisperFusion output parameters.
Definition: WisperFusion.h:117
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
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
const OutputParameters & operator=(const OutputParameters &params)
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: WisperFusion.h:79
WiSpeR fusion.
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: WisperFusion.h:89
WisperFusion input parameters.
Definition: WisperFusion.h:65
An abstract class for raster data strucutures.
Definition: Raster.h:71
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
void getIntersectionSRF(const std::map< double, double > &sRF1, const std::map< double, double > &sRF2, std::map< double, double > &intersectionSRF)
Return the intersetction SRF.
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:428
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
const InputParameters & operator=(const InputParameters &params)
bool DirectWaveletAtrous(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, te::rst::Raster &waveletRaster, const unsigned int levelsNumber, const boost::numeric::ublas::matrix< double > &filter)
Generate all wavelet planes from the given input raster.
Definition: Functions.cpp:2394
std::vector< std::map< double, double > > m_lowResRasterBandsSRFs
An optional vector of user supplied Spectral Response Functions for each low resolution band (The wav...
Definition: WisperFusion.h:75
std::vector< unsigned int > m_lowResRasterBands
Bands to processe from the low resolution raster.
Definition: WisperFusion.h:71
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
Definition: WisperFusion.h:95
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition: WisperFusion.h:77
void getUnionSRF(const std::map< double, double > &sRF1, const std::map< double, double > &sRF2, std::map< double, double > &unionSRF)
Return the union SRF.
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
Generic template matrix.
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: WisperFusion.h:123
te::rp::srf::SensorType m_hiResRasterBandSensor
The high resolution band sensor.
Definition: WisperFusion.h:81
void reset()
Reset (clear) the active instance data.
Definition: Matrix.h:480
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
Definition: Raster.cpp:228
AbstractParameters * clone() const
Create a clone copy of this instance.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
boost::numeric::ublas::matrix< double > CreateWaveletAtrousFilter(const WaveletAtrousFilterType &filterType)
Create a Wavele Atrous Filter.
Definition: Functions.cpp:2349
Abstract parameters base interface.
InputParameters m_inputParameters
Input execution parameters.
Definition: WisperFusion.h:161
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
static Raster * make()
It creates and returns an empty raster with default raster driver.
boost::numeric::ublas::matrix< double > const * m_userWaveletFilterPtr
An optional pointer to an user filter.
Definition: WisperFusion.h:93
std::map< double, double > m_hiResRasterBandsSRFs
An optional vector of user supplied Spectral Response Functions for the high resolution band (The wav...
Definition: WisperFusion.h:83
Raster Processing algorithm input parameters base interface.
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: WisperFusion.h:121
bool RasterResample(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const te::rst::Interpolator::Method interpMethod, const unsigned int firstRow, const unsigned int firstColumn, const unsigned int height, const unsigned int width, const unsigned int newheight, const unsigned int newwidth, const std::map< std::string, std::string > &rinfo, const std::string &dataSourceType, std::auto_ptr< te::rst::Raster > &resampledRasterPtr)
Resample a subset of the raster, given a box.
Definition: Functions.cpp:2614
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
double getSRFArea(const std::map< double, double > &sRFs)
Return the SRF area.
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:149
std::vector< te::rp::srf::SensorType > m_lowResRasterBandSensors
The low resolution bands sensors.
Definition: WisperFusion.h:73
te::rp::WaveletAtrousFilterType m_waveletFilterType
The wavelet filter type to use (default: TriangleWAFilter);.
Definition: WisperFusion.h:91