Skip to content
Snippets Groups Projects
Commit 356a24b3 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Adding small stuffs: progress reporting, mean baseline ratio estimation ...

parent 20f4307d
Branches
Tags
No related merge requests found
...@@ -93,6 +93,9 @@ public: ...@@ -93,6 +93,9 @@ public:
/** Get the size of the rectified image */ /** Get the size of the rectified image */
itkGetConstReferenceMacro(RectifiedImageSize,SizeType); itkGetConstReferenceMacro(RectifiedImageSize,SizeType);
/** Get the estimated mean baseline ratio */
itkGetConstReferenceMacro(MeanBaselineRatio,double);
/** Return the left deformation field (const version) */ /** Return the left deformation field (const version) */
const OutputImageType * GetLeftDeformationFieldOutput() const; const OutputImageType * GetLeftDeformationFieldOutput() const;
...@@ -115,6 +118,9 @@ protected: ...@@ -115,6 +118,9 @@ protected:
/** Generate output images information */ /** Generate output images information */
virtual void GenerateOutputInformation(); virtual void GenerateOutputInformation();
/** Enlarge output requested region (no streaming) */
virtual void EnlargeOutputRequestedRegion(itk::DataObject * itkNotUsed(output));
/** Compute the deformation field */ /** Compute the deformation field */
virtual void GenerateData(); virtual void GenerateData();
...@@ -159,6 +165,10 @@ private: ...@@ -159,6 +165,10 @@ private:
/** Output origin in left image (internal use) */ /** Output origin in left image (internal use) */
TDPointType m_OutputOriginInLeftImage; TDPointType m_OutputOriginInLeftImage;
/** This variable contains the estimated mean baseline ratio over
* the image */
double m_MeanBaselineRatio;
}; };
} // End namespace otb } // End namespace otb
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define __otbStereoSensorModelToElevationMapFilter_txx #define __otbStereoSensorModelToElevationMapFilter_txx
#include "otbStereorectificationDeformationFieldSource.h" #include "otbStereorectificationDeformationFieldSource.h"
#include "itkProgressReporter.h"
namespace otb namespace otb
{ {
...@@ -34,7 +35,8 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> ...@@ -34,7 +35,8 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
m_RightImage(), m_RightImage(),
m_LeftToRightTransform(), m_LeftToRightTransform(),
m_RightToLeftTransform(), m_RightToLeftTransform(),
m_OutputOriginInLeftImage() m_OutputOriginInLeftImage(),
m_MeanBaselineRatio(0)
{ {
// Set the number of outputs to 2 (one deformation field for each // Set the number of outputs to 2 (one deformation field for each
// image) // image)
...@@ -207,8 +209,16 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> ...@@ -207,8 +209,16 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
// Now, we can compute the origin of the epipolar images in the left // Now, we can compute the origin of the epipolar images in the left
// input image geometry (we rotate back) // input image geometry (we rotate back)
m_OutputOriginInLeftImage[0] = leftInputOrigin[0] + ux * minx + vx * miny; itk::ContinuousIndex<double,2> outputOriginCIndexInLeftImage;
m_OutputOriginInLeftImage[1] = leftInputOrigin[1] + uy * minx + vy * miny; outputOriginCIndexInLeftImage[0] = leftInputOrigin[0] + ux * minx + vx * miny;
outputOriginCIndexInLeftImage[1] = leftInputOrigin[1] + uy * minx + vy * miny;
PointType tmpPointForConversion;
m_LeftImage->TransformContinuousIndexToPhysicalPoint(outputOriginCIndexInLeftImage, tmpPointForConversion);
m_OutputOriginInLeftImage[0] = tmpPointForConversion[0];
m_OutputOriginInLeftImage[1] = tmpPointForConversion[1];
m_OutputOriginInLeftImage[2] = m_AverageElevation; m_OutputOriginInLeftImage[2] = m_AverageElevation;
// And also the size of the deformation field // And also the size of the deformation field
...@@ -228,6 +238,20 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> ...@@ -228,6 +238,20 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
rightDFPtr->SetSpacing(outputSpacing); rightDFPtr->SetSpacing(outputSpacing);
} }
template <class TInputImage, class TOutputImage>
void
StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
::EnlargeOutputRequestedRegion(itk::DataObject *)
{
// Retrieve the deformation field pointers
OutputImageType * leftDFPtr = this->GetLeftDeformationFieldOutput();
OutputImageType * rightDFPtr = this->GetLeftDeformationFieldOutput();
// Prevent from streaming
leftDFPtr->SetRequestedRegionToLargestPossibleRegion();
rightDFPtr->SetRequestedRegionToLargestPossibleRegion();
}
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
void void
StereorectificationDeformationFieldSource<TInputImage, TOutputImage> StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
...@@ -257,6 +281,13 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> ...@@ -257,6 +281,13 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
it1.GoToBegin(); it1.GoToBegin();
it2.GoToBegin(); it2.GoToBegin();
// Reset the mean baseline ratio
m_MeanBaselineRatio = 0;
// Set-up progress reporting
itk::ProgressReporter progress(this, 0, leftDFPtr->GetBufferedRegion().GetNumberOfPixels());
// We loop on the deformation fields // We loop on the deformation fields
while(!it1.IsAtEnd() && !it2.IsAtEnd()) while(!it1.IsAtEnd() && !it2.IsAtEnd())
...@@ -308,6 +339,15 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> ...@@ -308,6 +339,15 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
// of epiPoint2 at a higher elevation (using the offset) // of epiPoint2 at a higher elevation (using the offset)
epiPoint2[2] = m_AverageElevation + m_ElevationOffset; epiPoint2[2] = m_AverageElevation + m_ElevationOffset;
endLine1 = m_LeftToRightTransform->TransformPoint(epiPoint2); endLine1 = m_LeftToRightTransform->TransformPoint(epiPoint2);
// Estimate the local baseline ratio
double localBaselineRatio = ((endLine1[0] - startLine1[0])
* (endLine1[0] - startLine1[0])
+ (endLine1[1] - startLine1[1])
* (endLine1[1] - startLine1[1]))
/ 2*m_AverageElevation;
m_MeanBaselineRatio+=localBaselineRatio;
// Now, we can compute the equation of the epipolar line y = a*x+b // Now, we can compute the equation of the epipolar line y = a*x+b
// (do not forget that the y axis is flip in our case) // (do not forget that the y axis is flip in our case)
...@@ -392,8 +432,13 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> ...@@ -392,8 +432,13 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
// Last, we move forward // Last, we move forward
++it1; ++it1;
++it2; ++it2;
// Update progress
progress.CompletedPixel();
} }
// Compute the mean baseline ratio
m_MeanBaselineRatio /= leftDFPtr->GetBufferedRegion().GetNumberOfPixels();
} }
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
...@@ -401,7 +446,8 @@ void ...@@ -401,7 +446,8 @@ void
StereorectificationDeformationFieldSource<TInputImage, TOutputImage> StereorectificationDeformationFieldSource<TInputImage, TOutputImage>
::PrintSelf( std::ostream& os, itk::Indent indent ) const ::PrintSelf( std::ostream& os, itk::Indent indent ) const
{ {
// Call superclass implementation
Superclass::PrintSelf(os,indent);
} }
} // end namespace otb } // end namespace otb
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment