CLAHE - Contrast Limited Adaptive Histogram Normalization

  • Fu-Bama
  • Topic Author
More
3 years 8 months ago - 3 years 8 months ago #1 by Fu-Bama CLAHE - Contrast Limited Adaptive Histogram Normalization was created 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: 3 years 8 months 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.

  • Tojkar
More
3 years 8 months ago - 3 years 8 months ago #2 by Tojkar Replied by Tojkar on topic CLAHE - Contrast Limited Adaptive Histogram Normalization
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 years 8 months ago by Tojkar.

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

  • nikobellic
More
3 years 8 months ago #3 by nikobellic Replied by nikobellic on topic CLAHE - Contrast Limited Adaptive Histogram Normalization
I couldn't test the script, getting error "undeclared identifier BUFFER_PIXEL_SIZE"

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

  • Fu-Bama
  • Topic Author
More
3 years 8 months ago - 3 years 4 months ago #4 by Fu-Bama Replied by Fu-Bama on topic CLAHE - Contrast Limited Adaptive Histogram Normalization
@Tojkar
Thanks for the feedback. I updated the slider. You can grab the new version here:
github.com/Fubaxiusz/fubax-shaders-dev/b...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 ;)
Last edit: 3 years 4 months ago by Fu-Bama.
The following user(s) said Thank You: nikobellic

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

  • nikobellic
More
3 years 8 months ago #5 by nikobellic Replied by nikobellic on topic CLAHE - Contrast Limited Adaptive Histogram Normalization
Thanks, I feel dumb now.

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

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.