gamma_correct

Synopsis

The gamma_correct user macro performs full-color gamma correction on ARGB byte images.

Input Ports

Name Type Description

in Image_ARGB Image that should be gamma corrected.

Parameters

Name Type Description UI Control

gamma_value float Amount of gamma correction to apply. Slider
method int Type of gamma correction to apply. Radiobox

Output Ports

Name Type Description

out_image Image_ARGB Gamma corrected image.
out_obj DataObject Directly renderable output object.

Description

The gamma correct module performs gamma correction on an full colour AVS image. The user may control the amount of correction to apply. The user can also specify whether Chromatic or Achromatic gamma correction should be used.

Most common monitors do not have a linear colour transfer function. Hence images taken from real-life sources will not look correct when displayed. Gamma correction allows the user to correct for this non-linear transfer function. This is done by applying the inverse of the monitor transfer function to the image before it is sent to the monitor. The gamma_correct macro uses the following function to do this:

ouput_pixel = input_pixel ^ (1./gamma_value)

Where the range for input_pixel and output_pixel is 0 to 1, and gamma_value is the amount of gamma correction that should be applied. To completely compensate for the monitor transfer function you would use a gamma value of 2.5. However due to lighting conditions that monitors are normally used in gamma values will normally be lower than this.

This function can be applied to the input red, green and blue channels in several different ways. The gamma_correct macro supports two of these, achromatic and chromatic. Achromatic correction applies the gamma correction function independently to each of the red, green and blue channels. This allows the gamma correction to be done very quickly but does course the colours of the image to change. Chromatic correction prevents this colour change by transforming the RGB data into the HSV colour space. Once this is done the gamma correction is applied only to the Value component and the HSV data then transformed back to the RGB colour space. This preserves the colour contained in the image but does take significantly longer to compute. The alpha values contained with in the image are left unchanged by both of these techniques.

More information on gamma correction can be found on CGSD Corporation's gamma correction web-page. This web-page contains a good explanation of gamma correction and links to other online resources.

This module is a conversion of the AVS5 "gamma_correct" module, also found at the IAC in the AVS5 repository. The module implementation is now in C++, and has a new user interface. The low-level code operates on simple byte arrays rather than fields. A look-up table is used to speed up the conversion process.

Inputs

in

Full colour 2D image that is to be gamma corrected by the macro. The image should be a 2D uniform grid of type Image_ARGB. The read_image module outputs data of this type.

Parameters

gamma_value

Float parameter that specifies the amount of gamma correction that should be applied to the image. Typical gamma values will probably range from 0.5 to 3.0.

method

Integer parameter that specifies which type of gamma correction should be applied to the image. Currently two values are supported. A value of 0 implies that chromatic correction should be used whilst a value of 1 implies that achromatic correction should be used.

Outputs

out_image

Full colour 2D image after being gamma corrected by the macro. The output image is also of Image_ARGB type. The Red, Green and Blue channels will be changed by the gamma correction process. The Alpha channel should be identical to that in the input image.

out_obj

The GDobject version of the output, suitable for direct connection to the viewer. A 2D viewer is recommended.

Utility Macros

The GammaCorrectFunc macro makes use of the GammaCorrectCore low-level module. The gamma_correct user macro uses this functional macro and the GammaCorrectUI user interface macro. All these macros use the GammaCorrectParams parameter block.

Example

The GammaCorrectEg example application reads an image, performs gamma correction upon it and shows it in a viewer along side the original image.

Files

iac_proj/gamma/gam_mods.v contains the V definitions of the GammaCorrectCore module and the GammaCorrectParams parameter block.

iac_proj/gamma/gam_macs.v contains the V definitions of the GammaCorrectUI user interface macro, the GammaCorrectFunc functional macro, the gamma_correct user macro and the GammaCorrectEg example application.

Other Notes

The low-level GammaCorrectMods library containing the low-level GammaCorrectCore module does not specify a process. By default the express process will be used.

Authors

Wes Bethel, Lawrence Berkley Laboratory, (14 Oct 1992)
Sabreen Vig, Ian Curington (30 Nov 1999)
Advanced Visual Systems, Inc.

Modifications

Andrew Dodd,
International AVS Centre

Contact

International AVS Centre
Manchester Visualization Centre
Manchester Computing
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL

See Also