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
bfb10a47
Commit
bfb10a47
authored
14 years ago
by
Otmane Lahlou
Browse files
Options
Downloads
Patches
Plain Diff
ENH : use the new orhtorectification framework
parent
bbc25874
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
Projections/otbBundleToPerfectSensor.cxx
+28
-77
28 additions, 77 deletions
Projections/otbBundleToPerfectSensor.cxx
with
28 additions
and
77 deletions
Projections/otbBundleToPerfectSensor.cxx
+
28
−
77
View file @
bfb10a47
...
...
@@ -26,29 +26,17 @@ See OTBCopyright.txt for details.
#include
<iostream>
#include
"otbMetaDataKey.h"
#include
"otbCommandLineArgumentParser.h"
#include
"otbImageFileReader.h"
#include
"otbStreamingImageFileWriter.h"
#include
"otbImageFileWriter.h"
#include
"otbGenericRSTransform.h"
#include
"otbImage.h"
#include
"otbDEMHandler.h"
#include
"otbVectorImage.h"
#include
"otb
Macro
.h"
#include
"otb
GenericRSResampleImageFilter
.h"
#include
"itkExceptionObject.h"
#include
"itkMacro.h"
#include
"itkTransform.h"
#include
"otbStandardFilterWatcher.h"
#include
"itkTransformToDeformationFieldSource.h"
#include
"otbStreamingWarpImageFilter.h"
#include
"itkLinearInterpolateImageFunction.h"
#include
"otbSimpleRcsPanSharpeningFusionImageFilter.h"
#include
"otbMultiChannelExtractROI.h"
#include
"itkPixelBuilder.h"
#include
"init/ossimInit.h"
...
...
@@ -67,7 +55,7 @@ int main(int argc, char* argv[])
parser
->
SetProgramDescription
(
"Using available image metadata to determine the sensor model, computes a cartographic projection of the image"
);
parser
->
AddOutputImage
();
//
parser->AddOption("--DEMDirectory","Directory were to find the DEM tiles","-dem",1,false);
parser
->
AddOption
(
"--DEMDirectory"
,
"Directory were to find the DEM tiles"
,
"-dem"
,
1
,
false
);
parser
->
AddOption
(
"--NumStreamDivisions"
,
"Number of streaming divisions (optional)"
,
"-stream"
,
1
,
false
);
parser
->
AddOption
(
"--LocMapSpacing"
,
"Generate a coarser deformation field with the given spacing."
,
"-lmSpacing"
,
1
,
false
);
parser
->
AddOption
(
"--InputPanchro"
,
"The input panchromatic image"
,
"-inP"
,
1
,
true
);
...
...
@@ -103,16 +91,8 @@ int main(int argc, char* argv[])
typedef
otb
::
ImageFileReader
<
XsImageType
>
XsReaderType
;
typedef
otb
::
ImageFileReader
<
PanImageType
>
PanReaderType
;
typedef
otb
::
StreamingImageFileWriter
<
XsImageType
>
WriterType
;
typedef
otb
::
GenericRSTransform
<>
RSTransformType
;
typedef
RSTransformType
::
InputPointType
PointType
;
typedef
itk
::
FixedArray
<
double
,
2
>
DeformationValueType
;
typedef
otb
::
Image
<
DeformationValueType
>
DeformationFieldType
;
typedef
otb
::
StreamingImageFileWriter
<
DeformationFieldType
>
DeformationFieldWriterType
;
typedef
itk
::
TransformToDeformationFieldSource
<
DeformationFieldType
,
double
>
DeformationFieldGeneratorType
;
typedef
otb
::
StreamingWarpImageFilter
<
XsImageType
,
XsImageType
,
DeformationFieldType
>
WarpFilterType
;
typedef
itk
::
LinearInterpolateImageFunction
<
XsImageType
,
double
>
InterpolatorType
;
typedef
otb
::
GenericRSResampleImageFilter
<
XsImageType
,
XsImageType
>
ResamplerType
;
typedef
otb
::
SimpleRcsPanSharpeningFusionImageFilter
<
PanImageType
,
XsImageType
,
XsImageType
>
FusionFilterType
;
...
...
@@ -124,84 +104,55 @@ int main(int argc, char* argv[])
XsReaderType
::
Pointer
xsreader
=
XsReaderType
::
New
();
xsreader
->
SetFileName
(
parseResult
->
GetParameterString
(
"--InputXS"
));
xsreader
->
GenerateOutputInformation
();
// Generate RS Transform
RSTransformType
::
Pointer
rsTransform
=
RSTransformType
::
New
();
rsTransform
->
SetOutputKeywordList
(
xsreader
->
GetOutput
()
->
GetImageKeywordlist
());
rsTransform
->
SetInputKeywordList
(
preader
->
GetOutput
()
->
GetImageKeywordlist
());
// if(parseResult->IsOptionPresent("--DEMDirectory"))
// {
// rsTransform->SetDEMDirectory(parseResult->GetParameterString("--DEMDirectory",0));
// gcp2sensor->SetUseDEM(true);
// otb::DEMHandler::Pointer demHandler = otb::DEMHandler::New();
// demHandler->OpenDEMDirectory(parseResult->GetParameterString("--DEMDirectory",0).c_str());
// gcp2sensor->SetDEMHandler(demHandler);
// }
rsTransform
->
InstanciateTransform
();
// Resample filter
ResamplerType
::
Pointer
resampler
=
ResamplerType
::
New
();
// Add DEM if any
if
(
parseResult
->
IsOptionPresent
(
"--DEMDirectory"
))
{
resampler
->
SetDEMDirectory
(
parseResult
->
GetParameterString
(
"--DEMDirectory"
,
0
));
}
// Set up output image informations
XsImageType
::
SpacingType
spacing
=
preader
->
GetOutput
()
->
GetSpacing
();
XsImageType
::
IndexType
start
=
preader
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetIndex
();
XsImageType
::
SizeType
size
=
preader
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetSize
();
XsImageType
::
PointType
origin
=
preader
->
GetOutput
()
->
GetOrigin
();
DeformationFieldGeneratorType
::
Pointer
dfGenerator
=
DeformationFieldGeneratorType
::
New
();
dfGenerator
->
SetOutputOrigin
(
origin
);
dfGenerator
->
SetOutputIndex
(
start
);
if
(
parseResult
->
IsOptionPresent
(
"--LocMapSpacing"
))
{
double
defScalarSpacing
=
parseResult
->
GetParameterFloat
(
"--LocMapSpacing"
);
std
::
cout
<<
"Generating coarse deformation field (spacing="
<<
defScalarSpacing
<<
")"
<<
std
::
endl
;
XsImageType
::
SpacingType
defSpacing
;
XsImageType
::
SizeType
defSize
;
defSpacing
[
0
]
=
defScalarSpacing
;
defSpacing
[
1
]
=
defScalarSpacing
;
for
(
unsigned
int
dim
=
0
;
dim
<
XsImageType
::
ImageDimension
;
++
dim
)
{
defSize
[
dim
]
=
static_cast
<
unsigned
long
>
(
size
[
dim
]
*
vcl_abs
(
spacing
[
dim
]
/
defSpacing
[
dim
]));
}
std
::
cout
<<
"Deformation field spacing: "
<<
defSpacing
<<
std
::
endl
;
std
::
cout
<<
"Deformation field size: "
<<
defSize
<<
std
::
endl
;
dfGenerator
->
SetOutputSpacing
(
defSpacing
);
dfGenerator
->
SetOutputSize
(
defSize
);
resampler
->
SetDeformationFieldSpacing
(
defSpacing
);
}
else
{
dfGenerator
->
SetOutputSpacing
(
spacing
);
dfGenerator
->
SetOutputSize
(
size
);
resampler
->
SetDeformationFieldSpacing
(
spacing
);
}
dfGenerator
->
SetTransform
(
rsTransform
);
WarpFilterType
::
Pointer
warper
=
WarpFilterType
::
New
();
InterpolatorType
::
Pointer
interpolator
=
InterpolatorType
::
New
();
interpolator
->
SetInputImage
(
xsreader
->
GetOutput
());
warper
->
SetInterpolator
(
interpolator
);
XsImageType
::
PixelType
defaultValue
;
itk
::
PixelBuilder
<
XsImageType
::
PixelType
>::
Zero
(
defaultValue
,
xsreader
->
GetOutput
()
->
GetNumberOfComponentsPerPixel
());
itk
::
PixelBuilder
<
XsImageType
::
PixelType
>::
Zero
(
defaultValue
,
xsreader
->
GetOutput
()
->
GetNumberOfComponentsPerPixel
());
warp
er
->
SetInput
(
xsreader
->
GetOutput
());
warper
->
SetDeformationField
(
dfGenerato
r
->
G
etOutput
()
);
warp
er
->
SetOutput
Origin
(
orig
in
);
warp
er
->
SetOutputS
pacing
(
spacing
);
warp
er
->
SetOutputS
ize
(
size
);
warp
er
->
SetOutput
StartIndex
(
start
);
warp
er
->
SetEdgePaddingValue
(
defaultValue
);
resampl
er
->
SetInput
(
xsreader
->
GetOutput
());
resample
r
->
S
etOutput
Origin
(
origin
);
resampl
er
->
SetOutput
Spacing
(
spac
in
g
);
resampl
er
->
SetOutputS
ize
(
size
);
resampl
er
->
SetOutputS
tartIndex
(
start
);
resampl
er
->
SetOutput
KeywordList
(
preader
->
GetOutput
()
->
GetImageKeywordlist
()
);
resampl
er
->
SetEdgePaddingValue
(
defaultValue
);
FusionFilterType
::
Pointer
fusionFilter
=
FusionFilterType
::
New
();
fusionFilter
->
SetPanInput
(
preader
->
GetOutput
());
fusionFilter
->
SetXsInput
(
warp
er
->
GetOutput
());
fusionFilter
->
SetXsInput
(
resampl
er
->
GetOutput
());
fusionFilter
->
GetOutput
()
->
UpdateOutputInformation
();
std
::
cout
<<
"Output size: "
<<
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetSize
()
<<
std
::
endl
;
WriterType
::
Pointer
writer
=
WriterType
::
New
();
writer
->
SetFileName
(
parseResult
->
GetOutputImage
());
writer
->
SetInput
(
fusionFilter
->
GetOutput
());
...
...
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