Commit c030bcce2f040e89e50e96ae51201512ce6b39e7

Authored by Jordi Inglada
1 parent c5a3d513
Exists in nomalised_features

ENH: add options for relative reflectances to application

Showing 1 changed file with 45 additions and 31 deletions   Show diff stats
app/iota2FeatureExtraction.cxx
... ... @@ -82,6 +82,17 @@ private:
82 82 AddParameter(ParameterType_Empty, "copyinput", "Copy input bands to output image (true/false). Default value is false");
83 83 MandatoryOff("copyinput");
84 84  
  85 + AddParameter(ParameterType_Empty, "relrefl", "Compute relative reflectances (true/false). Default value is false");
  86 + MandatoryOff("relrefl");
  87 +
  88 + AddParameter(ParameterType_Int, "relindex", "Index for the band used as reference reflectance (starting at 1). The red band is used by default");
  89 + MandatoryOff("relindex");
  90 +
  91 + AddParameter(ParameterType_Empty, "keepduplicates", "Keep duplicate relative reflectances (true/false). Default value is false");
  92 + MandatoryOff("keepduplicates");
  93 +
  94 +
  95 +
85 96 AddRAMParameter();
86 97 }
87 98  
... ... @@ -91,46 +102,49 @@ private:
91 102  
92 103 void DoExecute()
93 104 {
94   - auto cpd = 1;
  105 + auto pars = FeatureExtractionFunctorType::Parameters{};
  106 +
  107 + FloatVectorImageType::Pointer inputImage = this->GetParameterImage("in");
  108 + inputImage->UpdateOutputInformation();
  109 + pars.NumberOfInputComponents = inputImage->GetNumberOfComponentsPerPixel();
  110 +
95 111 if(IsParameterEnabled("comp"))
96   - cpd = GetParameterInt("comp");
97   - auto redIndex = 3;
  112 + pars.ComponentsPerDate = GetParameterInt("comp");
98 113 if(IsParameterEnabled("red"))
99   - redIndex = GetParameterInt("red");
100   - auto nirIndex = 4;
  114 + pars.RedIndex = GetParameterInt("red");
101 115 if(IsParameterEnabled("nir"))
102   - nirIndex = GetParameterInt("nir");
103   - auto swirIndex = 5;
  116 + pars.NIRIndex = GetParameterInt("nir");
104 117 if(IsParameterEnabled("swir"))
105   - swirIndex = GetParameterInt("swir");
106   - auto normIndexFactor = float{1000};
  118 + pars.SWIRIndex = GetParameterInt("swir");
107 119 if(IsParameterEnabled("indfact"))
108   - normIndexFactor = GetParameterInt("indfact");
109   - auto noDataValue = float{-10000};
  120 + pars.NormalizedIndexFactor= GetParameterInt("indfact");
110 121 if(IsParameterEnabled("nodata"))
111   - noDataValue = GetParameterInt("nodata");
112   - auto copyInputBands = false;
  122 + pars.NoDataValue= GetParameterInt("nodata");
113 123 if (IsParameterEnabled("copyinput"))
114 124 {
115   - copyInputBands = true;
  125 + pars.CopyInputBands = true;
  126 + }
  127 + if(IsParameterEnabled("relrefl"))
  128 + {
  129 + std::cout << " Relative reflectances \n";
  130 + pars.RelativeReflectances = true;
  131 + if(IsParameterEnabled("keepduplicates"))
  132 + {
  133 + std::cout << " keep duplicates \n";
  134 + pars.RemoveDuplicates = false;
  135 + }
  136 + if(IsParameterEnabled("relindex"))
  137 + {
  138 + pars.ReferenceIndex = GetParameterInt("relindex");
  139 + if(pars.ReferenceIndex > pars.ComponentsPerDate)
  140 + {
  141 + itkExceptionMacro(<<"relindex must be between 1 and the number of components per date\n");
  142 + }
  143 + }
  144 + std::cout << " relative index " << pars.ReferenceIndex << " \n";
116 145 }
117 146  
118   - std::cout << "Copy input is " << copyInputBands << "\n";
119   - FloatVectorImageType::Pointer inputImage = this->GetParameterImage("in");
120   - inputImage->UpdateOutputInformation();
121   - auto nbOfInputBands = inputImage->GetNumberOfComponentsPerPixel();
122   -
123   - auto pars = FeatureExtractionFunctorType::Parameters{};
124   - pars.ComponentsPerDate = cpd;
125   - pars.RedIndex = redIndex;
126   - pars.NIRIndex = nirIndex;
127   - pars.SWIRIndex = swirIndex;
128   - pars.NormalizedIndexFactor = normIndexFactor;
129   - pars.NoDataValue = noDataValue;
130   - pars.NumberOfInputComponents = nbOfInputBands;
131   - pars.CopyInputBands = copyInputBands;
132   -
133   -
  147 +
134 148 auto fef = FeatureExtractionFunctorType(pars);
135 149 m_FeatureExtractionFilter = FeatureExtractionFilterType::New();
136 150 m_FeatureExtractionFilter->SetFunctor(fef);
... ... @@ -144,4 +158,4 @@ private:
144 158 } // end namespace Wrapper
145 159 } // end namespace otb
146 160  
147   -OTB_APPLICATION_EXPORT(otb::Wrapper::iota2FeatureExtraction)
  161 + OTB_APPLICATION_EXPORT(otb::Wrapper::iota2FeatureExtraction)
... ...