-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support tiled TIFFs #4201
Support tiled TIFFs #4201
Conversation
8a95ff9
to
9cbc30e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick, looks ok otherwise.
DALI_ENFORCE(TIFFReadTile(tiff.get(), buf.get(), tile_x, tile_y, 0, 0) > 0, | ||
"TIFFReadTile failed"); | ||
} else { | ||
LIBTIFF_CALL(TIFFReadScanline(tiff.get(), buf.get(), tile_y, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird, that we use both LIBTIFF_CALL and DALI_ENFORCE for TIFFRead***
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is weird, but that's libtiff. Almost all of its functions, including TIFFReadScanline
, return 1 on success and that's what LIBTIFF_CALL
checks for. But TIFFReadTile
returns the number of bytes read, because why not
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
f16855d
to
da680e4
Compare
// TODO(skarpinski) Support tiled images | ||
if (info.is_tiled) | ||
return {false, make_exception_ptr(std::logic_error("Tiled images are not yet supported"))}; | ||
if (info.is_tiled && info.tile_width % 16 != 0 && info.tile_height % 16 != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (info.is_tiled && info.tile_width % 16 != 0 && info.tile_height % 16 != 0) { | |
if (info.is_tiled && (info.tile_width % 16 != 0 || info.tile_height % 16 != 0)) { |
Shouldn't be both a multiple of 16?
@@ -234,7 +234,7 @@ class DecoderTestBase : public ::testing::Test { | |||
Tensor<CPUBackend> Crop(const Tensor<CPUBackend> &input, const ROI &roi) { | |||
int ndim = input.shape().sample_dim(); | |||
VALUE_SWITCH(ndim, Dims, (2, 3, 4), ( | |||
TYPE_SWITCH(input.type(), type2id, InputType, (IMGCODEC_TYPES), ( | |||
TYPE_SWITCH(input.type(), type2id, InputType, (IMGCODEC_TYPES, double), ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of adding double
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess numpy reference data.
!build |
CI MESSAGE: [5957668]: BUILD STARTED |
CI MESSAGE: [5957668]: BUILD PASSED |
Until now, only striped TIFFs were supported. In this PR I add support for tiled TIFFs. Additional information: The main disadvantage of striped TIFFs is that efficient ROI decoding is effectively impossible - you always need to read a whole strip. This is the reason why Tiled TIFFs are common in applications where the data is bigger, for example in spatial information or microscopy. That's why we want to support them. Before, this decoder was reading TIFF line-by-line. Now I extended it to support tiles and, in order to avoid code duplication, I simply pretend that lines are 1 x imagewidth tiles. We do not support exotic bitdepths (i.e. other than 8, 16 and 32), because I was unable to find software capable of correctly writing or reading those, so it was impossible to test reliably. Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Category:
New feature (non-breaking change which adds functionality)
Description:
Until now, only striped TIFFs were supported. In this PR I add support for tiled TIFFs.
Additional information:
The main disadvantage of striped TIFFs is that efficient ROI decoding is effectively impossible - you always need to read a whole strip. This is the reason why Tiled TIFFs are common in applications where the data is bigger, for example in spatial information or microscopy. That's why we want to support them.
Before, this decoder was reading TIFF line-by-line. Now I extended it to support tiles and, in order to avoid code duplication, I simply pretend that lines are
1 x imagewidth
tiles.I do not support exotic bitdepths (i.e. other than 8, 16 and 32), because I was unable to find software capable of correctly writing or reading those, so it was impossible to test reliably.
Affected modules and functionalities:
I've temporarily fixed the testing framework, but I'll rebase on the proper fix (#4217) once it's merged.
Key points relevant for the review:
Tests:
The tests require images from NVIDIA/DALI_extra#101
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: DALI-2924