jpegdna.codecs package¶
jpegdna.codecs.jpeg_dna module¶
Encoding and decoding main functions for JPEG-DNA
- class jpegdna.codecs.jpeg_dna.JpegDNA(alpha, sampler='4:2:2', verbosity=False, verbose=0)[source]¶
Bases:
object
General codec for JpegDNA
jpegdna.codecs.jpeg_dna_gray module¶
Encoding and decoding main functions for JPEG-DNA
- class jpegdna.codecs.jpeg_dna_gray.JPEGDNAGray(alpha, formatting=False, channel_type='luma', verbose=False, verbosity=0)[source]¶
Bases:
jpegdna.coders.AbstractCoder
JPEG-DNA codec for gray-level images
- Parameters
aplha – Alpha value (quantization step multiplier)
formatting (bool) – Formatting enabler
channel_type (str) – Channel type choice (‘luma’ or ‘chroma’)
verbose – bool
verbosity – int
- Variables
verbose – Verbosity enabler
verbosity – Verbosity level
alpha (float) – alpha value (compression rate?)
lut (list) – hexa codes for the categories
dct (jpegdna.transforms.dctransform.DCT) – dct transform
zigzag (jpegdna.transforms.zigzag.ZigZag) – Zigzag transform
dc_coeff_coder (jpegdna.coders.coefficientcoder.DCCoefficientCoder) – DC coefficient coder
ac_coeff_coder (jpegdna.coders.coefficientcoder.ACCoefficientCoder) – AC coefficient coder
- GAMMAS = array([[ 16, 11, 10, 16, 24, 40, 51, 61], [ 12, 12, 14, 19, 26, 58, 60, 55], [ 14, 13, 16, 24, 40, 57, 69, 56], [ 14, 17, 22, 29, 51, 87, 80, 62], [ 18, 22, 37, 56, 68, 109, 103, 77], [ 24, 35, 55, 64, 81, 104, 113, 92], [ 49, 64, 78, 87, 103, 121, 120, 101], [ 72, 92, 95, 98, 112, 100, 103, 99]])[source]¶
- GAMMAS_CHROMA = array([[17, 18, 24, 47, 99, 99, 99, 99], [18, 21, 26, 66, 99, 99, 99, 99], [24, 26, 59, 99, 99, 99, 99, 99], [47, 66, 99, 99, 99, 99, 99, 99], [99, 99, 99, 99, 99, 99, 99, 99], [99, 99, 99, 99, 99, 99, 99, 99], [99, 99, 99, 99, 99, 99, 99, 99], [99, 99, 99, 99, 99, 99, 99, 99]])[source]¶
- compute_min_dynamic(img, channel_type='luma')[source]¶
Compute the minimum possible alpha value for a given image
- Parameters
img (np.array) – input image
- Returns
minimum possible alpha value
- Return type
float
- decode(code)[source]¶
JPEG-DNA decoder: decodes the input DNA-like bitstream into an block image of size self.n x self.m
- Parameters
code (str) – DNA-like bitstream
- Returns
block image
- Return type
np.array
- encode(inp)[source]¶
JPEG-DNA encoder: encodes the image into a DNA-like bitstream
- Parameters
inp (np.array) – input image
- Returns
DNA-like bitstream
- Return type
str
- full_decode(code, *args)[source]¶
Encoding method
- Parameters
code (list|str) – Input to decode
args (any) – Decoding arguments
- Returns
Decoded message, decoding state
- Return type
list|str, any
- full_encode(inp, *args)[source]¶
Encoding method
- Parameters
inp (list|str) – Input to encode
args (any) – Encoding arguments
- Returns
Encoded message, encoding state
- Return type
list|str, any
- set_channel_type(channel_type)[source]¶
Setter for the channel type
- Parameters
channel_type (str) – Choice between ‘luma’ and ‘chroma’
- set_frequencies_from_array(freq_dc, freq_ac)[source]¶
Sets the frequencies used using a pre-existing frequency tables
- Parameters
freq_dc (array) – DC coefficients frequencies table
freq_ac – AC coefficients frequencies table
- set_frequencies_from_img(inp)[source]¶
Computes the frenquencies in function of the image DCT quantized coefficients
- Parameters
inp (np.array) – input image
- set_state(*args, case=None)[source]¶
Sets the state of the codec
- Parameters
freq_dc (list(float)) – List of appearance frequences for each element of the alphabet in the dc values
freq_ac (list(float)) – List of appearance frequences for each element of the alphabet in the ac values
m (int) – length of an image block
n (int) – height of an image block
jpegdna.codecs.jpeg_dna_rgb module¶
Encoding and decoding main functions for JPEG-DNA in RGB
- class jpegdna.codecs.jpeg_dna_rgb.JPEGDNARGB(alpha, formatting=False, verbose=False, verbosity=0, channel_sampler='4:2:2')[source]¶
Bases:
jpegdna.codecs.jpeg_dna_gray.JPEGDNAGray
JPEG-DNA codec for RGB images
- Parameters
aplha – Alpha value (quantization step multiplier)
formatting (bool) – Formatting enabler
channel_sampler (str) – Sampler name used to subsample chrominance channels
verbose – bool
verbosity – int
- Variables
verbose – Verbosity enabler
verbosity – Verbosity level
alpha (float) – alpha value (compression rate?)
lut (list) – hexa codes for the categories
dct (jpegdna.transforms.dctransform.DCT) – dct transform
zigzag (jpegdna.transforms.zigzag.ZigZag) – Zigzag transform
- compute_min_dynamic(img, channel_type=None)[source]¶
Compute the minimum possible alpha value for a given image
- Parameters
img (np.array) – input image
- Returns
minimum possible alpha value
- Return type
float
- full_decode(code, *args)[source]¶
Encoding method
- Parameters
code (list|str) – Input to decode
args (any) – Decoding arguments
- Returns
Decoded message, decoding state
- Return type
list|str, any
- full_encode(inp, *args)[source]¶
Encoding method
- Parameters
inp (list|str) – Input to encode
args (any) – Encoding arguments
- Returns
Encoded message, encoding state
- Return type
list|str, any