Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
70e90955
Commit
70e90955
authored
Apr 23, 2013
by
Davis King
Browse files
Added the jet color scheme.
parent
1a725ee4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
0 deletions
+107
-0
dlib/image_transforms/colormaps.h
dlib/image_transforms/colormaps.h
+84
-0
dlib/image_transforms/colormaps_abstract.h
dlib/image_transforms/colormaps_abstract.h
+23
-0
No files found.
dlib/image_transforms/colormaps.h
View file @
70e90955
...
@@ -125,6 +125,90 @@ namespace dlib
...
@@ -125,6 +125,90 @@ namespace dlib
return
matrix_op
<
op
>
(
op
(
img
,
max_val
,
min_val
));
return
matrix_op
<
op
>
(
op
(
img
,
max_val
,
min_val
));
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
op_jet
:
does_not_alias
{
op_jet
(
const
T
&
img_
,
const
double
max_val_
,
const
double
min_val_
)
:
img
(
img_
),
max_val
(
max_val_
),
min_val
(
min_val_
){}
const
T
&
img
;
const
double
max_val
;
const
double
min_val
;
const
static
long
cost
=
7
;
const
static
long
NR
=
0
;
const
static
long
NC
=
0
;
typedef
rgb_pixel
type
;
typedef
const
rgb_pixel
const_ret_type
;
typedef
typename
T
::
mem_manager_type
mem_manager_type
;
typedef
row_major_layout
layout_type
;
const_ret_type
apply
(
long
r
,
long
c
)
const
{
// scale the gray value into the range [0, 8]
const
double
gray
=
8
*
put_in_range
(
0
,
1
,
(
get_pixel_intensity
(
img
[
r
][
c
])
-
min_val
)
/
(
max_val
-
min_val
));
rgb_pixel
pix
;
// s is the slope of color change
const
double
s
=
1.0
/
2.0
;
if
(
gray
<=
1
)
{
pix
.
red
=
0
;
pix
.
green
=
0
;
pix
.
blue
=
static_cast
<
unsigned
char
>
((
gray
+
1
)
*
s
*
255
+
0.5
);
}
else
if
(
gray
<=
3
)
{
pix
.
red
=
0
;
pix
.
green
=
static_cast
<
unsigned
char
>
((
gray
-
1
)
*
s
*
255
+
0.5
);
pix
.
blue
=
255
;
}
else
if
(
gray
<=
5
)
{
pix
.
red
=
static_cast
<
unsigned
char
>
((
gray
-
3
)
*
s
*
255
+
0.5
);
pix
.
green
=
255
;
pix
.
blue
=
static_cast
<
unsigned
char
>
((
5
-
gray
)
*
s
*
255
+
0.5
);
}
else
if
(
gray
<=
7
)
{
pix
.
red
=
255
;
pix
.
green
=
static_cast
<
unsigned
char
>
((
7
-
gray
)
*
s
*
255
+
0.5
);
pix
.
blue
=
0
;
}
else
{
pix
.
red
=
static_cast
<
unsigned
char
>
((
9
-
gray
)
*
s
*
255
+
0.5
);
pix
.
green
=
0
;
pix
.
blue
=
0
;
}
return
pix
;
}
long
nr
()
const
{
return
img
.
nr
();
}
long
nc
()
const
{
return
img
.
nc
();
}
};
template
<
typename
image_type
>
const
matrix_op
<
op_jet
<
image_type
>
>
jet
(
const
image_type
&
img
,
double
max_val
,
double
min_val
=
0
)
{
typedef
op_jet
<
image_type
>
op
;
return
matrix_op
<
op
>
(
op
(
img
,
max_val
,
min_val
));
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/image_transforms/colormaps_abstract.h
View file @
70e90955
...
@@ -54,6 +54,29 @@ namespace dlib
...
@@ -54,6 +54,29 @@ namespace dlib
- The returned matrix will have the same dimensions as img.
- The returned matrix will have the same dimensions as img.
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
const
matrix_exp
jet
(
const
image_type
&
img
,
double
max_val
,
double
min_val
=
0
);
/*!
requires
- image_type is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<image_type::type> must be defined
ensures
- Interprets img as a grayscale image and returns a new matrix which represents
a colored version of img. In particular, the colors will depict img using a
jet color scheme where pixels with a value <= min_val are dark blue and
larger pixel values become light blue, then yellow, and then finally red as
they approach max_Val.
- The returned matrix will have the same dimensions as img.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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