DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
SimpleDistanceColorMap.h
1
16
17
#pragma once
18
30
31
#if defined(SimpleDistanceColorMap_RECURSES)
32
#error Recursive header files inclusion detected in SimpleDistanceColorMap.h
33
#else
// defined(SimpleDistanceColorMap_RECURSES)
35
#define SimpleDistanceColorMap_RECURSES
36
37
#if !defined SimpleDistanceColorMap_h
39
#define SimpleDistanceColorMap_h
40
42
// Inclusions
43
#include <iostream>
44
#include "DGtal/base/Common.h"
45
#include "DGtal/kernel/NumberTraits.h"
46
#include "DGtal/io/Color.h"
48
49
namespace
DGtal
50
{
51
53
// class SimpleDistanceColorMap
62
63
template
<
typename
TValue>
64
class
SimpleDistanceColorMap
65
{
66
// ----------------------- Standard services ------------------------------
67
public
:
68
70
typedef
TValue
Value
;
71
77
SimpleDistanceColorMap
(
const
SimpleDistanceColorMap
& other );
78
85
SimpleDistanceColorMap
&
operator=
(
const
SimpleDistanceColorMap
& anOther );
86
87
95
SimpleDistanceColorMap
(
const
Value
& amin,
96
const
Value
& amax,
97
const
bool
withTick=
true
):
98
myMin
(amin),
myMax
(amax),
myTick
(withTick)
99
{}
100
101
102
109
Color
operator()
(
const
Value
& aValue )
const
110
{
111
const
double
val = (
NumberTraits<Value>::castToDouble
(aValue) -
NumberTraits<Value>::castToDouble
(
myMin
))/
112
(
NumberTraits<Value>::castToDouble
(
myMax
) -
NumberTraits<Value>::castToDouble
(
myMin
));
113
const
double
d = 1. - val;
114
double
r = (1. - d*d) * .8;
115
double
g
= (1. - (2. * (d - .5)) * (2. * (d - .5))) * .7;
116
double
b = (1. - (1. - d) * (1. - d));
117
118
// lines
119
if
(
myTick
)
120
{
121
double
h = val;
122
h = h * 30.;
123
h = h - floor( h );
124
h = (1. / (1. + exp(-100.*(h - .55)))) + (1. / (1. + exp(-100.*(-h + .45))));
125
h = 1. - h;
126
r = h + (1. -h)*r;
127
g
= h + (1. - h)*
g
;
128
b = h + (1. - h)*b;
129
}
130
131
return
Color
(
static_cast<
unsigned
char
>
(r*255),
132
static_cast<
unsigned
char
>
(
g
*255),
133
static_cast<
unsigned
char
>
(b*255));
134
}
135
136
137
138
// ----------------------- Interface --------------------------------------
139
public
:
140
145
void
selfDisplay
( std::ostream & out )
const
;
146
151
bool
isValid
()
const
{
return
true
;}
152
158
const
Value
&
min
()
const
159
{
160
return
myMin
;
161
}
162
168
const
Value
&
max
()
const
169
{
170
return
myMax
;
171
}
172
173
// ------------------------- Protected Data ------------------------------
174
protected
:
175
177
Value
myMin
;
178
180
Value
myMax
;
181
183
bool
myTick
;
184
185
// ------------------------- Hidden services ------------------------------
186
protected
:
187
192
SimpleDistanceColorMap
();
193
194
195
};
// end of class SimpleDistanceColorMap
196
}
// namespace DGtal
197
198
199
// //
201
202
#endif
// !defined SimpleDistanceColorMap
203
204
#undef SimpleDistanceColorMap_RECURSES
205
#endif
// else defined(SimpleDistanceColorMap_RECURSES)
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::SimpleDistanceColorMap::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::SimpleDistanceColorMap::myMin
Value myMin
Min value.
Definition
SimpleDistanceColorMap.h:177
DGtal::SimpleDistanceColorMap::isValid
bool isValid() const
Definition
SimpleDistanceColorMap.h:151
DGtal::SimpleDistanceColorMap::SimpleDistanceColorMap
SimpleDistanceColorMap()
DGtal::SimpleDistanceColorMap::Value
TValue Value
Value type.
Definition
SimpleDistanceColorMap.h:70
DGtal::SimpleDistanceColorMap::SimpleDistanceColorMap
SimpleDistanceColorMap(const Value &amin, const Value &amax, const bool withTick=true)
Definition
SimpleDistanceColorMap.h:95
DGtal::SimpleDistanceColorMap::min
const Value & min() const
Definition
SimpleDistanceColorMap.h:158
DGtal::SimpleDistanceColorMap::operator=
SimpleDistanceColorMap & operator=(const SimpleDistanceColorMap &anOther)
DGtal::SimpleDistanceColorMap::myMax
Value myMax
Max value.
Definition
SimpleDistanceColorMap.h:180
DGtal::SimpleDistanceColorMap::SimpleDistanceColorMap
SimpleDistanceColorMap(const SimpleDistanceColorMap &other)
DGtal::SimpleDistanceColorMap::max
const Value & max() const
Definition
SimpleDistanceColorMap.h:168
DGtal::SimpleDistanceColorMap::operator()
Color operator()(const Value &aValue) const
Definition
SimpleDistanceColorMap.h:109
DGtal::SimpleDistanceColorMap::myTick
bool myTick
Boolean to activate/deactivate ticks.
Definition
SimpleDistanceColorMap.h:183
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::NumberTraitsImpl< std::decay< T >::type >::castToDouble
static double castToDouble(const T &aT)
Definition
NumberTraits.h:164
g
std::mt19937 g(rd())
src
DGtal
io
colormaps
SimpleDistanceColorMap.h
Generated on
for DGtal by
1.18.0