Skip to content
Snippets Groups Projects
Commit b0a4d2d9 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

BUG: Mantis 936: fix physical space checking for SubPixelDisparityFilter when...

BUG: Mantis 936: fix physical space checking for SubPixelDisparityFilter when a sub-sampled disparity map is used
parent e13f9924
No related branches found
No related tags found
No related merge requests found
......@@ -207,6 +207,13 @@ protected:
/** Destructor */
virtual ~SubPixelDisparityImageFilter();
/** \brief Verify that the input images are compatible
*
* This method needs to be re-implemented from ImageToImageFilter since
* the initial images and disparity maps may not have the same size
*/
virtual void VerifyInputInformation();
/** Generate output information */
virtual void GenerateOutputInformation();
......
......@@ -357,21 +357,73 @@ class TDisparityImage, class TMaskImage, class TBlockMatchingFunctor>
void
SubPixelDisparityImageFilter<TInputImage,TOutputMetricImage,
TDisparityImage,TMaskImage,TBlockMatchingFunctor>
::GenerateOutputInformation()
::VerifyInputInformation()
{
// Retrieve input pointers
const TInputImage * inLeftPtr = this->GetLeftInput();
const TDisparityImage * inHDispPtr = this->GetHorizontalDisparityInput();
const TInputImage * inLeftPtr = this->GetLeftInput();
const TInputImage * inRightPtr = this->GetRightInput();
const TMaskImage * inLeftMaskPtr = this->GetLeftMaskInput();
const TMaskImage * inRightMaskPtr = this->GetRightMaskInput();
const TDisparityImage * inHDispPtr = this->GetHorizontalDisparityInput();
const TDisparityImage * inVDispPtr = this->GetVerticalDisparityInput();
TOutputMetricImage * outMetricPtr = this->GetMetricOutput();
TDisparityImage * outHDispPtr = this->GetHorizontalDisparityOutput();
TDisparityImage * outVDispPtr = this->GetVerticalDisparityOutput();
const TOutputMetricImage * outMetricPtr = this->GetMetricOutput();
const TDisparityImage * outHDispPtr = this->GetHorizontalDisparityOutput();
const TDisparityImage * outVDispPtr = this->GetVerticalDisparityOutput();
// Check pointers before using them
if(!inLeftPtr || !inRightPtr)
{
itkExceptionMacro(<<"Missing input, need left and right input images.");
}
if (!inHDispPtr)
{
itkExceptionMacro(<<"Input horizontal disparity map is missing");
}
// Now, we impose that both inputs have the same size
if(inLeftPtr->GetLargestPossibleRegion()
!= inRightPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Left and right images do not have the same size ! Left largest region: "<<inLeftPtr->GetLargestPossibleRegion()<<", right largest region: "<<inRightPtr->GetLargestPossibleRegion());
}
// We also check that left mask image has same size if present
if(inLeftMaskPtr && inLeftPtr->GetLargestPossibleRegion() != inLeftMaskPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Left and mask images do not have the same size ! Left largest region: "<<inLeftPtr->GetLargestPossibleRegion()<<", mask largest region: "<<inLeftMaskPtr->GetLargestPossibleRegion());
}
// We also check that right mask image has same size if present
if(inRightMaskPtr && inRightPtr->GetLargestPossibleRegion() != inRightMaskPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Right and mask images do not have the same size ! Right largest region: "<<inRightPtr->GetLargestPossibleRegion()<<", mask largest region: "<<inRightMaskPtr->GetLargestPossibleRegion());
}
// We check that the input initial disparity maps have the same size if present
if (inHDispPtr && inVDispPtr && inHDispPtr->GetLargestPossibleRegion() != inVDispPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Initial horizontal and vertical disparity maps don't have the same size ! Horizontal disparity largest region: "<<inHDispPtr->GetLargestPossibleRegion()<<", vertical disparity largest region: "<<inVDispPtr->GetLargestPossibleRegion());
}
}
template <class TInputImage, class TOutputMetricImage,
class TDisparityImage, class TMaskImage, class TBlockMatchingFunctor>
void
SubPixelDisparityImageFilter<TInputImage,TOutputMetricImage,
TDisparityImage,TMaskImage,TBlockMatchingFunctor>
::GenerateOutputInformation()
{
// Retrieve input pointers
const TInputImage * inLeftPtr = this->GetLeftInput();
const TDisparityImage * inHDispPtr = this->GetHorizontalDisparityInput();
TOutputMetricImage * outMetricPtr = this->GetMetricOutput();
TDisparityImage * outHDispPtr = this->GetHorizontalDisparityOutput();
TDisparityImage * outVDispPtr = this->GetVerticalDisparityOutput();
outMetricPtr->CopyInformation(inHDispPtr);
outHDispPtr->CopyInformation(inHDispPtr);
outVDispPtr->CopyInformation(inHDispPtr);
......@@ -419,38 +471,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor>
TOutputMetricImage * outMetricPtr = this->GetMetricOutput();
TDisparityImage * outHDispPtr = this->GetHorizontalDisparityOutput();
TDisparityImage * outVDispPtr = this->GetVerticalDisparityOutput();
// Check pointers before using them
if(!inLeftPtr || !inRightPtr || !outMetricPtr || !outHDispPtr || !outVDispPtr)
{
return;
}
// Now, we impose that both inputs have the same size
if(inLeftPtr->GetLargestPossibleRegion()
!= inRightPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Left and right images do not have the same size ! Left largest region: "<<inLeftPtr->GetLargestPossibleRegion()<<", right largest region: "<<inRightPtr->GetLargestPossibleRegion());
}
// We also check that left mask image has same size if present
if(inLeftMaskPtr && inLeftPtr->GetLargestPossibleRegion() != inLeftMaskPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Left and mask images do not have the same size ! Left largest region: "<<inLeftPtr->GetLargestPossibleRegion()<<", mask largest region: "<<inLeftMaskPtr->GetLargestPossibleRegion());
}
// We also check that right mask image has same size if present
if(inRightMaskPtr && inRightPtr->GetLargestPossibleRegion() != inRightMaskPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Right and mask images do not have the same size ! Right largest region: "<<inRightPtr->GetLargestPossibleRegion()<<", mask largest region: "<<inRightMaskPtr->GetLargestPossibleRegion());
}
// We check that the input initial disparity maps have the same size if present
if (inHDispPtr && inVDispPtr && inHDispPtr->GetLargestPossibleRegion() != inVDispPtr->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Initial horizontal and vertical disparity maps don't have the same size ! Horizontal disparity largest region: "<<inHDispPtr->GetLargestPossibleRegion()<<", vertical disparity largest region: "<<inVDispPtr->GetLargestPossibleRegion());
}
// Retrieve requested region (TODO: check if we need to handle
// region for outHDispPtr)
RegionType outputRequestedRegion = outHDispPtr->GetRequestedRegion();
......
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