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

Details lost when lightening or brightening an image #227

Open
Sempervivum opened this issue Jun 9, 2021 · 0 comments
Open

Details lost when lightening or brightening an image #227

Sempervivum opened this issue Jun 9, 2021 · 0 comments

Comments

@Sempervivum
Copy link

Sempervivum commented Jun 9, 2021

When I used the function lighten() or brighten() I encountered the issue that details get lost in bright regions of an image. These areas simply grow white.
I coded another algorithms for brightening and it works much better: No details lost in bright regions.

    function brighten2(color, amount) {
        function helper(val, amount) {
            const delta = 255 - val,
                newVal = val + delta * amount / 100;
            return newVal;
        }
        amount = (amount === 0) ? 0 : (amount || 10);
        var rgb = tinycolor(color).toRgb();
        rgb.r = helper(rgb.r, amount);
        rgb.g = helper(rgb.g, amount);
        rgb.b = helper(rgb.b, amount);
        return tinycolor(rgb);
    }
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

1 participant