21 #ifndef otbLandsatTMIndices_h
22 #define otbLandsatTMIndices_h
26 #include "itkVariableLengthVector.h"
79 template <
class TInput,
class TOutput>
91 return !(*
this != other);
300 TInput newPix(inputPixel);
317 newPix[this->
m_TM60] = newPix[this->
m_TM60] / 100. - 273.15;
321 newPix[this->
m_TM61] = newPix[this->
m_TM61] / 100. - 273.15;
322 newPix[this->
m_TM62] = newPix[this->
m_TM62] / 100. - 273.15;
327 newPix[this->
m_TM1] = newPix[this->
m_TM1] / 1000.;
328 newPix[this->
m_TM2] = newPix[this->
m_TM2] / 1000.;
329 newPix[this->
m_TM3] = newPix[this->
m_TM3] / 1000.;
330 newPix[this->
m_TM4] = newPix[this->
m_TM4] / 1000.;
331 newPix[this->
m_TM5] = newPix[this->
m_TM5] / 1000.;
332 newPix[this->
m_TM7] = newPix[this->
m_TM7] / 1000.;
365 template <
class TInput,
class TOutput>
370 inline TOutput
operator()(
const TInput& inputPixel)
const;
373 virtual std::string
GetName()
const = 0;
400 template <
class TInput,
class TOutput>
421 double result = (newPixel[this->
m_TM1] + newPixel[this->
m_TM2] + 2 * newPixel[this->
m_TM3] + 2 * newPixel[this->
m_TM4] + newPixel[this->
m_TM5] +
422 newPixel[this->
m_TM7]) /
424 return static_cast<TOutput
>(result);
445 template <
class TInput,
class TOutput>
465 double result = (newPixel[this->
m_TM1] + newPixel[this->
m_TM2] + newPixel[this->
m_TM3]) / 3.0;
466 return static_cast<TOutput
>(result);
480 template <
class TInput,
class TOutput>
500 double result = newPixel[this->
m_TM4];
501 return static_cast<TOutput
>(result);
514 template <
class TInput,
class TOutput>
534 double result = newPixel[this->
m_TM5];
535 return static_cast<TOutput
>(result);
548 template <
class TInput,
class TOutput>
568 double result = newPixel[this->
m_TM7];
569 return static_cast<TOutput
>(result);
582 template <
class TInput,
class TOutput>
602 double result = newPixel[this->
m_TM62];
605 result = newPixel[this->
m_TM60];
607 return static_cast<TOutput
>(result);
630 template <
class TInput,
class TOutput>
650 double tir = newPixel[this->
m_TM62];
651 double mir1 = newPixel[this->
m_TM5];
654 tir = newPixel[this->
m_TM60];
656 double result = 255 * (1 - mir1) * (tir + 100) / 100.;
658 return static_cast<TOutput
>(result);
672 template <
class TInput,
class TOutput>
694 return static_cast<TOutput
>(result);
720 template <
class TInput,
class TOutput>
742 return static_cast<TOutput
>(result);
764 template <
class TInput,
class TOutput>
784 double result = ((newPixel[this->
m_TM5] + newPixel[this->
m_TM3]) - (newPixel[this->
m_TM4] + newPixel[this->
m_TM1])) /
785 ((newPixel[this->
m_TM5] + newPixel[this->
m_TM3]) + (newPixel[this->
m_TM4] + newPixel[this->
m_TM1]));
787 return static_cast<TOutput
>(result);
810 template <
class TInput,
class TOutput>
832 return static_cast<TOutput
>(result);
868 template <
class TInput,
class TOutput>
888 double vis = (newPixel[this->
m_TM1] + newPixel[this->
m_TM2] + newPixel[this->
m_TM3]) / 3.0;
891 return static_cast<TOutput
>(result);
915 template <
class TInput,
class TOutput>
936 return static_cast<TOutput
>(result);
961 template <
class TInput>
997 return "LandsatTM Linguistic Variables";
1014 PrecisionType maximumValue = itk::NumericTraits<PrecisionType>::max();
1015 PrecisionType minimumValue = itk::NumericTraits<PrecisionType>::NonpositiveMin();
1018 m_FvBright->SetMembership(
Low, minimumValue, minimumValue, 40 / 255., 40 / 255.);
1019 m_FvBright->SetMembership(
Medium, 40 / 255., 40 / 255., 60 / 255., 60 / 255.);
1020 m_FvBright->SetMembership(
High, 60 / 255., 60 / 255., maximumValue, maximumValue);
1022 m_FvVis->SetMembership(
Low, minimumValue, minimumValue, 30 / 255., 30 / 255.);
1023 m_FvVis->SetMembership(
Medium, 30 / 255., 30 / 255., 50 / 255., 50 / 255.);
1024 m_FvVis->SetMembership(
High, 50 / 255., 50 / 255., maximumValue, maximumValue);
1026 m_FvNIR->SetMembership(
Low, minimumValue, minimumValue, 40 / 255., 40 / 255.);
1027 m_FvNIR->SetMembership(
Medium, 40 / 255., 40 / 255., 60 / 255., 60 / 255.);
1028 m_FvNIR->SetMembership(
High, 60 / 255., 60 / 255., maximumValue, maximumValue);
1030 m_FvMIR1->SetMembership(
Low, minimumValue, minimumValue, 40 / 255., 40 / 255.);
1031 m_FvMIR1->SetMembership(
Medium, 40 / 255., 40 / 255., 60 / 255., 60 / 255.);
1032 m_FvMIR1->SetMembership(
High, 60 / 255., 60 / 255., maximumValue, maximumValue);
1034 m_FvMIR2->SetMembership(
Low, minimumValue, minimumValue, 30 / 255., 30 / 255.);
1035 m_FvMIR2->SetMembership(
Medium, 30 / 255., 30 / 255., 50 / 255., 50 / 255.);
1036 m_FvMIR2->SetMembership(
High, 50 / 255., 50 / 255., maximumValue, maximumValue);
1038 m_FvTIR->SetMembership(
Low, minimumValue, minimumValue, 0, 0);
1040 m_FvTIR->SetMembership(
High, 28, 28, maximumValue, maximumValue);
1042 m_FvMIRTIR->SetMembership(
Low, minimumValue, minimumValue, 180, 180);
1044 m_FvMIRTIR->SetMembership(
High, 220, 220, maximumValue, maximumValue);
1046 m_FvNDSIVis->SetMembership(
Low, minimumValue, minimumValue, 0, 0);
1048 m_FvNDSIVis->SetMembership(
High, 0.5, 0.5, maximumValue, maximumValue);
1050 m_FvNDBBBI->SetMembership(
Low, minimumValue, minimumValue, -0.20, -0.20);
1052 m_FvNDBBBI->SetMembership(
High, 0.10, 0.10, maximumValue, maximumValue);
1054 m_FvNDVI->SetMembership(
Low, minimumValue, minimumValue, 0.35, 0.35);
1056 m_FvNDVI->SetMembership(
High, 0.6, 0.6, maximumValue, maximumValue);
1058 m_FvNDBSI->SetMembership(
Low, minimumValue, minimumValue, -0.20, -0.20);
1060 m_FvNDBSI->SetMembership(
High, 0.0, 0.0, maximumValue, maximumValue);
1066 inline itk::FixedArray<unsigned int, 11>
operator()(
const TInput& inputPixel)
1069 itk::FixedArray<unsigned int, 11> result;
1082 result[
tir] =
m_FvTIR->GetMaxVar(tirF(newPixel));
1131 template <
class TInput,
class TOutput>
1141 return "LandsatTM KernelSpectralRule";
1181 std::vector<PrecisionType> v13;
1182 v13.push_back(inputPixel[this->
m_TM1]);
1183 v13.push_back(inputPixel[this->
m_TM3]);
1185 *max13 = *(std::max_element(v13.begin(), v13.end()));
1188 std::vector<PrecisionType> v123;
1189 v123.push_back(inputPixel[this->m_TM1]);
1190 v123.push_back(inputPixel[this->
m_TM2]);
1191 v123.push_back(inputPixel[this->m_TM3]);
1193 *max123 = *(std::max_element(v123.begin(), v123.end()));
1194 *min123 = *(std::min_element(v123.begin(), v123.end()));
1197 std::vector<PrecisionType> v12347;
1198 v12347.push_back(inputPixel[this->m_TM1]);
1199 v12347.push_back(inputPixel[this->m_TM2]);
1200 v12347.push_back(inputPixel[this->m_TM3]);
1201 v12347.push_back(inputPixel[this->
m_TM4]);
1202 v12347.push_back(inputPixel[this->
m_TM7]);
1204 *max12347 = *(std::max_element(v12347.begin(), v12347.end()));
1205 *min12347 = *(std::min_element(v12347.begin(), v12347.end()));
1207 std::vector<PrecisionType> v234;
1208 v234.push_back(inputPixel[this->m_TM2]);
1209 v234.push_back(inputPixel[this->m_TM3]);
1210 v234.push_back(inputPixel[this->m_TM4]);
1212 *max234 = *(std::max_element(v234.begin(), v234.end()));
1214 std::vector<PrecisionType> v45;
1215 v45.push_back(inputPixel[this->m_TM4]);
1216 v45.push_back(inputPixel[this->
m_TM5]);
1218 *max45 = *(std::max_element(v45.begin(), v45.end()));
1237 template <
class TInput,
class TOutput>
1247 return "LandsatTM ThickCloudsSpectralRule";
1267 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1269 bool result = (((min123 >= (this->
m_TV1 * max123) && (max123 <= this->
m_TV1 * newPixel[this->
m_TM4])) ||
1270 ((newPixel[this->
m_TM2] >= this->
m_TV1 * max13) && (max123 <= newPixel[this->
m_TM4]))) &&
1271 (newPixel[this->
m_TM5] <= this->
m_TV1 * newPixel[this->m_TM4]) && (newPixel[this->
m_TM5] >= this->
m_TV1 * max123) &&
1272 (newPixel[this->
m_TM7] <= this->
m_TV1 * newPixel[this->m_TM4]));
1274 return static_cast<TOutput
>(result);
1293 template <
class TInput,
class TOutput>
1303 return "LandsatTM ThinCloudsSpectralRule";
1323 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1326 bool result = (min123 >= (this->
m_TV1 * max123)) && (newPixel[this->
m_TM4] >= max123) &&
1327 !((newPixel[this->
m_TM1] <= newPixel[this->
m_TM2] && newPixel[this->
m_TM2] <= newPixel[this->
m_TM3] &&
1328 newPixel[this->
m_TM3] <= newPixel[this->
m_TM4]) &&
1330 (newPixel[this->
m_TM4] >= this->
m_TV1 * newPixel[this->
m_TM5]) && (newPixel[this->
m_TM5] >= this->
m_TV1 * newPixel[this->m_TM4]) &&
1333 return static_cast<TOutput
>(result);
1352 template <
class TInput,
class TOutput>
1362 return "LandsatTM SnowOrIceSpectralRule";
1382 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1385 bool result = (min123 >= (this->
m_TV1 * max123)) && (newPixel[this->
m_TM4] >= (this->
m_TV1 * max123)) &&
1388 (newPixel[this->
m_TM7] <= this->
m_TV1 * min123);
1390 return static_cast<TOutput
>(result);
1410 template <
class TInput,
class TOutput>
1420 return "LandsatTM WaterOrShadowSpectralRule";
1433 bool result = (newPixel[this->
m_TM1] >= newPixel[this->
m_TM2]) && (newPixel[this->
m_TM2] >= newPixel[this->
m_TM3]) &&
1434 (newPixel[this->
m_TM3] >= newPixel[this->
m_TM4]) && (newPixel[this->
m_TM4] >= newPixel[this->
m_TM5]) &&
1435 (newPixel[this->
m_TM4] >= newPixel[this->
m_TM7]);
1437 return static_cast<TOutput
>(result);
1457 template <
class TInput,
class TOutput>
1467 return "LandsatTM PitbogOrGreenhouseSpectralRule";
1487 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1490 bool result = (newPixel[this->
m_TM3] >= this->
m_TV1 * newPixel[this->
m_TM1]) && (newPixel[this->
m_TM1] >= this->
m_TV1 * newPixel[this->
m_TM3]) &&
1495 return static_cast<TOutput
>(result);
1514 template <
class TInput,
class TOutput>
1524 return "LandsatTM DominantBlueSpectralRule";
1537 bool result = (newPixel[this->
m_TM1] >= this->
m_TV1 * newPixel[this->
m_TM2]) && (newPixel[this->
m_TM1] >= this->
m_TV1 * newPixel[this->
m_TM3]) &&
1542 return static_cast<TOutput
>(result);
1562 template <
class TInput,
class TOutput>
1572 return "LandsatTM VegetationSpectralRule";
1592 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1595 bool result = (newPixel[this->
m_TM2] >= this->
m_TV2 * newPixel[this->
m_TM1]) && (newPixel[this->
m_TM2] >= this->
m_TV1 * newPixel[this->
m_TM3]) &&
1596 (newPixel[this->
m_TM3] < this->
m_TV1 * newPixel[this->
m_TM4]) && (newPixel[this->
m_TM4] > max123) &&
1597 (newPixel[this->
m_TM5] < this->
m_TV1 * newPixel[this->
m_TM4]) && (newPixel[this->
m_TM5] >= this->
m_TV1 * newPixel[this->m_TM3]) &&
1601 return static_cast<TOutput
>(result);
1621 template <
class TInput,
class TOutput>
1631 return "LandsatTM RangelandSpectralRule";
1651 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1654 bool result = (newPixel[this->
m_TM2] >= this->
m_TV2 * newPixel[this->
m_TM1]) && (newPixel[this->
m_TM2] >= this->
m_TV1 * newPixel[this->
m_TM3]) &&
1655 (newPixel[this->
m_TM4] > max123) && (newPixel[this->m_TM3] < this->
m_TV1 * newPixel[this->
m_TM4]) &&
1656 (newPixel[this->
m_TM4] >= this->
m_TV1 * newPixel[this->
m_TM5]) && (newPixel[this->
m_TM5] >= this->
m_TV1 * newPixel[this->m_TM4]) &&
1657 (newPixel[this->
m_TM5] > max123) && (newPixel[this->
m_TM7] < this->
m_TV1 * max45) && (newPixel[this->
m_TM5] >= newPixel[this->
m_TM7]);
1660 return static_cast<TOutput
>(result);
1679 template <
class TInput,
class TOutput>
1689 return "LandsatTM BarrenLandOrBuiltUpOrCloudsSpectralRule";
1709 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1712 bool result = (newPixel[this->
m_TM3] >= this->
m_TV2 * newPixel[this->
m_TM1]) && (newPixel[this->
m_TM3] >= this->
m_TV1 * newPixel[this->
m_TM2]) &&
1713 (newPixel[this->
m_TM4] >= this->
m_TV1 * max123) && (newPixel[this->
m_TM5] >= max123) &&
1715 (newPixel[this->
m_TM7] >= this->
m_TV2 * max45);
1717 return static_cast<TOutput
>(result);
1736 template <
class TInput,
class TOutput>
1746 return "LandsatTM FlatResponseBarrenLandOrBuiltUpSpectralRule";
1766 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1769 bool result = (newPixel[this->
m_TM5] >= this->
m_TV1 * max12347) && (min12347 >= this->
m_TV2 * newPixel[this->
m_TM5]);
1771 return static_cast<TOutput
>(result);
1791 template <
class TInput,
class TOutput>
1801 return "LandsatTM ShadowWithBarrenLandSpectralRule";
1814 bool result = (newPixel[this->
m_TM1] >= newPixel[this->
m_TM2]) && (newPixel[this->
m_TM2] >= newPixel[this->
m_TM3]) &&
1816 (newPixel[this->
m_TM5] >= this->
m_TV1 * newPixel[this->
m_TM4]) && (newPixel[this->m_TM5] >= this->
m_TV1 * newPixel[this->
m_TM7]);
1818 return static_cast<TOutput
>(result);
1838 template <
class TInput,
class TOutput>
1848 return "LandsatTM ShadowWithVegetationSpectralRule";
1861 bool result = (newPixel[this->
m_TM1] >= newPixel[this->
m_TM2]) && (newPixel[this->
m_TM2] >= newPixel[this->
m_TM3]) &&
1862 (newPixel[this->
m_TM1] >= this->
m_TV2 * newPixel[this->
m_TM4]) && (newPixel[this->m_TM3] < this->
m_TV1 * newPixel[this->
m_TM4]) &&
1863 (newPixel[this->
m_TM5] < this->
m_TV1 * newPixel[this->
m_TM4]) && (newPixel[this->m_TM3] >= this->
m_TV2 * newPixel[this->
m_TM5]) &&
1866 return static_cast<TOutput
>(result);
1886 template <
class TInput,
class TOutput>
1896 return "LandsatTM ShadowCloudOrSnowSpectralRule";
1916 this->
SetMinMax(newPixel, &max13, &min123, &max123, &min12347, &max12347, &max234, &max45);
1919 bool result = (newPixel[this->
m_TM1] >= this->
m_TV1 * max234) && (max234 >= this->
m_TV1 * newPixel[this->
m_TM1]) &&
1920 (newPixel[this->
m_TM5] < newPixel[this->
m_TM1]) && (newPixel[this->
m_TM7] < this->
m_TV1 * newPixel[this->m_TM1]);
1922 return static_cast<TOutput
>(result);
1942 template <
class TInput,
class TOutput>
1952 return "LandsatTM WetlandSpectralRule";
1965 bool result = (newPixel[this->
m_TM1] >= newPixel[this->
m_TM2]) && (newPixel[this->
m_TM2] >= newPixel[this->
m_TM3]) &&
1966 (newPixel[this->
m_TM1] >= this->
m_TV1 * newPixel[this->
m_TM4]) && (newPixel[this->m_TM3] < newPixel[this->
m_TM4]) &&
1967 (newPixel[this->
m_TM4] >= this->
m_TV1 * newPixel[this->
m_TM5]) && (newPixel[this->
m_TM5] >= this->
m_TV1 * newPixel[this->m_TM4]) &&
1970 return static_cast<TOutput
>(result);