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
01074177
Commit
01074177
authored
Apr 06, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgraded the dng image format so it can natively store floating point
pixel types without any information loss.
parent
90668383
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
7 deletions
+70
-7
image_loader.h
dlib/image_loader/image_loader.h
+0
-0
dng_shared.h
dlib/image_saver/dng_shared.h
+2
-1
image_saver.h
dlib/image_saver/image_saver.h
+63
-1
image_saver_abstract.h
dlib/image_saver/image_saver_abstract.h
+5
-5
No files found.
dlib/image_loader/image_loader.h
View file @
01074177
This diff is collapsed.
Click to expand it.
dlib/image_saver/dng_shared.h
View file @
01074177
...
...
@@ -20,7 +20,8 @@ namespace dlib
rgb_paeth
,
rgb_alpha
,
rgb_alpha_paeth
,
grayscale_16bit
grayscale_16bit
,
grayscale_float
};
const
unsigned
long
dng_magic_byte
=
100
;
...
...
dlib/image_saver/image_saver.h
View file @
01074177
...
...
@@ -15,6 +15,8 @@
#include "dng_shared.h"
#include "../uintn.h"
#include "../dir_nav.h"
#include "../float_details.h"
#include "../vectorstream.h"
namespace
dlib
{
...
...
@@ -249,7 +251,9 @@ namespace dlib
false
,
pixel_traits
<
typename
image_type
::
type
>::
rgb_alpha
,
false
,
pixel_traits
<
typename
image_type
::
type
>::
grayscale
&&
sizeof
(
typename
image_type
::
type
)
!=
1
pixel_traits
<
typename
image_type
::
type
>::
grayscale
&&
sizeof
(
typename
image_type
::
type
)
!=
1
&&
!
is_float_type
<
typename
image_type
::
type
>::
value
,
is_float_type
<
typename
image_type
::
type
>::
value
>::
value
>
struct
save_dng_helper
;
...
...
@@ -257,6 +261,64 @@ namespace dlib
typedef
entropy_encoder
::
kernel_2a
encoder_type
;
typedef
entropy_encoder_model
<
256
,
encoder_type
>::
kernel_5a
eem_type
;
typedef
entropy_encoder_model
<
256
,
encoder_type
>::
kernel_4a
eem_exp_type
;
template
<
typename
image_type
>
struct
save_dng_helper
<
image_type
,
grayscale_float
>
{
static
void
save_dng
(
const
image_type
&
image
,
std
::
ostream
&
out
)
{
out
.
write
(
"DNG"
,
3
);
unsigned
long
version
=
1
;
serialize
(
version
,
out
);
unsigned
long
type
=
grayscale_float
;
serialize
(
type
,
out
);
serialize
(
image
.
nc
(),
out
);
serialize
(
image
.
nr
(),
out
);
// Write the compressed exponent data into expbuf. We will append it
// to the stream at the end of the loops.
std
::
vector
<
char
>
expbuf
;
expbuf
.
reserve
(
image
.
size
()
*
2
);
vectorstream
outexp
(
expbuf
);
encoder_type
encoder
;
encoder
.
set_stream
(
outexp
);
eem_exp_type
eem_exp
(
encoder
);
float_details
prev
;
for
(
long
r
=
0
;
r
<
image
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
image
.
nc
();
++
c
)
{
float_details
cur
=
image
[
r
][
c
];
int16
exp
=
cur
.
exponent
-
prev
.
exponent
;
int64
man
=
cur
.
mantissa
-
prev
.
mantissa
;
prev
=
cur
;
unsigned
char
ebyte1
=
exp
&
0xFF
;
unsigned
char
ebyte2
=
exp
>>
8
;
eem_exp
.
encode
(
ebyte1
);
eem_exp
.
encode
(
ebyte2
);
serialize
(
man
,
out
);
}
}
// write out the magic byte to mark the end of the compressed data.
eem_exp
.
encode
(
dng_magic_byte
);
eem_exp
.
encode
(
dng_magic_byte
);
eem_exp
.
encode
(
dng_magic_byte
);
eem_exp
.
encode
(
dng_magic_byte
);
encoder
.
clear
();
serialize
(
expbuf
,
out
);
}
};
template
<
typename
image_type
>
struct
save_dng_helper
<
image_type
,
grayscale_16bit
>
{
...
...
dlib/image_saver/image_saver_abstract.h
View file @
01074177
...
...
@@ -90,11 +90,11 @@ namespace dlib
- image[0][0] will be in the upper left corner of the image.
- image[image.nr()-1][image.nc()-1] will be in the lower right
corner of the image.
- This routine can save images containing any type of pixel. However, the
DNG format can natively store only the following pixel types: rgb_pixel,
hsi_pixel, rgb_alpha_pixel, uint8,
and uint16. All other pixel types
will be converted into one of these types as appropriate before being
saved to disk.
- This routine can save images containing any type of pixel. However, the
DNG
format can natively store only the following pixel types: rgb_pixel,
hsi_pixel, rgb_alpha_pixel, uint8,
uint16, float, double, and long double.
All other pixel types will be converted into one of these types as
appropriate before being
saved to disk.
throws
- image_save_error
This exception is thrown if there is an error that prevents us
...
...
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