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

UPDATE : Add Information into Projeted DEM to specify each components

parent 87a57fd2
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,34 @@ public:
/** Runtime information */
itkTypeMacro(SARAmplitudeEstimationFunctor, itk::Object);
// override SetRequiredComponentsToInd
void SetRequiredComponentsToInd(std::map<std::string, int> mapForInd)
{
std::map<std::string, int>::const_iterator it = mapForInd.begin();
while(it!=mapForInd.end())
{
if (it->first == "L")
{
m_indL = it->second;
}
else if (it->first == "C")
{
m_indC = it->second;
}
else if (it->first == "Y")
{
m_indY = it->second;
}
else if (it->first == "Z")
{
m_indZ = it->second;
}
++it;
}
}
// override estimate
virtual void estimate(const int ind_LineSAR, TInputPixel * CLZY_InSideUpPtr,
TInputPixel * CLZY_InSideDownPtr,
TInputPixel * CLZY_OutSideUpPtr,
......@@ -95,19 +122,19 @@ public:
TInputPixel CLZY_OutSideDown = *CLZY_OutSideDownPtr;
// Define the coef a and b
a1 = CLZY_InSideUp[1] - ind_LineSAR;
a1 /= CLZY_InSideUp[1] - CLZY_InSideDown[1];
a1 = CLZY_InSideUp[m_indL] - ind_LineSAR;
a1 /= CLZY_InSideUp[m_indL] - CLZY_InSideDown[m_indL];
b1 = 1-a1;
c1 = b1*(CLZY_InSideUp[0]) + a1*(CLZY_InSideDown[0]);
c1 = b1*(CLZY_InSideUp[m_indC]) + a1*(CLZY_InSideDown[m_indC]);
a2 = CLZY_OutSideUp[1] - ind_LineSAR;
a2 /= (CLZY_OutSideUp[1] - CLZY_OutSideDown[1]);
a2 = CLZY_OutSideUp[m_indL] - ind_LineSAR;
a2 /= (CLZY_OutSideUp[m_indL] - CLZY_OutSideDown[m_indL]);
b2 = 1-a2;
c2 = b2*(CLZY_OutSideUp[0]) + a2*(CLZY_OutSideDown[0]);
c2 = b2*(CLZY_OutSideUp[m_indC]) + a2*(CLZY_OutSideDown[m_indC]);
// Caculate zE, yE, zS and yS
// Select input and output side for the current maille with c1 and c2 comparaison
......@@ -116,15 +143,15 @@ public:
aE = a1;
bE = b1;
zE = b1*(CLZY_InSideUp[2]) +
a1*(CLZY_InSideDown[2]);
yE = b1*(CLZY_InSideUp[3]) +
a1*(CLZY_InSideDown[3]);
zE = b1*(CLZY_InSideUp[m_indZ]) +
a1*(CLZY_InSideDown[m_indZ]);
yE = b1*(CLZY_InSideUp[m_indY]) +
a1*(CLZY_InSideDown[m_indY]);
zS = b2*(CLZY_OutSideUp[2]) +
a2*(CLZY_OutSideDown[2]);
yS = b2*(CLZY_OutSideUp[3]) +
a2*(CLZY_OutSideDown[3]);
zS = b2*(CLZY_OutSideUp[m_indZ]) +
a2*(CLZY_OutSideDown[m_indZ]);
yS = b2*(CLZY_OutSideUp[m_indY]) +
a2*(CLZY_OutSideDown[m_indY]);
cE = c1;
cS = c2;
......@@ -134,15 +161,15 @@ public:
aS = a2;
bS = b2;
zE = b2*(CLZY_OutSideUp[2]) +
a2*(CLZY_OutSideDown[2]);
yE = b2*(CLZY_OutSideUp[3]) +
a2*(CLZY_OutSideDown[3]);
zE = b2*(CLZY_OutSideUp[m_indZ]) +
a2*(CLZY_OutSideDown[m_indZ]);
yE = b2*(CLZY_OutSideUp[m_indY]) +
a2*(CLZY_OutSideDown[m_indY]);
zS = b1*(CLZY_InSideUp[2]) +
a1*(CLZY_InSideDown[2]);
yS = b1*(CLZY_InSideUp[3]) +
a1*(CLZY_InSideDown[3]);
zS = b1*(CLZY_InSideUp[m_indZ]) +
a1*(CLZY_InSideDown[m_indZ]);
yS = b1*(CLZY_InSideUp[m_indY]) +
a1*(CLZY_InSideDown[m_indY]);
cE = c2;
cS = c1;
......@@ -208,12 +235,20 @@ public:
this->SetNumberOfEstimatedComponents(1);
this->SetSavePolygons(false);
this->SetOutputGeometry("SAR");
// Set the vector of Required Components
std::vector<std::string> vecComponents;
vecComponents.push_back("C");
vecComponents.push_back("L");
vecComponents.push_back("Z");
vecComponents.push_back("Y");
this->SetRequiredComponents(vecComponents);
}
// Redefinition to use construction with gain
static Pointer New(double gain)
static Pointer New(double gain)
{
Pointer smartPtr = ::itk::ObjectFactory< Self >::Create();
Pointer smartPtr = ::itk::ObjectFactory< Self >::Create();
if ( smartPtr == nullptr )
{
smartPtr = new Self(gain);
......@@ -228,7 +263,10 @@ static Pointer New(double gain)
private :
double m_Gain;
int m_indL;
int m_indC;
int m_indZ;
int m_indY;
};
}
......
......@@ -58,6 +58,45 @@ public:
/** Runtime information */
itkTypeMacro(SARCartesianMeanFunctor, itk::Object);
// override SetRequiredComponentsToInd
void SetRequiredComponentsToInd(std::map<std::string, int> mapForInd)
{
std::map<std::string, int>::const_iterator it = mapForInd.begin();
while(it!=mapForInd.end())
{
if (it->first == "L")
{
m_indL = it->second;
}
else if (it->first == "C")
{
m_indC = it->second;
}
else if (it->first == "Y")
{
m_indY = it->second;
}
else if (it->first == "Z")
{
m_indZ = it->second;
}
else if (it->first == "XCart")
{
m_indXCart = it->second;
}
else if (it->first == "YCart")
{
m_indYCart = it->second;
}
else if (it->first == "ZCart")
{
m_indZCart = it->second;
}
++it;
}
}
// override initialize
virtual void initalize(int nbElt, TOutputPixel * outValue, int threadId=1)
{
int nbComponentsMax = this->GetNumberOfEstimatedComponents();
......@@ -79,6 +118,7 @@ public:
}
}
// override estimate
virtual void estimate(const int ind_LineSAR, TInputPixel * CLZY_InSideUpPtr,
TInputPixel * CLZY_InSideDownPtr,
TInputPixel * CLZY_OutSideUpPtr,
......@@ -88,6 +128,7 @@ public:
bool isFirstMaille, double & tgElevationMaxForCurrentLine,int threadId=1)
{
int nbComponentsMax = this->GetNumberOfEstimatedComponents();
// Initalize
if (isFirstMaille)
{
......@@ -102,7 +143,6 @@ public:
}
}
double aE, bE, cE, aS, bS, cS;
double dy, dz, dc;
int col1, col2;
......@@ -123,19 +163,19 @@ public:
TInputPixel CLZY_OutSideDown = *CLZY_OutSideDownPtr;
// Define the coef a and b
a1 = CLZY_InSideUp[1] - ind_LineSAR;
a1 /= CLZY_InSideUp[1] - CLZY_InSideDown[1];
a1 = CLZY_InSideUp[m_indL] - ind_LineSAR;
a1 /= CLZY_InSideUp[m_indL] - CLZY_InSideDown[m_indL];
b1 = 1-a1;
c1 = b1*(CLZY_InSideUp[0]) + a1*(CLZY_InSideDown[0]);
c1 = b1*(CLZY_InSideUp[m_indC]) + a1*(CLZY_InSideDown[m_indC]);
a2 = CLZY_OutSideUp[1] - ind_LineSAR;
a2 /= (CLZY_OutSideUp[1] - CLZY_OutSideDown[1]);
a2 = CLZY_OutSideUp[m_indL] - ind_LineSAR;
a2 /= (CLZY_OutSideUp[m_indL] - CLZY_OutSideDown[m_indL]);
b2 = 1-a2;
c2 = b2*(CLZY_OutSideUp[0]) + a2*(CLZY_OutSideDown[0]);
c2 = b2*(CLZY_OutSideUp[m_indC]) + a2*(CLZY_OutSideDown[m_indC]);
// Caculate zE, yE, zS and yS
// Select input and output side for the current maille with c1 and c2 comparaison
......@@ -144,29 +184,29 @@ public:
aE = a1;
bE = b1;
zE = b1*(CLZY_InSideUp[2]) +
a1*(CLZY_InSideDown[2]);
yE = b1*(CLZY_InSideUp[3]) +
a1*(CLZY_InSideDown[3]);
zE = b1*(CLZY_InSideUp[m_indZ]) +
a1*(CLZY_InSideDown[m_indZ]);
yE = b1*(CLZY_InSideUp[m_indY]) +
a1*(CLZY_InSideDown[m_indY]);
xCartE = b1*(CLZY_InSideUp[4]) +
a1*(CLZY_InSideDown[4]);
yCartE = b1*(CLZY_InSideUp[5]) +
a1*(CLZY_InSideDown[5]);
zCartE = b1*(CLZY_InSideUp[6]) +
a1*(CLZY_InSideDown[6]);
zS = b2*(CLZY_OutSideUp[2]) +
a2*(CLZY_OutSideDown[2]);
yS = b2*(CLZY_OutSideUp[3]) +
a2*(CLZY_OutSideDown[3]);
xCartE = b1*(CLZY_InSideUp[m_indXCart]) +
a1*(CLZY_InSideDown[m_indXCart]);
yCartE = b1*(CLZY_InSideUp[m_indYCart]) +
a1*(CLZY_InSideDown[m_indYCart]);
zCartE = b1*(CLZY_InSideUp[m_indZCart]) +
a1*(CLZY_InSideDown[m_indZCart]);
zS = b2*(CLZY_OutSideUp[m_indZ]) +
a2*(CLZY_OutSideDown[m_indZ]);
yS = b2*(CLZY_OutSideUp[m_indY]) +
a2*(CLZY_OutSideDown[m_indY]);
xCartS = b2*(CLZY_OutSideUp[4]) +
a2*(CLZY_OutSideDown[4]);
yCartS = b2*(CLZY_OutSideUp[5]) +
a2*(CLZY_OutSideDown[5]);
zCartS = b2*(CLZY_OutSideUp[6]) +
a2*(CLZY_OutSideDown[6]);
xCartS = b2*(CLZY_OutSideUp[m_indXCart]) +
a2*(CLZY_OutSideDown[m_indXCart]);
yCartS = b2*(CLZY_OutSideUp[m_indYCart]) +
a2*(CLZY_OutSideDown[m_indYCart]);
zCartS = b2*(CLZY_OutSideUp[m_indZCart]) +
a2*(CLZY_OutSideDown[m_indZCart]);
cE = c1;
cS = c2;
......@@ -176,29 +216,29 @@ public:
aS = a2;
bS = b2;
zE = b2*(CLZY_OutSideUp[2]) +
a2*(CLZY_OutSideDown[2]);
yE = b2*(CLZY_OutSideUp[3]) +
a2*(CLZY_OutSideDown[3]);
xCartE = b2*(CLZY_OutSideUp[4]) +
a2*(CLZY_OutSideDown[4]);
yCartE = b2*(CLZY_OutSideUp[5]) +
a2*(CLZY_OutSideDown[5]);
zCartE = b2*(CLZY_OutSideUp[6]) +
a2*(CLZY_OutSideDown[6]);
zS = b1*(CLZY_InSideUp[2]) +
a1*(CLZY_InSideDown[2]);
yS = b1*(CLZY_InSideUp[3]) +
a1*(CLZY_InSideDown[3]);
zE = b2*(CLZY_OutSideUp[m_indZ]) +
a2*(CLZY_OutSideDown[m_indZ]);
yE = b2*(CLZY_OutSideUp[m_indY]) +
a2*(CLZY_OutSideDown[m_indY]);
xCartE = b2*(CLZY_OutSideUp[m_indXCart]) +
a2*(CLZY_OutSideDown[m_indXCart]);
yCartE = b2*(CLZY_OutSideUp[m_indYCart]) +
a2*(CLZY_OutSideDown[m_indYCart]);
zCartE = b2*(CLZY_OutSideUp[m_indZCart]) +
a2*(CLZY_OutSideDown[m_indZCart]);
zS = b1*(CLZY_InSideUp[m_indZ]) +
a1*(CLZY_InSideDown[m_indZ]);
yS = b1*(CLZY_InSideUp[m_indY]) +
a1*(CLZY_InSideDown[m_indY]);
xCartS = b1*(CLZY_InSideUp[4]) +
a1*(CLZY_InSideDown[4]);
yCartS = b1*(CLZY_InSideUp[5]) +
a1*(CLZY_InSideDown[5]);
zCartS = b1*(CLZY_InSideUp[6]) +
a1*(CLZY_InSideDown[6]);
xCartS = b1*(CLZY_InSideUp[m_indXCart]) +
a1*(CLZY_InSideDown[m_indXCart]);
yCartS = b1*(CLZY_InSideUp[m_indYCart]) +
a1*(CLZY_InSideDown[m_indYCart]);
zCartS = b1*(CLZY_InSideUp[m_indZCart]) +
a1*(CLZY_InSideDown[m_indZCart]);
cE = c2;
cS = c1;
......@@ -293,6 +333,17 @@ public:
this->SetNumberOfEstimatedComponents(3);
this->SetSavePolygons(false);
this->SetOutputGeometry("SAR");
// Set the vector of Required Components
std::vector<std::string> vecComponents;
vecComponents.push_back("C");
vecComponents.push_back("L");
vecComponents.push_back("Z");
vecComponents.push_back("Y");
vecComponents.push_back("XCart");
vecComponents.push_back("YCart");
vecComponents.push_back("ZCart");
this->SetRequiredComponents(vecComponents);
}
// Redefinition to use construction with NumberOfThreads (Functor used in Multi-Threading)
......@@ -324,6 +375,14 @@ private :
int m_NbThreads;
int ** m_CountPolygons; // Counter of contribution for each thread
// Index for each components
int m_indL;
int m_indC;
int m_indZ;
int m_indY;
int m_indXCart;
int m_indYCart;
int m_indZCart;
};
}
......
......@@ -174,7 +174,8 @@ namespace otb
ImageInConstPointer inputPtr = this->GetInput();
ImageOutPointer outputPtr = this->GetOutput();
ImageKeywordlist inputKwl = inputPtr->GetImageKeywordlist();
// Check Input/Output in function of Functor
if (inputPtr->GetNameOfClass() != "VectorImage")
{
......@@ -209,6 +210,31 @@ namespace otb
return;
}
}
// Check the nature of Components into projeted DEM
std::string BandKey = "support_data.band.";
std::vector<std::string> vecRequiredComponents = m_FunctionOnPolygon->GetRequiredComponents();
std::map<std::string, int> mapRequiredComponents;
std::cout << "vecRequiredComponents.size() = " << vecRequiredComponents.size() << std::endl;
for (int i = 0; i < vecRequiredComponents.size(); i++)
{
std::string component = BandKey + vecRequiredComponents.at(i);
if (!inputKwl.HasKey(component))
{
itkExceptionMacro(<<"Missing Component into Projeted DEM.");
return;
}
else
{
std::cout << "component = " << component << std::endl;
std::cout << "vecRequiredComponents.at(i) = " << vecRequiredComponents.at(i) << std::endl;
mapRequiredComponents[vecRequiredComponents.at(i)] = atoi(inputKwl.GetMetadataByKey(component).c_str());
std::cout << "mapRequiredComponents[vecRequiredComponents.at(i)] = " << mapRequiredComponents[vecRequiredComponents.at(i)] << std::endl;
}
}
m_FunctionOnPolygon->SetRequiredComponentsToInd(mapRequiredComponents);
// Define geometry output with the used functor
m_OutGeometry = m_FunctionOnPolygon->GetOutputGeometry();
......@@ -659,12 +685,12 @@ namespace otb
bool
SARDEMPolygonsAnalysisImageFilter< TImageIn, TImageOut, TImageDEM, TImageSAR, TFunction >
::PolygonsScan(const int ind_LineSAR,
std::vector<std::vector<ImageInPixelType> *> * CLZY_InSideUp_Vec,
std::vector<std::vector<ImageInPixelType> *> * CLZY_InSideDown_Vec,
std::vector<std::vector<ImageInPixelType> *> * CLZY_OutSideUp_Vec,
std::vector<std::vector<ImageInPixelType> *> * CLZY_OutSideDown_Vec,
int firstCol_into_outputRegion,
int nbCol_into_outputRegion, ImageOutPixelType * outValueTab, int threadId)
std::vector<std::vector<ImageInPixelType> *> * CLZY_InSideUp_Vec,
std::vector<std::vector<ImageInPixelType> *> * CLZY_InSideDown_Vec,
std::vector<std::vector<ImageInPixelType> *> * CLZY_OutSideUp_Vec,
std::vector<std::vector<ImageInPixelType> *> * CLZY_OutSideDown_Vec,
int firstCol_into_outputRegion, int nbCol_into_outputRegion,
ImageOutPixelType * outValueTab, int threadId)
{
bool isFirstPolygon = true;
......
......@@ -89,6 +89,9 @@ SARDEMProjectionImageFilter< TImageIn, TImageOut >
ImageInConstPointer inputPtr = this->GetInput();
ImageOutPointer outputPtr = this->GetOutput();
// Image KeyWordList
ImageKeywordlist inputKwl = inputPtr->GetImageKeywordlist();
// Set the number of Components for the Output VectorImage
// At Least 4 Components :
// _ C : Colunm of DEM into SAR Image
......@@ -105,26 +108,41 @@ SARDEMProjectionImageFilter< TImageIn, TImageOut >
//
// m_withH = true => 1 component added H : high
// m_withXYZ = true => 3 Three components added Xcart Ycart Zcart : cartesien coordonates
// m_withSatPos = true => 3 Three components added : Satellite Position into cartesian
// m_withSatPos = true => 3 Three components added : Satellite Position into cartesian
// Fill KeyWordList
inputKwl.AddKey("support_data.band.L", std::to_string(1));
inputKwl.AddKey("support_data.band.C", std::to_string(0));
inputKwl.AddKey("support_data.band.Z", std::to_string(2));
inputKwl.AddKey("support_data.band.Y", std::to_string(3));
m_NbComponents = 4;
if (m_withH)
{
m_NbComponents += 1;
m_indSatPos += 1;
}
if (m_withXYZ)
{
m_NbComponents += 3;
m_indH += 3;
m_indSatPos += 3;
inputKwl.AddKey("support_data.band.XCart", std::to_string(4));
inputKwl.AddKey("support_data.band.YCart", std::to_string(5));
inputKwl.AddKey("support_data.band.ZCart", std::to_string(6));
}
if (m_withH)
{
m_NbComponents += 1;
m_indSatPos += 1;
inputKwl.AddKey("support_data.band.H", std::to_string(m_indH));
}
if (m_withSatPos)
{
m_NbComponents += 3;
inputKwl.AddKey("support_data.band.XSatPos", std::to_string(m_indSatPos));
inputKwl.AddKey("support_data.band.YSatPos", std::to_string(m_indSatPos+1));
inputKwl.AddKey("support_data.band.ZSatPos", std::to_string(m_indSatPos+2));
}
std::cout << "m_NbComponents = " << m_NbComponents << std::endl;
std::cout << "m_indH = " << m_indH << std::endl;
outputPtr->SetNumberOfComponentsPerPixel(m_NbComponents);
......@@ -148,6 +166,9 @@ SARDEMProjectionImageFilter< TImageIn, TImageOut >
outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion);
outputPtr->SetOrigin(static_cast<ImageOutPointType>(origin));
outputPtr->SetSpacing(static_cast<ImageOutSpacingType>(inSP));
// Set Image KeyWordList
outputPtr->SetImageKeywordList(inputKwl);
}
/**
......
......@@ -28,6 +28,9 @@
#include "itkObject.h"
#include "itkObjectFactory.h"
#include <map>
#include <string>
namespace otb
{
namespace Function
......@@ -39,7 +42,7 @@ namespace Function
*
* \ingroup OTBCommon
*/
template <class TInputPixel, class TOutputPixel>
template <class TInputPixel, class TOutputPixel>
class SARPolygonsFunctor : public itk::Object
{
public:
......@@ -75,11 +78,26 @@ public:
itkSetMacro(NumberOfEstimatedComponents, unsigned int);
itkSetMacro(SavePolygons, bool);
itkSetMacro(OutputGeometry, std::string);
itkSetMacro(RequiredComponents, std::vector<std::string>);
virtual void SetRequiredComponentsToInd(std::map<std::string, int> mapForInd)
{
std::map<std::string, int>::const_iterator it = mapForInd.begin();
while(it!=mapForInd.end())
{
m_RequiredComponentsToInd[it->first] = it->second;
++it;
}
}
itkGetMacro(NumberOfExpectedComponents, unsigned int);
itkGetMacro(NumberOfEstimatedComponents, unsigned int);
itkGetMacro(SavePolygons, bool);
itkGetMacro(OutputGeometry, std::string);
itkGetMacro(RequiredComponents, std::vector<std::string>);
std::map<std::string, int> & GetRequiredComponentsToInd()
{
return m_RequiredComponentsToInd;
}
/** Constructor */
SARPolygonsFunctor()
......@@ -103,10 +121,13 @@ private :
bool m_SavePolygons;
// Geometry of output image into PolygonsAnalysis Filter (SAR or Polygons)
std::string m_OutputGeometry;
};
}
// Vector of required Components
std::vector<std::string> m_RequiredComponents;
// Map of required Components
std::map<std::string, int> m_RequiredComponentsToInd;
};
}
}
#endif
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