Skip to content
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 raw RGB tiled TIFF #108

Merged
merged 3 commits into from
Sep 30, 2021

Conversation

gigony
Copy link
Contributor

@gigony gigony commented Sep 28, 2021

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
Copy link
Contributor

@grlee77 grlee77 left a comment

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
Copy link
Contributor Author

gigony commented Sep 28, 2021

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
Copy link
Contributor Author

gigony commented Sep 28, 2021

@grlee77 Added unit tests for this : 537c76e

Copy link
Contributor

@grlee77 grlee77 left a comment

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 requested a review from a team as a code owner September 29, 2021 18:09
Copy link
Member

@jakirkham jakirkham left a comment

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
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 *?

Copy link
Contributor Author

@gigony gigony Sep 29, 2021

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
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 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
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

Copy link
Contributor Author

@gigony gigony Sep 29, 2021

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.

Copy link
Member

@jakirkham jakirkham Sep 29, 2021

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
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.

Copy link
Contributor Author

@gigony gigony Sep 29, 2021

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

Copy link
Contributor Author

@gigony gigony left a comment

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,
Copy link
Contributor Author

@gigony gigony Sep 29, 2021

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 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
Contributor Author

@gigony gigony Sep 29, 2021

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
Member

rerun tests

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

@jakirkham
Copy link
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.

None yet

3 participants