Skip to content
Snippets Groups Projects
Commit 8de5d5ef authored by Gaëlle USSEGLIO's avatar Gaëlle USSEGLIO
Browse files

Directions on DEM mailles scan to respect SAR geometry into otbSARStreamingGainImageFilter

parent 58317998
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,16 @@ private:
AddParameter(ParameterType_Float, "ingain", "Multiplying gain");
SetParameterDescription("ingain", "Multiplying gain to obtain a mean radiometry at 100.");
AddParameter(ParameterType_Int, "indirectiondemc", "Range direction for DEM scan");
SetParameterDescription("indirectiondemc", "Range direction for DEM scan.");
SetDefaultParameterInt("indirectiondemc", 1);
MandatoryOff("indirectiondemc");
AddParameter(ParameterType_Int, "indirectiondeml", "Azimut direction for DEM scan");
SetParameterDescription("indirectiondeml", "Azimut direction for DEM scan.");
SetDefaultParameterInt("indirectiondeml", 1);
MandatoryOff("indirectiondeml");
AddParameter(ParameterType_OutputImage, "out", "Output amplitude Image");
SetParameterDescription("out","Output amplitude Image.");
......@@ -71,9 +81,14 @@ private:
void DoExecute()
{
// Get numeric parameters : gain
// Get numeric parameters : gain and directions for DEM scan
double gain = GetParameterFloat("ingain");
int DEMScanDirectionC = GetParameterInt("indirectiondemc");
int DEMScanDirectionL = GetParameterInt("indirectiondeml");
otbAppLogINFO(<<"Gain : "<<gain);
otbAppLogINFO(<<"Direction (DEM scan) in range : "<<DEMScanDirectionC);
otbAppLogINFO(<<"Direction (DEM scan) in azimut : "<<DEMScanDirectionL);
// Start the first pipelines (Read SAR and DEM image metedata)
ComplexFloatImageType::Pointer SARPtr = GetParameterComplexFloatImage("insar");
......@@ -85,7 +100,7 @@ private:
filterAmplitudeEstimation->SetSARImageKeyWorList(SARPtr->GetImageKeywordlist());
filterAmplitudeEstimation->SetSARImagePtr(SARPtr);
filterAmplitudeEstimation->SetDEMImagePtr(DEMPtr);
filterAmplitudeEstimation->SetGain(gain);
filterAmplitudeEstimation->SetDEMInformation(gain, DEMScanDirectionC, DEMScanDirectionL);
filterAmplitudeEstimation->initializeMarginAndRSTransform();
// Define the main pipeline (controlled with extended FileName)
......
......@@ -57,6 +57,16 @@ private:
SetParameterRole("gain", Role_Output);
SetDefaultParameterFloat("gain", 0);
AddParameter(ParameterType_Int,"directiontoscandemc","direction in range into DEM geometry to across SAR geometry from Near range to Far range (output of this application)");
SetParameterDescription("directiontoscandemc", "Range direction for DEM scan.");
SetParameterRole("directiontoscandemc", Role_Output);
SetDefaultParameterInt("directiontoscandemc", 1);
AddParameter(ParameterType_Int,"directiontoscandeml","direction in range into DEM geometry to across SAR geometry from Near range to Far range (output of this application)");
SetParameterDescription("directiontoscandeml", "Azimut direction for DEM scan.");
SetParameterRole("directiontoscandeml", Role_Output);
SetDefaultParameterInt("directiontoscandeml", 1);
AddRAMParameter();
SetDocExampleParameterValue("indem","S21E055.hgt");
......@@ -94,11 +104,14 @@ void DoExecute()
filterStreamingGain->SetInput(inputDEM);
filterStreamingGain->Update();
double gain = filterStreamingGain->GetGain();
double gain;
int directionDEM_forlines, directionDEM_forcolunms;
filterStreamingGain->GetDEMInformation(gain, directionDEM_forcolunms, directionDEM_forlines);
// Assigne Gain
SetParameterFloat("gain", gain);
SetParameterInt("directiontoscandemc", directionDEM_forcolunms);
SetParameterInt("directiontoscandeml", directionDEM_forlines);
}
// Vector for filters
std::vector<itk::ProcessObject::Pointer> m_Ref;
......
......@@ -78,6 +78,8 @@ private:
// Connexion between internal application (not image parameters with Connect)
Connect("DEMProjApp.gain","AmplitudeEstimationApp.ingain");
Connect("DEMProjApp.directiontoscandemc","AmplitudeEstimationApp.indirectiondemc");
Connect("DEMProjApp.directiontoscandeml","AmplitudeEstimationApp.indirectiondeml");
}
void DoUpdateParameters()
......
......@@ -115,7 +115,7 @@ public:
void SetSARImageKeyWorList(ImageKeywordlist sarImageKWL);
void SetSARImagePtr(ImageSARPointer sarPtr);
void SetDEMImagePtr(ImageDEMPointer demPtr);
void SetGain(double gain);
void SetDEMInformation(double gain, int DEMDirC, int DEMDirL);
// Getter
itkGetConstMacro(Gain, double);
......@@ -214,6 +214,10 @@ protected:
// Multiplying gain to obtain a mean radiometry at 100
double m_Gain;
// Directions to scan the DEM in function of SAR geometry (from near to far range)
int m_DEMdirL;
int m_DEMdirC;
// Margin for maille selection
int m_Margin;
......
......@@ -97,11 +97,17 @@ namespace otb
template<class TImageIn, class TImageOut, class TImageDEM, class TImageSAR>
void
SARAmplitudeEstimationImageFilter< TImageIn ,TImageOut, TImageDEM, TImageSAR >
::SetGain(double gain)
::SetDEMInformation(double gain, int DEMDirC, int DEMDirL)
{
// Check if gain is greater than 0
assert(gain > 0 && "gain must be greater than 0.");
// Check if directions are equal to 1 or -1
assert((DEMDirC == 1 || DEMDirC == -1) && "direction to scan the DEM in range must be 1 or -1.");
assert((DEMDirL == 1 || DEMDirL == -1) && "direction to scan the DEM in aimut must be 1 or -1.");
m_Gain = gain;
m_DEMdirL= DEMDirL;
m_DEMdirC = DEMDirC;
}
/**
......@@ -136,6 +142,8 @@ namespace otb
Superclass::PrintSelf(os, indent);
os << indent << "Gain : " << m_Gain << std::endl;
os << indent << "DEM scan direction in range : " << m_DEMdirC << std::endl;
os << indent << "DEM scan direction in aeimut : " << m_DEMdirL << std::endl;
}
/**
......@@ -736,23 +744,34 @@ namespace otb
double tgElevationMaxForCurrentLine = 0;
int nbLinesIntoDEM_withSelectedMailles = CLZY_InSideUp_Vec->size();
// Loop on mailles (for lines into DEM with al least one selected maille, the loop is decreasing)
for (int i = nbLinesIntoDEM_withSelectedMailles - 1; i >= 0; i--)
int ind_LDEM, ind_CDEM;
// Loop on mailles (for lines into DEM with al least one selected maille)
// the loop direction depends on m_DEMdirL
for (int i = 0 ; i < nbLinesIntoDEM_withSelectedMailles; i++)
{
int ind_LDEM = i;
// for colunms into DEM with selected mailles, depends of satellite pass
// If 1, the lines increase
if (m_DEMdirL == 1)
{
ind_LDEM = i;
}
// If -1, the lines decrease
else
{
ind_LDEM = nbLinesIntoDEM_withSelectedMailles - (i+1);
}
// for colunms into DEM with selected mailles, depends on m_DEMdirC
int nbColIntoDEM_withSelectedMailles = CLZY_InSideUp_Vec->at(ind_LDEM)->size();
for (int j = 0; j < nbColIntoDEM_withSelectedMailles; j++)
{
int ind_CDEM = 0;
// If ascending, the columns increase
if (m_SatellitePass == "ASCENDING")
// If 1, the columns increase
if (m_DEMdirC == 1)
{
ind_CDEM = j;
}
// If descending, the colunms decrease
// If -1, the colunms decrease
else
{
ind_CDEM = nbColIntoDEM_withSelectedMailles - (j+1);
......
......@@ -317,8 +317,8 @@ public:
return this->GetFilter()->GetSide_nbCol_nbLines_Output();
}
// gain estimation
double GetGain()
// Get some information abour DEM (gain estimation, direction to scan the DEM in function of SAR geometry)
void GetDEMInformation(double & gain, int & direction_toScan_DEMColunms, int & direction_toScan_DEMLines)
{
double deltaC[4];
double incidence[4];
......@@ -358,12 +358,19 @@ public:
Point3DType SatVel(0);
Point3DType R(0);
Point2DType col_row(0);
Point2DType y_z(0);
double incidence_moy = 0.;
double coef1 = 0.;
double coef2 = 0.;
IndexType idCurrent;
std::map<std::string,int> DEMSidesOrder_Into_SARGeometry;
double firstLine;
double lastLine;
double firstY;
double lastY;
// Loop on the four sides
for (int k = 0; k < 4; k++)
......@@ -378,9 +385,45 @@ public:
mntGeoPoint[2] = pixel_side[k];
// DeltaC (with colomn into SaR image)
m_SarSensorModelAdapter->WorldToLineSample(mntGeoPoint, col_row);
m_SarSensorModelAdapter->WorldToLineSampleYZ(mntGeoPoint, col_row, y_z);
deltaC[k] = col_row[0] - (nbColSAR/2);
// Compare each side of DEM to find the orientation related to SAR image
if (k == 0)
{
firstLine = col_row[1];
lastLine = col_row[1];
firstY = y_z[0];
lastY = y_z[0];
DEMSidesOrder_Into_SARGeometry["SideOf_L0"] = 0;
DEMSidesOrder_Into_SARGeometry["SideOf_Llast"] = 0;
DEMSidesOrder_Into_SARGeometry["SideOf_NR"] = 0;
DEMSidesOrder_Into_SARGeometry["SideOf_FR"] = 0;
}
else
{
if (col_row[1] < firstLine)
{
firstLine = col_row[1];
DEMSidesOrder_Into_SARGeometry["SideOf_L0"] = k;
}
if (col_row[1] > lastLine)
{
lastLine = col_row[1];
DEMSidesOrder_Into_SARGeometry["SideOf_Llast"] = k;
}
if (y_z[0] < firstY)
{
firstY = y_z[0];
DEMSidesOrder_Into_SARGeometry["SideOf_NR"] = k;
}
if (y_z[0] > lastY)
{
lastY = y_z[0];
DEMSidesOrder_Into_SARGeometry["SideOf_FR"] = k;
}
}
// Satelite Position
m_SarSensorModelAdapter->WorldToSatPositionAndVelocity(mntGeoPoint, SatPos, SatVel);
......@@ -402,13 +445,29 @@ public:
(2 * NormeCible * NormeR) ) * 180. / M_PI;
}
// Define the direction into DEM geometry in order to across SAR geometry from Near range to Far range
int NR_side, FR_side;
NR_side = DEMSidesOrder_Into_SARGeometry["SideOf_NR"];
FR_side = DEMSidesOrder_Into_SARGeometry["SideOf_FR"];
direction_toScan_DEMColunms = (ind_col[FR_side] > ind_col[NR_side]);
direction_toScan_DEMLines = (ind_lines[FR_side] > ind_lines[NR_side]);
if (direction_toScan_DEMColunms == 0)
{
direction_toScan_DEMColunms = -1;
}
if (direction_toScan_DEMLines == 0)
{
direction_toScan_DEMLines = -1;
}
// Fit function
this->fit2(deltaC, incidence, 4, &incidence_moy, &coef1, &coef2);
// Gain Estimation
double gain = 100.0 * tan(incidence_moy * M_PI / 180.);
return gain;
gain = 100.0 * tan(incidence_moy * M_PI / 180.);
}
......
......@@ -60,7 +60,7 @@ int otbSARAmplitudeEstimationImageFilterTest(int argc, char * argv[])
filter->SetSARImageKeyWorList(SARPtr->GetImageKeywordlist());
filter->SetSARImagePtr(SARPtr);
filter->SetDEMImagePtr(MNTPtr);
filter->SetGain(gain);
filter->SetDEMInformation(gain,1, 1);
std::cout<<"Print AmplitudeEstimation filter information: "<< std::endl;
std::cout << filter << std::endl;
......
......@@ -50,7 +50,12 @@ int otbSARStreamingGainImageFilterTest(int argc, char * argv[])
gainFilter->Update();
std::cout << gainFilter->GetSide_nbCol_nbLines() << std::endl;
std::cout << gainFilter->GetSide_0_0() << std::endl;
std::cout << gainFilter->GetGain() << std::endl;
double gain;
int directionDEM_forlines, directionDEM_forcolunms;
gainFilter->GetDEMInformation(gain, directionDEM_forlines, directionDEM_forcolunms);
std::cout << gain << std::endl;
std::cout << directionDEM_forlines << std::endl;
std::cout << directionDEM_forcolunms << std::endl;
}
catch (itk::ExceptionObject& err)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment