Commit 2745881cf2c7d07193ad178b624d11fbeb8a10a5

Authored by Jordi Inglada
1 parent 3810c87c
Exists in nomalised_features

TEST: relative reflectances and duplicates

Showing 1 changed file with 38 additions and 2 deletions   Show diff stats
test/iota2FeatureExtractionFunctor.cxx
... ... @@ -94,6 +94,7 @@ int fexFunctor(int argc, char * argv[])
94 94 }
95 95  
96 96  
  97 + auto tmpp0 = p[0];
97 98 p[0] = ndv;
98 99 res = func(p);
99 100 ndvi1_res = res[outOffset*nbd];
... ... @@ -102,6 +103,41 @@ int fexFunctor(int argc, char * argv[])
102 103 std::cout << p[0] << "\t" << res[1] << " --> should be no data\n";
103 104 return EXIT_FAILURE;
104 105 }
  106 + p[0] = tmpp0;
105 107  
106   - return EXIT_SUCCESS;
107   -}
  108 +
  109 + // test the relative reflectances
  110 + copyInputBands = true;
  111 + pars.CopyInputBands = copyInputBands;
  112 + pars.RelativeReflectances = true;
  113 + pars.ReferenceIndex = pars.RedIndex;
  114 + pars.RemoveDuplicates = false;
  115 +
  116 + func = iota2::FeatureExtractionFunctor<PixelType>(pars);
  117 + res = func(p);
  118 + ndvi1_res = res[cpd*nbd];
  119 + auto relref_res = res[pars.NIRIndex-1];
  120 + if(ndvi1_res != relref_res)
  121 + {
  122 + std::cout << "Relative reflectance for NIR != ndvi \n";
  123 + return EXIT_FAILURE;
  124 + }
  125 + if(p[pars.ReferenceIndex-1]!=res[pars.ReferenceIndex-1])
  126 + {
  127 + std::cout << "The relative reflectance of the reference index should be the original one\n";
  128 + return EXIT_FAILURE;
  129 + }
  130 +
  131 + //test remove duplicates
  132 + pars.RemoveDuplicates = true;
  133 + func = iota2::FeatureExtractionFunctor<PixelType>(pars);
  134 + res = func(p);
  135 + if(res.GetSize() != (cpd+2)*nbd)
  136 + {
  137 + std::cout << "Remove duplicates yields " << res.GetSize() << " components\n";
  138 + return EXIT_FAILURE;
  139 + }
  140 +
  141 +
  142 + return EXIT_SUCCESS;
  143 + }
... ...