Define quality (q) as an integer from interval <1, 99>
Compute alpha using formula from the lecture, then multiply both Q matrices with alpha
Use rgb2ycbcr to convert your input RGB image to YCbrCr color space
Iterate over image by blocks of 8 x 8, processing one block at the time.
Downsample Cb and Cr channel (channel 2 and 3) - omit every second column (4:2:2 chroma subsampling / or use different method if you wish)
On each channel peform dct2 and divide spectrum with corresponding Q matrix (Y channel - use ql, Cb and Cr - use qc), then round the result
Count number of zeros in the rounded result - compare with total number of pixels in image to get the compression ratio.
DO NOT IMPLEMENT: values from this step are encoded and saved to JPEG using Zig-Zag and some form of compression
Perform actions in reversed order
multiply with Q matrices
perform idct2
assign result to decompressed image
upsample where necessary (Cb and Cr channel)