CLAHE - Contrast Limited Adaptive Histogram Normalization

  • Posts: 161
1 week 5 days ago - 6 days 10 hours 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! [ Click to expand ]

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.
The following user(s) said Thank You: MacTir

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

  • Posts: 102
1 week 2 days ago - 1 week 2 days 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.

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

  • Posts: 8
1 week 2 days 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.

  • Posts: 161
6 days 10 hours 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.

  • Posts: 8
5 days 23 hours ago #5 by nikobellic
Thanks, I feel dumb now.

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