Skip to content

Improve recomposite color correct by fitting (s*v, v) instead of (s, v) #863

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

willhsmit
Copy link
Contributor

@willhsmit willhsmit commented Jul 3, 2025

This is an update to the change to implement #597. It attempts to improve the original "Linear" method by fitting to (s*v, v) instead of (s, v).

When correcting, S is unstable when V is very low (small changes in RGB yield big changes in S for very dark pixels). The linear method ends up doing poor color correction when there are very dark pixels in the region outside the mask that is used to sample for color correction. By fitting to S*V, those perturbations don't influence the fit as much.

My testing indicates that this improves some pathological cases with dark regions, and isn't noticeable one way or the other on other cases. Will add some examples in #597 .

Added this as an additional color correction method "Linear2", could also just replace the original Linear method depending how much you weigh backwards compatibility versus code proliferation. It would also be more efficient to map (r,g,b) <-> (h,s*v,v) directly in the rgb2hsv utility methods instead of computing (r,g,b) <-> (h,s,v) and multiply/divide, but I thought that might be less readable.

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