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
5d659af7
Commit
5d659af7
authored
Feb 08, 2014
by
Davis King
Browse files
Added tile_images()
parent
60333afe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
dlib/image_transforms/draw.h
dlib/image_transforms/draw.h
+46
-0
dlib/image_transforms/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