Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
95d4fa59
Commit
95d4fa59
authored
12 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
ENH: JIRA 352: work on left-right disparity bijection
parent
b381722d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/DisparityMap/otbBijectionCoherencyFilter.h
+28
-3
28 additions, 3 deletions
Code/DisparityMap/otbBijectionCoherencyFilter.h
Code/DisparityMap/otbBijectionCoherencyFilter.txx
+124
-11
124 additions, 11 deletions
Code/DisparityMap/otbBijectionCoherencyFilter.txx
with
152 additions
and
14 deletions
Code/DisparityMap/otbBijectionCoherencyFilter.h
+
28
−
3
View file @
95d4fa59
...
@@ -62,9 +62,10 @@ public:
...
@@ -62,9 +62,10 @@ public:
typedef
TDisparityImage
DispMapType
;
typedef
TDisparityImage
DispMapType
;
typedef
TOutputImage
MaskType
;
typedef
TOutputImage
MaskType
;
typedef
TOutputImage
::
RegionType
OutputRegionType
;
typedef
typename
MaskType
::
RegionType
OutputRegionType
;
typedef
TDisparityImage
::
RegionType
InputRegionType
;
typedef
typename
DispMapType
::
RegionType
InputRegionType
;
typedef
TDisparityImage
::
SizeType
SizeType
;
typedef
typename
DispMapType
::
SizeType
SizeType
;
typedef
typename
DispMapType
::
IndexType
IndexType
;
/** Set the direct horizontal disparity map */
/** Set the direct horizontal disparity map */
void
SetDirectHorizontalDisparityMapInput
(
const
TDisparityImage
*
hmap
);
void
SetDirectHorizontalDisparityMapInput
(
const
TDisparityImage
*
hmap
);
...
@@ -89,6 +90,19 @@ public:
...
@@ -89,6 +90,19 @@ public:
/** Get the tolerance radius */
/** Get the tolerance radius */
itkGetMacro
(
Tolerance
,
double
);
itkGetMacro
(
Tolerance
,
double
);
/** Set/Get macro for exploration area */
itkSetMacro
(
MinHDisp
,
int
);
itkGetMacro
(
MinHDisp
,
int
);
itkSetMacro
(
MaxHDisp
,
int
);
itkGetMacro
(
MaxHDisp
,
int
);
itkSetMacro
(
MinVDisp
,
int
);
itkGetMacro
(
MinVDisp
,
int
);
itkSetMacro
(
MaxVDisp
,
int
);
itkGetMacro
(
MaxVDisp
,
int
);
protected:
protected:
/** Constructor */
/** Constructor */
...
@@ -113,6 +127,17 @@ private:
...
@@ -113,6 +127,17 @@ private:
/** Tolerance radius (in pixels) */
/** Tolerance radius (in pixels) */
double
m_Tolerance
;
double
m_Tolerance
;
/** Minimum horizontal input disparity */
int
m_MinHDisp
;
/** Maximum horizontal input disparity */
int
m_MaxHDisp
;
/** Minimum vertical input disparity */
int
m_MinVDisp
;
/** Maximum vertical input disparity */
int
m_MaxVDisp
;
};
};
}
// end namespace otb
}
// end namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/DisparityMap/otbBijectionCoherencyFilter.txx
+
124
−
11
View file @
95d4fa59
...
@@ -34,6 +34,10 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
...
@@ -34,6 +34,10 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
this->SetNumberOfInputs(4);
this->SetNumberOfInputs(4);
this->SetNumberOfRequiredInputs(1);
this->SetNumberOfRequiredInputs(1);
this->m_Tolerance = 1.;
this->m_Tolerance = 1.;
this->m_MinHDisp = -5;
this->m_MaxHDisp = 5;
this->m_MinVDisp = -5;
this->m_MaxVDisp = 5;
// Set the outputs
// Set the outputs
this->SetNumberOfOutputs(1);
this->SetNumberOfOutputs(1);
...
@@ -135,6 +139,9 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
...
@@ -135,6 +139,9 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
const TDisparityImage * directHmap = this->GetDirectHorizontalDisparityMapInput();
const TDisparityImage * directHmap = this->GetDirectHorizontalDisparityMapInput();
const TDisparityImage * reverseHmap = this->GetReverseHorizontalDisparityMapInput();
const TDisparityImage * reverseHmap = this->GetReverseHorizontalDisparityMapInput();
const TDisparityImage * directVmap = this->GetDirectVerticalDisparityMapInput();
const TDisparityImage * reverseVmap = this->GetReverseVerticalDisparityMapInput();
if (!directHmap)
if (!directHmap)
{
{
itkExceptionMacro(<<"Direct horizontal disparity map is missing");
itkExceptionMacro(<<"Direct horizontal disparity map is missing");
...
@@ -145,8 +152,24 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
...
@@ -145,8 +152,24 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
itkExceptionMacro(<<"Reverse horizontal disparity map is missing");
itkExceptionMacro(<<"Reverse horizontal disparity map is missing");
}
}
// TODO : check sizes
if (directVmap && directVmap->GetLargestPossibleRegion() != directHmap->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Horizontal and vertical direct disparity maps have different sizes.");
}
if (reverseVmap && reverseVmap->GetLargestPossibleRegion() != reverseHmap->GetLargestPossibleRegion())
{
itkExceptionMacro(<<"Horizontal and vertical reverse disparity maps have different sizes.");
}
if (this->m_MinHDisp > this->m_MaxHDisp)
{
itkExceptionMacro(<<"Wrong horizontal exploration values");
}
if (this->m_MinVDisp > this->m_MaxVDisp)
{
itkExceptionMacro(<<"Wrong horizontal exploration values");
}
}
}
template <class TDisparityImage, class TOutputImage>
template <class TDisparityImage, class TOutputImage>
...
@@ -157,26 +180,116 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
...
@@ -157,26 +180,116 @@ BijectionCoherencyFilter<TDisparityImage,TOutputImage>
this->Superclass::GenerateInputRequestedRegion();
this->Superclass::GenerateInputRequestedRegion();
OutputRegionType requested = this->GetOutput()->GetRequestedRegion();
OutputRegionType requested = this->GetOutput()->GetRequestedRegion();
InputRegionType largest = this->GetDirectHorizontalDisparityMap()->GetLargestPossibleRegion();
InputRegionType directLargest = this->GetDirectHorizontalDisparityMap()->GetLargestPossibleRegion();
InputRegionType inputRequested;
InputRegionType directRequested;
this->CallCopyOutputRegionToInputRegion(inputRequested,requested);
InputRegionType reverseLargest = this->GetReverseHorizontalDisparityMap()->GetLargestPossibleRegion();
InputRegionType reverseRequested;
// TODO : the requested region on Reverse dispmap must be shifted with an estimate of the min/max disparities values
this->CallCopyOutputRegionToInputRegion(requested,directRequested);
// HOW CAN I DO THAT ???
SizeType radius;
reverseRequested.SetIndex(0,requested.GetIndex(0) + this->m_MinHDisp);
radius.Fill(static_cast<unsigned int>(vcl_ceil(this->m_Tolerance)));
reverseRequested.SetIndex(1,requested.GetIndex(1) + this->m_MinVDisp);
reverseRequested.SetSize(0,requested.GetSize(0) + this->m_MaxHDisp - this->m_MinHDisp);
reverseRequested.SetSize(1,requested.GetSize(1) + this->m_MaxVDisp - this->m_MinVDisp);
inputRequested.PadByRadius(radius);
reverseRequested.Crop(reverseLargest);
inputRequested.Crop(largest);
TDisparityImage * directHmap = const_cast<TDisparityImage *>(this->GetDirectHorizontalDisparityMapInput());
TDisparityImage * directHmap = const_cast<TDisparityImage *>(this->GetDirectHorizontalDisparityMapInput());
TDisparityImage * directVmap = const_cast<TDisparityImage *>(this->GetDirectVerticalDisparityMapInput());
TDisparityImage * directVmap = const_cast<TDisparityImage *>(this->GetDirectVerticalDisparityMapInput());
TDisparityImage * reverseHmap = const_cast<TDisparityImage *>(this->GetDirectHorizontalDisparityMapInput());
TDisparityImage * reverseVmap = const_cast<TDisparityImage *>(this->GetDirectVerticalDisparityMapInput());
directHmap->SetRequestedRegion(directRequested);
if (directVmap) directVmap->SetRequestedRegion(directRequested);
reverseHmap->SetRequestedRegion(reverseRequested);
if (reverseVmap) reverseVmap->SetRequestedRegion(reverseRequested);
}
}
template <class TDisparityImage, class TOutputImage>
void
BijectionCoherencyFilter<TDisparityImage,TOutputImage>
::ThreadedGenerateData(const RegionType & outputRegionForThread, int threadId)
{
const TDisparityImage * directHmap = this->GetDirectHorizontalDisparityMapInput();
const TDisparityImage * directVmap = this->GetDirectVerticalDisparityMapInput();
const TDisparityImage * reverseHmap = this->GetDirectHorizontalDisparityMapInput();
const TDisparityImage * reverseVmap = this->GetDirectVerticalDisparityMapInput();
TOutputImage * output = this->GetOutput();
InputRegionType buffered = reverseHmap->GetBufferedRegion();
typedef itk::ImageRegionIterator<TOutputImage> MaskIteratorType;
MaskIteratorType outIter = MaskIteratorType(output,outputRegionForThread);
typedef itk::ImageRegionConstIteratorWithIndex<TDisparityImage> DispIteratorType;
DispIteratorType directHorizIter = DispIteratorType(directHmap,outputRegionForThread);
DispIteratorType directVertiIter;
if (directVmap)
{
directVertiIter = DispIteratorType(directVmap,outputRegionForThread);
directVertiIter.GoToBegin();
}
outIter.GoToBegin();
directHorizIter.GoToBegin();
while (!outIter.IsAtEnd())
{
IndexType startIndex = directHorizIter.GetIndex();
itk::ContinuousIndex<double,2> tmpIndex(startIndex);
tmpIndex[0] += directHorizIter.Get();
if (directVmap) tmpIndex[1] += directVertiIter.Get();
// Interpolate in reverse disparity map
IndexType ul,ur,ll,lr;
ul[0] = static_cast<long>(vcl_floor(tmpIndex[0]));
ul[1] = static_cast<long>(vcl_floor(tmpIndex[1]));
if (ul[0]<buffered.GetIndex()[0]) ul[0]=buffered.GetIndex()[0];
if (ul[1]<buffered.GetIndex()[1]) ul[1]=buffered.GetIndex()[1];
if (ul[0]>(buffered.GetIndex()[0]+buffered.GetSize()[0]-1)) ul[0]=(buffered.GetIndex()[0]+buffered.GetSize()[0]-1);
if (ul[1]>(buffered.GetIndex()[1]+buffered.GetSize()[1]-1)) ul[1]=(buffered.GetIndex()[1]+buffered.GetSize()[1]-1);
ur = ul;
ur[0] += 1;
ll = ul;
ll[1] += 1;
lr = ul;
lr[0] += 1;
lr[1] += 1;
double rx = tmpIndex[0] - static_cast<double>(ul[0]);
double ry = tmpIndex[1] - static_cast<double>(ul[1]);
itk::ContinuousIndex<double,2> backIndex(tmpIndex);
backIndex[0] += (1. - ry) * ((1. - rx) * reverseHmap->GetPixel(ul) + rx * reverseHmap->GetPixel(ur)) +
ry * ((1. - rx) * reverseHmap->GetPixel(ll) + rx * reverseHmap->GetPixel(lr));
if (reverseVmap)
{
backIndex[1] += (1. - ry) * ((1. - rx) * reverseVmap->GetPixel(ul) + rx * reverseVmap->GetPixel(ur)) +
ry * ((1. - rx) * reverseVmap->GetPixel(ll) + rx * reverseVmap->GetPixel(lr));
}
if (vcl_abs(backIndex[0] - static_cast<double>(startIndex[0]))< this->m_Tolerance &&
vcl_abs(backIndex[1] - static_cast<double>(startIndex[1]))< this->m_Tolerance)
{
outIter.Set(255);
}
else
{
outIter.Set(0);
}
++outIter;
++directHorizIter;
if (directVmap) ++directVertiIter;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment