Skip navigation.
 
mlRe: CILinearGradient not linear?
FROM : Christian Walther
DATE : Tue May 30 10:29:11 2006

George Orthwein wrote:
> The CTGradient looks almost identical to the Photoshop gradient but 
> the Core Image gradient differs quite a bit... showing more lighter 
> tones and then dropping to black very quickly at the end. The 
> midpoint is 32% black instead of 50%.


A wild guess without any knowledge about Core Image whatsoever (and 
without having tried out your suggestions):

It seems that both gradients are actually "linear", they're just 
linear to different quantities.

The CT and Photoshop gradients are probably linear in the pixel 
values they send to video hardware - 0 for black, 255 for white, and 
128 for the middle gray in the center. Incidentally, this is also 
approximately linear in perceived brightness.

The CI gradient is probably linear in actual physical light 
intensity. Try comparing this gradient with a checkerboard pattern of 
white and black pixels (if you're on an LCD, on a CRT use alternating 
white and black horizontal lines), you'll see that it approximately 
matches the brightness in the middle of the gradient.

On a properly calibrated Mac display, the relationship is that 
light_intensity = pixel_value ^ 1.8, with both quantities measured 
from 0 to 1. In your example: 0.5 = 0.68 ^ 1.8, with 0.68 being the 
complement of your "32% black".

If this sounds all greek to you, read up on "gamma", especially 
<http://www.poynton.com/notes/colour_and_gamma/GammaFAQ.html>, or on 
colorimetry in general. It's a wide and not completely trivial field, 
but understanding it helps a lot if you're seriously interested in 
computer graphics.

  -Christian

Related mailsAuthorDate
mlCILinearGradient not linear? George Orthwein May 29, 20:13
mlRe: CILinearGradient not linear? Christian Walther May 30, 10:29
mlRe: CILinearGradient not linear? George Orthwein Jun 26, 21:34