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
bb5e847b
Commit
bb5e847b
authored
May 14, 2013
by
Davis King
Browse files
Made image saving routines work on matrix objects in addition to array2d
objects.
parent
13b8c5f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
8 deletions
+62
-8
dlib/image_saver/image_saver.h
dlib/image_saver/image_saver.h
+31
-2
dlib/image_saver/image_saver_abstract.h
dlib/image_saver/image_saver_abstract.h
+8
-4
dlib/image_saver/save_png.h
dlib/image_saver/save_png.h
+21
-1
dlib/image_saver/save_png_abstract.h
dlib/image_saver/save_png_abstract.h
+2
-1
No files found.
dlib/image_saver/image_saver.h
View file @
bb5e847b
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
#include "../dir_nav.h"
#include "../dir_nav.h"
#include "../float_details.h"
#include "../float_details.h"
#include "../vectorstream.h"
#include "../vectorstream.h"
#include "../matrix/matrix_exp.h"
#include "../image_transforms/assign_image.h"
namespace
dlib
namespace
dlib
{
{
...
@@ -229,7 +231,7 @@ namespace dlib
...
@@ -229,7 +231,7 @@ namespace dlib
template
<
template
<
typename
image_type
typename
image_type
>
>
inline
void
save_bmp
(
inline
typename
disable_if
<
is_matrix
<
image_type
>
>::
type
save_bmp
(
const
image_type
&
image
,
const
image_type
&
image
,
std
::
ostream
&
out
std
::
ostream
&
out
)
)
...
@@ -237,6 +239,19 @@ namespace dlib
...
@@ -237,6 +239,19 @@ namespace dlib
save_bmp_helper
<
image_type
>::
save_bmp
(
image
,
out
);
save_bmp_helper
<
image_type
>::
save_bmp
(
image
,
out
);
}
}
template
<
typename
EXP
>
inline
void
save_bmp
(
const
matrix_exp
<
EXP
>&
image
,
std
::
ostream
&
out
)
{
array2d
<
typename
EXP
::
type
>
temp
;
assign_image
(
temp
,
image
);
save_bmp_helper
<
array2d
<
typename
EXP
::
type
>
>::
save_bmp
(
temp
,
out
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
namespace
dng_helpers_namespace
namespace
dng_helpers_namespace
...
@@ -578,7 +593,7 @@ namespace dlib
...
@@ -578,7 +593,7 @@ namespace dlib
template
<
template
<
typename
image_type
typename
image_type
>
>
inline
void
save_dng
(
inline
typename
disable_if
<
is_matrix
<
image_type
>
>::
type
save_dng
(
const
image_type
&
image
,
const
image_type
&
image
,
std
::
ostream
&
out
std
::
ostream
&
out
)
)
...
@@ -587,6 +602,20 @@ namespace dlib
...
@@ -587,6 +602,20 @@ namespace dlib
save_dng_helper
<
image_type
>::
save_dng
(
image
,
out
);
save_dng_helper
<
image_type
>::
save_dng
(
image
,
out
);
}
}
template
<
typename
EXP
>
inline
void
save_dng
(
const
matrix_exp
<
EXP
>&
image
,
std
::
ostream
&
out
)
{
array2d
<
typename
EXP
::
type
>
temp
;
assign_image
(
temp
,
image
);
using
namespace
dng_helpers_namespace
;
save_dng_helper
<
array2d
<
typename
EXP
::
type
>
>::
save_dng
(
temp
,
out
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
template
<
typename
image_type
>
...
...
dlib/image_saver/image_saver_abstract.h
View file @
bb5e847b
...
@@ -29,7 +29,8 @@ namespace dlib
...
@@ -29,7 +29,8 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
- pixel_traits<typename image_type::type> is defined
ensures
ensures
- writes the image to the out stream in the Microsoft Windows BMP format.
- writes the image to the out stream in the Microsoft Windows BMP format.
...
@@ -57,7 +58,8 @@ namespace dlib
...
@@ -57,7 +58,8 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
- pixel_traits<typename image_type::type> is defined
ensures
ensures
- opens the file indicated by file_name with an output file stream named fout
- opens the file indicated by file_name with an output file stream named fout
...
@@ -83,7 +85,8 @@ namespace dlib
...
@@ -83,7 +85,8 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
- pixel_traits<typename image_type::type> is defined
ensures
ensures
- writes the image to the out stream in the dlib dng format.
- writes the image to the out stream in the dlib dng format.
...
@@ -111,7 +114,8 @@ namespace dlib
...
@@ -111,7 +114,8 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
- pixel_traits<typename image_type::type> is defined
ensures
ensures
- opens the file indicated by file_name with an output file stream named fout
- opens the file indicated by file_name with an output file stream named fout
...
...
dlib/image_saver/save_png.h
View file @
bb5e847b
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#include <vector>
#include <vector>
#include <string>
#include <string>
#include "../pixel.h"
#include "../pixel.h"
#include "../matrix/matrix_exp.h"
#include "../image_transforms/assign_image.h"
namespace
dlib
namespace
dlib
{
{
...
@@ -38,7 +40,7 @@ namespace dlib
...
@@ -38,7 +40,7 @@ namespace dlib
template
<
template
<
typename
image_type
typename
image_type
>
>
void
save_png
(
typename
disable_if
<
is_matrix
<
image_type
>
>::
type
save_png
(
const
image_type
&
img
,
const
image_type
&
img
,
const
std
::
string
&
file_name
const
std
::
string
&
file_name
)
)
...
@@ -130,6 +132,24 @@ namespace dlib
...
@@ -130,6 +132,24 @@ namespace dlib
#endif
#endif
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
void
save_png
(
const
matrix_exp
<
EXP
>&
img
,
const
std
::
string
&
file_name
)
{
array2d
<
typename
EXP
::
type
>
temp
;
assign_image
(
temp
,
img
);
save_png
(
temp
,
file_name
);
}
// ----------------------------------------------------------------------------------------
}
}
#ifdef NO_MAKEFILE
#ifdef NO_MAKEFILE
...
...
dlib/image_saver/save_png_abstract.h
View file @
bb5e847b
...
@@ -19,7 +19,8 @@ namespace dlib
...
@@ -19,7 +19,8 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
- pixel_traits<typename image_type::type> is defined
- image.size() != 0
- image.size() != 0
ensures
ensures
...
...
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