gamma_imagegamma_imageGammaImageGammaImagegamma_image (Operator)


gamma_imagegamma_imageGammaImageGammaImagegamma_image — Perform a gamma encoding or decoding of an image.


gamma_image(Image : GammaImage : Gamma, Offset, Threshold, MaxGray, Encode : )

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)

void GammaImage(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)

static void HOperatorSet.GammaImage(HObject image, out HObject gammaImage, HTuple gamma, HTuple offset, HTuple threshold, HTuple maxGray, HTuple encode)

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)

def gamma_image(image: HObject, gamma: float, offset: float, threshold: float, max_gray: Union[float, int], encode: str) -> HObject


gamma_imagegamma_imageGammaImageGammaImageGammaImagegamma_image performs a general gamma encoding or decoding of the input image ImageImageImageImageimageimage and returns the resulting image in GammaImageGammaImageGammaImageGammaImagegammaImagegamma_image. A generalized gamma encoding can be described as follows: Here, G' is the gamma-encoded gray value, G is the linear gray value, , o = OffsetOffsetOffsetOffsetoffsetoffset, m = MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray, t = ThresholdThresholdThresholdThresholdthresholdthreshold, and s is a factor that is computed from GammaGammaGammaGammagammagamma, OffsetOffsetOffsetOffsetoffsetoffset, ThresholdThresholdThresholdThresholdthresholdthreshold, and MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_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: where the variables have identical meanings as for the gamma encoding and .

For example, the gamma encoding or decoding required by the sRGB standard can be obtained by setting GammaGammaGammaGammagammagamma = 1.0/2.4, OffsetOffsetOffsetOffsetoffsetoffset = 0.055, and ThresholdThresholdThresholdThresholdthresholdthreshold = 0.0031308. Similarly, the gamma encoding or decoding required by the HDTV video standard can be obtained by setting GammaGammaGammaGammagammagamma = 0.45, OffsetOffsetOffsetOffsetoffsetoffset = 0.099, and ThresholdThresholdThresholdThresholdthresholdthreshold = 0.018. In any case, MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray should be set as appropriate for the image type of ImageImageImageImageimageimage (e.g., 255.0 for byte images).


gamma_imagegamma_imageGammaImageGammaImageGammaImagegamma_image 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


ImageImageImageImageimageimage (input_object)  (multichannel-)image(-array) objectHImageHObjectHImageHobject (byte* / uint2* / real*) *allowed for compute devices

Input image.

GammaImageGammaImageGammaImageGammaImagegammaImagegamma_image (output_object)  (multichannel-)image(-array) objectHImageHObjectHImageHobject * (byte / uint2 / real)

Output image.

GammaGammaGammaGammagammagamma (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Gamma coefficient of the exponential part of the transformation.

Default value: 0.416666666667

Suggested values: 0.416666666667, 0.45

OffsetOffsetOffsetOffsetoffsetoffset (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Offset of the exponential part of the transformation.

Default value: 0.055

Suggested values: 0.055, 0.099

ThresholdThresholdThresholdThresholdthresholdthreshold (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

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

Default value: 0.0031308

Suggested values: 0.0031308, 0.018

MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray (input_control)  number HTupleUnion[float, int]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Maximum gray value of the input image type.

Default value: 255.0

Suggested values: 1.0, 255.0, 511.0, 1023.0, 4095.0, 16383.0, 65535.0

EncodeEncodeEncodeEncodeencodeencode (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

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

Default value: 'true' "true" "true" "true" "true" "true"

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



See also

sqrt_imagesqrt_imageSqrtImageSqrtImageSqrtImagesqrt_image, exp_imageexp_imageExpImageExpImageExpImageexp_image, log_imagelog_imageLogImageLogImageLogImagelog_image


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.”