Skip to content

gamma_imageGammaImageGammaImagegamma_imagegamma_imageπŸ”—

Short descriptionπŸ”—

gamma_imageGammaImageGammaImagegamma_imagegamma_image β€” Perform a gamma encoding or decoding of an image.

SignatureπŸ”—

gamma_image( image Image, out image GammaImage, real Gamma, real Offset, real Threshold, number MaxGray, string Encode )void GammaImage( const HObject& Image, HObject* GammaImage, const HTuple& Gamma, const HTuple& Offset, const HTuple& Threshold, const HTuple& MaxGray, const HTuple& Encode )static void HOperatorSet.GammaImage( HObject image, out HObject gammaImage, HTuple gamma, HTuple offset, HTuple threshold, HTuple maxGray, HTuple encode )def gamma_image( image: HObject, gamma: float, offset: float, threshold: float, max_gray: Union[float, int], encode: str ) -> HObject

Herror gamma_image( const Hobject Image, Hobject* GammaImage, double Gamma, double Offset, double Threshold, double MaxGray, const char* Encode )

Herror T_gamma_image( const Hobject Image, Hobject* GammaImage, const Htuple Gamma, const Htuple Offset, const Htuple Threshold, const Htuple MaxGray, const Htuple Encode )

HImage HImage::GammaImage( double Gamma, double Offset, double Threshold, const HTuple& MaxGray, const HString& Encode ) const

HImage HImage::GammaImage( double Gamma, double Offset, double Threshold, double MaxGray, const HString& Encode ) const

HImage HImage::GammaImage( double Gamma, double Offset, double Threshold, double MaxGray, const char* Encode ) const

HImage HImage::GammaImage( double Gamma, double Offset, double Threshold, double MaxGray, const wchar_t* Encode ) const (Windows only)

HImage HImage.GammaImage( double gamma, double offset, double threshold, HTuple maxGray, string encode )

HImage HImage.GammaImage( double gamma, double offset, double threshold, double maxGray, string encode )

DescriptionπŸ”—

gamma_imageGammaImage performs a general gamma encoding or decoding of the input image Imageimageimage and returns the resulting image in GammaImagegammaImagegamma_image. A generalized gamma encoding can be described as follows:

\[\begin{eqnarray*} G' = \left\{ \begin{array}{ll} m \left( (1+o) (G/m)^\gamma - o \right), & t < G/m \le 1 \\ s G, & 0 \le G/m \le t \end{array} \right. \end{eqnarray*}\]

Here, \(G'\) is the gamma-encoded gray value, \(G\) is the linear gray value, \(\gamma = \textrm{Gamma}\), \(o = \textrm{Offset}\), \(m = \textrm{MaxGray}\), \(t = \textrm{Threshold}\), and \(s\) is a factor that is computed from Gammagammagamma, Offsetoffsetoffset, Thresholdthresholdthreshold, and MaxGraymaxGraymax_gray in such a way that the linear and exponential parts of the transformation are continuous.

Analogously, a generalized gamma decoding can be described as follows:

\[\begin{eqnarray*} G = \left\{ \begin{array}{ll} m \left( \frac{G'/m + o}{1+o} \right)^{1/\gamma}, & t' < G'/m \le 1 \\ G'/s, & 0 \le G'/m \le t' \end{array} \right. \end{eqnarray*}\]

where the variables have identical meanings as for the gamma encoding and \(t' = s t\).

For example, the gamma encoding or decoding required by the sRGB standard can be obtained by setting \(\textrm{Gamma} = 1.0/2.4\), \(\textrm{Offset} = 0.055\), and \(\textrm{Threshold} = 0.0031308\). Similarly, the gamma encoding or decoding required by the HDTV video standard can be obtained by setting \(\textrm{Gamma} = 0.45\), \(\textrm{Offset} = 0.099\), and \(\textrm{Threshold} = 0.018\). In any case, MaxGraymaxGraymax_gray should be set as appropriate for the image type of Imageimageimage (e.g., 255.0 for byte images).

AttentionπŸ”—

gamma_imageGammaImage can be executed on an OpenCL device for byte, uint2 and real images. As the operation is performed in single precision floating point instead of double precision as on the CPU, the result of the OpenCL implementation can vary slightly from that of the CPU implementation.

Execution informationπŸ”—

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on domain level.

ParametersπŸ”—

Imageimageimage (input_object) (multichannel-)image(-array) β†’ object (byte* / uint2* / real*)HObject (byte* / uint2* / real*)HImage (byte* / uint2* / real*)HObject (byte* / uint2* / real*)Hobject (byte* / uint2* / real*) *allowed for compute devices

Input image.

GammaImagegammaImagegamma_image (output_object) (multichannel-)image(-array) β†’ object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject * (byte / uint2 / real)

Output image.

Gammagammagamma (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Gamma coefficient of the exponential part of the transformation.

Default: 0.4166666666670.416666666667
Suggested values: 0.416666666667, 0.450.416666666667, 0.45

Offsetoffsetoffset (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Offset of the exponential part of the transformation.

Default: 0.0550.055
Suggested values: 0.055, 0.0990.055, 0.099

Thresholdthresholdthreshold (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Gray value for which the transformation switches from linear to exponential.

Default: 0.00313080.0031308
Suggested values: 0.0031308, 0.0180.0031308, 0.018

MaxGraymaxGraymax_gray (input_control) number β†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Maximum gray value of the input image type.

Default: 255.0255.0
Suggested values: 1.0, 255.0, 511.0, 1023.0, 4095.0, 16383.0, 65535.01.0, 255.0, 511.0, 1023.0, 4095.0, 16383.0, 65535.0

Encodeencodeencode (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

If 'true'"true", perform a gamma encoding, otherwise a gamma decoding.

Default: 'true'"true"
List of values: 'false', 'true'"false", "true"

Combinations with other operatorsπŸ”—

Combinations

Alternatives

pow_imagePowImage

See also

sqrt_imageSqrtImage, exp_imageExpImage, log_imageLogImage

ReferencesπŸ”—

Erik Reinhard, Erum Arif Khan, Ahmet Oguz AkyΓΌz, Garret M. Johnson: β€œColor Imaging: Fundamentals and Applications.” A K Peters, Ltd., 2008.

CEI/IEC 61966-2-1:1999: ``Colour management – Default RGB colour space – sRGB.β€™β€˜

ITU-R BT.709-5: ``Parameter values for the HDTV standards for production and international programme exchange.β€™β€˜

ModuleπŸ”—

Foundation