Orfeo Toolbox  4.0
otbLandsatTMIndices.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbLandsatTMIndices_h
19 #define __otbLandsatTMIndices_h
20 
21 #include "otbMath.h"
23 #include "itkFixedArray.h"
24 #include "otbBandName.h"
25 #include "otbFuzzyVariable.h"
26 #include <vector>
27 #include <algorithm>
28 
29 namespace otb
30 {
31 
32 namespace Functor
33 {
34 
35 namespace LandsatTM
36 {
37 
39 enum SATType {L5, L7};
61 template<class TInput, class TOutput>
63 {
64 public:
65 
66  //operators !=
67  bool operator !=(const LandsatTMIndexBase&) const
68  {
69  return false;
70  }
71  //operator ==
72  bool operator ==(const LandsatTMIndexBase& other) const
73  {
74  return !(*this != other);
75  }
76 
80  virtual ~LandsatTMIndexBase() {}
81 
83  void SetIndex(BandName::LandsatTMBandNames band, unsigned int channel)
84  {
85  switch( band )
86  {
87  case BandName::TM1:
88  m_TM1 = channel;
89  break;
90  case BandName::TM2:
91  m_TM2 = channel;
92  break;
93  case BandName::TM3:
94  m_TM3 = channel;
95  break;
96  case BandName::TM4:
97  m_TM4 = channel;
98  break;
99  case BandName::TM5:
100  m_TM5 = channel;
101  break;
102  case BandName::TM60:
103  m_TM60 = channel;
104  break;
105  case BandName::TM61:
106  m_TM61 = channel;
107  break;
108  case BandName::TM62:
109  m_TM62 = channel;
110  break;
111  case BandName::TM7:
112  m_TM7 = channel;
113  break;
114  }
115  }
117  unsigned int GetIndex(BandName::LandsatTMBandNames band) const
118  {
119  switch( band )
120  {
121  case BandName::TM1:
122  return m_TM1;
123  break;
124  case BandName::TM2:
125  return m_TM2;
126  break;
127  case BandName::TM3:
128  return m_TM3;
129  break;
130  case BandName::TM4:
131  return m_TM4;
132  break;
133  case BandName::TM5:
134  return m_TM5;
135  break;
136  case BandName::TM60:
137  return m_TM60;
138  break;
139  case BandName::TM61:
140  return m_TM61;
141  break;
142  case BandName::TM62:
143  return m_TM62;
144  break;
145  case BandName::TM7:
146  return m_TM7;
147  break;
148  }
149  return m_TM1;
150  }
151 
152  unsigned int GetTM1() const
153  {
154  return this->m_TM1;
155  }
156 
157  unsigned int GetTM2() const
158  {
159  return this->m_TM2;
160  }
161 
162  unsigned int GetTM3() const
163  {
164  return this->m_TM3;
165  }
166 
167  unsigned int GetTM4() const
168  {
169  return this->m_TM4;
170  }
171 
172  unsigned int GetTM5() const
173  {
174  return this->m_TM5;
175  }
176 
177  unsigned int GetTM60() const
178  {
179  return this->m_TM60;
180  }
181 
182  unsigned int GetTM61() const
183  {
184  return this->m_TM61;
185  }
186 
187  unsigned int GetTM62() const
188  {
189  return this->m_TM62;
190  }
191 
192  unsigned int GetTM7() const
193  {
194  return this->m_TM7;
195  }
196 
197  void SetSAT(SATType sat)
198  {
199 
200  this->m_SAT = sat;
201 
202  if( sat == L5 )
203  {
204  m_TM1 = 0;
205  m_TM2 = 1;
206  m_TM3 = 2;
207  m_TM4 = 3;
208  m_TM5 = 4;
209  m_TM60 = 5;
210  m_TM7 = 6;
211  m_SAT = L5;
212  }
213  else
214  {
215  m_TM1 = 0;
216  m_TM2 = 1;
217  m_TM3 = 2;
218  m_TM4 = 3;
219  m_TM5 = 4;
220  m_TM61 = 5;
221  m_TM62 = 6;
222  m_TM7 = 7;
223  m_SAT = L7;
224  }
225  }
226 
227  SATType GetSAT() const
228  {
229  return this->m_SAT;
230  }
231 
233  {
234  this->m_Degree = deg;
235  }
236 
238  {
239  return this->m_Degree;
240  }
241 
243  {
244  this->m_Reflectance = ref;
245  }
246 
248  {
249  return this->m_Reflectance;
250  }
251 
253  {
254  return this->m_EpsilonToBeConsideredAsZero;
255  }
256 
257 protected:
259 
260  TInput PrepareValues(const TInput& inputPixel)
261  {
262 
263  TInput newPix( inputPixel );
264  if( this->m_Degree == Kelvin )
265  {
266  if(this->m_SAT == L5)
267  {
268  newPix[this->m_TM60] = newPix[this->m_TM60]-273.15;
269  }
270  else
271  {
272  newPix[this->m_TM61] = newPix[this->m_TM61]-273.15;
273  newPix[this->m_TM62] = newPix[this->m_TM62]-273.15;
274  }
275  }
276  else
277  if( this->m_Degree == HundredsKelvin )
278  {
279  if(this->m_SAT == L5)
280  {
281  newPix[this->m_TM60] = newPix[this->m_TM60]/100.-273.15;
282  }
283  else
284  {
285  newPix[this->m_TM61] = newPix[this->m_TM61]/100.-273.15;
286  newPix[this->m_TM62] = newPix[this->m_TM62]/100.-273.15;
287  }
288  }
289  if( this->m_Reflectance == Thousands )
290  {
291  newPix[this->m_TM1] = newPix[this->m_TM1]/1000.;
292  newPix[this->m_TM2] = newPix[this->m_TM2]/1000.;
293  newPix[this->m_TM3] = newPix[this->m_TM3]/1000.;
294  newPix[this->m_TM4] = newPix[this->m_TM4]/1000.;
295  newPix[this->m_TM5] = newPix[this->m_TM5]/1000.;
296  newPix[this->m_TM7] = newPix[this->m_TM7]/1000.;
297  }
298 
299  return newPix;
300  }
301 
302 
304 
305  unsigned int m_TM1;
306  unsigned int m_TM2;
307  unsigned int m_TM3;
308  unsigned int m_TM4;
309  unsigned int m_TM5;
310  unsigned int m_TM60;
311  unsigned int m_TM61;
312  unsigned int m_TM62;
313  unsigned int m_TM7;
314 
318 
319 };
320 
321 
328 template <class TInput, class TOutput>
329 class LandsatTMIndex : public LandsatTMIndexBase<TInput, TOutput>
330 {
331 public:
332 
333  // Operator performing the work
334  inline TOutput operator ()(const TInput& inputPixel) const;
335 
337  virtual std::string GetName() const = 0;
338 
340  virtual ~LandsatTMIndex() {}
341 
342 
343 };
344 
360 template <class TInput, class TOutput>
361 class Bright : public LandsatTMIndex<TInput, TOutput>
362 {
363 public:
365  virtual std::string GetName() const
366  {
367  return "Bright";
368  }
369 
370  Bright() {}
371  virtual ~Bright() {}
372 
373  inline TOutput operator ()(const TInput& inputPixel)
374  {
375 
376  TInput newPixel(this->PrepareValues( inputPixel ));
377  double result = (newPixel[this->m_TM1]+newPixel[this->m_TM2]+2*newPixel[this->m_TM3]+2*newPixel[this->m_TM4]+newPixel[this->m_TM5]+newPixel[this->m_TM7])/8.0;
378  return static_cast<TOutput>(result);
379  }
380 
381 
382 };
383 
399 template <class TInput, class TOutput>
400 class Vis : public LandsatTMIndex<TInput, TOutput>
401 {
402 public:
404  virtual std::string GetName() const
405  {
406  return "Vis";
407  }
408 
409  Vis() {}
410  virtual ~Vis() {}
411 
412  inline TOutput operator ()(const TInput& inputPixel)
413  {
414  TInput newPixel(this->PrepareValues( inputPixel ));
415  double result = (newPixel[this->m_TM1]+newPixel[this->m_TM2]+newPixel[this->m_TM3])/3.0;
416  return static_cast<TOutput>(result);
417  }
418 
419 
420 };
421 
422 
430 template <class TInput, class TOutput>
431 class NIR : public LandsatTMIndex<TInput, TOutput>
432 {
433 public:
435  virtual std::string GetName() const
436  {
437  return "NIR";
438  }
439 
440  NIR() {}
441  virtual ~NIR() {}
442 
443  inline TOutput operator ()(const TInput& inputPixel)
444  {
445  TInput newPixel(this->PrepareValues( inputPixel ));
446  double result = newPixel[this->m_TM4];
447  return static_cast<TOutput>(result);
448  }
449 
450 
451 };
452 
460 template <class TInput, class TOutput>
461 class MIR1 : public LandsatTMIndex<TInput, TOutput>
462 {
463 public:
465  virtual std::string GetName() const
466  {
467  return "MIR1";
468  }
469 
470  MIR1() {}
471  virtual ~MIR1() {}
472 
473  inline TOutput operator ()(const TInput& inputPixel)
474  {
475  TInput newPixel(this->PrepareValues( inputPixel ));
476  double result = newPixel[this->m_TM5];
477  return static_cast<TOutput>(result);
478  }
479 
480 
481 };
482 
490 template <class TInput, class TOutput>
491 class MIR2 : public LandsatTMIndex<TInput, TOutput>
492 {
493 public:
495  virtual std::string GetName() const
496  {
497  return "MIR2";
498  }
499 
500  MIR2() {}
501  virtual ~MIR2() {}
502 
503  inline TOutput operator ()(const TInput& inputPixel)
504  {
505  TInput newPixel(this->PrepareValues( inputPixel ));
506  double result = newPixel[this->m_TM7];
507  return static_cast<TOutput>(result);
508  }
509 
510 
511 };
512 
520 template <class TInput, class TOutput>
521 class TIR : public LandsatTMIndex<TInput, TOutput>
522 {
523 public:
525  virtual std::string GetName() const
526  {
527  return "TIR";
528  }
529 
530  TIR() {}
531  virtual ~TIR() {}
532 
533  inline TOutput operator ()(const TInput& inputPixel)
534  {
535  TInput newPixel(this->PrepareValues( inputPixel ));
536  double result = newPixel[this->m_TM62];
537 
538  if( this->m_SAT == L5 )
539  result = newPixel[this->m_TM60];
540 
541  return static_cast<TOutput>(result);
542  }
543 
544 
545 };
546 
564 template <class TInput, class TOutput>
565 class MIRTIR : public LandsatTMIndex<TInput, TOutput>
566 {
567 public:
569  virtual std::string GetName() const
570  {
571  return "MIRTIR";
572  }
573 
574  MIRTIR() {}
575  virtual ~MIRTIR() {}
576 
577  inline TOutput operator ()(const TInput& inputPixel)
578  {
579  TInput newPixel(this->PrepareValues( inputPixel ));
580  double tir = newPixel[this->m_TM62];
581  double mir1 = newPixel[this->m_TM5];
582 
583  if( this->m_SAT == L5 )
584  tir = newPixel[this->m_TM60];
585 
586  double result = 255*(1 - mir1)*(tir+100)/100.;
587 
588  return static_cast<TOutput>(result);
589  }
590 
591 
592 };
593 
602 template <class TInput, class TOutput>
603 class NDVI : public LandsatTMIndex<TInput, TOutput>
604 {
605 public:
607  virtual std::string GetName() const
608  {
609  return "NDVI";
610  }
611 
612  NDVI() {}
613  virtual ~NDVI() {}
614 
615  inline TOutput operator ()(const TInput& inputPixel)
616  {
617  TInput newPixel(this->PrepareValues( inputPixel ));
618  double result = (newPixel[this->m_TM4] - newPixel[this->m_TM3])/
619  (newPixel[this->m_TM4] + newPixel[this->m_TM3] + this->m_EpsilonToBeConsideredAsZero);
620 
621  return static_cast<TOutput>(result);
622  }
623 
624 
625 };
626 
647 template <class TInput, class TOutput>
648 class NDBSI : public LandsatTMIndex<TInput, TOutput>
649 {
650 public:
652  virtual std::string GetName() const
653  {
654  return "NDBSI";
655  }
656 
657  NDBSI() {}
658  virtual ~NDBSI() {}
659 
660  inline TOutput operator ()(const TInput& inputPixel)
661  {
662  TInput newPixel(this->PrepareValues( inputPixel ));
663  double result = (newPixel[this->m_TM5] - newPixel[this->m_TM4])/
664  (newPixel[this->m_TM5] + newPixel[this->m_TM4] + this->m_EpsilonToBeConsideredAsZero);
665 
666  return static_cast<TOutput>(result);
667  }
668 
669 
670 };
671 
688 template <class TInput, class TOutput>
689 class BIO : public LandsatTMIndex<TInput, TOutput>
690 {
691 public:
693  virtual std::string GetName() const
694  {
695  return "BIO";
696  }
697 
698  BIO() {}
699  virtual ~BIO() {}
700 
701  inline TOutput operator ()(const TInput& inputPixel)
702  {
703  TInput newPixel(this->PrepareValues( inputPixel ));
704  double result = ((newPixel[this->m_TM5] + newPixel[this->m_TM3])
705  - (newPixel[this->m_TM4] + newPixel[this->m_TM1]))
706  /((newPixel[this->m_TM5] + newPixel[this->m_TM3])
707  + (newPixel[this->m_TM4] + newPixel[this->m_TM1]));
708 
709  return static_cast<TOutput>(result);
710  }
711 
712 
713 };
714 
715 
732 template <class TInput, class TOutput>
733 class NDSI : public LandsatTMIndex<TInput, TOutput>
734 {
735 public:
737  virtual std::string GetName() const
738  {
739  return "NDSI";
740  }
741 
742  NDSI() {}
743  virtual ~NDSI() {}
744 
745  inline TOutput operator ()(const TInput& inputPixel)
746  {
747  TInput newPixel(this->PrepareValues( inputPixel ));
748  double result = (newPixel[this->m_TM2] - newPixel[this->m_TM5])
749  /(newPixel[this->m_TM2] + newPixel[this->m_TM5] + this->m_EpsilonToBeConsideredAsZero);
750 
751  return static_cast<TOutput>(result);
752  }
753 
754 
755 };
756 
787 template <class TInput, class TOutput>
788 class NDSIVis : public LandsatTMIndex<TInput, TOutput>
789 {
790 public:
792  virtual std::string GetName() const
793  {
794  return "NDSIVis";
795  }
796 
797  NDSIVis() {}
798  virtual ~NDSIVis() {}
799 
800  inline TOutput operator ()(const TInput& inputPixel)
801  {
802  TInput newPixel(this->PrepareValues( inputPixel ));
803  double vis = (newPixel[this->m_TM1]+newPixel[this->m_TM2]+newPixel[this->m_TM3])/3.0;
804  double result = (vis - newPixel[this->m_TM5])/(vis + newPixel[this->m_TM5] + this->m_EpsilonToBeConsideredAsZero);
805 
806  return static_cast<TOutput>(result);
807  }
808 
809 
810 };
811 
830 template <class TInput, class TOutput>
831 class NDBBBI : public LandsatTMIndex<TInput, TOutput>
832 {
833 public:
835  virtual std::string GetName() const
836  {
837  return "NDBBBI";
838  }
839 
840  NDBBBI() {}
841  virtual ~NDBBBI() {}
842 
843  inline TOutput operator ()(const TInput& inputPixel)
844  {
845  TInput newPixel(this->PrepareValues( inputPixel ));
846  double result = (newPixel[this->m_TM1] - newPixel[this->m_TM5])
847  /(newPixel[this->m_TM1] + newPixel[this->m_TM5] + this->m_EpsilonToBeConsideredAsZero);
848  return static_cast<TOutput>(result);
849  }
850 
851 
852 };
853 
873 template <class TInput>
874 class LinguisticVariables : public LandsatTMIndexBase<TInput, itk::FixedArray<unsigned int, 11> >
875 {
876 public:
877 
878  typedef typename TInput::ValueType PrecisionType;
881 
884 
886  virtual std::string GetName() const
887  {
888  return "LandsatTM Linguistic Variables";
889  }
890 
892  {
904 
907 
908  // the thresholds are computed wrt Baraldi's paper (normalized 0-255 values)
909  m_FvBright->SetMembership(Low, minimumValue, minimumValue, 40/255., 40/255.);
910  m_FvBright->SetMembership(Medium, 40/255., 40/255., 60/255., 60/255.);
911  m_FvBright->SetMembership(High, 60/255., 60/255., maximumValue, maximumValue);
912 
913  m_FvVis->SetMembership(Low, minimumValue, minimumValue, 30/255., 30/255.);
914  m_FvVis->SetMembership(Medium, 30/255., 30/255., 50/255., 50/255.);
915  m_FvVis->SetMembership(High, 50/255., 50/255., maximumValue, maximumValue);
916 
917  m_FvNIR->SetMembership(Low, minimumValue, minimumValue, 40/255., 40/255.);
918  m_FvNIR->SetMembership(Medium, 40/255., 40/255., 60/255., 60/255.);
919  m_FvNIR->SetMembership(High, 60/255., 60/255., maximumValue, maximumValue);
920 
921  m_FvMIR1->SetMembership(Low, minimumValue, minimumValue, 40/255., 40/255.);
922  m_FvMIR1->SetMembership(Medium, 40/255., 40/255., 60/255., 60/255.);
923  m_FvMIR1->SetMembership(High, 60/255., 60/255., maximumValue, maximumValue);
924 
925  m_FvMIR2->SetMembership(Low, minimumValue, minimumValue, 30/255., 30/255.);
926  m_FvMIR2->SetMembership(Medium, 30/255., 30/255., 50/255., 50/255.);
927  m_FvMIR2->SetMembership(High, 50/255., 50/255., maximumValue, maximumValue);
928 
929  m_FvTIR->SetMembership(Low, minimumValue, minimumValue, 0, 0);
930  m_FvTIR->SetMembership(Medium, 0, 0, 28, 28);
931  m_FvTIR->SetMembership(High, 28, 28, maximumValue, maximumValue);
932 
933  m_FvMIRTIR->SetMembership(Low, minimumValue, minimumValue, 180, 180);
934  m_FvMIRTIR->SetMembership(Medium, 180, 180, 220, 220);
935  m_FvMIRTIR->SetMembership(High, 220, 220, maximumValue, maximumValue);
936 
937  m_FvNDSIVis->SetMembership(Low, minimumValue, minimumValue, 0, 0);
938  m_FvNDSIVis->SetMembership(Medium, 0, 0, 0.5, 0.5);
939  m_FvNDSIVis->SetMembership(High, 0.5, 0.5, maximumValue, maximumValue);
940 
941  m_FvNDBBBI ->SetMembership(Low, minimumValue, minimumValue, -0.20, -0.20);
942  m_FvNDBBBI->SetMembership(Medium, -0.20, -0.20, 0.10, 0.10);
943  m_FvNDBBBI->SetMembership(High, 0.10, 0.10, maximumValue, maximumValue);
944 
945  m_FvNDVI->SetMembership(Low, minimumValue, minimumValue, 0.35, 0.35);
946  m_FvNDVI->SetMembership(Medium, 0.35, 0.35, 0.6, 0.6);
947  m_FvNDVI->SetMembership(High, 0.6, 0.6, maximumValue, maximumValue);
948 
949  m_FvNDBSI->SetMembership(Low, minimumValue, minimumValue, -0.20, -0.20);
950  m_FvNDBSI->SetMembership(Medium, -0.20, -0.20, 0.0, 0.0);
951  m_FvNDBSI->SetMembership(High, 0.0, 0.0, maximumValue, maximumValue);
952  }
953  virtual ~LinguisticVariables() {}
954 
955  inline itk::FixedArray<unsigned int, 11> operator ()(const TInput& inputPixel)
956  {
957  TInput newPixel(this->PrepareValues( inputPixel ));
959 
960  result[ bright ] = m_FvBright->GetMaxVar(Bright<TInput, PrecisionType>()( newPixel ));
961  result[ vis ] = m_FvVis->GetMaxVar(Vis<TInput, PrecisionType>()( newPixel ));
962  result[ nir ] = m_FvNIR->GetMaxVar(NIR<TInput, PrecisionType>()( newPixel ));
963  result[ mir1 ] = m_FvMIR1->GetMaxVar(MIR1<TInput, PrecisionType>()( newPixel ));
964 
966  mir2F.SetSAT( this->m_SAT );
967  result[ mir2 ] = m_FvMIR2->GetMaxVar(mir2F( newPixel ));
968 
970  tirF.SetSAT( this->m_SAT );
971  result[ tir ] = m_FvTIR->GetMaxVar(tirF( newPixel ));
972 
974  mirtirF.SetSAT( this->m_SAT );
975  result[ mirtir ] = m_FvMIRTIR->GetMaxVar(mirtirF( newPixel ));
976 
977  result[ ndsivis ] = m_FvNDSIVis->GetMaxVar(NDSIVis<TInput, PrecisionType>()( newPixel ));
978 
979  result[ ndbbbi ] = m_FvNDBBBI->GetMaxVar(NDBBBI<TInput, PrecisionType>()( newPixel ));
980 
981  result[ ndvi ] = m_FvNDVI->GetMaxVar(NDVI<TInput, PrecisionType>()( newPixel ));
982 
983  result[ ndbsi ] = m_FvNDBSI->GetMaxVar(NDBSI<TInput, PrecisionType>()( newPixel ));
984 
985  return result;
986  }
987 
988 protected:
1000 
1001 
1002 };
1003 
1004 
1020 template <class TInput, class TOutput>
1021 class KernelSpectralRule : public LandsatTMIndexBase<TInput, TOutput >
1022 {
1023 public:
1024 
1025  typedef typename TInput::ValueType PrecisionType;
1026  typedef bool OutputPixelType;
1027 
1029  virtual std::string GetName() const
1030  {
1031  return "LandsatTM KernelSpectralRule";
1032  }
1033 
1034  KernelSpectralRule() : m_TV1(0.7), m_TV2(0.5) { }
1035  virtual ~KernelSpectralRule() {}
1036 
1038  {
1039  this->m_TV1 = tv1;
1040  }
1041 
1043  {
1044  this->m_TV2 = tv2;
1045  }
1046 
1048  {
1049  return this->m_TV1;
1050  }
1051 
1053  {
1054  return this->m_TV2;
1055  }
1056 
1057 protected:
1062 
1063  void SetMinMax(const TInput& inputPixel, PrecisionType* max13, PrecisionType* min123, PrecisionType* max123, PrecisionType* min12347, PrecisionType* max12347, PrecisionType* max234, PrecisionType* max45)
1064  {
1065  std::vector< PrecisionType > v13;
1066  v13.push_back(inputPixel[this->m_TM1]);
1067  v13.push_back(inputPixel[this->m_TM3]);
1068 
1069  *max13 = *(std::max_element ( v13.begin(), v13.end() ));
1070 
1071 
1072  std::vector< PrecisionType > v123;
1073  v123.push_back(inputPixel[this->m_TM1]);
1074  v123.push_back(inputPixel[this->m_TM2]);
1075  v123.push_back(inputPixel[this->m_TM3]);
1076 
1077  *max123 = *(std::max_element ( v123.begin(), v123.end() ));
1078  *min123 = *(std::min_element ( v123.begin(), v123.end() ));
1079 
1080 
1081  std::vector< PrecisionType > v12347;
1082  v12347.push_back(inputPixel[this->m_TM1]);
1083  v12347.push_back(inputPixel[this->m_TM2]);
1084  v12347.push_back(inputPixel[this->m_TM3]);
1085  v12347.push_back(inputPixel[this->m_TM4]);
1086  v12347.push_back(inputPixel[this->m_TM7]);
1087 
1088  *max12347 = *(std::max_element ( v12347.begin(), v12347.end() ));
1089  *min12347 = *(std::min_element ( v12347.begin(), v12347.end() ));
1090 
1091  std::vector< PrecisionType > v234;
1092  v234.push_back(inputPixel[this->m_TM2]);
1093  v234.push_back(inputPixel[this->m_TM3]);
1094  v234.push_back(inputPixel[this->m_TM4]);
1095 
1096  *max234 = *(std::max_element ( v234.begin(), v234.end() ));
1097 
1098  std::vector< PrecisionType > v45;
1099  v45.push_back(inputPixel[this->m_TM4]);
1100  v45.push_back(inputPixel[this->m_TM5]);
1101 
1102  *max45 = *(std::max_element ( v45.begin(), v45.end() ));
1103  }
1104 };
1105 
1119 template <class TInput, class TOutput>
1120 class ThickCloudsSpectralRule : public KernelSpectralRule<TInput, TOutput>
1121 {
1122 public:
1123 
1124  typedef typename TInput::ValueType PrecisionType;
1125  typedef bool OutputPixelType;
1126 
1128  virtual std::string GetName() const
1129  {
1130  return "LandsatTM ThickCloudsSpectralRule";
1131  }
1132 
1135 
1136  inline TOutput operator ()(const TInput& inputPixel)
1137  {
1138  TInput newPixel(this->PrepareValues( inputPixel ));
1139  PrecisionType max13;
1140  PrecisionType max123;
1141  PrecisionType min123;
1142  PrecisionType max12347;
1143  PrecisionType min12347;
1144  PrecisionType max234;
1145  PrecisionType max45;
1146  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1147 
1148  bool result = (
1149  ((min123 >= (this->m_TV1 * max123)
1150  && (max123 <= this->m_TV1 * newPixel[this->m_TM4]))
1151  || ((newPixel[this->m_TM2] >= this->m_TV1 * max13)
1152  && (max123 <= newPixel[this->m_TM4])))
1153  && (newPixel[this->m_TM5] <= this->m_TV1 * newPixel[this->m_TM4])
1154  && (newPixel[this->m_TM5] >= this->m_TV1 * max123)
1155  && (newPixel[this->m_TM7] <= this->m_TV1 * newPixel[this->m_TM4]));
1156 
1157  return static_cast<TOutput>(result);
1158  }
1159 
1160 };
1161 
1175 template <class TInput, class TOutput>
1176 class ThinCloudsSpectralRule : public KernelSpectralRule<TInput, TOutput>
1177 {
1178 public:
1179 
1180  typedef typename TInput::ValueType PrecisionType;
1181  typedef bool OutputPixelType;
1182 
1184  virtual std::string GetName() const
1185  {
1186  return "LandsatTM ThinCloudsSpectralRule";
1187  }
1188 
1191 
1192  inline TOutput operator ()(const TInput& inputPixel)
1193  {
1194  TInput newPixel(this->PrepareValues( inputPixel ));
1195  PrecisionType max13;
1196  PrecisionType max123;
1197  PrecisionType min123;
1198  PrecisionType max12347;
1199  PrecisionType min12347;
1200  PrecisionType max234;
1201  PrecisionType max45;
1202  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1203 
1204 
1205  bool result = (min123 >= (this->m_TV1 * max123))
1206  && (newPixel[this->m_TM4] >= max123)
1207  && !((newPixel[this->m_TM1] <= newPixel[this->m_TM2]
1208  && newPixel[this->m_TM2] <= newPixel[this->m_TM3]
1209  && newPixel[this->m_TM3] <= newPixel[this->m_TM4])
1210  && (newPixel[this->m_TM3] >= this->m_TV1 * newPixel[this->m_TM4]))
1211  && (newPixel[this->m_TM4] >= this->m_TV1 * newPixel[this->m_TM5])
1212  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM4])
1213  && (newPixel[this->m_TM5] >= this->m_TV1 * max123)
1214  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM7]);
1215 
1216  return static_cast<TOutput>(result);
1217  }
1218 
1219 };
1220 
1234 template <class TInput, class TOutput>
1235 class SnowOrIceSpectralRule : public KernelSpectralRule<TInput, TOutput>
1236 {
1237 public:
1238 
1239  typedef typename TInput::ValueType PrecisionType;
1240  typedef bool OutputPixelType;
1241 
1243  virtual std::string GetName() const
1244  {
1245  return "LandsatTM SnowOrIceSpectralRule";
1246  }
1247 
1250 
1251  inline TOutput operator ()(const TInput& inputPixel)
1252  {
1253  TInput newPixel(this->PrepareValues( inputPixel ));
1254  PrecisionType max13;
1255  PrecisionType max123;
1256  PrecisionType min123;
1257  PrecisionType max12347;
1258  PrecisionType min12347;
1259  PrecisionType max234;
1260  PrecisionType max45;
1261  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1262 
1263 
1264  bool result = (min123 >= (this->m_TV1 * max123))
1265  && (newPixel[this->m_TM4] >= (this->m_TV1 * max123))
1266  && (newPixel[this->m_TM5] <= this->m_TV2 * newPixel[this->m_TM4])
1267  && (newPixel[this->m_TM5] <= this->m_TV1 * min123)
1268  && (newPixel[this->m_TM5] <= this->m_TV1 * max123)
1269  && (newPixel[this->m_TM7] <= this->m_TV2 * newPixel[this->m_TM4])
1270  && (newPixel[this->m_TM7] <= this->m_TV1 * min123);
1271 
1272  return static_cast<TOutput>(result);
1273  }
1274 
1275 };
1276 
1277 
1291 template <class TInput, class TOutput>
1292 class WaterOrShadowSpectralRule : public KernelSpectralRule<TInput, TOutput>
1293 {
1294 public:
1295 
1296  typedef typename TInput::ValueType PrecisionType;
1297  typedef bool OutputPixelType;
1298 
1300  virtual std::string GetName() const
1301  {
1302  return "LandsatTM WaterOrShadowSpectralRule";
1303  }
1304 
1307 
1308  inline TOutput operator ()(const TInput& inputPixel)
1309  {
1310  TInput newPixel(this->PrepareValues( inputPixel ));
1311  bool result = (newPixel[this->m_TM1] >= newPixel[this->m_TM2])
1312  && (newPixel[this->m_TM2] >= newPixel[this->m_TM3])
1313  && (newPixel[this->m_TM3] >= newPixel[this->m_TM4])
1314  && (newPixel[this->m_TM4] >= newPixel[this->m_TM5])
1315  && (newPixel[this->m_TM4] >= newPixel[this->m_TM7]);
1316 
1317  return static_cast<TOutput>(result);
1318  }
1319 
1320 };
1321 
1322 
1336 template <class TInput, class TOutput>
1338 {
1339 public:
1340 
1341  typedef typename TInput::ValueType PrecisionType;
1342  typedef bool OutputPixelType;
1343 
1345  virtual std::string GetName() const
1346  {
1347  return "LandsatTM PitbogOrGreenhouseSpectralRule";
1348  }
1349 
1352 
1353  inline TOutput operator ()(const TInput& inputPixel)
1354  {
1355  TInput newPixel(this->PrepareValues( inputPixel ));
1356  PrecisionType max13;
1357  PrecisionType max123;
1358  PrecisionType min123;
1359  PrecisionType max12347;
1360  PrecisionType min12347;
1361  PrecisionType max234;
1362  PrecisionType max45;
1363  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1364 
1365 
1366  bool result = (newPixel[this->m_TM3] >= this->m_TV1 * newPixel[this->m_TM1])
1367  && (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM3])
1368  && (max123 <= this->m_TV1 * newPixel[this->m_TM4])
1369  && (newPixel[this->m_TM5] <= this->m_TV1 * newPixel[this->m_TM4])
1370  && (newPixel[this->m_TM3] >= this->m_TV2 * newPixel[this->m_TM5])
1371  && (min123 >= this->m_TV1 * newPixel[this->m_TM7]);
1372 
1373 
1374  return static_cast<TOutput>(result);
1375  }
1376 
1377 };
1378 
1392 template <class TInput, class TOutput>
1393 class DominantBlueSpectralRule : public KernelSpectralRule<TInput, TOutput>
1394 {
1395 public:
1396 
1397  typedef typename TInput::ValueType PrecisionType;
1398  typedef bool OutputPixelType;
1399 
1401  virtual std::string GetName() const
1402  {
1403  return "LandsatTM DominantBlueSpectralRule";
1404  }
1405 
1408 
1409  inline TOutput operator ()(const TInput& inputPixel)
1410  {
1411  TInput newPixel(this->PrepareValues( inputPixel ));
1412  bool result = (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM2])
1413  && (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM3])
1414  && (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM4])
1415  && (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM5])
1416  && (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM7]);
1417 
1418 
1419  return static_cast<TOutput>(result);
1420  }
1421 
1422 };
1423 
1424 
1438 template <class TInput, class TOutput>
1439 class VegetationSpectralRule : public KernelSpectralRule<TInput, TOutput>
1440 {
1441 public:
1442 
1443  typedef typename TInput::ValueType PrecisionType;
1444  typedef bool OutputPixelType;
1445 
1447  virtual std::string GetName() const
1448  {
1449  return "LandsatTM VegetationSpectralRule";
1450  }
1451 
1454 
1455  inline TOutput operator ()(const TInput& inputPixel)
1456  {
1457  TInput newPixel(this->PrepareValues( inputPixel ));
1458  PrecisionType max13;
1459  PrecisionType max123;
1460  PrecisionType min123;
1461  PrecisionType max12347;
1462  PrecisionType min12347;
1463  PrecisionType max234;
1464  PrecisionType max45;
1465  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1466 
1467 
1468  bool result = (newPixel[this->m_TM2] >= this->m_TV2 * newPixel[this->m_TM1])
1469  && (newPixel[this->m_TM2] >= this->m_TV1 * newPixel[this->m_TM3])
1470  && (newPixel[this->m_TM3] < this->m_TV1 * newPixel[this->m_TM4])
1471  && (newPixel[this->m_TM4] > max123)
1472  && (newPixel[this->m_TM5] < this->m_TV1 * newPixel[this->m_TM4])
1473  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM3])
1474  && (newPixel[this->m_TM7] < this->m_TV1 * newPixel[this->m_TM5]);
1475 
1476 
1477  return static_cast<TOutput>(result);
1478  }
1479 
1480 };
1481 
1482 
1496 template <class TInput, class TOutput>
1497 class RangelandSpectralRule : public KernelSpectralRule<TInput, TOutput>
1498 {
1499 public:
1500 
1501  typedef typename TInput::ValueType PrecisionType;
1502  typedef bool OutputPixelType;
1503 
1505  virtual std::string GetName() const
1506  {
1507  return "LandsatTM RangelandSpectralRule";
1508  }
1509 
1512 
1513  inline TOutput operator ()(const TInput& inputPixel)
1514  {
1515  TInput newPixel(this->PrepareValues( inputPixel ));
1516  PrecisionType max13;
1517  PrecisionType max123;
1518  PrecisionType min123;
1519  PrecisionType max12347;
1520  PrecisionType min12347;
1521  PrecisionType max234;
1522  PrecisionType max45;
1523  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1524 
1525 
1526  bool result = (newPixel[this->m_TM2] >= this->m_TV2 * newPixel[this->m_TM1])
1527  && (newPixel[this->m_TM2] >= this->m_TV1 * newPixel[this->m_TM3])
1528  && (newPixel[this->m_TM4] > max123)
1529  && (newPixel[this->m_TM3] < this->m_TV1 * newPixel[this->m_TM4])
1530  && (newPixel[this->m_TM4] >= this->m_TV1 * newPixel[this->m_TM5])
1531  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM4])
1532  && (newPixel[this->m_TM5] > max123)
1533  && (newPixel[this->m_TM7] < this->m_TV1 * max45)
1534  && (newPixel[this->m_TM5] >= newPixel[this->m_TM7]);
1535 
1536 
1537  return static_cast<TOutput>(result);
1538  }
1539 
1540 };
1541 
1555 template <class TInput, class TOutput>
1557 {
1558 public:
1559 
1560  typedef typename TInput::ValueType PrecisionType;
1561  typedef bool OutputPixelType;
1562 
1564  virtual std::string GetName() const
1565  {
1566  return "LandsatTM BarrenLandOrBuiltUpOrCloudsSpectralRule";
1567  }
1568 
1571 
1572  inline TOutput operator ()(const TInput& inputPixel)
1573  {
1574  TInput newPixel(this->PrepareValues( inputPixel ));
1575  PrecisionType max13;
1576  PrecisionType max123;
1577  PrecisionType min123;
1578  PrecisionType max12347;
1579  PrecisionType min12347;
1580  PrecisionType max234;
1581  PrecisionType max45;
1582  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1583 
1584 
1585  bool result = (newPixel[this->m_TM3] >= this->m_TV2 * newPixel[this->m_TM1])
1586  && (newPixel[this->m_TM3] >= this->m_TV1 * newPixel[this->m_TM2])
1587  && (newPixel[this->m_TM4] >= this->m_TV1 * max123)
1588  && (newPixel[this->m_TM5] >= max123)
1589  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM4])
1590  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM7])
1591  && (newPixel[this->m_TM7] >= this->m_TV2 * max45);
1592 
1593  return static_cast<TOutput>(result);
1594  }
1595 
1596 };
1597 
1611 template <class TInput, class TOutput>
1613 {
1614 public:
1615 
1616  typedef typename TInput::ValueType PrecisionType;
1617  typedef bool OutputPixelType;
1618 
1620  virtual std::string GetName() const
1621  {
1622  return "LandsatTM FlatResponseBarrenLandOrBuiltUpSpectralRule";
1623  }
1624 
1627 
1628  inline TOutput operator ()(const TInput& inputPixel)
1629  {
1630  TInput newPixel(this->PrepareValues( inputPixel ));
1631  PrecisionType max13;
1632  PrecisionType max123;
1633  PrecisionType min123;
1634  PrecisionType max12347;
1635  PrecisionType min12347;
1636  PrecisionType max234;
1637  PrecisionType max45;
1638  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1639 
1640 
1641  bool result = (newPixel[this->m_TM5] >= this->m_TV1 * max12347)
1642  && (min12347 >= this->m_TV2 * newPixel[this->m_TM5]);
1643 
1644  return static_cast<TOutput>(result);
1645  }
1646 
1647 };
1648 
1649 
1663 template <class TInput, class TOutput>
1665 {
1666 public:
1667 
1668  typedef typename TInput::ValueType PrecisionType;
1669  typedef bool OutputPixelType;
1670 
1672  virtual std::string GetName() const
1673  {
1674  return "LandsatTM ShadowWithBarrenLandSpectralRule";
1675  }
1676 
1679 
1680  inline TOutput operator ()(const TInput& inputPixel)
1681  {
1682  TInput newPixel(this->PrepareValues( inputPixel ));
1683  bool result = (newPixel[this->m_TM1] >= newPixel[this->m_TM2])
1684  && (newPixel[this->m_TM2] >= newPixel[this->m_TM3])
1685  && (newPixel[this->m_TM3] >= this->m_TV1 * newPixel[this->m_TM4])
1686  && (newPixel[this->m_TM1] >= newPixel[this->m_TM5])
1687  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM4])
1688  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM7]);
1689 
1690  return static_cast<TOutput>(result);
1691  }
1692 };
1693 
1694 
1708 template <class TInput, class TOutput>
1710 {
1711 public:
1712 
1713  typedef typename TInput::ValueType PrecisionType;
1714  typedef bool OutputPixelType;
1715 
1717  virtual std::string GetName() const
1718  {
1719  return "LandsatTM ShadowWithVegetationSpectralRule";
1720  }
1721 
1724 
1725  inline TOutput operator ()(const TInput& inputPixel)
1726  {
1727  TInput newPixel(this->PrepareValues( inputPixel ));
1728  bool result = (newPixel[this->m_TM1] >= newPixel[this->m_TM2])
1729  && (newPixel[this->m_TM2] >= newPixel[this->m_TM3])
1730  && (newPixel[this->m_TM1] >= this->m_TV2 * newPixel[this->m_TM4])
1731  && (newPixel[this->m_TM3] < this->m_TV1 * newPixel[this->m_TM4])
1732  && (newPixel[this->m_TM5] < this->m_TV1 * newPixel[this->m_TM4])
1733  && (newPixel[this->m_TM3] >= this->m_TV2 * newPixel[this->m_TM5])
1734  && (newPixel[this->m_TM7] < this->m_TV1 * newPixel[this->m_TM4]);
1735 
1736  return static_cast<TOutput>(result);
1737  }
1738 };
1739 
1740 
1754 template <class TInput, class TOutput>
1755 class ShadowCloudOrSnowSpectralRule : public KernelSpectralRule<TInput, TOutput>
1756 {
1757 public:
1758 
1759  typedef typename TInput::ValueType PrecisionType;
1760  typedef bool OutputPixelType;
1761 
1763  virtual std::string GetName() const
1764  {
1765  return "LandsatTM ShadowCloudOrSnowSpectralRule";
1766  }
1767 
1770 
1771  inline TOutput operator ()(const TInput& inputPixel)
1772  {
1773  TInput newPixel(this->PrepareValues( inputPixel ));
1774  PrecisionType max13;
1775  PrecisionType max123;
1776  PrecisionType min123;
1777  PrecisionType max12347;
1778  PrecisionType min12347;
1779  PrecisionType max234;
1780  PrecisionType max45;
1781  this->SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1782 
1783 
1784  bool result = (newPixel[this->m_TM1] >= this->m_TV1 * max234)
1785  && (max234 >= this->m_TV1 * newPixel[this->m_TM1])
1786  && (newPixel[this->m_TM5] < newPixel[this->m_TM1])
1787  && (newPixel[this->m_TM7] < this->m_TV1 * newPixel[this->m_TM1]);
1788 
1789  return static_cast<TOutput>(result);
1790  }
1791 };
1792 
1793 
1807 template <class TInput, class TOutput>
1808 class WetlandSpectralRule : public KernelSpectralRule<TInput, TOutput>
1809 {
1810 public:
1811 
1812  typedef typename TInput::ValueType PrecisionType;
1813  typedef bool OutputPixelType;
1814 
1816  virtual std::string GetName() const
1817  {
1818  return "LandsatTM WetlandSpectralRule";
1819  }
1820 
1823 
1824  inline TOutput operator ()(const TInput& inputPixel)
1825  {
1826  TInput newPixel(this->PrepareValues( inputPixel ));
1827  bool result = (newPixel[this->m_TM1] >= newPixel[this->m_TM2])
1828  && (newPixel[this->m_TM2] >= newPixel[this->m_TM3])
1829  && (newPixel[this->m_TM1] >= this->m_TV1 * newPixel[this->m_TM4])
1830  && (newPixel[this->m_TM3] < newPixel[this->m_TM4])
1831  && (newPixel[this->m_TM4] >= this->m_TV1 * newPixel[this->m_TM5])
1832  && (newPixel[this->m_TM5] >= this->m_TV1 * newPixel[this->m_TM4])
1833  && (newPixel[this->m_TM3] >= this->m_TV2 * newPixel[this->m_TM5])
1834  && (newPixel[this->m_TM5] >= newPixel[this->m_TM7]);
1835 
1836  return static_cast<TOutput>(result);
1837  }
1838 };
1839 
1840 
1841 } // namespace LandsatTM
1842 } // namespace Functor
1843 } // namespace otb
1844 
1845 #endif

Generated at Sat Mar 8 2014 16:04:56 for Orfeo Toolbox with doxygen 1.8.3.1