-
Notifications
You must be signed in to change notification settings - Fork 25
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
Downscaling in linear color space? #3
Comments
The current implementation does nothing special with pixel components and knows nothing about color space of image. The main feature of this crate is the use of SIMD instructions of CPU to speed up image resizing. So it is most likely not possible to simply use closures for pixel transforming. Because this will significantly slow down the resizing. I'll can try to add support of images with u16 components of pixel ( |
It doesn't need to be closures. It can be something based on macros so users can have compile-time optimized paths for common encodings like Without this the the crate is useless for downscaling I would put a note in the README at least. |
I've added support of U16x3 pixels. For now without optimizations using SIMD. |
v0.8.0
|
In version 2.0.0 I added PixelComponentMapper structure that allows you to create colorspace converters for images whose pixels based on u8 and u16 components. Source and destination images for mapper may have different bit depth of one pixel component. But count of components must be equal. For example, you may convert In addition, the crate contains functions You may use |
I can't find anything in the documentation (or the source) that indicates that there is any support for conversion of data into a linear color space during resizing.
This is required to get correct results when downscaling images that are not in a linear color space. I.e. any 24/32bit PNG, 24bit JPG etc. one would find in the wild.
While this linearization could be done outside the resizing code (and thus this crate) for the supported
i32
andf32
types, for theu8
case this is not possible. If the crate user linearizes the input data from some color spaceu8
to linearu8
there is too much loss of information – banding/posterization ensues. See example images in above linked article.For this reason the linearization before the filtering and de-linearization after has to be part of the resizing process itself for
u8
grayscale or[u8; 3]
RGB.Would it be possible to add support for this? Basically
u8
data needs to be linearized to at leastu16
, betteru32
orf32
, resized, de-linearized and stored back intou8
. And the color space can't be baked into the crate. I.e. you can not just assume sRGB or gamma 2.2 if you want to do this properly.Possibly through feature-flag gated support for e.g.:
colstodian
In case of closures the closure should have access to all components of a color so it can convert to/from other spaces, e.g. RGB to Lab, if the user wishes the resize to happen in that space.
The text was updated successfully, but these errors were encountered: