# nvidia.dali.fn.jpeg_compression_distortion¶

nvidia.dali.fn.jpeg_compression_distortion(*inputs, **kwargs)

Introduces JPEG compression artifacts to RGB images.

JPEG is a lossy compression format which exploits characteristics of natural images and human visual system to achieve high compression ratios. The information loss originates from sampling the color information at a lower spatial resolution than the brightness and from representing high frequency components of the image with a lower effective bit depth. The conversion to frequency domain and quantization is applied independently to 8x8 pixel blocks, which introduces additional artifacts at block boundaries.

This operation produces images by subjecting the input to a transformation that mimics JPEG compression with given quality factor followed by decompression.

This operator allows sequence inputs.

Supported backends
• ‘cpu’

• ‘gpu’

Parameters

input (TensorList ('HWC', 'FHWC')) – Input to the operator.

Keyword Arguments
• bytes_per_sample_hint (int or list of int, optional, default = [0]) –

Output size hint, in bytes per sample.

If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

• preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

• quality (int or TensorList of int, optional, default = 50) –

JPEG compression quality from 1 (lowest quality) to 100 (highest quality).

Any values outside the range 1-100 will be clamped.

• seed (int, optional, default = -1) –

Random seed.

If not provided, it will be populated based on the global seed of the pipeline.