Darryl A. Fleurantin
Kai Maffucci
This implementation utilizes Professor Daniels at the University of Rhode Island array2 and bitpack implementations.
Usage:
Compression:
rpeg -c [filename]
Decompression:
rpeg -d [filename]
Architecture:
-
Data Structures:
- RgbFloat: Represents RGB colors in floating-point format.
- Crt: Represents color space conversion in floating-point format.
- Avg: Enum for different types of avergaes used in quantization.
- Quantized: Struct for quantized data with coefficients and average pb/pr.
- EncodedQuanta: Struct for encoded quantized data used in compression and decoding.
-
Modules:
-
structures.rs: Defines the data structures (RgbFloat, Crt, Avg, Quantized, EncodedQuanta) for managing data formats.
-
compression.rs: Handles RGB to CRT conversion, to DCT, averaging, quantization, encoding, and packing data into codewords.
-
decompression.rs: Extracts encoded data from codewords, reverses indexing, decoding coefficients and averages, setting pb/pr values, IDCT, and conversion from CRT to RGB.
-
-
Compressing ppm image:
- Read ppm image with class crate
- Create array2 array of pixels from image
- Trim array if uneven dimensions with
trim_arrayfunction and update dimensions - Utilize
rgb_int_array_to_rgb_float_arrayfunction to convert pixels to floats - Utilize
rgb_float_array_to_crt_arrayfunction to convert pixels floats to component video color space values - Utilize
new_quantized_arrayfunction to create an array2 of empty quantized structs - Utilize
dctfunction to perform DCT on CRT array (Y/Pb/Pr) and update the empty array2 quantized structs with the new coefficients - Utilize
average_pb_prfunction to get average pb and pr values from CRT array and update the array2 quantized structs with the new pb and pr values - Utilize
new_encoded_quanta_arrayfunction to create an array2 of empty encoded quanta structs - Utilize
index_of_chroma_arrayfunction to convert pb and pr averages to 4-bit values from quantized structs and update empty encoded quanta structs with the new pb and pr values - Utilize
encode_coefficients_arrayfunction to perform quantization on quantized structs coefficients and update quanta structs with the new coefficients - Utilize
pack_encoded_quantafunction to pack data from quanta structs into codewords - Convert codewords into bytes and output with class crate
-
Decompressing compressed image:
- Read rpeg data with class crate
- Convert rpeg data to codewords
- Convert codewords to an Array2 struct
- Utilize
extract_encoded_datafunction to unpack codewords to encoded quanta array - Utilize
new_quantized_arrayfunction to create an array2 of empty quantized structs - Utilize
chroma_of_index_arrayfunction to reverse index of chroma from quanta array and update the empty quantized structs with the new pb and pr values - Utilize
decode_coefficients_arrayfunction to dequantized quantized coefficients from quanta array and update quantized structs with the new coefficients - Utilize
new_crt_arrayfunction to create empty CRT array - Utilize
set_pb_prfunction to set pb and pr values of CRT array respective to averages from quantized structs - Utilize
inverse_dctfunction to perform inverse DCT from quantized structs and update CRT array with the new y values - Utilize
crt_array_to_rgb_float_arrayfunction to convert CRT array to rgb float array - Utilize
rgb_float_array_to_rgb_int_arrayfunction to convert rgb float array to rgb int array - Convert rgb int array into pixels
- Create rgb image from pixels
- Write image to standard out