jpegdna.transforms package

Module contents

Transforms collection useful for jpegdna

class jpegdna.transforms.AbstractTransform[source]

Bases: abc.ABC

Abstract class for codec definition

abstract forward(inp)[source]

Forward transform method

Parameters

inp – Input to transform

Type

any

Returns

Transformed message

Return type

any

full_forward(inp, *args)[source]

Forward transform method

Parameters
  • inp – Input to transform

  • args (any) – Supplementary arguments for the forward transforms

Type

any

Returns

Transformed message

Return type

any

full_inverse(inp, *args)[source]

Inverse transform wrapper method

Parameters
  • inp – Input to apply inverse transform

  • args (any) – Supplementary arguments for the inverse transforms

Type

any

Returns

Inverse transformed message

Return type

any

get_state(case=None)[source]

Helper method to get the state of the codec if necessary

Return type

any

abstract inverse(inp)[source]

Inverse transform method

Parameters

inp – Input to apply inverse transform

Type

any

Returns

Inverse transformed message

Return type

any

set_state(*args, case=None)[source]

Helper method to set the state of the codec if necessary

Return type

None

exception jpegdna.transforms.AutomataException[source]

Bases: Exception

exception jpegdna.transforms.AutomataGetterException[source]

Bases: jpegdna.transforms.AutomataException

exception jpegdna.transforms.AutomataGetterExceptionForward[source]

Bases: jpegdna.transforms.AutomataGetterException

exception jpegdna.transforms.AutomataGetterExceptionInverse[source]

Bases: jpegdna.transforms.AutomataGetterException

exception jpegdna.transforms.AutomataSetterException[source]

Bases: jpegdna.transforms.AutomataException

exception jpegdna.transforms.AutomataSetterExceptionForward[source]

Bases: jpegdna.transforms.AutomataSetterException

exception jpegdna.transforms.AutomataSetterExceptionInverse[source]

Bases: jpegdna.transforms.AutomataSetterException

jpegdna.transforms.colortransform module

YCbCr converter for RGB management

class jpegdna.transforms.colortransform.RGBYCbCr[source]

Bases: jpegdna.transforms.AbstractTransform

RGB YCbCr color converter

forward(inp)[source]

Wrapper method to covert RGB to YCbCr

Parameters

inp (np.array) – Input image

Returns

YCbCr image

Return type

np.array

inverse(inp)[source]

Wrapper method to covert YCbCr to RGB

Parameters

inp (np.array) – Input YCbCr image

Returns

RGB image

Return type

np.array

jpegdna.transforms.dctransform module

Discrete cosine forward and inverse transforms

class jpegdna.transforms.dctransform.DCT[source]

Bases: jpegdna.transforms.AbstractTransform

For Jpeg

forward(inp)[source]

Forward 2D DCT

Parameters

inp (np.array) – input image block

Returns

DCT coefficients

Return type

np.array

full_forward(inp, *args)[source]

Forward 2D DCT

Parameters
  • inp (np.array) – input image block

  • norm (str) – Type of DCT (default: None)

Returns

DCT coefficients

Return type

np.array

full_inverse(inp, *args)[source]

Inverse 2D DCT

Parameters
  • inp (np.array) – input image block

  • norm (str) – Type of DCT (default: None)

Returns

DCT coefficients

Return type

np.array

inverse(inp)[source]

Inverse 2D DCT

Parameters

inp (np.array) – DCT coefficients

Returns

image block

Return type

np.array

jpegdna.transforms.sampler module

Sampler class for 3-channels management

class jpegdna.transforms.sampler.ChannelSampler(sampler='4:2:2')[source]

Bases: jpegdna.transforms.AbstractTransform

Channel Sampler

Variables

sampler – Sampler name (default: “4:2:2”)

Parameters

sampler – str

forward(inp)[source]

Sampling method

Parameters

inp (np.array) – 3-channel image

Returns

Tuple of the 3 sampled channels (Y not subsampled usually)

Return type

tuple

get_sampler()[source]

Get sampler name

inverse(inp)[source]

Desampling method

Parameters

inp (np.array) – Tuple of the 3 sampled channels (Y not subsampled usually)

Returns

3-channel image

Return type

np.array

set_sampler(sampler)[source]

Set sampler from its name

jpegdna.transforms.zigzag module

Zigzag algorithm

class jpegdna.transforms.zigzag.ZigZag(verbose=False)[source]

Bases: jpegdna.transforms.AbstractTransform

Zig-zag transform

Variables
  • verbose – Verbosity enabler

  • vmax (int) – width of the matrix

  • hmax (int) – height of the matrix

Parameters

verbose – bool

forward(inp)[source]

Transform the inp matrix into a sequence element following the zig-zag reading order

Parameters

inp (np.array) – Input to be transformed

Returns

Zig-zag read sequence

Return type

np.array

full_inverse(inp, *args)[source]

Inverse transform wrapper method

Parameters
  • inp – Input to apply inverse transform

  • args (any) – Supplementary arguments for the inverse transforms

Type

any

Returns

Inverse transformed message

Return type

any

inverse(inp)[source]

Reconstruct matrix from a sequence of zig-zag read values

Parameters

inp (np.array) – Sequence of values

Returns

reconstructed matrix

Return type

np.array

set_state(*args, case=None)[source]

Sets the state of the transform

Parameters
  • hmax

  • vmax (int) –