ICogAcqContrast Contrast Property Cognex VisionPro 9.20
Reads or sets the contrast level. Contrast values are in the range 0-1 inclusive.

Namespace: Cognex.VisionPro
Assembly: Cognex.VisionPro.Core (in Cognex.VisionPro.Core.dll) Version: 80.0.0.0
Syntax

double Contrast { get; set; }

Property Value

Type: Double
Events

Event TypeReason
ICogChangedEvent Changed

Fires when the contrast is changed.

The following state flag may be affected:

Exceptions

ExceptionCondition
NotImplementedExceptionThe attached hardware is an L4000. Note that this is different from behavior of other platforms where the interface will be null and may require an extra check where an L4000 may potentially be accessed by the calling code.
ArgumentExceptionValue is less than 0 or Value is greater than 1.0.
Remarks

Sets or gets the contrast level. This value ranges from 0.0 (least contrast) to 1.0 (most contrast).

Not all FIFOs support this property. Check whether the FIFO supports it, as in the example, before using this property.

The contrast and brightness values control how different light levels are mapped to pixel values. Assume that you are working with an 8-bit image. All the light levels entering the camera must be mapped to a pixel value from 0 to 255.

Contrast determines how the light levels are mapped to the 256 light levels. A low value closer to 0.0 maps more light values to the pixel value range.

A high value closer to 1.0 maps fewer light values to the pixel value range. Light values that are below or above the contrast threshold are mapped to the lowest and highest pixel values, respectively.

For multichannel FIFOs, Contrast sets the contrast of all channels to the same value. To set the contrast of individual channels, use ICogAcqContrastMultiChannel.SetContrastMultiChannel(Int32, Double).

Default Value: CDC-50 camera: 0.15 CDC-100 camera: 0.66 CDC-200 camera: 0.45 All other cameras: 0.35

Examples

using Cognex.VisionPro;

private CogFrameGrabbers myFrameGrabbers;
private ICogFrameGrabber myFrameGrabber;
private ICogAcqFifo myAcqFifo;

private void InitializeFifo()
{
    const string VIDEO_FORMAT = "Sony XC75 640x480";
    ICogAcqContrast contrastParams;

    myFrameGrabbers = new CogFrameGrabbers();
    myFrameGrabber = myFrameGrabbers[0];
    myAcqFifo = myFrameGrabber.CreateAcqFifo(VIDEO_FORMAT, 
        Cognex.VisionPro.CogAcqFifoPixelFormatConstants.Format8Grey, 0, false);

    contrastParams = myAcqFifo.OwnedContrastParams;
    if (contrastParams != null)
        contrastParams.Contrast = .8;
}
Imports Cognex.VisionPro

Private myFrameGrabbers As CogFrameGrabbers
Private myFrameGrabber As Cognex.VisionPro.ICogFrameGrabber
Private myAcqFifo As Cognex.VisionPro.ICogAcqFifo

Private Sub InitializeFifo()
    Const VIDEO_FORMAT = "Sony XC75 640x480"
    Dim contrastParams As Cognex.VisionPro.ICogAcqContrast

    myFrameGrabbers = New CogFrameGrabbers
    myFrameGrabber = myFrameGrabbers.Item(0)
    myAcqFifo = myFrameGrabber.CreateAcqFifo(VIDEO_FORMAT, CogAcqFifoPixelFormatConstants.Format8Grey, 0, False)

    contrastParams = myAcqFifo.OwnedContrastParams

    If Not contrastParams Is Nothing Then
        contrastParams.Contrast = 0.8
    End If
End Sub
See Also