Brightness Contrast

group NVCV_C_ALGORITHM_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 Type      | Allowed
 -------------- | -------------
 8bit  Unsigned | Yes
 8bit  Signed   | No
 16bit Unsigned | Yes
 16bit Signed   | Yes
 32bit Unsigned | No
 32bit Signed   | Yes
 32bit Float    | Yes
 64bit Float    | No
Output:
 Data Type      | Allowed
 -------------- | -------------
 8bit  Unsigned | Yes
 8bit  Signed   | No
 16bit Unsigned | Yes
 16bit Signed   | Yes
 32bit Unsigned | No
 32bit Signed   | Yes
 32bit Float    | Yes
 64bit Float    | No
Input/Output dependency

Property

Input == Output

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.