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

Better scale uint32 images. #1017

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Better release file handles ([#1007](../../pull/1007))
- Support tiny images from the test source ([#1013](../../pull/1013))
- Speed up loading or parsing some multi sources ([#1015](../../pull/1015))
- Better scale uint32 images ([#1017](../../pull/1017))

### Changes
- Don't report filename in internal PIL metadata ([#1006](../../pull/1006))
Expand Down
4 changes: 3 additions & 1 deletion large_image/tilesource/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def _imageToPIL(image, setMode=None):
mode = ['L', 'LA', 'RGB', 'RGBA'][image.shape[2] - 1]
if len(image.shape) == 3 and image.shape[2] == 1:
image = numpy.resize(image, image.shape[:2])
if image.dtype == numpy.uint16:
if image.dtype == numpy.uint32:
image = numpy.floor_divide(image, 2 ** 24).astype(numpy.uint8)
elif image.dtype == numpy.uint16:
image = numpy.floor_divide(image, 256).astype(numpy.uint8)
# TODO: The scaling of float data needs to be identical across all
# tiles of an image. This means that we need a reference to the parent
Expand Down