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
David Youssefi
otb
Commits
52a8d6bf
Commit
52a8d6bf
authored
16 years ago
by
Jordi Inglada
Browse files
Options
Downloads
Patches
Plain Diff
DOC: SIFT latching example works
parent
6dcdb9ee
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Examples/DisparityMap/SIFTDisparityMapEstimation.cxx
+113
-63
113 additions, 63 deletions
Examples/DisparityMap/SIFTDisparityMapEstimation.cxx
with
113 additions
and
63 deletions
Examples/DisparityMap/SIFTDisparityMapEstimation.cxx
+
113
−
63
View file @
52a8d6bf
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
// Software Guide : BeginCommandLineArgs
// Software Guide : BeginCommandLineArgs
// INPUTS: {ROI_IKO_PAN_LesHalles_pos_spacing.tif}, {ROI_IKO_PAN_LesHalles_warped_pos_spacing.tif}
// INPUTS: {ROI_IKO_PAN_LesHalles_pos_spacing.tif}, {ROI_IKO_PAN_LesHalles_warped_pos_spacing.tif}
// OUTPUTS: {SIFTdeformationFieldOutput.png}
,{SIFTresampledMovingOutput.png}
// OUTPUTS: {SIFTdeformationFieldOutput.png}
// Software Guide : EndCommandLineArgs
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
// Software Guide : BeginLatex
...
@@ -61,14 +61,14 @@
...
@@ -61,14 +61,14 @@
#include
"otbImageFileWriter.h"
#include
"otbImageFileWriter.h"
#include
"itkRescaleIntensityImageFilter.h"
#include
"itkRescaleIntensityImageFilter.h"
#include
"itkPointSet.h"
#include
"itkPointSet.h"
#include
"otbMultiToMonoChannelExtractROI.h"
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
if
(
argc
!=
5
)
if
(
argc
!=
4
)
{
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
];
std
::
cerr
<<
"Usage: "
<<
argv
[
0
];
std
::
cerr
<<
"fixedFileName movingFileName fieldOutName
imageOutName
"
<<
std
::
endl
;
std
::
cerr
<<
"fixedFileName movingFileName fieldOutName"
<<
std
::
endl
;
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
...
@@ -207,19 +207,31 @@ int main (int argc, char* argv[])
...
@@ -207,19 +207,31 @@ int main (int argc, char* argv[])
double
secondOrderThreshold
=
0.5
;
double
secondOrderThreshold
=
0.5
;
bool
useBackMatching
=
0
;
bool
useBackMatching
=
0
;
filter1
->
SetInput
(
fixedReader
->
GetOutput
()
);
filter1
->
SetInput
(
0
,
fixedReader
->
GetOutput
()
);
filter2
->
SetInput
(
movingReader
->
GetOutput
()
);
filter1
->
SetNumberOfScales
(
3
);
filter2
->
SetInput
(
0
,
movingReader
->
GetOutput
()
);
filter2
->
SetNumberOfScales
(
3
);
euclideanMatcher
->
SetInput1
(
filter1
->
GetOutput
());
euclideanMatcher
->
SetInput1
(
filter1
->
GetOutput
());
euclideanMatcher
->
SetInput2
(
filter2
->
GetOutput
());
euclideanMatcher
->
SetInput2
(
filter2
->
GetOutput
());
euclideanMatcher
->
SetDistanceThreshold
(
secondOrderThreshold
);
euclideanMatcher
->
SetDistanceThreshold
(
secondOrderThreshold
);
euclideanMatcher
->
SetUseBackMatching
(
useBackMatching
);
euclideanMatcher
->
SetUseBackMatching
(
useBackMatching
);
euclideanMatcher
->
Update
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The matched points will be stored into a landmark list.
//
// Software Guide : EndLatex
LandmarkListType
::
Pointer
landmarkList
;
// Software Guide : BeginCodeSnippet
euclideanMatcher
->
Update
();
LandmarkListType
::
Pointer
landmarkList
;
landmarkList
=
euclideanMatcher
->
GetOutput
();
MatchVectorType
trueSecondOrder
;
// Software Guide : EndCodeSnippet
MatchVectorType
trueSecondOrder
;
for
(
LandmarkListType
::
Iterator
it
=
landmarkList
->
Begin
();
it
!=
landmarkList
->
End
();
++
it
)
for
(
LandmarkListType
::
Iterator
it
=
landmarkList
->
Begin
();
it
!=
landmarkList
->
End
();
++
it
)
{
{
...
@@ -286,9 +298,17 @@ int main (int argc, char* argv[])
...
@@ -286,9 +298,17 @@ int main (int argc, char* argv[])
}
}
// Software Guide : BeginLatex
//
// The landmarks are used for building a deformation field. The
// deformation field is an image of vectors created by the
// \doxygen{itk}{DeformationFieldSource} class.
//
// Software Guide : EndLatex
typedef
float
VectorComponentType
;
// Software Guide : BeginCodeSnippet
typedef
itk
::
Vector
<
VectorComponentType
,
Dimension
>
VectorType
;
typedef
itk
::
Vector
<
RealType
,
Dimension
>
VectorType
;
typedef
otb
::
Image
<
VectorType
,
Dimension
>
DeformationFieldType
;
typedef
otb
::
Image
<
VectorType
,
Dimension
>
DeformationFieldType
;
typedef
itk
::
DeformationFieldSource
<
typedef
itk
::
DeformationFieldSource
<
...
@@ -297,6 +317,14 @@ int main (int argc, char* argv[])
...
@@ -297,6 +317,14 @@ int main (int argc, char* argv[])
DeformationSourceType
::
Pointer
deformer
=
DeformationSourceType
::
New
();
DeformationSourceType
::
Pointer
deformer
=
DeformationSourceType
::
New
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The deformation field needs information about the extent and
// spacing of the images on which it is defined.
//
// Software Guide : EndLatex
ImageType
::
ConstPointer
fixedImage
=
fixedReader
->
GetOutput
();
ImageType
::
ConstPointer
fixedImage
=
fixedReader
->
GetOutput
();
...
@@ -304,6 +332,15 @@ int main (int argc, char* argv[])
...
@@ -304,6 +332,15 @@ int main (int argc, char* argv[])
deformer
->
SetOutputOrigin
(
fixedImage
->
GetOrigin
()
);
deformer
->
SetOutputOrigin
(
fixedImage
->
GetOrigin
()
);
deformer
->
SetOutputRegion
(
fixedImage
->
GetLargestPossibleRegion
()
);
deformer
->
SetOutputRegion
(
fixedImage
->
GetLargestPossibleRegion
()
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We will need some intermediate variables in order to pass the
// matched SIFTs to the deformation field source.
//
// Software Guide : EndLatex
typedef
DeformationSourceType
::
LandmarkContainerPointer
typedef
DeformationSourceType
::
LandmarkContainerPointer
LandmarkContainerPointer
;
LandmarkContainerPointer
;
typedef
DeformationSourceType
::
LandmarkContainer
typedef
DeformationSourceType
::
LandmarkContainer
...
@@ -316,6 +353,14 @@ int main (int argc, char* argv[])
...
@@ -316,6 +353,14 @@ int main (int argc, char* argv[])
LandmarkPointType
sourcePoint
;
LandmarkPointType
sourcePoint
;
LandmarkPointType
targetPoint
;
LandmarkPointType
targetPoint
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We can now iterate through the list of matched points and store
// them in the intermediate landmark sets.
//
// Software Guide : EndLatex
unsigned
int
pointId
=
0
;
unsigned
int
pointId
=
0
;
...
@@ -336,79 +381,84 @@ int main (int argc, char* argv[])
...
@@ -336,79 +381,84 @@ int main (int argc, char* argv[])
sourceLandmarks
->
InsertElement
(
pointId
,
sourcePoint
);
sourceLandmarks
->
InsertElement
(
pointId
,
sourcePoint
);
targetLandmarks
->
InsertElement
(
pointId
,
targetPoint
);
targetLandmarks
->
InsertElement
(
pointId
,
targetPoint
);
std
::
cout
<<
sourcePoint
<<
" "
<<
targetPoint
<<
std
::
endl
;
++
pointId
;
++
pointId
;
}
}
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We pass the landmarks to the deformer and we run it.
//
// Software Guide : EndLatex
deformer
->
SetSourceLandmarks
(
sourceLandmarks
.
GetPointer
()
);
deformer
->
SetSourceLandmarks
(
sourceLandmarks
.
GetPointer
()
);
deformer
->
SetTargetLandmarks
(
targetLandmarks
.
GetPointer
()
);
deformer
->
SetTargetLandmarks
(
targetLandmarks
.
GetPointer
()
);
try
deformer
->
UpdateLargestPossibleRegion
();
{
deformer
->
UpdateLargestPossibleRegion
();
}
catch
(
itk
::
ExceptionObject
&
excp
)
{
std
::
cerr
<<
"Exception thrown "
<<
std
::
endl
;
std
::
cerr
<<
excp
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
DeformationFieldType
::
ConstPointer
deformationField
=
deformer
->
GetOutput
();
DeformationFieldType
::
ConstPointer
deformationField
=
deformer
->
GetOutput
();
deformer
->
Update
();
deformer
->
Update
();
std
::
cout
<<
"Image Resampling"
<<
std
::
endl
;
// Software Guide : EndCodeSnippet
typedef
itk
::
WarpImageFilter
<
ImageType
,
ImageType
,
DeformationFieldType
>
FilterType
;
FilterType
::
Pointer
warper
=
FilterType
::
New
();
typedef
itk
::
LinearInterpolateImageFunction
<
ImageType
,
double
>
InterpolatorType
;
InterpolatorType
::
Pointer
interpolator
=
InterpolatorType
::
New
();
warper
->
SetInterpolator
(
interpolator
);
warper
->
SetOutputSpacing
(
deformationField
->
GetSpacing
()
);
warper
->
SetOutputOrigin
(
deformationField
->
GetOrigin
()
);
warper
->
SetDeformationField
(
deformationField
);
warper
->
SetInput
(
movingReader
->
GetOutput
()
);
ImageType
::
Pointer
outdf
=
ImageType
::
New
();
outdf
->
SetRegions
(
fixedReader
->
GetOutput
()
->
GetLargestPossibleRegion
());
outdf
->
Allocate
();
itk
::
ImageRegionIterator
<
ImageType
>
outIt
(
outdf
,
outdf
->
GetLargestPossibleRegion
());
typedef
otb
::
ImageFileWriter
<
ImageType
>
WriterType
;
itk
::
ImageRegionIterator
<
DeformationFieldType
>
inIt
(
deformer
->
GetOutput
(),
deformer
->
GetOutput
()
->
GetLargestPossibleRegion
());
WriterType
::
Pointer
movingWriter
=
WriterType
::
New
();
outIt
.
GoToBegin
();
inIt
.
GoToBegin
();
movingWriter
->
SetFileName
(
argv
[
6
]
);
while
(
!
inIt
.
IsAtEnd
()
&&
!
outIt
.
IsAtEnd
())
movingWriter
->
SetInput
(
warper
->
GetOutput
()
);
{
std
::
cout
<<
inIt
.
Get
()
<<
std
::
endl
;
outIt
.
Set
(
inIt
.
Get
()[
1
]);
++
inIt
;
try
++
outIt
;
{
movingWriter
->
Update
();
}
catch
(
itk
::
ExceptionObject
&
excp
)
{
std
::
cerr
<<
"Exception thrown "
<<
std
::
endl
;
std
::
cerr
<<
excp
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
}
typedef
otb
::
ImageFileWriter
<
DeformationFieldType
>
DeformationWriterType
;
typedef
itk
::
RescaleIntensityImageFilter
<
ImageType
,
OutputImageType
>
RescaleType
;
DeformationWriterType
::
Pointer
defWriter
=
DeformationWriterType
::
New
();
RescaleType
::
Pointer
rescaler
=
RescaleType
::
New
();
rescaler
->
SetInput
(
outdf
);
rescaler
->
SetOutputMinimum
(
0
);
rescaler
->
SetOutputMaximum
(
255
);
defWriter
->
SetFileName
(
"deformation.mhd"
);
typedef
otb
::
ImageFileWriter
<
OutputImageType
>
WriterType
;
defWriter
->
SetInput
(
deformationField
);
WriterType
::
Pointer
writer
=
WriterType
::
New
();
defWriter
->
Update
();
writer
->
SetInput
(
rescaler
->
GetOutput
()
);
writer
->
SetFileName
(
argv
[
3
]
);
writer
->
Update
();
// Software Guide : BeginLatex
//
// Figure~\ref{fig:SIFTDME} shows the result of applying the SIFT
// disparity map estimation. Only the horizontal component of the
// deformation is shown.
//
// \begin{figure}
// \center
// \includegraphics[width=0.40\textwidth]{ROI_IKO_PAN_LesHalles_pos_spacing.eps}
// \includegraphics[width=0.40\textwidth]{ROI_IKO_PAN_LesHalles_warped_pos_spacing.eps}
// \includegraphics[width=0.40\textwidth]{SIFTdeformationFieldOutput.eps}
// \itkcaption[Deformation field from SIFT disparity map estimation]{From left
// to right and top to bottom: fixed input image, moving image with a sinusoid deformation,
// estimated deformation field in the horizontal direction.}
// \label{fig:SIFTDME}
// \end{figure}
//
// Software Guide : EndLatex
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
...
...
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