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
65ff0514
Commit
65ff0514
authored
13 years ago
by
Julien Malik
Browse files
Options
Downloads
Plain Diff
MRG
parents
00318143
b8a71a74
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
Applications/Projections/otbBundleToPerfectSensor.cxx
+182
-0
182 additions, 0 deletions
Applications/Projections/otbBundleToPerfectSensor.cxx
with
182 additions
and
0 deletions
Applications/Projections/otbBundleToPerfectSensor.cxx
0 → 100644
+
182
−
0
View file @
65ff0514
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include
"otbWrapperApplication.h"
#include
"otbWrapperApplicationFactory.h"
#include
"itkVectorIndexSelectionCastImageFilter.h"
#include
"otbGenericRSResampleImageFilter.h"
#include
"otbBCOInterpolateImageFunction.h"
#include
"otbSimpleRcsPanSharpeningFusionImageFilter.h"
#include
"itkPixelBuilder.h"
#include
"itkFixedArray.h"
namespace
otb
{
namespace
Wrapper
{
class
BundleToPerfectSensor
:
public
Application
{
public:
/** Standard class typedefs. */
typedef
BundleToPerfectSensor
Self
;
typedef
Application
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macro */
itkNewMacro
(
Self
);
itkTypeMacro
(
BundleToPerfectSensor
,
otb
::
Application
);
private:
BundleToPerfectSensor
()
{
SetName
(
"BundleToPerfectSensor"
);
SetDescription
(
"Perform P+XS pansharpening"
);
}
virtual
~
BundleToPerfectSensor
()
{
}
void
DoCreateParameters
()
{
AddParameter
(
ParameterType_InputImage
,
"inp"
,
"Input PAN Image"
);
AddParameter
(
ParameterType_InputImage
,
"inxs"
,
"Input XS Image"
);
AddParameter
(
ParameterType_Directory
,
"dem"
,
"DEM directory"
);
AddParameter
(
ParameterType_Float
,
"lms"
,
"Spacing of the deformation field"
);
AddParameter
(
ParameterType_OutputImage
,
"out"
,
"Output image"
);
MandatoryOff
(
"lms"
);
MandatoryOff
(
"dem"
);
}
void
DoUpdateParameters
()
{
// Nothing to do here : all parameters are independent
}
void
DoExecute
()
{
FloatVectorImageType
*
panchroV
=
GetParameterImage
(
"inp"
);
if
(
panchroV
->
GetNumberOfComponentsPerPixel
()
!=
1
)
{
itkExceptionMacro
(
<<
"The panchromatic image must be a single channel image"
)
}
// Transform the PAN image to otb::Image
typedef
otb
::
Image
<
FloatVectorImageType
::
InternalPixelType
>
FloatImageType
;
typedef
itk
::
VectorIndexSelectionCastImageFilter
<
FloatVectorImageType
,
FloatImageType
>
VectorIndexSelectionCastImageFilterType
;
VectorIndexSelectionCastImageFilterType
::
Pointer
channelSelect
=
VectorIndexSelectionCastImageFilterType
::
New
();
m_Ref
.
push_back
(
channelSelect
.
GetPointer
());
channelSelect
->
SetIndex
(
0
);
channelSelect
->
SetInput
(
panchroV
);
channelSelect
->
UpdateOutputInformation
();
FloatImageType
::
Pointer
panchro
=
channelSelect
->
GetOutput
();
FloatVectorImageType
*
xs
=
GetParameterImage
(
"inxs"
);
typedef
otb
::
BCOInterpolateImageFunction
<
FloatVectorImageType
>
InterpolatorType
;
typedef
otb
::
GenericRSResampleImageFilter
<
FloatVectorImageType
,
FloatVectorImageType
>
ResamplerType
;
typedef
otb
::
SimpleRcsPanSharpeningFusionImageFilter
<
FloatImageType
,
FloatVectorImageType
,
FloatVectorImageType
>
FusionFilterType
;
// Resample filter
ResamplerType
::
Pointer
resampler
=
ResamplerType
::
New
();
m_Ref
.
push_back
(
resampler
.
GetPointer
());
InterpolatorType
::
Pointer
interpolator
=
InterpolatorType
::
New
();
resampler
->
SetInterpolator
(
interpolator
);
// Configure DEM directory
if
(
IsParameterEnabled
(
"dem"
)
&&
HasValue
(
"dem"
))
{
resampler
->
SetDEMDirectory
(
GetParameterString
(
"dem"
)
);
}
else
{
if
(
otb
::
ConfigurationFile
::
GetInstance
()
->
IsValid
()
)
{
resampler
->
SetDEMDirectory
(
otb
::
ConfigurationFile
::
GetInstance
()
->
GetDEMDirectory
());
}
}
// Set up output image informations
FloatVectorImageType
::
SpacingType
spacing
=
panchro
->
GetSpacing
();
FloatVectorImageType
::
IndexType
start
=
panchro
->
GetLargestPossibleRegion
().
GetIndex
();
FloatVectorImageType
::
SizeType
size
=
panchro
->
GetLargestPossibleRegion
().
GetSize
();
FloatVectorImageType
::
PointType
origin
=
panchro
->
GetOrigin
();
if
(
IsParameterEnabled
(
"lms"
)
&&
HasValue
(
"lms"
))
{
double
defScalarSpacing
=
GetParameterFloat
(
"lms"
);
std
::
cout
<<
"Generating coarse deformation field (spacing="
<<
defScalarSpacing
<<
")"
<<
std
::
endl
;
FloatVectorImageType
::
SpacingType
defSpacing
;
defSpacing
[
0
]
=
defScalarSpacing
;
defSpacing
[
1
]
=
defScalarSpacing
;
resampler
->
SetDeformationFieldSpacing
(
defSpacing
);
}
else
{
FloatVectorImageType
::
SpacingType
defSpacing
;
defSpacing
[
0
]
=
10
*
spacing
[
0
];
defSpacing
[
1
]
=
10
*
spacing
[
1
];
resampler
->
SetDeformationFieldSpacing
(
defSpacing
);
}
FloatVectorImageType
::
PixelType
defaultValue
;
itk
::
PixelBuilder
<
FloatVectorImageType
::
PixelType
>::
Zero
(
defaultValue
,
xs
->
GetNumberOfComponentsPerPixel
());
resampler
->
SetInput
(
xs
);
resampler
->
SetOutputOrigin
(
origin
);
resampler
->
SetOutputSpacing
(
spacing
);
resampler
->
SetOutputSize
(
size
);
resampler
->
SetOutputStartIndex
(
start
);
resampler
->
SetOutputKeywordList
(
panchro
->
GetImageKeywordlist
());
resampler
->
SetOutputProjectionRef
(
panchro
->
GetProjectionRef
());
resampler
->
SetEdgePaddingValue
(
defaultValue
);
resampler
->
UpdateOutputInformation
();
FloatVectorImageType
::
Pointer
xsResample
=
resampler
->
GetOutput
();
FusionFilterType
::
Pointer
fusionFilter
=
FusionFilterType
::
New
();
m_Ref
.
push_back
(
fusionFilter
.
GetPointer
());
fusionFilter
->
SetPanInput
(
panchro
);
fusionFilter
->
SetXsInput
(
resampler
->
GetOutput
());
fusionFilter
->
UpdateOutputInformation
();
SetParameterOutputImage
(
"out"
,
fusionFilter
->
GetOutput
());
}
std
::
vector
<
itk
::
ProcessObject
::
Pointer
>
m_Ref
;
};
}
}
OTB_APPLICATION_EXPORT
(
otb
::
Wrapper
::
BundleToPerfectSensor
)
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