trandoductin wrote:
Okay so I can set each Red/Green/Blue Channel in levels to black and white points, but what about the middle gray? what's the math behind gamma?
You should double-check things, but I believe gamma can be calculated as follows:
; gray-color is the RGB value of the gray point: (list red green blue)
; gray-pt is value of the particular channel's gray point
; black-pt is value of the particular channel's black point
; white-pt is value of the particular channel's white point
(define (gray-pt->gamma gray-color gray-pt black-pt white-pt)
(let ((luminosity (+ (* (car gray-color) 0.2126)
(* (cadr gray-color) 0.7152)
(* (caddr gray-color) 0.0722) ))
(range (- white-pt black-pt))
(offset (- gray-pt black-pt)) )
(/ (log (/ offset range))
(log (/ luminosity range)) )))