DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
DGtal
io
colormaps
GrayscaleColorMap.ih
1
30
31
#include <cstdlib>
33
35
// IMPLEMENTATION of inline methods.
37
39
// ----------------------- Standard services ------------------------------
40
41
template
<
typename
Value>
42
inline
43
DGtal::GrayscaleColorMap<Value>::GrayscaleColorMap
(
const
Value
& aMin,
44
const
Value
& aMax )
45
: myMin( aMin ), myMax( aMax )
46
{ }
47
48
template
<
typename
Value>
49
inline
50
DGtal::GrayscaleColorMap<Value>::GrayscaleColorMap
51
(
const
GrayscaleColorMap<Value>
& other )
52
: myMin( other.
myMin
), myMax( other.
myMax
)
53
{
54
}
55
56
template
<
typename
Value>
57
inline
58
DGtal::GrayscaleColorMap<Value>::~GrayscaleColorMap
()
59
{
60
}
61
62
template
<
typename
Value>
63
GrayscaleColorMap<Value>
&
64
GrayscaleColorMap<Value>::operator
=
65
(
const
GrayscaleColorMap<Value>
& other )
66
{
67
if
( &other !=
this
) {
68
myMin = other.
myMin
;
69
myMax = other.
myMax
;
70
}
71
return
*
this
;
72
}
73
75
// Interface - public :
76
77
78
template
<
typename
Value>
79
inline
80
const
Value &
81
DGtal::GrayscaleColorMap<Value>::min
()
const
82
{
83
return
myMin;
84
}
85
86
template
<
typename
Value>
87
inline
88
const
Value &
89
DGtal::GrayscaleColorMap<Value>::max
()
const
90
{
91
return
myMax;
92
}
93
94
template
<
typename
Value>
95
inline
96
Color
97
DGtal::GrayscaleColorMap<Value>::operator()
(
const
Value
& value )
const
98
{
99
return
GrayscaleColorMap<Value>::getColor
( myMin, myMax, value );
100
}
101
106
template
<
typename
Value>
107
inline
108
void
109
DGtal::GrayscaleColorMap<Value>::selfDisplay
( std::ostream & out )
const
110
{
111
out <<
"[GrayscaleColorMap "
112
<<
" min="
<< myMin
113
<<
" max="
<< myMax
114
<<
" ]"
;
115
}
116
121
template
<
typename
Value>
122
inline
123
bool
124
DGtal::GrayscaleColorMap<Value>::isValid
()
const
125
{
126
return
true
;
127
}
128
129
130
template
<
typename
Value>
131
inline
132
Color
133
DGtal::GrayscaleColorMap<Value>::getColor
(
const
Value
& min,
134
const
Value
& max,
135
const
Value
& value )
136
{
137
double
range =
static_cast<
double
>
( max - min );
138
double
scale =
static_cast<
double
>
( value - min );
139
unsigned
char
gray =
static_cast<
unsigned
char
>
( 255.0 * ( scale / range ) );
140
return
Color
( gray );
141
}
142
144
// Implementation of inline functions //
145
146
template
<
typename
Value>
147
inline
148
std::ostream&
149
DGtal::operator<<
( std::ostream & out,
150
const
GrayscaleColorMap<Value>
&
object
)
151
{
152
object
.selfDisplay( out );
153
return
out;
154
}
155
156
// //
158
159
Generated on Wed Dec 19 2012 19:10:25 for DGtal by
1.8.1.1