TheAvalanche/MATLAB-Jpeg-encoder

great code but there seems to be a bug

Closed this issue · 3 comments

Hi,

Really nice code. But there seems to be a bug as when I run main everything works but the image output is slightly scrambled and becomes increasingly scrambled as you move down the image. Any ideas?

many thanks,

Will

I also find that problem.

I figured it out - the behaviour of bitshift has changed in later iterations of matlab Replace

PutBuffer = bitshift(PutBuffer, 8); in huffman.m with

PutBuffer = bitshiftLEGACY(PutBuffer, 8);

function out=bitshiftLEGACY(val,sh)
out = bitshift(val, sh);
full64=dec2bin(out,64);
trunc53=full64(12:end);
out=bin2dec(trunc53);

To code the code running without changing it revert to matlab 2011a.

good luck!

It works!! Thank you so much!!