def main(argv): # discretize_channel(9) # discretize_channel(10) vals = discretize_channel(9) print vals rand_block = random_11_block(vals) print rand_block dctd = two_dim_DCT(rand_block) print 'DCTd' print_8_by_8(dctd) jpeg = JPEG() print # For visualizing the quantization matrices. # # for quality in range(5, 96): # quantized = jpeg.scaled_luminance_quant_matrix(quality) # with open('quant_%s.log' % quality, 'w') as fh: # for row in range(8): # for col in range(8): # fh.write('%d %d %d\n' % (row, col, quantized[row,col])) quantized = jpeg.luminance_quantize(dctd, 75) print_8_by_8(quantized) print 'Dequanitzed' dequantized = jpeg.luminance_dequantize(quantized, 75) print_8_by_8(dequantized) idctd = two_dim_DCT(dequantized, False) print 'iDCT' print_8_by_8(idctd) print 'Diff' print_8_by_8( idctd - rand_block) print 'FS' dithered = jpeg.fs_dither(idctd) print_8_by_8(dithered) print 'Diff Dither' print_8_by_8( dithered - rand_block)
for col in range(8): print '%5.1f' % orig_mat[row, col], print '' print # Shift for [-128, 127] mat = orig_mat - 128 for row in range(8): for col in range(8): print '%4d' % mat[row, col], print '' print dct_mat = two_dim_DCT(mat) for row in range(8): for col in range(8): print '%8.2f' % dct_mat[row, col], print '' print scale_factor = jpeg_scale_factor(_QUALITY) print scale_factor quantized_mat = numpy.zeros((8,8)) for i, quant in enumerate(_QUANT_TABLE): row = i / 8 col = i % 8 # temp = float(quant)