Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
b4d0dff4
Commit
b4d0dff4
authored
Jan 29, 2013
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added minimal support for tiff encoder parameters and test for issue #2161
parent
3dbb98e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
grfmt_tiff.cpp
modules/highgui/src/grfmt_tiff.cpp
+17
-1
test_grfmt.cpp
modules/highgui/test/test_grfmt.cpp
+19
-0
No files found.
modules/highgui/src/grfmt_tiff.cpp
View file @
b4d0dff4
...
@@ -402,7 +402,18 @@ void TiffEncoder::writeTag( WLByteStream& strm, TiffTag tag,
...
@@ -402,7 +402,18 @@ void TiffEncoder::writeTag( WLByteStream& strm, TiffTag tag,
}
}
#ifdef HAVE_TIFF
#ifdef HAVE_TIFF
bool
TiffEncoder
::
writeLibTiff
(
const
Mat
&
img
,
const
vector
<
int
>&
/*params*/
)
static
void
readParam
(
const
vector
<
int
>&
params
,
int
key
,
int
&
value
)
{
for
(
size_t
i
=
0
;
i
+
1
<
params
.
size
();
i
+=
2
)
if
(
params
[
i
]
==
key
)
{
value
=
params
[
i
+
1
];
break
;
}
}
bool
TiffEncoder
::
writeLibTiff
(
const
Mat
&
img
,
const
vector
<
int
>&
params
)
{
{
int
channels
=
img
.
channels
();
int
channels
=
img
.
channels
();
int
width
=
img
.
cols
,
height
=
img
.
rows
;
int
width
=
img
.
cols
,
height
=
img
.
rows
;
...
@@ -429,7 +440,9 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const vector<int>& /*params*/)
...
@@ -429,7 +440,9 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const vector<int>& /*params*/)
const
int
bitsPerByte
=
8
;
const
int
bitsPerByte
=
8
;
size_t
fileStep
=
(
width
*
channels
*
bitsPerChannel
)
/
bitsPerByte
;
size_t
fileStep
=
(
width
*
channels
*
bitsPerChannel
)
/
bitsPerByte
;
int
rowsPerStrip
=
(
int
)((
1
<<
13
)
/
fileStep
);
int
rowsPerStrip
=
(
int
)((
1
<<
13
)
/
fileStep
);
readParam
(
params
,
TIFFTAG_ROWSPERSTRIP
,
rowsPerStrip
);
if
(
rowsPerStrip
<
1
)
if
(
rowsPerStrip
<
1
)
rowsPerStrip
=
1
;
rowsPerStrip
=
1
;
...
@@ -450,6 +463,9 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const vector<int>& /*params*/)
...
@@ -450,6 +463,9 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const vector<int>& /*params*/)
int
compression
=
COMPRESSION_LZW
;
int
compression
=
COMPRESSION_LZW
;
int
predictor
=
PREDICTOR_HORIZONTAL
;
int
predictor
=
PREDICTOR_HORIZONTAL
;
readParam
(
params
,
TIFFTAG_COMPRESSION
,
compression
);
readParam
(
params
,
TIFFTAG_PREDICTOR
,
predictor
);
int
colorspace
=
channels
>
1
?
PHOTOMETRIC_RGB
:
PHOTOMETRIC_MINISBLACK
;
int
colorspace
=
channels
>
1
?
PHOTOMETRIC_RGB
:
PHOTOMETRIC_MINISBLACK
;
if
(
!
TIFFSetField
(
pTiffHandle
,
TIFFTAG_IMAGEWIDTH
,
width
)
if
(
!
TIFFSetField
(
pTiffHandle
,
TIFFTAG_IMAGEWIDTH
,
width
)
...
...
modules/highgui/test/test_grfmt.cpp
View file @
b4d0dff4
...
@@ -291,3 +291,22 @@ TEST(Highgui_Jpeg, encode_empty)
...
@@ -291,3 +291,22 @@ TEST(Highgui_Jpeg, encode_empty)
ASSERT_THROW
(
cv
::
imencode
(
".jpg"
,
img
,
jpegImg
),
cv
::
Exception
);
ASSERT_THROW
(
cv
::
imencode
(
".jpg"
,
img
,
jpegImg
),
cv
::
Exception
);
}
}
#endif
#endif
#ifdef HAVE_TIFF
#include "tiff.h"
TEST
(
Highgui_Tiff
,
decode_tile16384x16384
)
{
// see issue #2161
cv
::
Mat
big
(
16384
,
16384
,
CV_8UC1
,
cv
::
Scalar
::
all
(
0
));
string
file
=
cv
::
tempfile
(
".tiff"
);
std
::
vector
<
int
>
params
;
params
.
push_back
(
TIFFTAG_ROWSPERSTRIP
);
params
.
push_back
(
big
.
rows
);
cv
::
imwrite
(
file
,
big
,
params
);
big
.
release
();
EXPECT_NO_THROW
(
cv
::
imread
(
file
));
remove
(
file
.
c_str
());
}
#endif
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