Gamma Contrast
- group Gamma Contrast
Functions
-
NVCVStatus cvcudaGammaContrastCreate(NVCVOperatorHandle *handle, const int32_t maxVarShapeBatchSize, const int32_t maxVarShapeChannelCount)
Constructs an instance of the GammaContrast.
- Parameters:
handle – [out] Where the operator instance handle will be written to.
Must not be NULL.
maxVarShapeBatchSize – [in] is the positive maximum batch size for the operator.
maxVarShapeChannelCount – [in] is the positive maximum channel count for the operator.
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – Handle is null or an input limit is not positive.
NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.
NVCV_SUCCESS – Operation executed successfully.
-
NVCVStatus cvcudaGammaContrastVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVImageBatchHandle out, NVCVTensorHandle gamma)
Executes the GammaContrast operation on the given cuda stream. This operation does not wait for completion.
Limitations:
Input image batch: 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 image batch: 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 == Output -------------- | ------------- Data Layout | Yes Data Type | Yes Number | Yes Channels | Yes Width | Yes Height | Yes
- Parameters:
handle – [in] Handle to the operator.
Must not be NULL.
stream – [in] Handle to a valid CUDA stream.
in – [in] Input image batch.
out – [out] Output image batch.
gamma – [in] 1D tensor with the gamma value for each image / image channel.
- 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 cvcudaGammaContrastSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, NVCVTensorHandle gamma)
Executes the GammaContrast operation on a tensor input/output (interleaved (N)HWC or planar (N)CHW layout). This operation does not wait for completion.
- Parameters:
handle – [in] Handle to the operator. Must not be NULL.
stream – [in] Handle to a valid CUDA stream.
in – [in] Input tensor.
out – [out] Output tensor.
gamma – [in] 1D tensor with the gamma value for each sample / sample channel.
- 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 cvcudaGammaContrastScalarSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, float gamma, float gain, NVCVRoundMode roundMode)
Executes the GammaContrast operation on a tensor input/output using host-scalar gamma and gain (interleaved (N)HWC or planar (N)CHW layout). This operation does not wait for completion.
Unlike cvcudaGammaContrastSubmit, gamma and gain are plain host floats passed by value into the kernel launch, so no gamma tensor is allocated and no host->device copy is performed. The same gamma/gain is applied to every sample and channel, computing out = gain * in**gamma (the torchvision adjust_gamma formula). With gain == 1.0f and roundMode == NVCV_ROUND_NEAREST, the result is bit-exact with cvcudaGammaContrastSubmit fed a gamma tensor filled with the same value. Data layout, channel, and data-type support match cvcudaGammaContrastSubmit.
Because no gamma scratch is used, the max-batch/max-channel capacities given to cvcudaGammaContrastCreate do not constrain this function (they only bound the gamma-tensor staging used by the tensor and var-shape submits). gamma and gain are not range-validated; a negative gamma follows powf semantics (NaN for fractional exponents of negative inputs).
- Parameters:
handle – [in] Handle to the operator. Must not be NULL.
stream – [in] Handle to a valid CUDA stream.
in – [in] Input tensor.
out – [out] Output tensor.
gamma – [in] Host-scalar gamma exponent applied to every sample/channel.
gain – [in] Host-scalar output gain applied to every sample/channel.
roundMode – [in] Rounding mode used for integer outputs, cf. NVCVRoundMode. Use NVCV_ROUND_NEAREST to preserve the tensor-gamma behavior or NVCV_ROUND_TRUNCATE to truncate toward zero. Floating-point outputs are unaffected.
- 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 cvcudaGammaContrastCreate(NVCVOperatorHandle *handle, const int32_t maxVarShapeBatchSize, const int32_t maxVarShapeChannelCount)