Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
223a82d1
Commit
223a82d1
authored
Oct 08, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added randomly_color_image()
parent
6bf11ad2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
image_transforms.h
dlib/image_transforms.h
+1
-0
randomly_color_image.h
dlib/image_transforms/randomly_color_image.h
+71
-0
randomly_color_image_abstract.h
dlib/image_transforms/randomly_color_image_abstract.h
+41
-0
No files found.
dlib/image_transforms.h
View file @
223a82d1
...
...
@@ -13,6 +13,7 @@
#include "image_transforms/integral_image.h"
#include "image_transforms/image_pyramid.h"
#include "image_transforms/label_connected_blobs.h"
#include "image_transforms/randomly_color_image.h"
#endif // DLIB_IMAGE_TRANSFORMs_
dlib/image_transforms/randomly_color_image.h
0 → 100644
View file @
223a82d1
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_RANDOMLY_COlOR_IMAGE_H__
#define DLIB_RANDOMLY_COlOR_IMAGE_H__
#include "randomly_color_image_abstract.h"
#include "../hash.h"
#include "../pixel.h"
#include "../matrix.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
op_randomly_color_image
:
does_not_alias
{
op_randomly_color_image
(
const
T
&
img_
)
:
img
(
img_
){}
const
T
&
img
;
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
{
const
unsigned
long
gray
=
get_pixel_intensity
(
img
[
r
][
c
]);
if
(
gray
!=
0
)
{
const
uint32
h
=
murmur_hash3
(
&
gray
,
sizeof
(
gray
));
rgb_pixel
pix
;
pix
.
red
=
static_cast
<
unsigned
char
>
(
h
)
%
200
+
55
;
pix
.
green
=
static_cast
<
unsigned
char
>
(
h
>>
8
)
%
200
+
55
;
pix
.
blue
=
static_cast
<
unsigned
char
>
(
h
>>
16
)
%
200
+
55
;
return
pix
;
}
else
{
// keep black pixels black
return
rgb_pixel
(
0
,
0
,
0
);
}
}
long
nr
()
const
{
return
img
.
nr
();
}
long
nc
()
const
{
return
img
.
nc
();
}
};
template
<
typename
image_type
>
const
matrix_op
<
op_randomly_color_image
<
image_type
>
>
randomly_color_image
(
const
image_type
&
img
)
{
typedef
op_randomly_color_image
<
image_type
>
op
;
return
matrix_op
<
op
>
(
op
(
img
));
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RANDOMLY_COlOR_IMAGE_H__
dlib/image_transforms/randomly_color_image_abstract.h
0 → 100644
View file @
223a82d1
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_RANDOMLY_COlOR_IMAGE_ABSTRACT_H__
#ifdef DLIB_RANDOMLY_COlOR_IMAGE_ABSTRACT_H__
#include "randomly_color_image_abstract.h"
#include "../hash.h"
#include "../pixel.h"
#include "../matrix.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
const
matrix_exp
randomly_color_image
(
const
image_type
&
img
);
/*!
requires
- image_type is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<image_type::type> must be defined
ensures
- randomly generates a mapping from gray level pixel values
to the RGB pixel space and then uses this mapping to create
a colored version of img. Returns a matrix which represents
this colored version of img.
- black pixels in img will remain black in the output image.
- The returned matrix will have the same dimensions as img.
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RANDOMLY_COlOR_IMAGE_ABSTRACT_H__
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