Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Main Repositories
otb
Commits
87b0c511
Commit
87b0c511
authored
Apr 02, 2020
by
Cédric Traizet
Browse files
ENH: add functor to compute spectral angle on a vector of reference pixel
parent
c93be2c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Modules/Filtering/ImageManipulation/include/otbSpectralAngleFunctor.h
View file @
87b0c511
...
@@ -96,9 +96,52 @@ private :
...
@@ -96,9 +96,52 @@ private :
double
m_RefNorm
;
double
m_RefNorm
;
};
};
template
<
class
TInput
,
class
TReference
,
class
TOutput
>
class
SpectralAngleMapperFunctor
{
public:
SpectralAngleMapperFunctor
()
=
default
;
virtual
~
SpectralAngleMapperFunctor
()
=
default
;
// Binary operator
inline
TOutput
operator
()(
const
TInput
&
inPix
)
const
{
TOutput
res
;
res
.
SetSize
(
m_ReferencePixels
.
size
());
for
(
unsigned
int
i
=
0
;
i
<
m_ReferencePixels
.
size
();
i
++
)
{
res
[
i
]
=
SpectralAngleDetails
::
ComputeSpectralAngle
<
TInput
,
TInput
,
typename
TOutput
::
ValueType
>
(
inPix
,
m_ReferencePixels
[
i
],
m_ReferenceNorm
[
i
]);
}
return
res
;
}
size_t
OutputSize
(...)
const
{
return
m_ReferencePixels
.
size
();
}
void
SetReferencePixels
(
std
::
vector
<
TReference
>
const
&
ref
)
{
m_ReferencePixels
=
ref
;
// Precompute the norm of reference pixels
for
(
auto
const
&
pix
:
ref
)
{
m_ReferenceNorm
.
push_back
(
pix
.
GetNorm
());
}
}
std
::
vector
<
TReference
>
GetReferencePixels
()
const
{
return
m_ReferencePixels
;
}
private:
std
::
vector
<
TReference
>
m_ReferencePixels
;
std
::
vector
<
double
>
m_ReferenceNorm
;
};
}
// end namespace functor
}
// end namespace functor
}
// end namespace otb
}
// end namespace otb
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment