From 3a971e3ada7d5ca7ed79a36c74f0f6fc08294eba Mon Sep 17 00:00:00 2001 From: OTB Bot <otbbot@orfeo-toolbox.org> Date: Tue, 27 Mar 2012 19:56:07 +0200 Subject: [PATCH] STYLE --- .../otbPixelWiseBlockMatchingImageFilter.h | 24 +++---- .../otbPixelWiseBlockMatchingImageFilter.txx | 64 +++++++++---------- .../otbSubPixelDisparityImageFilter.h | 20 +++--- .../otbSubPixelDisparityImageFilter.txx | 19 +++--- 4 files changed, 63 insertions(+), 64 deletions(-) diff --git a/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.h b/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.h index 10422ebcc8..0674370dff 100644 --- a/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.h +++ b/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.h @@ -178,9 +178,9 @@ private: * between a pair of image. This is especially useful in the case of * stereo pairs in epipolar geometry, where displacements * corresponding to differences of elevation occur in the horizontal - * direction only (in that case, the exploration along the vertical - * direction can be disabled). Please note that only integer pixel - * displacement are explored. For finer results, consider up-sampling + * direction only (in that case, the exploration along the vertical + * direction can be disabled). Please note that only integer pixel + * displacement are explored. For finer results, consider up-sampling * the input images or use the SubPixelDisparityImageFilter. * * The block-matching metric itself is defined by a template functor @@ -194,13 +194,13 @@ private: * * Only a user defined area of disparities between the two images is * explored, which can be set by using the SetMinimumHorizontalDisparity() - * , SetMinimumVerticalDisparity(), SetMaximumHorizontalDisparity() + * , SetMinimumVerticalDisparity(), SetMaximumHorizontalDisparity() * and SetMaximumVerticalDisparity() methods. * - * This filter has three outputs: the first is the metric image, - * which contains the metric optimum value corresponding to the - * estimated displacement. The second and last outputs are the - * horizontal and vertical disparity maps, which can be retrieved + * This filter has three outputs: the first is the metric image, + * which contains the metric optimum value corresponding to the + * estimated displacement. The second and last outputs are the + * horizontal and vertical disparity maps, which can be retrieved * using the GetHorizontalDisparityOutput() and GetVerticalDisparityOutput() * methods. They contain the horizontal and vertical local displacement * between the two input images (displacement is given in pixels, from left @@ -209,14 +209,14 @@ private: * Masks are not mandatory. A mask allows to indicate pixels validity in * either left or right image. Left and right masks can be used independently. * If masks are used, only pixels whose mask values are strictly positive - * will be considered for disparity matching. The other will exhibit a null + * will be considered for disparity matching. The other will exhibit a null * metric value and a disparity corresponding to the minimum allowed * disparity. * * The disparity exploration can also be reduced thanks to initial disparity * maps. The user can provide initial disparity estimate (using the same image * type and size as the output disparities), or global disparity values. Then - * an exploration radius indicates the disparity range to be explored around + * an exploration radius indicates the disparity range to be explored around * the initial estimate (global minimum and maximum values are still in use). * * \sa FineRegistrationImageFilter @@ -401,11 +401,11 @@ private: /** Block-matching functor */ BlockMatchingFunctorType m_Functor; - /** Initial horizontal disparity (0 by default, used if an exploration radius is set and if no input horizontal + /** Initial horizontal disparity (0 by default, used if an exploration radius is set and if no input horizontal disparity map is given) */ int m_InitHorizontalDisparity; - /** Initial vertical disparity (0 by default, used if an exploration radius is set and if no input vertical + /** Initial vertical disparity (0 by default, used if an exploration radius is set and if no input vertical disparity map is given) */ int m_InitVerticalDisparity; }; diff --git a/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.txx b/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.txx index 1bceba04f1..9d86b2c852 100644 --- a/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.txx +++ b/Code/DisparityMap/otbPixelWiseBlockMatchingImageFilter.txx @@ -685,28 +685,28 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> // itk::ImageRegionIterator<TOutputDisparityImage> outHDispIt(outHDispPtr,outputRegionForThread); // itk::ImageRegionIterator<TOutputDisparityImage> outVDispIt(outVDispPtr,outputRegionForThread); // itk::ImageRegionIterator<TOutputMetricImage> outMetricIt(outMetricPtr,outputRegionForThread); -// +// // itk::ConstantBoundaryCondition<TInputImage> nbc1; // leftIt.OverrideBoundaryCondition(&nbc1); -// +// // leftIt.GoToBegin(); // outHDispIt.GoToBegin(); // outVDispIt.GoToBegin(); // outMetricIt.GoToBegin(); -// +// // while (!leftIt.IsAtEnd() // || !outHDispIt.IsAtEnd() // || !outVDispIt.IsAtEnd() // || !outMetricIt.IsAtEnd()) // { // bool isInterpolated = InterpolateSubPixelPosition(leftIt,outHDispIt,outVDispIt,outMetricIt); -// +// // ++leftIt; // ++outHDispIt; // ++outVDispIt; // ++outMetricIt; // } -// +// // } } @@ -723,44 +723,44 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> // { // IndexType curLeftPos = leftPatch.GetIndex(); // SizeType curRadius = leftPatch.GetRadius(); -// +// // const TInputImage * inRightPtr = this->GetRightInput(); // RegionType rightLargestRegion = inRightPtr->GetLargestPossibleRegion(); -// +// // float hDisp_f = static_cast<float>(hDispIt.Get()); // float vDisp_f = static_cast<float>(vDispIt.Get()); -// +// // int hDisp_i = static_cast<int>(vcl_floor(hDisp_f + 0.5)); // int vDisp_i = static_cast<int>(vcl_floor(vDisp_f + 0.5)); -// +// // IndexType curRightPos(curLeftPos); // curRightPos[0]+=hDisp_i; // curRightPos[1]+=vDisp_i; -// +// // // check if the current right position is inside the right image // if (!rightLargestRegion.IsInside(curRightPos)) // { // return false; // } -// +// // // compute metric around current right position // bool horizontalInterpolation = false; // bool verticalInterpolation = false; -// +// // // metrics for neighbors positions, sorted like this : // // [up,up-right,right,down-right,down,down-left,left,up-left] // double neighborsMetric[8] = {0,0,0,0,0,0,0,0}; // int firstNeighbor = 0; // int stepNeighbor = 4; -// +// // RegionType smallRightRegion; // smallRightRegion.SetIndex(0,curRightPos[0]-1); // smallRightRegion.SetIndex(1,curRightPos[1]-1); // smallRightRegion.SetSize(0,3); // smallRightRegion.SetSize(1,3); -// +// // itk::ConstNeighborhoodIterator<TInputImage> rightIt(curRadius,inRightPtr,smallRightRegion); -// +// // if (m_MinimumVerticalDisparity < vDisp_i && vDisp_i < m_MaximumVerticalDisparity) // { // IndexType upIndex(curRightPos); @@ -770,16 +770,16 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> // if ( rightLargestRegion.IsInside(upIndex) && rightLargestRegion.IsInside(downIndex) ) // { // verticalInterpolation = true; -// +// // rightIt.SetLocation(upIndex); // neighborsMetric[0] = m_Functor(leftPatch,rightIt); -// +// // rightIt.SetLocation(downIndex); // neighborsMetric[4] = m_Functor(leftPatch,rightIt); -// +// // } // } -// +// // if (m_MinimumHorizontalDisparity < hDisp_i && hDisp_i < m_MaximumHorizontalDisparity) // { // IndexType leftIndex(curRightPos); @@ -790,52 +790,52 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> // { // horizontalInterpolation = true; // firstNeighbor = 2; -// +// // rightIt.SetLocation(rightIndex); // neighborsMetric[2] = m_Functor(leftPatch,rightIt); -// +// // rightIt.SetLocation(leftIndex); // neighborsMetric[6] = m_Functor(leftPatch,rightIt); -// +// // } // } -// +// // if ( !verticalInterpolation && !horizontalInterpolation) // { // return false; // } -// +// // // if both vertical and horizontal interpolation, compute metrics on corners // if (verticalInterpolation && horizontalInterpolation) // { // firstNeighbor = 0; // stepNeighbor = 1; -// +// // IndexType uprightIndex(curRightPos); // uprightIndex[0]+= 1; // uprightIndex[1]+= (-1); // rightIt.SetLocation(uprightIndex); // neighborsMetric[1] = m_Functor(leftPatch,rightIt); -// +// // IndexType downrightIndex(curRightPos); // downrightIndex[0]+= 1; // downrightIndex[1]+= 1; // rightIt.SetLocation(downrightIndex); // neighborsMetric[3] = m_Functor(leftPatch,rightIt); -// +// // IndexType downleftIndex(curRightPos); // downleftIndex[0]+= (-1); // downleftIndex[1]+= 1; // rightIt.SetLocation(downleftIndex); // neighborsMetric[5] = m_Functor(leftPatch,rightIt); -// +// // IndexType upleftIndex(curRightPos); // upleftIndex[0]+= (-1); // upleftIndex[1]+= (-1); // rightIt.SetLocation(upleftIndex); // neighborsMetric[7] = m_Functor(leftPatch,rightIt); // } -// +// // // check if the position is a minimum (or maximum if !m_Minimize) // double curMetric = metricIt.Get(); // for (unsigned int i=firstNeighbor; i<8; i+=stepNeighbor) @@ -855,8 +855,8 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> // } // } // } -// -// +// +// // // Interpolate position : parabola fit // if (verticalInterpolation && !horizontalInterpolation) // { @@ -912,7 +912,7 @@ TOutputDisparityImage,TMaskImage,TBlockMatchingFunctor> // } // } // } -// +// // return true; // } diff --git a/Code/DisparityMap/otbSubPixelDisparityImageFilter.h b/Code/DisparityMap/otbSubPixelDisparityImageFilter.h index a65e80aef9..20b7dbf530 100644 --- a/Code/DisparityMap/otbSubPixelDisparityImageFilter.h +++ b/Code/DisparityMap/otbSubPixelDisparityImageFilter.h @@ -31,22 +31,22 @@ namespace otb * * This filter is intended to be placed after a PixelWiseBlockMatchingImageFilter. Its role is to produce an estimate * of the disparities (both horizontal and vertical) with sub-pixel precision. The integer input disparities are used - * as starting points for the disparity refinement. The refinement is done within a 3x3 neighborhood around this - * position (it is neighborhood in the 2D disparity space). If no input disparity is given, the shift between + * as starting points for the disparity refinement. The refinement is done within a 3x3 neighborhood around this + * position (it is neighborhood in the 2D disparity space). If no input disparity is given, the shift between * input images is assumed to be null along both directions. * - * Left and right masks can be used to skip the sub-pixel disparity refinement for couples of pixels carrying a - * non-positive mask value. - * + * Left and right masks can be used to skip the sub-pixel disparity refinement for couples of pixels carrying a + * non-positive mask value. + * * The exploration limits for horizontal and vertical disparities can be set like in PixelWiseBlockMatchingFilter. * If the 3x3 neighborhood around the initial estimate is not inside the exploration area, refinement is skipped for * the current pixel. * - * Before trying to refine the integer disparity, the filter checks that the initial position is an extrema for the - * metric used. Depending on the 3x3 neighborhood, the refinement can be done along the horizontal axis only, along + * Before trying to refine the integer disparity, the filter checks that the initial position is an extrema for the + * metric used. Depending on the 3x3 neighborhood, the refinement can be done along the horizontal axis only, along * the vertical axis only, and also in 2D. Three refinement methods are proposed : parabolic, triangular and dichotomy. - * The parabolic method tries to fit a parabola to the metric scores on the 3x3 neighborhood. The triangular - * method tries to fit local scores to a circular cone. The dichotomy method tries to find the local extrema by + * The parabolic method tries to fit a parabola to the metric scores on the 3x3 neighborhood. The triangular + * method tries to fit local scores to a circular cone. The dichotomy method tries to find the local extrema by * a dichotomic search (non-integer disparity positions are tested after a resampling of the right image). * * \sa PixelWiseBlockMatchingImageFilter @@ -57,7 +57,7 @@ namespace otb * \ingroup Threaded * */ -template <class TInputImage, class TOutputMetricImage, class TDisparityImage = TOutputMetricImage, +template <class TInputImage, class TOutputMetricImage, class TDisparityImage = TOutputMetricImage, class TMaskImage = otb::Image<unsigned char>, class TBlockMatchingFunctor = Functor::SSDBlockMatching<TInputImage,TOutputMetricImage> > class ITK_EXPORT SubPixelDisparityImageFilter : diff --git a/Code/DisparityMap/otbSubPixelDisparityImageFilter.txx b/Code/DisparityMap/otbSubPixelDisparityImageFilter.txx index c1fa6fb116..cf9bfd9b0c 100644 --- a/Code/DisparityMap/otbSubPixelDisparityImageFilter.txx +++ b/Code/DisparityMap/otbSubPixelDisparityImageFilter.txx @@ -19,7 +19,6 @@ #define __otbSubPixelDisparityImageFilter_txx - namespace otb { template <class TInputImage, class TOutputMetricImage, @@ -794,7 +793,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> //vertical only double deltaV = 0.5 - (1.0 / (1.0 + (neighborsMetric[1][0]-neighborsMetric[1][1]) / (neighborsMetric[1][2]-neighborsMetric[1][1]))); - double interpMetric = neighborsMetric[1][1] - + double interpMetric = neighborsMetric[1][1] - (0.5 * (neighborsMetric[1][0]+neighborsMetric[1][2]) - neighborsMetric[1][1]) * deltaV * deltaV; if (deltaV > (-0.5) && deltaV < 0.5) { @@ -811,7 +810,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> // horizontal only double deltaH = 0.5 - (1.0 / (1.0 + (neighborsMetric[0][1]-neighborsMetric[1][1]) / (neighborsMetric[2][1]-neighborsMetric[1][1]))); - double interpMetric = neighborsMetric[1][1] - + double interpMetric = neighborsMetric[1][1] - (0.5 * (neighborsMetric[0][1]+neighborsMetric[2][1]) - neighborsMetric[1][1]) * deltaH * deltaH; if (deltaH > (-0.5) && deltaH < 0.5) { @@ -841,7 +840,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> { double deltaH = (-dx * dyy + dy * dxy )/det; double deltaV = ( dx * dxy - dy * dxx )/det; - double interpMetric = neighborsMetric[1][1] - + double interpMetric = neighborsMetric[1][1] - ( dxx * deltaH * deltaH + 2.0 * dxy * deltaH * deltaV + dyy * deltaV * deltaV); if (deltaH > (-1.0) && deltaH < 1.0 && deltaV > (-1.0) && deltaV < 1.0) { @@ -976,7 +975,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> bool horizontalInterpolation = false; bool verticalInterpolation = false; - // metrics for neighbors positions : first index is x, second is y + // metrics for neighbors positions : first index is x, second is y double neighborsMetric[3][3] = {{0,0,0},{0,0,0},{0,0,0}}; while (!leftIt.IsAtEnd() @@ -1054,7 +1053,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> rightIt.SetLocation(downIndex); neighborsMetric[1][2] = m_Functor(leftIt,rightIt); - // check that current position is an extrema + // check that current position is an extrema if (m_Minimize) { if (neighborsMetric[1][1] < neighborsMetric[1][0] && neighborsMetric[1][1] < neighborsMetric[1][2]) @@ -1079,14 +1078,14 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> IndexType rightIndex(curRightPos); rightIndex[0]+= 1; if ( rightBufferedRegion.IsInside(leftIndex) && rightBufferedRegion.IsInside(rightIndex) ) - { + { rightIt.SetLocation(rightIndex); neighborsMetric[2][1] = m_Functor(leftIt,rightIt); rightIt.SetLocation(leftIndex); neighborsMetric[0][1] = m_Functor(leftIt,rightIt); - // check that current position is an extrema + // check that current position is an extrema if (m_Minimize) { if (neighborsMetric[1][1] < neighborsMetric[0][1] && neighborsMetric[1][1] < neighborsMetric[2][1]) @@ -1243,7 +1242,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> { outVDispIt.Set( static_cast<double>(vDisp_i) + deltaV); outHDispIt.Set( static_cast<double>(hDisp_i) + deltaH); - outMetricIt.Set( interpMetricH*(vcl_abs(deltaH)/(vcl_abs(deltaV)+vcl_abs(deltaH))) + + outMetricIt.Set( interpMetricH*(vcl_abs(deltaH)/(vcl_abs(deltaV)+vcl_abs(deltaH))) + interpMetricV*(vcl_abs(deltaV)/(vcl_abs(deltaV)+vcl_abs(deltaH)))); } else @@ -1672,7 +1671,7 @@ TDisparityImage,TMaskImage,TBlockMatchingFunctor> offsetTransfo[1] = 0.0; - for (unsigned int k=0 ; k<nbIterMax ; k++) + for (unsigned int k=0; k<nbIterMax; k++) { if ( (xb-xa) < (xc-xb) ) { -- GitLab