Brightness Contrast

group Brightness Contrast

Functions

NVCVStatus cvcudaBrightnessContrastCreate(NVCVOperatorHandle *handle)

Constructs an instance of the BrightnessContrast operator.

Parameters:

handle[out] Where the image instance handle will be written to.

  • Must not be NULL.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Handle is null.

  • NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaBrightnessContrastSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, NVCVTensorHandle brightness, NVCVTensorHandle contrast, NVCVTensorHandle brightnessShift, NVCVTensorHandle contrastCenter)

Executes the BrightnessContrast operation on the given cuda stream. This operation does not wait for completion.

The brightness and contrast are adjusted based on the following formula:

  out = brightnessShift + brightness * (contrastCenter + contrast * (in - contrastCenter))

If input or output type is (u)int32, the brightness, contrast, brightness shift and contrast center must have float64 type, otherwise they are expected to be of float32 type.

Limitations:

Input: Data Layout: [kNHWC, kHWC, kNCHW, kCHW] Channels: [1, 2, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

No

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

No

32bit Signed

Yes

16bit Float

No

32bit Float

Yes

64bit Float

No

Output: Data Layout: [kNHWC, kHWC, kNCHW, kCHW] Channels: [1, 2, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

No

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

No

32bit Signed

Yes

16bit Float

No

32bit Float

Yes

64bit Float

No

Input/Output dependency

Property

Input == Out

Data Layout

Yes

Data Type

No

Channels

Yes

Width

Yes

Height

Yes

Samples

Yes

Parameters:
  • handle[in] Handle to the operator.

    • Must not be NULL.

  • stream[in] Handle to a valid CUDA stream.

  • in[in] Input tensor to get values from.

    • Must not be NULL.

  • out[out] Output tensor to set values to.

    • Must not be NULL.

  • brightness[in] Optional tensor describing brightness multiplier. If specified, it must contain either 1 or N elements where N is the number of input images. If it contains a single element, the same value is used for all input images. If not specified, the neutral 1. is used.

  • contrast[in] Optional tensor describing contrast multiplier. If specified, it must contain either 1 or N elements where N is the number of input images. If it contains a single element, the same value is used for all input images. If not specified, the neutral 1. is used.

  • brightnessShift[in] Optional tensor describing brightness shift. If specified, it must contain either 1 or N elements where N is the number of input images. If it contains a single element, the same value is used for all input images. If not specified, the neutral 0. is used.

  • contrastCenter[in] Optional tensor describing contrast center. If specified, it must contain either 1 or N elements where N is the number of input images. If it contains a single element, the same value is used for all input images. If not specified, the middle of the assumed input type range is used. For floats it is 0.5, for unsigned integer types it is 2 ** (number_of_bits - 1), for signed integer types it is 2 ** (number_of_bits - 2).

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaBrightnessContrastVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVImageBatchHandle out, NVCVTensorHandle brightness, NVCVTensorHandle contrast, NVCVTensorHandle brightnessShift, NVCVTensorHandle contrastCenter)

Executes the BrightnessContrast operation on a batch of images.

Apart from input and output image batches, all parameters are the same as cvcudaBrightnessContrastSubmit.

Parameters:
  • in[in] Input image batch.

  • out[out] Output image batch.

NVCVStatus cvcudaBrightnessContrastScalarSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, double brightness, double contrast, double brightnessShift, double contrastCenter, bool clamp)

Executes BrightnessContrast with one set of parameters supplied by value for every input image.

The affine formula and input/output limitations are the same as cvcudaBrightnessContrastSubmit. Unlike the tensor-parameter entry point, this path requires no parameter tensors or host-to-device copies.

Parameters:
  • handle[in] Handle to the operator.

  • stream[in] Handle to a valid CUDA stream.

  • in[in] Input tensor.

  • out[out] Output tensor.

  • brightness[in] Brightness multiplier.

  • contrast[in] Contrast multiplier.

  • brightnessShift[in] Brightness shift.

  • contrastCenter[in] Contrast center.

  • clamp[in] If true, clamp to the nominal image range before conversion: [0, 1] for floating-point output and [0, max] for integer output. If false, preserve the existing BrightnessContrast behavior.

NVCVStatus cvcudaBrightnessContrastVarShapeScalarSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVImageBatchHandle out, double brightness, double contrast, double brightnessShift, double contrastCenter, bool clamp)

Executes the by-value BrightnessContrast path on a variable-shape image batch.

Apart from input and output image batches, all parameters are the same as cvcudaBrightnessContrastScalarSubmit.