Compressing a binary matrix

We were asked to find a way to compress a square binary matrix as much as possible, and if possible, to add redundancy bits to check and maybe correct errors.

The redundancy thing is easy to implement in my opinion. The complicated part is compressing the matrix. I thought about using run-length after reshaping the matrix to a vector because there will be more zeros than ones, but I only achieved a 40bits compression (we are working on small sizes) although I thought it'd be better.

Also, after run-length an idea was Huffman coding the matrix, but a dictionary must be sent in order to recover the original information.

I'd like to know what would be the best way to compress a binary matrix?

After reading some comments, yes @Adam you're right, the 14x14 matrix should be compressed in 128bits, so if I only use the coordinates (rows&cols) for each non-zero element, still it would be 160bits (since there are twenty ones). I'm not looking for an exact solution but for a useful idea.

5
задан anniesboobs 19 May 2011 в 09:10
поделиться