Main Content

vision.GammaCorrector

Apply or remove gamma correction from images or video streams

Description

To apply gamma correction to input images or a video stream:

  1. Create thevision.GammaCorrectorobject and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, seeWhat Are System Objects?

Creation

Description

example

gammaCorr=愿景。GammaCorrectorreturns a gamma corrector object,gammaCorr. You can use the gamma corrector to apply or remove gamma correction from images or video streams.

gammaCorr=愿景。GammaCorrector(Name,Value)sets properties using one or more name-value pairs. Enclose each property name in quotes. For example,gammaCorr =愿景。GammaCorrector ('Correction','Gamma')

gammaCorr=愿景。GammaCorrector(gamma,Name,Value)additionally sets theGammaproperty.

Properties

expand all

Unless otherwise indicated, properties arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

If a property istunable, you can change its value at any time.

For more information on changing property values, seeSystem Design in MATLAB Using System Objects.

Specify gamma correction or linearization, specified as'Gamma'or'De-gamma'.

Gamma value of output or input, specified as numeric scalar greater than or equal to1. When you set theCorrectionproperty toGamma, this property gives the desired gamma value of the output video stream. When you set theCorrectionproperty toDe-gamma, this property indicates the gamma value of the input video stream.

Enable gamma curve to have linear portion near origin, specified as真正的orfalse.

I-axis value of the end of gamma correction linear segment, specified as a numeric scalar value in the range (0,1). This property applies when you set theLinearSegmentproperty to真正的.

Usage

Description

example

y= gammaCorr(input)applies or removes gamma correction from inputI, and returns the gamma corrected or linearized outputy.

Input Arguments

expand all

Input, specified as anM-by-Nmatrix of intensity values orM-by-N-Pcolor video, wherePis the number of color planes.

Output Arguments

expand all

Output, returned as anM-by-Nmatrix of intensity values orM-by-N-Pcolor video, wherePis the number of color planes.

Object Functions

To use an object function, specify the System object™ as the first input argument. For example, to release system resources of a System object namedobj, use this syntax:

release(obj)

expand all

step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

collapse all

Create a gamma corrector object with the gamma property set to2.0.

hgamma = vision.GammaCorrector(2.0,'Correction','De-gamma');

Read an image.

img = imread('pears.png');

Apply gamma correction.

imgCor = hgamma(img);

Show the original and corrected images.

imshow(img); title('Original Image');

figure, imshow(imgCor); title('Enhanced Image after De-gamma Correction');

Extended Capabilities

Version History

Introduced in R2012a

See Also