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
51421098
Commit
51421098
authored
Feb 21, 2014
by
Roman Donchenko
Committed by
OpenCV Buildbot
Feb 21, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2201 from mattip:2.4
parents
3e589069
dc50dc72
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
10 deletions
+55
-10
grfmt_tiff.cpp
modules/highgui/src/grfmt_tiff.cpp
+14
-10
test_grfmt.cpp
modules/highgui/test/test_grfmt.cpp
+41
-0
No files found.
modules/highgui/src/grfmt_tiff.cpp
View file @
51421098
...
...
@@ -238,11 +238,15 @@ bool TiffDecoder::readData( Mat& img )
{
case
8
:
{
uchar
*
bstart
=
buffer
;
if
(
!
is_tiled
)
ok
=
TIFFReadRGBAStrip
(
tif
,
y
,
(
uint32
*
)
buffer
);
else
{
ok
=
TIFFReadRGBATile
(
tif
,
x
,
y
,
(
uint32
*
)
buffer
);
//Tiles fill the buffer from the bottom up
bstart
+=
(
tile_height0
-
tile_height
)
*
tile_width0
*
4
;
}
if
(
!
ok
)
{
close
();
...
...
@@ -251,11 +255,11 @@ bool TiffDecoder::readData( Mat& img )
for
(
i
=
0
;
i
<
tile_height
;
i
++
)
if
(
color
)
icvCvt_BGRA2BGR_8u_C4C3R
(
b
uffer
+
i
*
tile_width
*
4
,
0
,
icvCvt_BGRA2BGR_8u_C4C3R
(
b
start
+
i
*
tile_width0
*
4
,
0
,
data
+
x
*
3
+
img
.
step
*
(
tile_height
-
i
-
1
),
0
,
cvSize
(
tile_width
,
1
),
2
);
else
icvCvt_BGRA2Gray_8u_C4C1R
(
b
uffer
+
i
*
tile_width
*
4
,
0
,
icvCvt_BGRA2Gray_8u_C4C1R
(
b
start
+
i
*
tile_width0
*
4
,
0
,
data
+
x
+
img
.
step
*
(
tile_height
-
i
-
1
),
0
,
cvSize
(
tile_width
,
1
),
2
);
break
;
...
...
@@ -280,19 +284,19 @@ bool TiffDecoder::readData( Mat& img )
{
if
(
ncn
==
1
)
{
icvCvt_Gray2BGR_16u_C1C3R
(
buffer16
+
i
*
tile_width
*
ncn
,
0
,
icvCvt_Gray2BGR_16u_C1C3R
(
buffer16
+
i
*
tile_width
0
*
ncn
,
0
,
(
ushort
*
)(
data
+
img
.
step
*
i
)
+
x
*
3
,
0
,
cvSize
(
tile_width
,
1
)
);
}
else
if
(
ncn
==
3
)
{
icvCvt_RGB2BGR_16u_C3R
(
buffer16
+
i
*
tile_width
*
ncn
,
0
,
icvCvt_RGB2BGR_16u_C3R
(
buffer16
+
i
*
tile_width
0
*
ncn
,
0
,
(
ushort
*
)(
data
+
img
.
step
*
i
)
+
x
*
3
,
0
,
cvSize
(
tile_width
,
1
)
);
}
else
{
icvCvt_BGRA2BGR_16u_C4C3R
(
buffer16
+
i
*
tile_width
*
ncn
,
0
,
icvCvt_BGRA2BGR_16u_C4C3R
(
buffer16
+
i
*
tile_width
0
*
ncn
,
0
,
(
ushort
*
)(
data
+
img
.
step
*
i
)
+
x
*
3
,
0
,
cvSize
(
tile_width
,
1
),
2
);
}
...
...
@@ -302,12 +306,12 @@ bool TiffDecoder::readData( Mat& img )
if
(
ncn
==
1
)
{
memcpy
((
ushort
*
)(
data
+
img
.
step
*
i
)
+
x
,
buffer16
+
i
*
tile_width
*
ncn
,
buffer16
+
i
*
tile_width
0
*
ncn
,
tile_width
*
sizeof
(
buffer16
[
0
]));
}
else
{
icvCvt_BGRA2Gray_16u_CnC1R
(
buffer16
+
i
*
tile_width
*
ncn
,
0
,
icvCvt_BGRA2Gray_16u_CnC1R
(
buffer16
+
i
*
tile_width
0
*
ncn
,
0
,
(
ushort
*
)(
data
+
img
.
step
*
i
)
+
x
,
0
,
cvSize
(
tile_width
,
1
),
ncn
,
2
);
}
...
...
@@ -335,13 +339,13 @@ bool TiffDecoder::readData( Mat& img )
if
(
dst_bpp
==
32
)
{
memcpy
((
float
*
)(
data
+
img
.
step
*
i
)
+
x
,
buffer32
+
i
*
tile_width
*
ncn
,
buffer32
+
i
*
tile_width
0
*
ncn
,
tile_width
*
sizeof
(
buffer32
[
0
]));
}
else
{
memcpy
((
double
*
)(
data
+
img
.
step
*
i
)
+
x
,
buffer64
+
i
*
tile_width
*
ncn
,
buffer64
+
i
*
tile_width
0
*
ncn
,
tile_width
*
sizeof
(
buffer64
[
0
]));
}
}
...
...
modules/highgui/test/test_grfmt.cpp
View file @
51421098
...
...
@@ -467,4 +467,45 @@ TEST(Highgui_Tiff, write_read_16bit_big_little_endian)
}
}
class
CV_GrfmtReadTifTiledWithNotFullTiles
:
public
cvtest
::
BaseTest
{
public
:
void
run
(
int
)
{
try
{
/* see issue #3472 - dealing with tiled images where the tile size is
* not a multiple of image size.
* The tiled images were created with 'convert' from ImageMagick,
* using the command 'convert <input> -define tiff:tile-geometry=128x128 -depth [8|16] <output>
* Note that the conversion to 16 bits expands the range from 0-255 to 0-255*255,
* so the test converts back but rounding errors cause small differences.
*/
cv
::
Mat
img
=
imread
(
string
(
ts
->
get_data_path
())
+
"readwrite/non_tiled.tif"
,
-
1
);
if
(
img
.
empty
())
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
ASSERT_TRUE
(
img
.
channels
()
==
3
);
cv
::
Mat
tiled8
=
imread
(
string
(
ts
->
get_data_path
())
+
"readwrite/tiled_8.tif"
,
-
1
);
if
(
tiled8
.
empty
())
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
ASSERT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
0
,
0
),
img
,
tiled8
);
cv
::
Mat
tiled16
=
imread
(
string
(
ts
->
get_data_path
())
+
"readwrite/tiled_16.tif"
,
-
1
);
if
(
tiled16
.
empty
())
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
ASSERT_TRUE
(
tiled16
.
elemSize
()
==
6
);
tiled16
.
convertTo
(
tiled8
,
CV_8UC3
,
1.
/
256.
);
ASSERT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
2
,
0
),
img
,
tiled8
);
// What about 32, 64 bit?
}
catch
(...)
{
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_EXCEPTION
);
}
ts
->
set_failed_test_info
(
cvtest
::
TS
::
OK
);
}
};
TEST
(
Highgui_Tiff
,
decode_tile_remainder
)
{
CV_GrfmtReadTifTiledWithNotFullTiles
test
;
test
.
safe_run
();
}
#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