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

Feature: map_linear_colors #447

Closed
carrascomj opened this issue Nov 9, 2020 · 2 comments
Closed

Feature: map_linear_colors #447

carrascomj opened this issue Nov 9, 2020 · 2 comments

Comments

@carrascomj
Copy link

This may be a bit too specific but I find it quite common. The idea is to have a function map_linear_colors(), similar to map_colors(), that operates on Images with Rgb/a pixels. For each pixel:

  1. Remove gamma correction: Rgb<u8> [0,255] -> linear Rgb<f32> [0,1].
  2. Apply user function: f(linear RGB) -> linear RGB.
  3. Apply gamma correction: linear Rgb<f32> [0,1] -> Rgb<u8> [0,255].

(I think I got the naming right)

If is interesting for the library, I could do a PR for it.

@ripytide
Copy link
Contributor

I think this libraries policy is to always assume linear color space due to implementation complexity/performance and we are otherwise color-space agnostic.

That said you could accomplish this pretty easily in user-land using:

let mut image = Image::new(..);
map_pixels_mut(image, |pixel| {
    let linear = to_linear(pixel);
    let mapped = f(linear);
    to_gamma(mapped)
});

So I'm not sure if this is a necessary function for the library.

@carrascomj
Copy link
Author

Yes, with the perspective or time, I think that's fair, we can close this issue.

@carrascomj carrascomj closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2024
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

No branches or pull requests

2 participants