Skip to content

Support raw RGB tiled TIFF - #108

Merged
rapids-bot[bot] merged 3 commits into
rapidsai:branch-21.10from
gigony:support_nocompression
Sep 30, 2021
Merged

rapids-bot[bot] merged 3 commits into
rapidsai:branch-21.10from
gigony:support_nocompression

Conversation

@gigony

@gigony gigony commented Sep 28, 2021

Copy link
Copy Markdown
Contributor

Due to #17 ([BUG] Compression scheme 33003 tile decoding is not implemented), #19 (Check compression method used in the image) was merged so cuCIM has been handling only particular formats (only jpeg/deflate-compressed image).

If the input TIFF image has no-compressed RAW tile image, cuCIM showed the following error message:

RuntimeError: This format (compression: 1, sample_per_pixel: 1, planar_config: 1, photometric: 1) is not supported yet!. https://github.com/Project-MONAI/MONAI/pull/2987/checks?check_run_id=3667530814#step:7:15641

This patch is to support raw RGB tiled TIFF with fast-path, re-allowing non-compressed image with slow-path (in case the input is not tiled RGB image).

This supports Project-MONAI/MONAI#2987.

@gigony gigony added the feature request New feature or request label Sep 28, 2021
@gigony gigony added this to the v21.10 milestone Sep 28, 2021
@gigony
gigony requested review from a team as code owners September 28, 2021 22:37
@gigony gigony self-assigned this Sep 28, 2021
@gigony gigony added the non-breaking Introduces a non-breaking change label Sep 28, 2021

@grlee77 grlee77 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but is there a simple test we can add to ensure it is working as expected? Maybe read a simple raw TIFF generated in PIL via Python?

@gigony

gigony commented Sep 28, 2021

Copy link
Copy Markdown
Contributor Author

This looks good, but is there a simple test we can add to ensure it is working as expected? Maybe read a simple raw TIFF generated in PIL via Python?

Thanks @grlee77 for the review!
Sure. Will add a test case soon.

@gigony

gigony commented Sep 28, 2021

Copy link
Copy Markdown
Contributor Author

@grlee77 Added unit tests for this : 537c76e

@grlee77 grlee77 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it looks like the test failures here will be resolved by #110

@gigony
gigony force-pushed the support_nocompression branch from 537c76e to 3049233 Compare September 29, 2021 18:09
@gigony
gigony requested a review from a team as a code owner September 29, 2021 18:09

@jakirkham jakirkham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Gigon! 😄

Had a couple questions above

unsigned char* raw_buf,
uint64_t offset,
uint64_t size,
uint8_t** dest,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be ** as opposed to *?

@gigony gigony Sep 29, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same reason that cudaMalloc accept '**' (https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g37d37965bfb4803b6d4e59ff26856356) -- decoders may need to allocate memory and setting the address to dest if needed.

See

if ((*dest = (unsigned char*)tjAlloc(width * height * tjPixelSize[pixelFormat])) == nullptr)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was mostly thinking about this in terms of the nullptr checks below. We may want to look into using references for this kind of thing in the future, but not urgent. Can be addressed later

Comment thread cpp/plugins/cucim.kit.cuslide/src/cuslide/raw/raw.cpp
Comment on lines +371 to +377
case COMPRESSION_NONE:
case COMPRESSION_JPEG:
case COMPRESSION_ADOBE_DEFLATE:
case COMPRESSION_DEFLATE:
return true;
default:
return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth indenting these to make this a bit more readable

@gigony gigony Sep 29, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will do.

It turns out that the style is auto-formatted by the current clang-formatter setting (.clang-format) so this is the right style as long as we update clang-format configuration.

@jakirkham jakirkham Sep 29, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. Maybe we can track C++ formatting cleanup as an issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will create an issue for that.

@gigony gigony Sep 29, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created an issue for that: #116

@gigony gigony left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jakirkham for the review! Will update it soon.

unsigned char* raw_buf,
uint64_t offset,
uint64_t size,
uint8_t** dest,

@gigony gigony Sep 29, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same reason that cudaMalloc accept '**' (https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g37d37965bfb4803b6d4e59ff26856356) -- decoders may need to allocate memory and setting the address to dest if needed.

See

if ((*dest = (unsigned char*)tjAlloc(width * height * tjPixelSize[pixelFormat])) == nullptr)

Comment thread cpp/plugins/cucim.kit.cuslide/src/cuslide/raw/raw.cpp
Comment on lines +371 to +377
case COMPRESSION_NONE:
case COMPRESSION_JPEG:
case COMPRESSION_ADOBE_DEFLATE:
case COMPRESSION_DEFLATE:
return true;
default:
return false;

@gigony gigony Sep 29, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will do.

It turns out that the style is auto-formatted by the current clang-formatter setting (.clang-format) so this is the right style as long as we update clang-format configuration.

@jakirkham

Copy link
Copy Markdown
Member

rerun tests

(looks like one of the jobs failed due to some sort of Jenkins issue)

@gigony
gigony force-pushed the support_nocompression branch from 7e81eb4 to b9df835 Compare September 29, 2021 23:07
@jakirkham

Copy link
Copy Markdown
Member

@gpucibot merge

@rapids-bot
rapids-bot Bot merged commit 4d861fe into rapidsai:branch-21.10 Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants