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
fff5a3b7
Commit
fff5a3b7
authored
Oct 13, 2014
by
Davis King
Browse files
Defined the jpeg quality measure.
parent
264c2b6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
dlib/image_saver/save_jpeg.cpp
dlib/image_saver/save_jpeg.cpp
+11
-0
dlib/image_saver/save_jpeg_abstract.h
dlib/image_saver/save_jpeg_abstract.h
+3
-0
No files found.
dlib/image_saver/save_jpeg.cpp
View file @
fff5a3b7
...
@@ -48,6 +48,11 @@ namespace dlib
...
@@ -48,6 +48,11 @@ namespace dlib
"
\t
save_jpeg()"
"
\t
save_jpeg()"
<<
"
\n\t
You can't save an empty image as a JPEG."
<<
"
\n\t
You can't save an empty image as a JPEG."
);
);
DLIB_CASSERT
(
0
<=
quality
&&
quality
<=
100
,
"
\t
save_jpeg()"
<<
"
\n\t
Invalid quality value."
<<
"
\n\t
quality: "
<<
quality
);
FILE
*
outfile
=
fopen
(
filename
.
c_str
(),
"wb"
);
FILE
*
outfile
=
fopen
(
filename
.
c_str
(),
"wb"
);
if
(
!
outfile
)
if
(
!
outfile
)
...
@@ -104,6 +109,12 @@ namespace dlib
...
@@ -104,6 +109,12 @@ namespace dlib
"
\t
save_jpeg()"
"
\t
save_jpeg()"
<<
"
\n\t
You can't save an empty image as a JPEG."
<<
"
\n\t
You can't save an empty image as a JPEG."
);
);
DLIB_CASSERT
(
0
<=
quality
&&
quality
<=
100
,
"
\t
save_jpeg()"
<<
"
\n\t
Invalid quality value."
<<
"
\n\t
quality: "
<<
quality
);
FILE
*
outfile
=
fopen
(
filename
.
c_str
(),
"wb"
);
FILE
*
outfile
=
fopen
(
filename
.
c_str
(),
"wb"
);
if
(
!
outfile
)
if
(
!
outfile
)
...
...
dlib/image_saver/save_jpeg_abstract.h
View file @
fff5a3b7
...
@@ -25,6 +25,7 @@ namespace dlib
...
@@ -25,6 +25,7 @@ namespace dlib
- image_type == an image object that implements the interface defined in
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h or a matrix expression
dlib/image_processing/generic_image.h or a matrix expression
- image.size() != 0
- image.size() != 0
- 0 <= quality <= 100
ensures
ensures
- writes the image to the file indicated by file_name in the JPEG format.
- writes the image to the file indicated by file_name in the JPEG format.
- image[0][0] will be in the upper left corner of the image.
- image[0][0] will be in the upper left corner of the image.
...
@@ -34,6 +35,8 @@ namespace dlib
...
@@ -34,6 +35,8 @@ namespace dlib
save_jpeg() can only natively store rgb_pixel and uint8 pixel types. All
save_jpeg() can only natively store rgb_pixel and uint8 pixel types. All
other pixel types will be converted into one of these types as appropriate
other pixel types will be converted into one of these types as appropriate
before being saved to disk.
before being saved to disk.
- The quality value determines how lossy the compression is. Larger quality
values result in larger output images but the images will look better.
throws
throws
- image_save_error
- image_save_error
This exception is thrown if there is an error that prevents us from saving
This exception is thrown if there is an error that prevents us from saving
...
...
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