POV-Ray : Newsgroups : povray.pov4.discussion.general : Gamma correction of input colours/image files : Re: Gamma correction of input colours/image files Server Time
17 May 2024 20:22:40 EDT (-0400)
  Re: Gamma correction of input colours/image files  
From: Allen
Date: 19 Nov 2008 08:00:00
Message: <web.49240bd180bfb2618f162dfb0@news.povray.org>
I think that the following are the most likely situations:

Colors:

1. I want 0.5 to mean 50% brightness

Use color rgb 0.5 and povray stores internally as 0.5

2. I want 0.5 to mean an output of RGB 128,128,128

Use display_color rgb 0.5 and povray would do an inverse correction based on
display_gamma to store it internally something like 0.217


Images as maps for heightfields, color/texture maps

1. I want 128 in the image to represent 50% height, or 0.5 in the
color_map/texture_map

When loading the image, ignore any file gamma and let RGB 128,128,128 be
internally treated as 0.5

3. I want the true brightness of the image to represent the height or position
in color_map,texture_map

When loading the image, apply gamma correction based on the file gamma, so that
if the file gamma of a PNG is 0.4545454 and a pixel is 128,128,128, it would
represent ~ 0.217, about 21.7% height or 0.217 in color_map and height_map


Images as images/textures:

1.  I want 128 to represent 50% brightness

When loading the image, do not do any gamma correction based on the file gamma
so 128 loads as 0.5, when rendering, output gamma correction will make it 50%
brightness, depending on other scene factors

2. I want 128 input to represent 128 output

When loading the image, do not do any gamma correction based on file gamma so
128 loads internally as 0.5.  Then with the 0.5 do a correction like with
display_color, so that 0.5 becomes corrected to 0.217 if display_gamma is 2.2

3. I want the original brightness of the image to be the output brightness as
well.

When loading the image, perform gamma correction based on file gamma to get the
original brightness values, then output gamma correction will keep the
brightness.

4.  Probably a lesser situation.  I want the original brightness value to be the
pixel output value. (an input of 196 may represent 50% brightness, so should
have an output 'pixel' of 128)

When loading the image, perform gamma correction based on file gamma to get the
original brightness values.  Then perform yet another gamma correction like
display_color on those brightness values.



For colors, color and display_color could be used.

For input images, perhaps a flag gamma_method could be used to indicate which
method to use when decoding the input image, 0-4, 0 = default based on the
type, 1-4 represents on of the above.  For height fields, etc 0 would mean 1
from above, for everything else, 0 would mean 3 from above.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.