diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 722facc4be7252f76d01fd6c69329e98e847a603..f96615cc11cc4634991727f00fedd2c4d2533126 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -87,7 +87,7 @@ public: /** Burst extraction and return lines/samples to keep into image file (the required burst) */ bool BurstExtraction(const unsigned int burst_index, std::pair<unsigned long,unsigned long> & lines, - std::pair<unsigned long,unsigned long> & samples); + std::pair<unsigned long,unsigned long> & samples, bool allPixels=false); /** Deburst metadata if possible and prepare the burst concatenation */ diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index 3a2fc9f40d685c93c88ce50667e6aed56a74e02b..35517a83805cc9eb4f29dc8d2b629905f247d874 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -103,11 +103,11 @@ bool SarSensorModelAdapter::Deburst(std::vector<std::pair<unsigned long, unsigne bool SarSensorModelAdapter::BurstExtraction(const unsigned int burst_index, std::pair<unsigned long,unsigned long> & lines, - std::pair<unsigned long,unsigned long> & samples) + std::pair<unsigned long,unsigned long> & samples, bool allPixels) { if(m_SensorModel.get()) { - return m_SensorModel->burstExtraction(burst_index, lines, samples); + return m_SensorModel->burstExtraction(burst_index, lines, samples, allPixels); } return false; diff --git a/Modules/Applications/AppSARCalibration/app/otbSARBurstExtraction.cxx b/Modules/Applications/AppSARCalibration/app/otbSARBurstExtraction.cxx index b92fa4568413c721712c66a32391a7eae617b180..36082b796fe59fa58e353cc0ad057c2280f99fb1 100644 --- a/Modules/Applications/AppSARCalibration/app/otbSARBurstExtraction.cxx +++ b/Modules/Applications/AppSARCalibration/app/otbSARBurstExtraction.cxx @@ -59,7 +59,10 @@ private: "Note that the output sensor model is updated accordingly. This burst" " extraction is the perfect preprocessing step for S1 IW SLC" " product with OTB without suffering from artifacts caused by" - " bursts separation."); + " bursts separation\n." + + "Two modes are available for the output image : with all pixels and" + "with only valid pixels "); SetDocLimitations("Only Sentinel1 IW SLC products are supported for now. Processing of" " other Sentinel1 modes or TerrasarX images will result in no changes in" @@ -90,6 +93,9 @@ private: "burst) between the prefix and the extension, such as: outimage_Burst0.tif and " "outimage_Burst1.tif (if 2 bursts)."); + AddParameter(ParameterType_Bool, "allpixels", "Select the modes for output image"); + SetParameterDescription("allpixels", "If true, all pixels of the current burst are selected."); + AddRAMParameter(); SetDocExampleParameterValue("in","s1_iw_slc.tif"); @@ -122,6 +128,11 @@ private: m_BurstExtractionFilter = BurstExtractionFilterType::New(); m_BurstExtractionFilter->SetInput(in); + if (IsParameterEnabled("allpixels")) + { + m_BurstExtractionFilter->SetAllPixels(true); + } + // Get the number of Bursts unsigned int nbBursts = 1; try diff --git a/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.h b/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.h index 3d3c5a5f16997abe31c1fd3337ff9758bb1ffb53..420870e469a40ad3516fb25131ce9f4c902abc9c 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.h @@ -67,7 +67,8 @@ public: // Setter itkSetMacro(BurstIndex, unsigned int); - + itkSetMacro(AllPixels, bool); + protected: // Constructor SarBurstExtractionImageFilter(); @@ -96,9 +97,13 @@ private: // Pair for sample valid selection RecordType m_SamplesRecord; + // Burst index unsigned int m_BurstIndex; - + // Mode for extraction : + // If true : all pixels of the burst are selected + // If false : only valid pixels are selected + bool m_AllPixels; }; } // End namespace otb diff --git a/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.hxx b/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.hxx index 8c077a2e2d9467ee6a0bc8ca5901ecd24883a216..a2d4f2df5bc324650762bf83975049f30f91a18c 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.hxx +++ b/Modules/Radiometry/SARCalibration/include/otbSarBurstExtractionImageFilter.hxx @@ -34,7 +34,7 @@ namespace otb { // Constructor template <class TImage> SarBurstExtractionImageFilter<TImage>::SarBurstExtractionImageFilter() - : m_LinesRecord(), m_SamplesRecord(), m_BurstIndex(0) + : m_LinesRecord(), m_SamplesRecord(), m_BurstIndex(0), m_AllPixels(false) {} // Needs to be re-implemented since size of output is modified @@ -68,7 +68,8 @@ SarBurstExtractionImageFilter<TImage>::GenerateOutputInformation() itkExceptionMacro(<<"Input image does not contain a valid SAR sensor model."); // Try to call the burst extraction function - bool burstExtractionOk = sarSensorModel->BurstExtraction(m_BurstIndex, m_LinesRecord, m_SamplesRecord); + bool burstExtractionOk = sarSensorModel->BurstExtraction(m_BurstIndex, m_LinesRecord, m_SamplesRecord, + m_AllPixels); if(!burstExtractionOk) itkExceptionMacro(<<"Could not etract Burst from input image"); diff --git a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h index 8a989dec78fa132f3f20376748f13797b8edfec0..8cd2881e0e1fd1b6794ceb44a8562b68aa25a0ce 100644 --- a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h +++ b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h @@ -333,7 +333,7 @@ public: * standalone burst. */ bool burstExtraction(const unsigned int burst_index, std::pair<unsigned long,unsigned long> & lines, - std::pair<unsigned long,unsigned long> & samples); + std::pair<unsigned long,unsigned long> & samples, bool allPixels=false); /** * This method will perform a deburst and concatenation operation, and return the @@ -495,6 +495,9 @@ protected: TimeType theFirstLineTime; TimeType theLastLineTime; + unsigned long theNumberOfLinesPerBurst; + unsigned long theNumberOfSamplesPerBurst; + bool redaptMedataAfterDeburst; static const double C; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp index ce8e20dfae001cd18df9e4f42912290ea499df05..426ea68004ad1a3b3a911da5c5b665ec3eccbda3 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp @@ -1395,17 +1395,26 @@ bool ossimSarSensorModel::worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeT get(kwl, SUPPORT_DATA_PREFIX, "radar_frequency" , theRadarFrequency ); double azimuthTimeInterval = 0.; // in seconds get(kwl, SUPPORT_DATA_PREFIX, "line_time_interval" , azimuthTimeInterval); + #if defined(USE_BOOST_TIME) theAzimuthTimeInterval = boost::posix_time::precise_duration(azimuthTimeInterval * 1000000.); #else theAzimuthTimeInterval = seconds(azimuthTimeInterval); #endif - get(kwl, theOrbitRecords); // TODO: don't fetch burst records if already read thanks to xml loading // that required them theBurstRecords.clear(); get(kwl, theBurstRecords); + + if(theBurstRecords.size() > 1) + { + const std::string BURST_NUMBER_LINES_KEY = "support_data.geom.bursts.number_lines_per_burst"; + const std::string BURST_NUMBER_SAMPLES_KEY = "support_data.geom.bursts.number_samples_per_burst"; + get(kwl, BURST_NUMBER_LINES_KEY, theNumberOfLinesPerBurst); + get(kwl, BURST_NUMBER_SAMPLES_KEY, theNumberOfSamplesPerBurst); + } + if (isGRD()) { get(kwl, SR_PREFIX, keySr0, theSlantRangeToGroundRangeRecords); @@ -1598,7 +1607,7 @@ bool ossimSarSensorModel::deburst(std::vector<std::pair<unsigned long, unsigned bool ossimSarSensorModel::burstExtraction(const unsigned int burst_index, std::pair<unsigned long,unsigned long> & lines, - std::pair<unsigned long,unsigned long> & samples) + std::pair<unsigned long,unsigned long> & samples, bool allPixels) { if(theBurstRecords.empty()) return false; @@ -1610,27 +1619,59 @@ ossimSarSensorModel::burstExtraction(const unsigned int burst_index, return false; } - // Retrieve into TheBurstRecord, the required index - BurstRecordType burstInd_Record = theBurstRecords[burst_index]; - lines = std::make_pair(burstInd_Record.startLine, burstInd_Record.endLine); - samples = std::make_pair(burstInd_Record.startSample, burstInd_Record.endSample); - TimeType burstAzimuthStartTime = burstInd_Record.azimuthStartTime; - TimeType burstAzimuthStopTime = burstInd_Record.azimuthStopTime; - - // Clear the previous burst records - theBurstRecords.clear(); - - // Create the single burst - BurstRecordType oneBurst; - oneBurst.startLine = 0; - oneBurst.azimuthStartTime = burstAzimuthStartTime; - oneBurst.endLine = lines.second - lines.first; - oneBurst.azimuthStopTime = burstAzimuthStopTime; - oneBurst.startSample = 0; - oneBurst.endSample = samples.second - samples.first; + // If all pixels is required + if (allPixels) + { + samples = std::make_pair(0, theNumberOfSamplesPerBurst - 1); + lines = std::make_pair(burst_index*theNumberOfLinesPerBurst, (burst_index+1)*theNumberOfLinesPerBurst - 1); + + redaptMedataAfterDeburst = true; + theFirstLineTime = theBurstRecords[burst_index].azimuthStartTime - (theBurstRecords[burst_index].startLine - lines.first) * theAzimuthTimeInterval; + theLastLineTime = theFirstLineTime + (lines.second - lines.first) * theAzimuthTimeInterval; + + // Clear the previous burst records + theBurstRecords.clear(); + + // Create the single burst + BurstRecordType oneBurst; + oneBurst.startLine = 0; + oneBurst.azimuthStartTime = theFirstLineTime; + oneBurst.endLine = lines.second - lines.first; + oneBurst.azimuthStopTime = theLastLineTime; + oneBurst.startSample = 0; + oneBurst.endSample = samples.second - samples.first; + + theBurstRecords.push_back(oneBurst); + } + else + { + // Retrieve into TheBurstRecord, the required index + BurstRecordType burstInd_Record = theBurstRecords[burst_index]; + lines = std::make_pair(burstInd_Record.startLine, burstInd_Record.endLine); + samples = std::make_pair(burstInd_Record.startSample, burstInd_Record.endSample); + TimeType burstAzimuthStartTime = burstInd_Record.azimuthStartTime; + TimeType burstAzimuthStopTime = burstInd_Record.azimuthStopTime; + + // Clear the previous burst records + theBurstRecords.clear(); + + // Create the single burst + BurstRecordType oneBurst; + oneBurst.startLine = 0; + oneBurst.azimuthStartTime = burstAzimuthStartTime; + oneBurst.endLine = lines.second - lines.first; + oneBurst.azimuthStopTime = burstAzimuthStopTime; + oneBurst.startSample = 0; + oneBurst.endSample = samples.second - samples.first; - theBurstRecords.push_back(oneBurst); + theBurstRecords.push_back(oneBurst); + // Adapt general metadata : theNearRangeTime, first_time_line, last_time_line + redaptMedataAfterDeburst = true; + theFirstLineTime = oneBurst.azimuthStartTime; + theLastLineTime = oneBurst.azimuthStopTime; + theNearRangeTime += samples.first*(1/theRangeSamplingRate); + } std::vector<GCPRecordType> oneBurstGCPs; @@ -1676,12 +1717,6 @@ ossimSarSensorModel::burstExtraction(const unsigned int burst_index, theGCPRecords.swap(oneBurstGCPs); - // Adapt general metadata : theNearRangeTime, first_time_line, last_time_line - redaptMedataAfterDeburst = true; - theFirstLineTime = oneBurst.azimuthStartTime; - theLastLineTime = oneBurst.azimuthStopTime; - theNearRangeTime += samples.first*(1/theRangeSamplingRate); - return true; }