Ivan Seidel - 9 months ago 66

Javascript Question

I'm reading some noisy images, and getting a few bits from it (21 bits).

I only need to use 15 of them, leaving me

`21 - 15 = 6`

What I intend to do, is use it for both Checksum and error correction, however, I started digging the web, and found that

`Reed-Solomon`

My question is: Since I'm dealing with a small amount of data, is there a good algorithm to use, so that it's not (so) expensive in processing, and serves as both checksum and error correction? (It will run with Node.js)

Thanks,

Ivan

Answer Source

There is good news and bad news.

The good news is that most of the complexity in schemes such as Reed-Solomon is there to support clever means of decoding, which you don't need. With only 5 check bits, http://en.wikipedia.org/wiki/Decoding_methods#Syndrome_decoding will do perfectly well. Essentially you recompute the check bits from the data bits and xor it with the check bits you received. This gives you a bit-pattern which would be zero if there were no errors and otherwise depends only on the pattern of errors and not the data bits. By considering what you want to do for all the error patterns you are prepared to cope with (e.g. all patterns of up to k errors for small k) you can build a look-up table which takes you from the bit-pattern to a bitmap of error locations.

The bad news is that these schemes are developed to support large linear codes because larger codes are more efficient. With only 21 bits to work with you won't do as well.

With 15 data bits and 21 total bits I would start off with the Hamming code described in http://en.wikipedia.org/wiki/Hamming_code, which has 15 data bits and 21 total bits, and put an arbitrary linear check on the 15 data bits on the extra 21st bit. You can decode this with syndrome decoding.