Search code examples
javascripthtmlcanvasfiltercontrast

HTML5 Canvas contrast filter


How can i adjust the contrast of an image using HTML5 Canvas pixel manipulation capabilities ? I already succeeded in changing the brightness of the image quite easily, but contrast seems to be a little bit more complex.

Does anyone know of an algorithm i can follow or perhaps sample javascript code i could take ideas from ?

thanks in advance for any help regarding this issue.


Solution

  • Since you said you already adjusted the brightness and it sounds like all you need is the algorithm for contrast adjusting here's a thread for a C# method (Look at Update 2), the logic of the code is sound and will work in any program:

    Adjust the contrast of an image in C# efficiently - Stack Overflow