-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add ColorType::Multiband enum variant to support samples>1 per pixel #224
Conversation
…lowing BlackIsZero and WhiteIsZero to have up to 64 bits per sample. Also includes decode_geotiff_images unit test.
Contains attributes bit_depth and num_samples
When PhotometricInterpretation is BlackisZero or WhiteIsZero, and samples per pixel is more than 1, set the ColorType to Multiband. Also ensure that the expand_chunk function handles ColorType::Multiband, and updated the decode_geotiff_images unit test.
src/decoder/image.rs
Outdated
( | ||
ColorType::Multiband { | ||
bit_depth: _n, | ||
num_samples: _samples, | ||
}, | ||
_, | ||
) => {} |
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.
A little unsure if this should be a separate branch, or go in one of the branches above. Not familiar with what the Horizontal and FloatingPoint predictors are.
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.
The predictors are filters that are applied to the pixel data before compression, to help improve the compression ratio. Multiband should be included in both the match existing match arms where Gray is.
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.
Ok, done at e0b9ae0, but best if you can double check it. I don't have a multi-band TIFF file with a Horizontal/FloatingPoint predictor to test this out on.
Pulling from the `multi-band-geotiff` branch from my personal fork, that is currently in a pull request at image-rs/image-tiff#224.
The Multi-band PR at image-rs/image-tiff#224 has been merged, so updating to use the main branch instead.
* 📌 Use image-tiff fork with multi-band support Pulling from the `multi-band-geotiff` branch from my personal fork, that is currently in a pull request at image-rs/image-tiff#224. * ✨ Support reading multi-band GeoTIFF files Count the number of bands or channels in the GeoTIFF file when decoding by looking at the ColorType. E.g. Gray = 1 band, Multiband = N bands. Added a unit test to read a 2-band float32 GeoTIFF file. * ✅ Pytest check reading multi-band remote GeoTIFF Ensure that reading a multi-band GeoTIFF file from a remote URL works. * 📝 Update note on multi-band support in main README.md Also clarify that the roadmap item on reading single-band GeoTIFFs is for different dtypes. * 📌 Pin to image-tiff 0c54a18 The Multi-band PR at image-rs/image-tiff#224 has been merged, so updating to use the main branch instead. * 🥅 Return TiffUnsupportedError instead of unimplemented panic Replace `unimplemented!` with a recoverable TiffError::UnsupportedError instead to allow for better exception handling. Moved the band counting logic in the ndarray method above the image dimension line, and added a unit test to ensure unsupported ColorType TIFFs are handled properly.
Building on the work at #216 to support reading multi-band TIFF images (common in GeoTIFFs).
This PR extends the work done by @tromper in #216 which added the unit test for reading a 5-band GeoTIFF. I've just added the
ColorType::Multiband
enum variant as suggested at #216 (comment)), and made sure that the decoder functions can handle this multi-band type.References:
Supersedes #216, closes #214 and resolves #147.