Commit 50263edc authored by Gaëlle USSEGLIO's avatar Gaëlle USSEGLIO

ENH : Enhance SARConcatenateBursts to concatenate interferograms

parent 6fcc483c
...@@ -92,7 +92,9 @@ public: ...@@ -92,7 +92,9 @@ public:
/** Deburst metadata if possible and prepare the burst concatenation */ /** Deburst metadata if possible and prepare the burst concatenation */
bool DeburstAndConcatenate(std::vector<std::pair<unsigned long, unsigned long> > & linesBursts, bool DeburstAndConcatenate(std::vector<std::pair<unsigned long, unsigned long> > & linesBursts,
std::vector<std::pair<unsigned long,unsigned long> > & samplesBursts); std::vector<std::pair<unsigned long,unsigned long> > & samplesBursts,
unsigned int & linesOffset, unsigned int first_burstInd,
bool inputWithInvalidPixels=false);
/** Transform world point (lat,lon,hgt) to input image point /** Transform world point (lat,lon,hgt) to input image point
......
...@@ -115,11 +115,14 @@ bool SarSensorModelAdapter::BurstExtraction(const unsigned int burst_index, ...@@ -115,11 +115,14 @@ bool SarSensorModelAdapter::BurstExtraction(const unsigned int burst_index,
bool bool
SarSensorModelAdapter::DeburstAndConcatenate(std::vector<std::pair<unsigned long, unsigned long> > & linesBursts, SarSensorModelAdapter::DeburstAndConcatenate(std::vector<std::pair<unsigned long, unsigned long> > & linesBursts,
std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts) std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts,
unsigned int & linesOffset, unsigned int first_burstInd,
bool inputWithInvalidPixels)
{ {
if(m_SensorModel.get()) if(m_SensorModel.get())
{ {
return m_SensorModel->deburstAndConcatenate(linesBursts, samplesBursts); return m_SensorModel->deburstAndConcatenate(linesBursts, samplesBursts, linesOffset, first_burstInd,
inputWithInvalidPixels);
} }
return false; return false;
......
...@@ -79,6 +79,11 @@ private: ...@@ -79,6 +79,11 @@ private:
AddParameter(ParameterType_OutputImage, "out", "Output Image"); AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "The concatenated and debursted output image."); SetParameterDescription("out", "The concatenated and debursted output image.");
AddParameter(ParameterType_Int, "burstindex", "Index of the first Burst");
SetParameterDescription("burstindex", "Index for the first required Burst (By default 0)");
MandatoryOff("burstindex");
SetDefaultParameterInt("burstindex", 0);
AddRAMParameter(); AddRAMParameter();
// Doc example parameter settings // Doc example parameter settings
...@@ -94,6 +99,9 @@ private: ...@@ -94,6 +99,9 @@ private:
void DoExecute() override void DoExecute() override
{ {
// Get the first Burst index
int burst_index = GetParameterInt("burstindex");
// Instanciate filters // Instanciate filters
ExtractROIFilterListType::Pointer m_ExtractorList = ExtractROIFilterListType::New(); ExtractROIFilterListType::Pointer m_ExtractorList = ExtractROIFilterListType::New();
ImageListType::Pointer m_ImageList = ImageListType::New(); ImageListType::Pointer m_ImageList = ImageListType::New();
...@@ -129,7 +137,18 @@ private: ...@@ -129,7 +137,18 @@ private:
// Coniguration for fusion filter // Coniguration for fusion filter
fusionFilter->SetSLCImageKeyWorList(in->GetImageKeywordlist()); fusionFilter->SetSLCImageKeyWorList(in->GetImageKeywordlist());
fusionFilter->getDeburstLinesAndSamples(lines, samples); // Get Invalid pixel Key (from Image 0)
FloatVectorImageType::Pointer Im0 = inList->GetNthElement(0);
Im0->UpdateOutputInformation();
bool inputWithInvalidPixels = false;
if (Im0->GetImageKeywordlist().HasKey("support_data.invalid_pixels"))
{
if (Im0->GetImageKeywordlist().GetMetadataByKey("support_data.invalid_pixels") == "yes")
{
inputWithInvalidPixels = true;
}
}
fusionFilter->getDeburstLinesAndSamples(lines, samples, burst_index, inputWithInvalidPixels);
// Split each input burst to keep only interested region // Split each input burst to keep only interested region
for( unsigned int i=0; i<inList->Size(); i++ ) for( unsigned int i=0; i<inList->Size(); i++ )
...@@ -137,6 +156,23 @@ private: ...@@ -137,6 +156,23 @@ private:
FloatVectorImageType::Pointer vectIm = inList->GetNthElement(i); FloatVectorImageType::Pointer vectIm = inList->GetNthElement(i);
vectIm->UpdateOutputInformation(); vectIm->UpdateOutputInformation();
bool inputWithInvalidPixels_loop = false;
// Check invalid Pixel Key
if (vectIm->GetImageKeywordlist().HasKey("support_data.invalid_pixels"))
{
if (vectIm->GetImageKeywordlist().GetMetadataByKey("support_data.invalid_pixels") == "yes")
{
inputWithInvalidPixels_loop = true;
}
}
if (inputWithInvalidPixels_loop != inputWithInvalidPixels)
{
// Throw an execption
throw std::runtime_error("Incoherency between input images (for support_data.invalid_pixels key).");
}
unsigned long originOffset_samples = static_cast<long>(vectIm->GetOrigin()[0]-0.5); unsigned long originOffset_samples = static_cast<long>(vectIm->GetOrigin()[0]-0.5);
unsigned long originOffset_lines = static_cast<long>(vectIm->GetOrigin()[1]-0.5); unsigned long originOffset_lines = static_cast<long>(vectIm->GetOrigin()[1]-0.5);
......
...@@ -140,6 +140,15 @@ SarBurstExtractionImageFilter<TImage>::GenerateOutputInformation() ...@@ -140,6 +140,15 @@ SarBurstExtractionImageFilter<TImage>::GenerateOutputInformation()
newKwl.AddKey("number_samples", std::to_string(burstSize[0])); newKwl.AddKey("number_samples", std::to_string(burstSize[0]));
newKwl.AddKey("number_lines", std::to_string(burstSize[1])); newKwl.AddKey("number_lines", std::to_string(burstSize[1]));
if (m_AllPixels)
{
newKwl.AddKey("support_data.invalid_pixels", "yes");
}
else
{
newKwl.AddKey("support_data.invalid_pixels", "no");
}
// Set new keyword list to output image // Set new keyword list to output image
outputPtr->SetImageKeywordList(newKwl); outputPtr->SetImageKeywordList(newKwl);
......
...@@ -69,6 +69,7 @@ public: ...@@ -69,6 +69,7 @@ public:
typedef typename ImageType::Pointer ImagePointerType; typedef typename ImageType::Pointer ImagePointerType;
typedef typename ImageType::SizeType SizeType; typedef typename ImageType::SizeType SizeType;
typedef typename ImageType::RegionType RegionType; typedef typename ImageType::RegionType RegionType;
typedef typename ImageType::PointType PointType;
typedef std::pair<unsigned long, unsigned long> RecordType; typedef std::pair<unsigned long, unsigned long> RecordType;
typedef std::vector<RecordType> LinesRecordVectorType; typedef std::vector<RecordType> LinesRecordVectorType;
...@@ -82,7 +83,8 @@ public: ...@@ -82,7 +83,8 @@ public:
// Setter // Setter
void SetSLCImageKeyWorList(ImageKeywordlist sarImageKWL); void SetSLCImageKeyWorList(ImageKeywordlist sarImageKWL);
bool getDeburstLinesAndSamples(LinesRecordVectorType & linesRecord, LinesRecordVectorType & samplesRecord); bool getDeburstLinesAndSamples(LinesRecordVectorType & linesRecord, LinesRecordVectorType & samplesRecord,
unsigned int first_burstInd, bool inputWithInvalidPixels);
protected: protected:
/** Constructor */ /** Constructor */
...@@ -104,6 +106,8 @@ private: ...@@ -104,6 +106,8 @@ private:
// Deburst SLC KeywordList // Deburst SLC KeywordList
ImageKeywordlist m_DeburstSLCImageKWL; ImageKeywordlist m_DeburstSLCImageKWL;
unsigned int m_Offset_OriginL;
}; };
} // end namespace itk } // end namespace itk
......
...@@ -38,7 +38,8 @@ SarConcatenateBurstsImageFilter<TImage> ...@@ -38,7 +38,8 @@ SarConcatenateBurstsImageFilter<TImage>
template <class TImage> template <class TImage>
bool bool
SarConcatenateBurstsImageFilter<TImage> SarConcatenateBurstsImageFilter<TImage>
::getDeburstLinesAndSamples(LinesRecordVectorType & linesRecord, LinesRecordVectorType & samplesRecord) ::getDeburstLinesAndSamples(LinesRecordVectorType & linesRecord, LinesRecordVectorType & samplesRecord,
unsigned int first_burstInd, bool inputWithInvalidPixels)
{ {
// Try to create a SarSensorModelAdapter // Try to create a SarSensorModelAdapter
SarSensorModelAdapter::Pointer sarSensorModel = SarSensorModelAdapter::New(); SarSensorModelAdapter::Pointer sarSensorModel = SarSensorModelAdapter::New();
...@@ -47,9 +48,13 @@ SarConcatenateBurstsImageFilter<TImage> ...@@ -47,9 +48,13 @@ SarConcatenateBurstsImageFilter<TImage>
if(!loadOk || !sarSensorModel->IsValidSensorModel()) if(!loadOk || !sarSensorModel->IsValidSensorModel())
itkExceptionMacro(<<"Input image does not contain a valid SAR sensor model."); itkExceptionMacro(<<"Input image does not contain a valid SAR sensor model.");
LinesRecordVectorType lines;
// Try to call the deburstAndConcatenate function // Try to call the deburstAndConcatenate function
bool deburstAndConcatenateOk = sarSensorModel->DeburstAndConcatenate(linesRecord, samplesRecord); bool deburstAndConcatenateOk = sarSensorModel->DeburstAndConcatenate(linesRecord, samplesRecord,
m_Offset_OriginL, first_burstInd,
inputWithInvalidPixels);
if(!deburstAndConcatenateOk) if(!deburstAndConcatenateOk)
itkExceptionMacro(<<"Could not deburst or concatenate from input bursts"); itkExceptionMacro(<<"Could not deburst or concatenate from input bursts");
...@@ -71,9 +76,16 @@ SarConcatenateBurstsImageFilter<TImage> ...@@ -71,9 +76,16 @@ SarConcatenateBurstsImageFilter<TImage>
// First, call superclass implementation // First, call superclass implementation
Superclass::GenerateOutputInformation(); Superclass::GenerateOutputInformation();
// Output KeywordList
ImageType * outputPtr = this->GetOutput(); ImageType * outputPtr = this->GetOutput();
// Origin to (0.5, 0.5) : Metadata are already adjusted
PointType origin;
origin[0] = 0.5;
origin[1] = 0.5 + m_Offset_OriginL;
outputPtr->SetOrigin(origin);
// Output KeywordList
m_DeburstSLCImageKWL.AddKey("support_data.number_samples", std::to_string(this->GetOutput()-> m_DeburstSLCImageKWL.AddKey("support_data.number_samples", std::to_string(this->GetOutput()->
GetLargestPossibleRegion(). GetLargestPossibleRegion().
GetSize()[0])); GetSize()[0]));
......
...@@ -351,7 +351,9 @@ public: ...@@ -351,7 +351,9 @@ public:
* \param lines A Boolean to indicate only valids samples are required. * \param lines A Boolean to indicate only valids samples are required.
*/ */
bool deburstAndConcatenate(std::vector<std::pair<unsigned long,unsigned long> >& linesBursts, bool deburstAndConcatenate(std::vector<std::pair<unsigned long,unsigned long> >& linesBursts,
std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts); std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts,
unsigned int & linesOffset, unsigned int first_burstInd,
bool inputWithInvalidPixels=false);
/** /**
* Returns pointer to a new instance, copy of this. * Returns pointer to a new instance, copy of this.
......
...@@ -1728,7 +1728,9 @@ ossimSarSensorModel::burstExtraction(const unsigned int burst_index, ...@@ -1728,7 +1728,9 @@ ossimSarSensorModel::burstExtraction(const unsigned int burst_index,
bool bool
ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,unsigned long> >& linesBursts, ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,unsigned long> >& linesBursts,
std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts) std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts,
unsigned int & linesOffset, unsigned int first_burstInd,
bool inputWithInvalidPixels)
{ {
if(theBurstRecords.empty()) if(theBurstRecords.empty())
return false; return false;
...@@ -1865,7 +1867,20 @@ ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,u ...@@ -1865,7 +1867,20 @@ ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,u
for(; itBursts!= theBurstRecords.end() ;++itBursts) for(; itBursts!= theBurstRecords.end() ;++itBursts)
{ {
unsigned long currentStart_L = halfLineOverlapBegin[counter]; unsigned long currentStart_L = halfLineOverlapBegin[counter];
if (inputWithInvalidPixels)
{
currentStart_L = itBursts->startLine - counter*theNumberOfLinesPerBurst +
halfLineOverlapBegin[counter];
}
unsigned long currentStop_L = itBursts->endLine - itBursts->startLine - halfLineOverlapEnd[counter]; unsigned long currentStop_L = itBursts->endLine - itBursts->startLine - halfLineOverlapEnd[counter];
if (inputWithInvalidPixels)
{
currentStop_L = itBursts->endLine - counter*theNumberOfLinesPerBurst - halfLineOverlapEnd[counter];
}
linesBursts.push_back(std::make_pair(currentStart_L, currentStop_L)); linesBursts.push_back(std::make_pair(currentStart_L, currentStop_L));
unsigned long currentStart_S = 0; unsigned long currentStart_S = 0;
...@@ -1875,6 +1890,11 @@ ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,u ...@@ -1875,6 +1890,11 @@ ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,u
{ {
currentStart_S = samples.first - itBursts->startSample; currentStart_S = samples.first - itBursts->startSample;
} }
if (inputWithInvalidPixels)
{
currentStart_S = samples.first;
}
currentStop_S += currentStart_S; currentStop_S += currentStart_S;
samplesBursts.push_back(std::make_pair(currentStart_S, currentStop_S)); samplesBursts.push_back(std::make_pair(currentStart_S, currentStop_S));
...@@ -1882,6 +1902,9 @@ ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,u ...@@ -1882,6 +1902,9 @@ ossimSarSensorModel::deburstAndConcatenate(std::vector<std::pair<unsigned long,u
++counter; ++counter;
} }
// Define linesOffset
linesOffset = (theBurstRecords[first_burstInd].azimuthStartTime - theBurstRecords[0].azimuthStartTime)/theAzimuthTimeInterval;
// Clear the previous burst records // Clear the previous burst records
theBurstRecords.clear(); theBurstRecords.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment