eschombu / cisc4080

Fordham CISC 4080 Computer Algorithms
0 stars 3 forks source link

matrix<string> reduce_img_mat(matrix<double> & original, int nlevels) #3

Closed cshue1 closed 6 years ago

cshue1 commented 6 years ago

https://github.com/prof-erik/cisc4080/blob/cf3d4247701e4e5c70ef56721537d4d40d84ed2f/huffman.cpp#L12-L30

I'm having trouble understanding what to do for this function...

prof-erik commented 6 years ago

The function reduces the bit rate (maybe I should've called it reduce_bit_rate or something more informative) by reducing the number of possible color/luminance levels that pixels can take. So for example, if the input image matrix can have pixels be one of 32 possible values (encoded by 5 bits), i.e., 0, 0.03125, 0.0625, 0.09375, 0.125, 0.15625, ..., 0.96875, and nlevels=8, the output image's pixels can be only one of 8 possible values: 0, 0.125, 0.25, 0.375, ....

Does that help? Essentially, you need to round the old values for each pixel to the nearest new possible value.