Jump to content
How to Install Plugins ×

HSLuv Hue / Saturation and Levels adjustments (v1.2, 14 Nov 2023)


frio

Recommended Posts

Adjustments->Hue / Saturation (HSLuv)

Adjustments->Levels (HSLuv)

 

Download:

F_AdjustHSLuv.zip

 

Description:

HSLuv is an alternative color space to the classic HSV/HSL. It kind of combines the intuitiveness of the hue-saturation model with the more perceptually even color saturation and brightness from the CIELUV color space. Not really a replacement for the standard Hue / Saturation and Levels adjustment, but can be handy especially for photos as it often preserves color details better.

 

The plugin also implements the HPLuv and LCh(uv) color space modes: HPLuv is a more subtle and desaturated, but very perceptually even variant of HSLuv, and LCh(uv) is an intermediate between the other two and CIELUV.

 

Demo images (oops, they should say "HSL" and not "HSV" for the bottom right images):

gKAZeTh.pngHue -60: note the preserved details on the blue flower and un-blown out color on yellow.

h01wRUS.pngSaturation +66: also -25 lightness on HSL or else it'd be blown out very hard.

XbqpUyi.pngLightness +25: retains much more contrast.

MuNF84w.pngLevels, Lightness: Top right and bottom right have roughly similar levels adjustments. Bottom left shows color extraction.

 

Settings, Hue / Saturation:

  • Hue: works like standard hue.
  • Saturation/chromaticity: in HSLuv and HPLuv, works like standard saturation, though in its distinctive ways. LCh(uv) is a chromaticity color space, hence the double duty name for the slider.
  • Lightness: again, works like standard lightness, with its own twist.
  • Color space: HSLuv is maybe the best for most situations, but HPLuv's suppressed saturation can be useful. LCh(uv) is mostly provided for completeness, but can have different results as well.
  • Gamut checks: the range of colors HSLuv/HPLuv/LCh(uv) can display aren't the same as the RGB on your screen. Input gamut check happens after the RGB color is converted to the chosen color space, and the output check happens after the color space is converted back to RGB. Check types:
    • Clamp: clamps the pixel to the nearest in-bounds values in the color spaces.
    • To primary/secondary: highlightd pixels that have gone outside the gamut with your current colors. Colors with components below minimum use the primary color, colors with components above maximum use the secondary.
    • To transparent: as above, except it turns all out-of-gamut colors transparent.
    • Bypass (input check only): if you want to live dangerously and work with values outside the gamut anyway. Very likely to produce glitches at high saturation/chromaticity.

 

Settings, Levels:

  • Input low, input high: like standard Levels tool input values, only with 0-100 instead of 0-255 range.
  • Output low, output high: like standard Levels.
  • Output balance: just a different name and scale but works like Levels output midtone/gamma. +0 balance is equivalent to 1.0 gamma, +0.333 balance to 0.5 gamma, -0.333 balance to 2.0 gamma. 
  • Channel: lightness is the one that more corresponds to what you see on the Levels adjustment, but saturation is also available.
  • Color space & gamut checks: same as the other adjustment.

 

Notes:

  • Glitchy colors are likely to happen when using LCh(uv), as the chromaticity is an absolute value and not a relative percentage; it easily goes out of gamut. Experiment with different gamut checks.
  • No nice histogram window in the Levels tool, sorry.

 

HSLuv license:

Spoiler
Original HSLuv algorithm:
Copyright (c) 2016 Alexei Boronine

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

C# port: Mark Wonnacott

 

 

Version history:

V1.2:

  • Increased performance by optimizing the HSLuv library code for this purpose, now about 4x faster.
  • Added Levels tool.

V1.1:

  • Immediate update due to a nasty logic bug with saturation, oops.

 

Edited by frio
v1.2, added levels adjustment, speed up 4x
  • Like 3
  • Upvote 1
Link to comment
Share on other sites

  • frio changed the title to HSLuv Hue / Saturation adjustment (v1.1, 13 Nov 2023)
  • frio changed the title to HSLuv Hue / Saturation and Levels adjustments (v1.2, 14 Nov 2023)

And another quick v1.2 update, but while mulling over the idea of a levels tool working in HSLuv color space I managed to speed up the HSLuv library with some optimizations (the original code sure used a lot of heap allocations, they're about all gone now) and wanted to get the thing updated immediately and bundled the levels tool.

 

Now it should no longer be noticeably slow under any circumstances, even on huge images.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...