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
5d659af7
Commit
5d659af7
authored
Feb 08, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tile_images()
parent
60333afe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
draw.h
dlib/image_transforms/draw.h
+46
-0
draw_abstract.h
dlib/image_transforms/draw_abstract.h
+19
-0
No files found.
dlib/image_transforms/draw.h
View file @
5d659af7
...
...
@@ -6,6 +6,7 @@
#include "draw_abstract.h"
#include "../algs.h"
#include "../pixel.h"
#include "../matrix.h"
#include <cmath>
namespace
dlib
...
...
@@ -229,6 +230,51 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_array_type
>
matrix
<
typename
image_array_type
::
value_type
::
type
>
tile_images
(
const
image_array_type
&
images
)
{
typedef
typename
image_array_type
::
value_type
::
type
T
;
if
(
images
.
size
()
==
0
)
return
matrix
<
T
>
();
const
unsigned
long
size_nc
=
square_root
(
images
.
size
());
const
unsigned
long
size_nr
=
(
size_nc
*
(
size_nc
-
1
)
>=
images
.
size
())
?
size_nc
-
1
:
size_nc
;
// Figure out the size we have to use for each chip in the big main image. We will
// use the largest dimensions seen across all the chips.
long
nr
=
0
;
long
nc
=
0
;
for
(
unsigned
long
i
=
0
;
i
<
images
.
size
();
++
i
)
{
nr
=
std
::
max
(
images
[
i
].
nr
(),
nr
);
nc
=
std
::
max
(
images
[
i
].
nc
(),
nc
);
}
matrix
<
T
>
temp
(
size_nr
*
nr
,
size_nc
*
nc
);
T
background_color
;
assign_pixel
(
background_color
,
0
);
temp
=
background_color
;
unsigned
long
idx
=
0
;
for
(
long
r
=
0
;
r
<
size_nr
;
++
r
)
{
for
(
long
c
=
0
;
c
<
size_nc
;
++
c
)
{
if
(
idx
<
images
.
size
())
{
set_subm
(
temp
,
r
*
nr
,
c
*
nc
,
nr
,
nc
)
=
mat
(
images
[
idx
]);
}
++
idx
;
}
}
return
temp
;
}
// ----------------------------------------------------------------------------------------
}
...
...
dlib/image_transforms/draw_abstract.h
View file @
5d659af7
...
...
@@ -3,6 +3,7 @@
#undef DLIB_DRAW_IMAGe_ABSTRACT
#ifdef DLIB_DRAW_IMAGe_ABSTRACT
#include "../matrix.h"
namespace
dlib
{
...
...
@@ -94,6 +95,24 @@ namespace dlib
- fills the area defined by rect in the given image with the given pixel value.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_array_type
>
matrix
<
typename
image_array_type
::
value_type
::
type
>
tile_images
(
const
image_array_type
&
images
);
/*!
requires
- image_array_type is a dlib::array of array2d objects, each containing pixels
with a pixel_traits definition or any type with a compatible interface.
ensures
- This function takes the given images and tiles them into a single large
square image and returns this new big tiled image. Therefore, it is a useful
method to visualize many small images at once.
!*/
// ----------------------------------------------------------------------------------------
}
...
...
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