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

Be more specific in casting when converting images via vips #1795

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

manthey
Copy link
Member

@manthey manthey commented Jan 30, 2025

If a source image was not uint8 or uint16 we used the full range of the datatype for some of the conversion, but, to maximize compatibility, we always output either uint8 or uint16 pixels. In a sample image that was stored in int32 but only had pixels with values 0, 1, 2, this resulted it scaling the output by (val * 2 ** -16) + 2 ** 15, but in that resulted in all output pixels having the value of 32768.

Now, we check the range of all frames of an image first, and try to intelligently pick a datatype and scaling based on the actual range of the data. This will still be wrong in some instances, but should at least result in visible images.

If a source image was not uint8 or uint16 we used the full range of the
datatype for some of the conversion, but, to maximize compatibility, we
always output either uint8 or uint16 pixels.  In a sample image that was
stored in int32 but only had pixels with values 0, 1, 2, this resulted
it scaling the output by (val * 2 ** -16) + 2 ** 15, but in that
resulted in all output pixels having the value of 32768.

Now, we check the range of all frames of an image first, and try to
intelligently pick a datatype and scaling based on the actual range of
the data.  This will still be wrong in some instances, but should at
least result in visible images.
@manthey manthey merged commit ae9dc53 into master Jan 30, 2025
17 checks passed
@manthey manthey deleted the vips-cast-convert branch January 30, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant