Gamma/LUT correction

Description

This code performs digital image corrections based on LUT (LookUp Table). Firstly designed for gamma correction, I have written the code to make it as flexible as possible. Thus it can perform gamma correction, contrast enhancement, posterization effect, tresholding discrimination and grayscale conversion.

You can easily add your own correction by filling the LUT, here is an example of such an operation:

'--- Create LUT from gamma
Private Sub CreateLutFromGamma()
Dim i As Integer, L as Double, dL As Double
Dim Lg As Double, Lmax As Integer, V as Long
 Lmax = maxStreamData-1
 dL = 1/CDbl(Lmax)
 L=0
 For i=0 to Lmax
  Lg=L^dGamma
  V=Round(Lg*Lmax)
    If V < 0 Then V=0
    If V > Lmax Then V=Lmax
    LUT(i)=V
    L=L+dL
 Next i
End Sub 

Screenshots