Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
54021a37
Commit
54021a37
authored
Feb 27, 2010
by
Emmanuel Christophe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: add relief colormap functor
parent
393f20ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
6 deletions
+159
-6
Code/BasicFilters/otbReliefColormapFunctor.h
Code/BasicFilters/otbReliefColormapFunctor.h
+75
-0
Code/BasicFilters/otbReliefColormapFunctor.txx
Code/BasicFilters/otbReliefColormapFunctor.txx
+78
-0
Examples/BasicFilters/DEMToRainbowExample.cxx
Examples/BasicFilters/DEMToRainbowExample.cxx
+6
-6
No files found.
Code/BasicFilters/otbReliefColormapFunctor.h
0 → 100644
View file @
54021a37
/*=========================================================================
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.
=========================================================================*/
#ifndef __otbReliefColormapFunctor_h
#define __otbReliefColormapFunctor_h
#include "itkColormapFunctor.h"
namespace
otb
{
namespace
Functor
{
/**
* \class ReliefColormapFunctor
* \brief Function object which maps a scalar value into an RGB colormap value for relief representation.
*
* This code is working with the framework contributed in the Insight Journal paper:
*
* "Meeting Andy Warhol Somewhere Over the Rainbow: RGB Colormapping and ITK"
* http://www.insight-journal.org/browse/publication/285
* http://hdl.handle.net/1926/1452
*
*/
template
<
class
TScalar
,
class
TRGBPixel
>
class
ITK_EXPORT
ReliefColormapFunctor
:
public
itk
::
Functor
::
ColormapFunctor
<
TScalar
,
TRGBPixel
>
{
public:
typedef
ReliefColormapFunctor
Self
;
typedef
itk
::
Functor
::
ColormapFunctor
<
TScalar
,
TRGBPixel
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Method for creation through the object factory. */
itkNewMacro
(
Self
);
typedef
typename
Superclass
::
RGBPixelType
RGBPixelType
;
typedef
typename
Superclass
::
ScalarType
ScalarType
;
typedef
typename
Superclass
::
RealType
RealType
;
virtual
RGBPixelType
operator
()(
const
TScalar
&
)
const
;
protected:
ReliefColormapFunctor
(){};
~
ReliefColormapFunctor
()
{};
private:
ReliefColormapFunctor
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
};
}
// end namespace functor
}
// end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbReliefColormapFunctor.txx"
#endif
#endif
Code/BasicFilters/otbReliefColormapFunctor.txx
0 → 100644
View file @
54021a37
/*=========================================================================
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.
=========================================================================*/
#ifndef __otbReliefColormapFunctor_txx
#define __otbReliefColormapFunctor_txx
#include "otbReliefColormapFunctor.h"
namespace otb {
namespace Functor {
template <class TScalar, class TRGBPixel>
typename ReliefColormapFunctor<TScalar, TRGBPixel>::RGBPixelType
ReliefColormapFunctor<TScalar, TRGBPixel>
::operator()( const TScalar & v ) const
{
float m_Borders[] = {0.0, 0.2, 0.43, 0.71, 1.0};
float m_RedValues[] = {0.2, 0.94, 0.74, 0.92, 1.0};
float m_GreenValues[] = {0.7, 0.98, 0.72, 0.86, 1.0};
float m_BlueValues[] = {0.2, 0.59, 0.53, 0.69, 1.0};
// Map the input scalar between [0, 1].
RealType value = this->RescaleInputValue( v );
int i = 1;
while (value > m_Borders[i]) i++;
float factor = (value-m_Borders[i-1]) / (m_Borders[i]-m_Borders[i-1]);
// Apply the color mapping.
RealType red = m_RedValues[i-1]+factor*(m_RedValues[i]-m_RedValues[i-1]);
RealType green = m_GreenValues[i-1]+factor*(m_GreenValues[i]-m_GreenValues[i-1]);
RealType blue = m_BlueValues[i-1]+factor*(m_BlueValues[i]-m_BlueValues[i-1]);
// Normalize the values
red = vnl_math_max( 0.0, red );
red = vnl_math_min( 1.0, red );
green = vnl_math_max( 0.0, green );
green = vnl_math_min( 1.0, green );
blue = vnl_math_max( 0.0, blue );
blue = vnl_math_min( 1.0, blue );
// Set the rgb components after rescaling the values.
RGBPixelType pixel;
pixel[0] = this->RescaleRGBComponentValue( red );
pixel[1] = this->RescaleRGBComponentValue( green );
pixel[2] = this->RescaleRGBComponentValue( blue );
return pixel;
}
} // end namespace Functor
} // end namespace otb
#endif
Examples/BasicFilters/DEMToRainbowExample.cxx
View file @
54021a37
...
...
@@ -35,8 +35,8 @@
// Software Guide : EndCommandLineArgs
// Software Guide : BeginCommandLineArgs
// OUTPUTS: {DEMTo
Jet
ImageGenerator.png}
// 6.5 45.5 500 500 0.002 -0.002 ${OTB_DATA_ROOT}/Examples/DEM_srtm
jet
// OUTPUTS: {DEMTo
Relief
ImageGenerator.png}
// 6.5 45.5 500 500 0.002 -0.002 ${OTB_DATA_ROOT}/Examples/DEM_srtm
relief
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
...
...
@@ -62,7 +62,7 @@
#include "itkScalarToRGBColormapImageFilter.h"
#include "otbScalarToRainbowRGBPixelFunctor.h"
#include "otbDEMToImageGenerator.h"
#include "otbReliefColormapFunctor.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -141,7 +141,7 @@ int main(int argc, char * argv[])
else
{
if
(
strcmp
(
argv
[
8
],
"hot"
)
==
0
)
if
(
strcmp
(
argv
[
9
],
"hot"
)
==
0
)
{
typedef
itk
::
Functor
::
HotColormapFunctor
<
PixelType
,
RGBPixelType
>
ColorMapFunctorType
;
ColorMapFunctorType
::
Pointer
colormap
=
ColorMapFunctorType
::
New
();
...
...
@@ -151,7 +151,7 @@ int main(int argc, char * argv[])
}
else
{
typedef
itk
::
Functor
::
Jet
ColormapFunctor
<
PixelType
,
RGBPixelType
>
ColorMapFunctorType
;
typedef
otb
::
Functor
::
Relief
ColormapFunctor
<
PixelType
,
RGBPixelType
>
ColorMapFunctorType
;
ColorMapFunctorType
::
Pointer
colormap
=
ColorMapFunctorType
::
New
();
colormap
->
SetMinimumInputValue
(
0
);
colormap
->
SetMaximumInputValue
(
4000
);
...
...
@@ -192,7 +192,7 @@ int main(int argc, char * argv[])
// \includegraphics[width=0.44\textwidth]{pretty_DEMToImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToRainbowImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToHotImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMTo
Jet
ImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMTo
Relief
ImageGenerator.eps}
// \itkcaption[Grayscale to color]{The gray level DEM extracted from SRTM
// data (top-left) and the same area in color representation.}
// \label{fig:RAINBOW_FILTER}
...
...
Write
Preview
Markdown
is supported
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