MATLAB: LZW Compression Via Gif Transformation

lampel zivlzw compression

Hi everyone, i can compress an array which be formed binary data but i can't decompress it. I use "gif" transformation to compress the array.
%Generates bits with equal probabilities
n=100000;
prob = [.5 .5];
Input=[0 1];
fp =randsrc(1,n,[Input;prob]);
data1 = uint8(fp);
imwrite(data1,'1KB.gif');
fp2 = fopen('1KB.gif','rb');
data = uint8(fread(fp2));
it works but i need to de decompress it.
i need the first binary array after the decompression. How can i do that ?
Thanks for your Help.

Best Answer

Writing GIF compresses the data with LZW, but adds a header also. If you really want this, imread can import the data again.
I'd prefer a direct approach, e.g. FEX: lzw compression or FEX: lzw image codec.
Related Question