function [ reconstructed_image, quantized_coefficients ] = mOptimalDCT8x8ImageAndCoeffs( image, weight_scale ) image_mean = round( mean(mean(image)) ); M = 8; [ coefficients, image_size_vector ] = mDCT8x8( image - image_mean ); quantized_coefficients = mDCT8x8WeightedQuantization( coefficients, weight_scale ); reconstruction_coefficients = mDCT8x8InverseWeightedQuant( quantized_coefficients, weight_scale ); DC_coefficients = quantized_coefficients( 1:M:image_size_vector( 1 ), 1:M:image_size_vector( 2 ) ); DPCM_DC_coefficients = mDPCMEncode( DC_coefficients ); quantized_coefficients( 1:M:image_size_vector( 1 ), 1:M:image_size_vector( 2 ) ) = DPCM_DC_coefficients; reconstructed_image = round( mInverseDCT8x8( reconstruction_coefficients, image_size_vector ) ) + image_mean;