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
e5a09e4c
Commit
e5a09e4c
authored
14 years ago
by
Julien Malik
Browse files
Options
Downloads
Patches
Plain Diff
BUG: OutputImage was not referenced correctly. also add new warped output
parent
12ca180e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DisparityMap/otbFineRegistration.cxx
+75
-19
75 additions, 19 deletions
DisparityMap/otbFineRegistration.cxx
with
75 additions
and
19 deletions
DisparityMap/otbFineRegistration.cxx
+
75
−
19
View file @
e5a09e4c
...
...
@@ -39,10 +39,43 @@
#include
"itkAbsImageFilter.h"
#include
"itkVectorIndexSelectionCastImageFilter.h"
#include
"itkBinaryThresholdImageFilter.h"
#include
"otbStreamingWarpImageFilter.h"
#include
"otbMultiChannelExtractROI.h"
#include
"itkCastImageFilter.h"
namespace
otb
{
const
unsigned
int
Dimension
=
2
;
typedef
double
PixelType
;
typedef
itk
::
FixedArray
<
PixelType
,
Dimension
>
DeformationValueType
;
typedef
otb
::
Image
<
PixelType
,
Dimension
>
ImageType
;
typedef
otb
::
VectorImage
<
PixelType
,
Dimension
>
VectorImageType
;
typedef
otb
::
ImageList
<
ImageType
>
ImageListType
;
typedef
otb
::
ImageListToVectorImageFilter
<
ImageListType
,
VectorImageType
>
IL2VIFilterType
;
typedef
otb
::
Image
<
DeformationValueType
,
Dimension
>
FieldImageType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
typedef
otb
::
ImageFileReader
<
VectorImageType
>
VectorReaderType
;
typedef
otb
::
StreamingImageFileWriter
<
VectorImageType
>
WriterType
;
typedef
otb
::
FineRegistrationImageFilter
<
ImageType
,
ImageType
,
FieldImageType
>
RegistrationFilterType
;
typedef
itk
::
DiscreteGaussianImageFilter
<
ImageType
,
ImageType
>
GaussianFilterType
;
typedef
itk
::
VectorIndexSelectionCastImageFilter
<
FieldImageType
,
ImageType
>
VectorImageToImageFilterType
;
typedef
itk
::
AbsImageFilter
<
ImageType
,
ImageType
>
AbsFilterType
;
typedef
itk
::
BinaryThresholdImageFilter
<
ImageType
,
ImageType
>
BinaryThresholdImageFilterType
;
template
<
class
TVLV
,
class
TFixedArray
>
class
VLVToFixedArray
{
public:
TFixedArray
operator
()(
const
TVLV
&
vlv
)
{
TFixedArray
output
;
output
[
0
]
=
vlv
[
0
];
output
[
1
]
=
vlv
[
1
];
}
};
int
FineRegistration
::
Describe
(
ApplicationDescriptor
*
descriptor
)
{
descriptor
->
SetName
(
"FineRegistration"
);
...
...
@@ -50,9 +83,13 @@ int FineRegistration::Describe(ApplicationDescriptor* descriptor)
descriptor
->
AddOption
(
"Reference"
,
"The reference image"
,
"ref"
,
1
,
true
,
ApplicationDescriptor
::
InputImage
);
descriptor
->
AddOption
(
"Secondary"
,
"The secondary image"
,
"sec"
,
1
,
true
,
ApplicationDescriptor
::
FileNam
e
);
descriptor
->
AddOption
(
"Output"
,
"The output image"
,
"sec"
,
1
,
true
,
ApplicationDescriptor
::
InputImag
e
);
descriptor
->
AddOption
(
"Output
Image
"
,
"The output image"
,
"out"
,
1
,
true
,
ApplicationDescriptor
::
OutputImage
);
descriptor
->
AddOption
(
"ImageToWarp"
,
"The image to warp after disparity estimation is complete"
,
"w"
,
1
,
true
,
ApplicationDescriptor
::
InputImage
);
descriptor
->
AddOption
(
"WarpOutput"
,
"The output warped image"
,
"wo"
,
1
,
true
,
ApplicationDescriptor
::
OutputImage
);
descriptor
->
AddOption
(
"ExplorationRadius"
,
"Radius (in pixels) of the exploration window"
,
"er"
,
2
,
true
,
ApplicationDescriptor
::
Integer
);
descriptor
->
AddOption
(
"MetricRadius"
,
"Radius (in pixels) of the metric computation window"
,
...
...
@@ -77,22 +114,6 @@ int FineRegistration::Describe(ApplicationDescriptor* descriptor)
int
FineRegistration
::
Execute
(
otb
::
ApplicationOptionsResult
*
parseResult
)
{
const
unsigned
int
Dimension
=
2
;
typedef
double
PixelType
;
typedef
itk
::
FixedArray
<
PixelType
,
Dimension
>
DeformationValueType
;
typedef
otb
::
Image
<
PixelType
,
Dimension
>
ImageType
;
typedef
otb
::
VectorImage
<
PixelType
,
Dimension
>
VectorImageType
;
typedef
otb
::
ImageList
<
ImageType
>
ImageListType
;
typedef
otb
::
ImageListToVectorImageFilter
<
ImageListType
,
VectorImageType
>
IL2VIFilterType
;
typedef
otb
::
Image
<
DeformationValueType
,
Dimension
>
FieldImageType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
typedef
otb
::
StreamingImageFileWriter
<
VectorImageType
>
WriterType
;
typedef
otb
::
FineRegistrationImageFilter
<
ImageType
,
ImageType
,
FieldImageType
>
RegistrationFilterType
;
typedef
itk
::
DiscreteGaussianImageFilter
<
ImageType
,
ImageType
>
GaussianFilterType
;
typedef
itk
::
VectorIndexSelectionCastImageFilter
<
FieldImageType
,
ImageType
>
VectorImageToImageFilterType
;
typedef
itk
::
AbsImageFilter
<
ImageType
,
ImageType
>
AbsFilterType
;
typedef
itk
::
BinaryThresholdImageFilter
<
ImageType
,
ImageType
>
BinaryThresholdImageFilterType
;
// Read reference image
ReaderType
::
Pointer
freader
=
ReaderType
::
New
();
...
...
@@ -239,7 +260,7 @@ int FineRegistration::Execute(otb::ApplicationOptionsResult* parseResult)
else
{
std
::
cerr
<<
"Metric "
<<
metricId
<<
" not recognized."
<<
std
::
endl
;
std
::
cerr
<<
"Possible choices are: CC, CC
M
S, MSD, MRSD, MI"
<<
std
::
endl
;
std
::
cerr
<<
"Possible choices are: CC, CCS
M
, MSD, MRSD, MI"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
VectorImageToImageFilterType
::
Pointer
xExtractor
=
VectorImageToImageFilterType
::
New
();
...
...
@@ -268,6 +289,8 @@ int FineRegistration::Execute(otb::ApplicationOptionsResult* parseResult)
il
->
PushBack
(
registration
->
GetOutput
());
}
registration
->
UpdateOutputInformation
();
BinaryThresholdImageFilterType
::
Pointer
threshold
;
if
(
parseResult
->
IsOptionPresent
(
"ValidityMask"
))
{
...
...
@@ -316,6 +339,39 @@ int FineRegistration::Execute(otb::ApplicationOptionsResult* parseResult)
writer
->
Update
();
std
::
cout
<<
"Start warping"
<<
std
::
endl
;
// Now reuse the written deformation field to warp
VectorReaderType
::
Pointer
deformationReader
=
VectorReaderType
::
New
();
deformationReader
->
SetFileName
(
parseResult
->
GetOutputImage
());
typedef
otb
::
MultiChannelExtractROI
<
PixelType
,
PixelType
>
ExtractROIFilterType
;
ExtractROIFilterType
::
Pointer
extractROIFilter
=
ExtractROIFilterType
::
New
();
extractROIFilter
->
SetChannel
(
1
);
extractROIFilter
->
SetChannel
(
2
);
extractROIFilter
->
SetInput
(
deformationReader
->
GetOutput
());
typedef
VLVToFixedArray
<
VectorImageType
::
PixelType
,
FieldImageType
::
PixelType
>
VLVToFixedArrayType
;
typedef
itk
::
UnaryFunctorImageFilter
<
VectorImageType
,
FieldImageType
,
VLVToFixedArrayType
>
CastFilterType
;
CastFilterType
::
Pointer
cast
=
CastFilterType
::
New
();
cast
->
SetInput
(
extractROIFilter
->
GetOutput
());
VectorReaderType
::
Pointer
imageToWarpReader
=
VectorReaderType
::
New
();
imageToWarpReader
->
SetFileName
(
parseResult
->
GetParameterString
(
"ImageToWarp"
));
typedef
StreamingWarpImageFilter
<
VectorImageType
,
VectorImageType
,
FieldImageType
>
WarpFilterType
;
WarpFilterType
::
Pointer
warp
=
WarpFilterType
::
New
();
warp
->
SetDeformationField
(
cast
->
GetOutput
());
warp
->
SetInput
(
imageToWarpReader
->
GetOutput
());
warp
->
SetOutputParametersFromImage
(
freader
->
GetOutput
());
WriterType
::
Pointer
wrappedWriter
=
WriterType
::
New
();
wrappedWriter
->
SetFileName
(
parseResult
->
GetParameterString
(
"WarpOutput"
));
wrappedWriter
->
SetInput
(
warp
->
GetOutput
());
otb
::
StandardWriterWatcher
watcher2
(
wrappedWriter
,
warp
,
"Warp"
);
wrappedWriter
->
Update
();
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