CLAHE - Contrast Limited Adaptive Histogram Normalization

More
3 months 3 days ago - 2 months 4 weeks ago #1 by Fu-Bama
Hello,
for some time I was reverse-engineering CLAHE filter and came up with this working solution.
I don't feel it's ready yet, as it does not give such dramatic improvement to the image like other implementations of CLAHE filter in photo-editing software.

So if you feel an idea, feel free to improve this shader. (Post edited code in this thread)

Here's the shader: *Update grab this link instead.
Warning: Spoiler!

In short summary this shader analyzes the Back Buffer luma channel in blocks 8x8. Within those blocks it grabs highest and lowest luma values and saves them into RG channel of the render target.
The values are then clipped according to contrast range limit and average luma within the block.
On the second pass, histogram normalization is applied to the Back Buffer luma according to the lowest-highest values from histogram stats texture.
Last edit: 2 months 4 weeks ago by Fu-Bama. Reason: added link to updated version
The following user(s) said Thank You: aaronth07, MacTir

Please Log in or Create an account to join the conversation.

More
3 months 20 hours ago - 3 months 20 hours ago #2 by Tojkar
This actually looks really nice when applied very slightly. The effect is very similar as what Clarity does, but somehow is much more pleasing to my eyes. The slider is confusing as hell, hough. The numbers goes backwards and lower settings makes the effect stronger. Should be easy enough to make that more intuitive with simple arithmetics.

Hopefully you don't leave developing this further yourself.
Last edit: 3 months 20 hours ago by Tojkar.

Please Log in or Create an account to join the conversation.

More
3 months 10 hours ago #3 by nikobellic
I couldn't test the script, getting error "undeclared identifier BUFFER_PIXEL_SIZE"

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #4 by Fu-Bama
@Tojkar
Thanks for the feedback. I updated the slider. You can grab the new version here:
github.com/Fubaxiusz/fubax-shaders/blob/...ers/LocalContrast.fx

nikobellic wrote: I couldn't test the script, getting error "undeclared identifier BUFFER_PIXEL_SIZE"

BUFFER_PIXEL_SIZE is in ReShade.fxh , you also need ReShadeUI.fxh . Put them in the same folder where LocalContrast.fx is ;)
The following user(s) said Thank You: nikobellic

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #5 by nikobellic
Thanks, I feel dumb now.

Please Log in or Create an account to join the conversation.