This file is indexed.

/usr/include/OTB-5.8/otbLandsatTMSpectralRuleBasedClassifier.h is in libotb-dev 5.8.0+dfsg-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef otbLandsatTMSRBC_h
#define otbLandsatTMSRBC_h

#include "otbLandsatTMIndices.h"

namespace otb
{

namespace Functor
{

namespace LandsatTM
{

/** \class SpectralRuleBasedClassifier
 *
 * \brief Implementation of the SpectralRuleBasedClassifier for
 *  Landsat TM image land cover classification as described in table
 *  IV of Baraldi et al. 2006, "Automatic Spectral Rule-Based
 *  Preliminary Mapping of Calibrated Landsat TM and ETM+ Images",
 *  IEEE Trans. on Geoscience and Remote Sensing, vol 44, no 9. This
 *  classifier assumes that the input image is calibrated in
 *  reflectances and in temperature. The reflectances can be given in
 *  the 0-1 range (Normalized) or in 0-1000 (Thousands). Temperatures
 *  can be given in Kelvin, in Kelvin*100 or in Celsius. Appropriate
 *  accessors are available for setting these units.
 *
 *  The OTB development team acknowledges the contribution of Andrea
 *  Baraldi, who provided the correct set of threshold values for the
 *  published rule set implementation to be reproduced. Andrea Baraldi
 *  is the inventor of the Satellite Image Automatic Mapper TradeMark (SIAM)
 *  software product conceived, developed and supported solely by
 *  Baraldi Consultancy in Remote Sensing of Andrea Baraldi.
 *
 * \ingroup Functor
 * \ingroup Radiometry
 * \ingroup LandsatTMIndices
 *
 * \ingroup OTBLandSatClassifier
 */
template <class TInput, class TOutput>
class SpectralRuleBasedClassifier : public KernelSpectralRule<TInput, TOutput>
{
public:
  // Spectral categories
  enum SpectralCategory {
    NOCLASS, // 0 -if the pixel is not classified; just for error
             // checking; different from SU, which is a real rejection
             // class
    TKCL, // 1 -thick clouds
    TNCL, // 2 -thin clouds; possible confusions with cold light toned
          // (highly reflective) barren land and range land
    SN,   // 3 -snow
    ICSN, // 4 -ice or snow
    DPWASH, // 5 -deep clear water and shadow areas; possible confusions
            // with lava rocks
    SLWASH, // 6 -shallow clear water and shadow areas
    PBHNDVI, // 7 -pit bog with high NDVI
    PBMNDVI, // 8 -pit bog with medium NDVI
    PBLNDVI, // 9 -pit bog with low NDVI; possible confusions with
             // greenhouses
    SVHNIR, // 10 - strong vegetation with high NIR; includes broadleaved
            // decideous forests, vegetated cropland and pastures;
            // possible confusions with mixed forests
    SVLNIR, // 11 -strong vegetation with low NIR; includes evergreen
            // forests and mixed forests; possible confusions with
            // forest land in shadow areas
    AVHNIR, // 12 -average vegetation with high NIR; includes cropland and
            // pastures; possible confusions with evergreen forests
            // and mixed forests
    AVLNIR, // 13 -average vegetation with low NIR; includes evergreen
            // forests, especially coniferous; possible confusions
            // with forest land in shadow areas
    WVHNIR, // 14 -weak vegetation with high NIR; includes scarcely
            // vegetated areas
    WVLNIR, // 15 -weak vegetation with low NIR; includes forested wetland
    SSRHNIR, // 16 -strong shrub rangeland with high NIR; includes
             // herbaceous rangeland; possible confusions with shrub
             // and brush rangeland
    SSRLNIR, // 17 -strong shrub rangeland with low NIR; includes shrub
             // and brush rangeland; possible confusions with
             // herbaceous rangeland
    ASRHNIR, // 18 -average shrub rangeland with high NIR; includes
             // herbaceous rangeland; possible confusions with shrub
             // and brush rangeland
    ASRLNIR, // 19 -average shrub rangeland with low NIR; includes shrub
             // and brush rangeland; possible confusions with
             // herbaceous rangeland
    SHR,     // 20 - strong herbaceous rangeland; possible confusions with
             // vegetated cropland ans pastures
    AHR,     // 21 -average herbaceous rangeland; includes herbaceous
             // rangeland and barren land scarcely vegetated; possible
             // confusions with vegetated cropland and pastures
    DR,      // 22 -dark rangeland; includes mixed rangeland eventually in
             // shadow areas and non forested wetland; possible
             // confusions with mixed urban or built up
    BBBHTIRF, // 23 -bright barren land or built up with high TIR and flat
              // spectral response; includes urban or built up and
              // concrete roads
    BBBHTIRNF, // 24 -bright barren land or built up with high TIR and non flat
              // spectral response;
    BBBLTIRF, // 25 -bright barren land or built up with low TIR and flat
              // spectral response; includes urban or built up and
              // concrete roads
    BBBLTIRNF, // 26 -bright barren land or built up with low TIR and non flat
              // spectral response;
    SBBHTIRF, // 27 -strong barren land or built up with high TIR and flat
              // spectral response; includes urban or built up and
              // concrete roads
    SBBHTIRNF, // 28 -strong barren land or built up with high TIR with non flat
              // spectral response; includes ploughed fields, barren
              // land -- including bare exposed rocks -- and beaches
    SBBLTIRF, // 29 -strong barren land or built up with low TIR and flat
              // spectral response; includes urban or built up and
              // concrete roads
    SBBLTIRNF, // 30 -strong barren land or built up with low TIR with non flat
              // spectral response; includes ploughed fields, barren
              // land -- including bare exposed rocks -- and beaches
    ABBHTIRF, // 31 -average barren land or built up with high TIR and flat
              // spectral response; includes urban or built up and
              // concrete roads
    ABBHTIRNF, // 32 -average barren land or built up with high TIR with non flat
              // spectral response
    ABBLTIRF, // 33 -average barren land or built up with low TIR and flat
              // spectral response; includes urban or built up and
              // concrete roads
    ABBLTIRNF, // 34 -average barren land or built up with low TIR with non flat
              // spectral response
    DBBHTIRF, // 35 -dark barren land or built up with high TIR and flat
              // spectral response; includes urban or built up land,
              // in particular parking lots, concrete roads, asphalt
              // roads, grey-brown tile roofs, tan composite shingle
              // roofs; possible confusions with barren land on dark
              // mountain slopes including burned areas and bare
              // exposed rocks, especially dark-toned soil
    DBBHTIRNF, // 36 -dark barren land or built up with high TIR and non
               // flat spectral response; includes barren land, bare
               // exposed rocks, especially dark-toned soil
    DBBLTIRF, // 37 -dark barren land or built up with low TIR and flat
              // spectral response; includes urban or built up land,
              // in particular parking lots, concrete roads, asphalt
              // roads, grey-brown tile roofs, tan composite shingle
              // roofs; possible confusions with barren land on dark
              // mountain slopes including burned areas and bare
              // exposed rocks, especially dark-toned soil
    DBBLTIRNF, // 38 -dark barren land or built up with low TIR and non
               // flat spectral response; includes barren land, bare
               // exposed rocks, especially dark-toned soil
    WR,        // 39 -weak rangeland; includes herbaceous rangeland
    SHV,       // 40 -shadow area with vegetation; possible confusions
               // with non forested wetland
    SHB,       // 41 -shadow with barren land; includes also lava rock;
               // possible confusions with buil up areas, especially
               // asphalt roads
    SHCL,      // 42 -clouds in shadow areas
    TWASHSN,   // 43 -snow in shadow areas
    WE,        // 44 -non forested wetland; possible confusions with
               // shadow areas with vegetation
    TWA,       // 45 -turbid water; possible confusions with shadow areas
    SU        // 46 -shadow areas or unknown pixels
  };
  typedef typename TInput::ValueType PrecisionType;
  typedef bool OutputPixelType;

    /** Return the index name */
  std::string GetName() const ITK_OVERRIDE
  {
    return "LandsatTM SpectralRuleBasedClassifier";
  }

  SpectralRuleBasedClassifier() { }
  ~SpectralRuleBasedClassifier() ITK_OVERRIDE {}

  inline TOutput operator ()(const TInput& inputPixel)
  {
    // We normalize the pixel just once, so that the indices do not
    // need to do it
    TInput newPixel(this->PrepareValues( inputPixel ));


    // Get the linguistic variables
    typedef LinguisticVariables<TInput> LVType;
    LVType lvf = LVType();
    lvf.SetSAT( this->m_SAT );
    typename LVType::OutputPixelType lv = lvf( newPixel );


    typedef ThickCloudsSpectralRule<TInput, bool> TKCLSRType;
    TKCLSRType tkclsrf = TKCLSRType();
    tkclsrf.SetTV1( this->m_TV1 );
    tkclsrf.SetTV2( this->m_TV2 );
    tkclsrf.SetSAT( this->m_SAT );

    bool tkclsr = tkclsrf( newPixel );

    typedef ThinCloudsSpectralRule<TInput, bool> TNCLSRType;
    TNCLSRType tnclsrf = TNCLSRType();
    tnclsrf.SetTV1( this->m_TV1 );
    tnclsrf.SetTV2( this->m_TV2 );
    tnclsrf.SetSAT( this->m_SAT );

    bool tnclsr = tnclsrf( newPixel );

    bool lBright     = (lv[ LVType::bright ] == LVType::Low);
    bool lVis        = (lv[ LVType::vis ] == LVType::Low);
    bool lNIR        = (lv[ LVType::nir ] == LVType::Low);
    bool hNDSIVis    = (lv[ LVType::ndsivis ] == LVType::High);
    bool lMIR1       = (lv[ LVType::mir1 ] == LVType::Low);
    bool lMIR2       = (lv[ LVType::mir2 ] == LVType::Low);
    bool hTIR        = (lv[ LVType::tir ] == LVType::High);
    bool hMIRTIR     = (lv[ LVType::mirtir ] == LVType::High);
    bool mMIRTIR     = (lv[ LVType::mirtir ] == LVType::Medium);
    bool lMIRTIR     = (lv[ LVType::mirtir ] == LVType::Low);


    // cloud spectral category
    bool clsc = (tkclsr || tnclsr) && !(lBright ||
                                         lVis || lNIR ||
                                         hNDSIVis ||
                                         lMIR1 ||
                                         lMIR2 || hTIR
                                         || hMIRTIR);

    // thick cloud spectral category
    if(clsc && lMIRTIR)
      return static_cast<TOutput>(TKCL);

    // thin cloud spectral category
    if(clsc && mMIRTIR)
      return static_cast<TOutput>(TNCL);


    typedef SnowOrIceSpectralRule<TInput, bool> SNICSRType;
    SNICSRType snicsrf = SNICSRType();
    snicsrf.SetTV1( this->m_TV1 );
    snicsrf.SetTV2( this->m_TV2 );
    snicsrf.SetSAT( this->m_SAT );

    bool snicsr = snicsrf( newPixel );

    bool lNDBSI     = (lv[ LVType::ndbsi ] == LVType::Low);
    bool lNDSIVis   = (lv[ LVType::ndsivis ] == LVType::Low);
    bool hMIR1      = (lv[ LVType::mir1 ] == LVType::High);
    bool hMIR2      = (lv[ LVType::mir2 ] == LVType::High);

    // snow or ice spectral category
    bool snicsc = (snicsr && lNDBSI && !(lBright ||
                     lVis || lNDSIVis || lNIR || hMIR1 || hMIR2 || hTIR ));

    // snow spectral category
    if(snicsc && hNDSIVis)
      return static_cast<TOutput>(SN);

    bool mNDSIVis     = (lv[ LVType::ndsivis ] == LVType::Medium);
    // ice or snow spectral category
    if(snicsc && mNDSIVis)
      return static_cast<TOutput>(ICSN);


    typedef WaterOrShadowSpectralRule<TInput, bool> WASHSRType;
    WASHSRType washsrf = WASHSRType();
    washsrf.SetTV1( this->m_TV1 );
    washsrf.SetTV2( this->m_TV2 );
    washsrf.SetSAT( this->m_SAT );

    bool washsr = washsrf( newPixel );


    bool lNDVI = (lv[ LVType::ndvi ] == LVType::Low);
    bool lTIR  = (lv[ LVType::tir ] == LVType::Low);
    // water or shadow spectral category
    bool washsc = washsr && lBright && lVis && lNDVI && lNIR && lMIR1 && lMIR2 && !(lTIR);


    // deep water or shadow spectral category
    if( washsc && hNDSIVis)
      return static_cast<TOutput>(DPWASH);

    // shallow water or shadow spectral category
    if( washsc && !(hNDSIVis))
      return static_cast<TOutput>(SLWASH);


    typedef PitbogOrGreenhouseSpectralRule<TInput, bool> PBGHSRType;
    PBGHSRType pbghsrf = PBGHSRType();
    pbghsrf.SetTV1( this->m_TV1 );
    pbghsrf.SetTV2( this->m_TV2 );
    pbghsrf.SetSAT( this->m_SAT );

    bool pbghsr = pbghsrf( newPixel );

    // Pit bog spectral category
    bool pbsc = pbghsr && lMIR1 && lMIR2 && lNDBSI && !(lNIR);

    bool mNDVI = (lv[ LVType::ndvi ] == LVType::Medium);
    bool hNDVI = (lv[ LVType::ndvi ] == LVType::High);
    // Pit bog categories for each ndvi
    if( pbsc && hNDVI)
      return static_cast<TOutput>(PBHNDVI);
    if( pbsc && mNDVI)
      return static_cast<TOutput>(PBMNDVI);
    if( pbsc && lNDVI)
      return static_cast<TOutput>(PBLNDVI);


    typedef VegetationSpectralRule<TInput, bool> VSRType;
    VSRType vsrf = VSRType();
    vsrf.SetTV1( this->m_TV1 );
    vsrf.SetTV2( this->m_TV2 );
    vsrf.SetSAT( this->m_SAT );

    bool vsr = vsrf( newPixel );

    bool hNDBSI = (lv[ LVType::ndbsi ] == LVType::High);
    bool hNIR   = (lv[ LVType::nir ] == LVType::High);

    // strong vegetation spectral category
    bool svsc = vsr && hNDVI && !(hMIR1 || hMIR2 || hNDBSI);

    if( svsc && hNIR)
      return static_cast<TOutput>(SVHNIR);
    if( svsc && !(hNIR))
      return static_cast<TOutput>(SVLNIR);

    typedef ShadowWithVegetationSpectralRule<TInput, bool> SHVSRType;
    SHVSRType shvsrf = SHVSRType();
    shvsrf.SetTV1( this->m_TV1 );
    shvsrf.SetTV2( this->m_TV2 );
    shvsrf.SetSAT( this->m_SAT );

    bool shvsr = shvsrf( newPixel );


    typedef DominantBlueSpectralRule<TInput, bool> DBSRType;
    DBSRType dbsrf = DBSRType();
    dbsrf.SetTV1( this->m_TV1 );
    dbsrf.SetTV2( this->m_TV2 );
    dbsrf.SetSAT( this->m_SAT );

    bool dbsr = dbsrf( newPixel );

    // average vegetation spectral category
    bool avsc = (vsr || shvsr) && mNDVI && !(hMIR1 || hMIR2 || hNDBSI || dbsr);

    if( avsc && hNIR)
      return static_cast<TOutput>(AVHNIR);
    if( avsc && !(hNIR))
      return static_cast<TOutput>(AVLNIR);

    typedef RangelandSpectralRule<TInput, bool> RSRType;
    RSRType rsrf = RSRType();
    rsrf.SetTV1( this->m_TV1 );
    rsrf.SetTV2( this->m_TV2 );
    rsrf.SetSAT( this->m_SAT );

    bool rsr = rsrf( newPixel );

    // weak vegetation spectral category
    bool wvsc = (vsr || rsr || shvsr) && lNDVI && lNDBSI && lMIR1 && lMIR2 && !(dbsr);

    if( wvsc && hNIR)
      return static_cast<TOutput>(WVHNIR);
    if( wvsc && !(hNIR))
      return static_cast<TOutput>(WVLNIR);

    bool mNDBSI = (lv[ LVType::ndbsi ] == LVType::Medium);
    // strong shrub rangeland spectral category
    bool ssrsc = rsr && hNDVI && mNDBSI;
    if( ssrsc && hNIR)
      return static_cast<TOutput>(SSRHNIR);
    if( ssrsc && !(hNIR))
      return static_cast<TOutput>(SSRLNIR);

    typedef WetlandSpectralRule<TInput, bool> WESRType;
    WESRType wesrf = WESRType();
    wesrf.SetTV1( this->m_TV1 );
    wesrf.SetTV2( this->m_TV2 );
    wesrf.SetSAT( this->m_SAT );

    bool wesr = wesrf( newPixel );

    // average shrub rangeland spectral category
    bool asrsc = rsr && mNDVI && mNDBSI && !(shvsr || wesr);
    if( asrsc && hNIR)
      return static_cast<TOutput>(ASRHNIR);
    if( asrsc && !(hNIR))
      return static_cast<TOutput>(ASRLNIR);


    // strong herbaceous rangeland spectral category
    bool shrsc = rsr && hNDVI && hNDBSI;
    if( shrsc )
      return static_cast<TOutput>(SHR);

    typedef BarrenLandOrBuiltUpOrCloudsSpectralRule<TInput, bool> BBCSRType;
    BBCSRType bbcsrf = BBCSRType();
    bbcsrf.SetTV1( this->m_TV1 );
    bbcsrf.SetTV2( this->m_TV2 );
    bbcsrf.SetSAT( this->m_SAT );

    bool bbcsr = bbcsrf( newPixel );
    // average herbaceous rangeland spectral category
    bool ahrsc = (rsr || bbcsr) && mNDVI && hNDBSI;
    if( ahrsc )
      return static_cast<TOutput>(AHR);

    // dark rangeland spectral category
    bool drsc = (vsr || rsr) && lNDVI && lMIR2 && !(hNIR || hMIR1 || lNDBSI);
    if( drsc )
      return static_cast<TOutput>(DR);

    // bright barren land or built up spectral category
    bool bbbsc = bbcsr && hNIR && lNDVI && hNDBSI && !(lMIR1 || lMIR2);

    bool lNDBBBI  = (lv[ LVType::ndbbbi ] == LVType::Low);

    bool bbbhtirsc = bbbsc && hTIR;

    if( bbbhtirsc && !(lNDBBBI) )
      return static_cast<TOutput>(BBBHTIRF);
    if( bbbhtirsc && lNDBBBI )
      return static_cast<TOutput>(BBBHTIRNF);

    bool bbbltirsc = bbbsc && !(hTIR);
    if( bbbltirsc && !(lNDBBBI) )
      return static_cast<TOutput>(BBBLTIRF);
    if( bbbltirsc && lNDBBBI )
      return static_cast<TOutput>(BBBLTIRNF);

    typedef FlatResponseBarrenLandOrBuiltUpSpectralRule<TInput, bool> FBBSRType;
    FBBSRType fbbsrf = FBBSRType();
    fbbsrf.SetTV1( this->m_TV1 );
    fbbsrf.SetTV2( this->m_TV2 );
    fbbsrf.SetSAT( this->m_SAT );

    bool fbbsr = fbbsrf( newPixel );
    // strong barren land or built up spectral category
    bool sbbsc = (bbcsr || fbbsr) && lNDVI && hNDBSI && !( hNIR || lMIR1);

    bool sbbhtirsc = sbbsc && hTIR;

    if( sbbhtirsc && (dbsr || fbbsr) )
      return static_cast<TOutput>(SBBHTIRF);
    if( sbbhtirsc && !(dbsr || fbbsr) )
      return static_cast<TOutput>(SBBHTIRNF);

    bool sbbltirsc = sbbsc && !(hTIR);
    if( sbbltirsc && (dbsr || fbbsr) )
      return static_cast<TOutput>(SBBLTIRF);
    if( sbbltirsc && !((dbsr || fbbsr)) )
      return static_cast<TOutput>(SBBLTIRNF);

    // average barren land or built up spectral category
    bool abbsc = (bbcsr || fbbsr) && lNDVI && mNDBSI && !(lMIR1);

    bool abbhtirsc = abbsc && hTIR;

    if( abbhtirsc && !(lNDBBBI) )
      return static_cast<TOutput>(ABBHTIRF);
    if( abbhtirsc && lNDBBBI )
      return static_cast<TOutput>(ABBHTIRNF);

    bool abbltirsc = abbsc && !(hTIR);
    if( abbltirsc && !(lNDBBBI) )
      return static_cast<TOutput>(ABBLTIRF);
    if( abbltirsc && lNDBBBI )
      return static_cast<TOutput>(ABBLTIRNF);

    // dark barren land or built
    bool dbbsc = (bbcsr || fbbsr) && lNDVI && lMIR1 && !( hNIR || hMIR2 || lNDBSI);

    bool dbbhtirsc = dbbsc && hTIR;

    if( dbbhtirsc && (dbsr || fbbsr) )
      return static_cast<TOutput>(DBBHTIRF);
    if( dbbhtirsc && !(dbsr || fbbsr) )
      return static_cast<TOutput>(DBBHTIRNF);

    bool dbbltirsc = dbbsc && !(hTIR);
    if( dbbltirsc && (dbsr || fbbsr) )
      return static_cast<TOutput>(DBBLTIRF);
    if( dbbltirsc && !((dbsr || fbbsr)) )
      return static_cast<TOutput>(DBBLTIRNF);

    // weak rangeland spectral category
    bool wrsc = rsr && lNDVI && !(lNDBSI);
    if( wrsc )
      return static_cast<TOutput>(WR);

    // shadow area with vegetation spectral category
    bool shvsc = dbsr && shvsr && lBright && lVis && lNIR && lMIR1 && lMIR2 && !(hNDVI);
    if( shvsc )
      return static_cast<TOutput>(SHV);

    typedef ShadowWithBarrenLandSpectralRule<TInput, bool> SHBSRType;
    SHBSRType shbsrf = SHBSRType();
    shbsrf.SetTV1( this->m_TV1 );
    shbsrf.SetTV2( this->m_TV2 );
    shbsrf.SetSAT( this->m_SAT );

    bool shbsr = shbsrf( newPixel );
    // shadow with barren land spectral category
    bool shbsc = dbsr && shbsr && lBright && lVis && lNDVI && lNIR && lMIR1 && lMIR2;
    if( shbsc )
      return static_cast<TOutput>(SHB);

    typedef ShadowCloudOrSnowSpectralRule<TInput, bool> SHCLSNSRType;
    SHCLSNSRType shclsnsrf = SHCLSNSRType();
    shclsnsrf.SetTV1( this->m_TV1 );
    shclsnsrf.SetTV2( this->m_TV2 );
    shclsnsrf.SetSAT( this->m_SAT );

    bool shclsnsr = shclsnsrf( newPixel );
    // clouds in shadow areas spectral category
    bool shclsc = dbsr && shclsnsr && !(hNDSIVis || lNIR || lBright || lVis || hNDBSI || hTIR);
    if( shclsc )
      return static_cast<TOutput>(SHCL);

    bool hBright     = (lv[ LVType::bright ] == LVType::High);
    bool hVis        = (lv[ LVType::vis ] == LVType::High);
    // turbid water or shadow snow spectral category
    bool twashsnsc = dbsr && shclsnsr && hNDSIVis && lNIR && lMIR1 && lMIR2 && !(hBright || hVis || hNDBSI || hTIR);
    if( twashsnsc )
      return static_cast<TOutput>(TWASHSN);

    // non forested wetland spectral category
    bool wesc = dbsr && wesr && lBright && lVis && lNIR && lMIR1 && lMIR2 && !(hNDVI || hNDBSI || lNDSIVis);
    if( wesc )
      return static_cast<TOutput>(WE);

    // turbid water spectral category
    bool twasc = dbsr && lNDVI && lMIR1 && lMIR2 && !(hBright || hVis || hNIR || lNDSIVis);
    if( twasc )
      return static_cast<TOutput>(TWA);

    return static_cast<TOutput>(SU);

  }
};


} // namespace LandsatTM
} // namespace Functor
} // namespace otb

#endif