Precision Loss in Arithmetic Encoding of Binary Vectors for Reversible Data Hiding in 3D Meshes
29 views (last 30 days)
Show older comments
Harpreet
on 10 Sep 2025 at 7:50
I’m currently working on a reversible data hiding scheme and using arithmetic encoding to compress auxiliary data. The data is a binary vector of approximately 7000 bits. The encoder outputs a fractional value between 0 and 1, which I store and later use for decoding.
However, during decompression, the reconstructed binary vector does not match the original, indicating a loss of precision—likely due to MATLAB’s handling of floating-point numbers. I’ve tried increasing numeric precision using vpa and symbolic variables, but the mismatch persists.
Accepted Answer
John D'Errico
on 10 Sep 2025 at 13:08
Edited: John D'Errico
on 10 Sep 2025 at 13:12
You are telling us that you effectively have a binary number with 7000 binary bits. You convert it to a decimal number, and then convert it back to binary. And you are surpised you have lost some low order bits in the process? A double will surely fail here. You say you used vpa, but you don't need to do so. str2sym will suffice.
B0 = char(randi([0 1],[1,7000]) + '0');
B0((-100:0) + end) % the lowest order bits
Dsym = str2sym(['0b',B0])
B1 = dec2bin(Dsym);
isequal(B0,B1)
As you can see, the original bit string and the reconstruction are identical. Be careful of using vpa, because it specifies the number of digits. Maybe that was your problem. I don't know what you did, since you were too vague for us to know.
1 Comment
More Answers (1)
Walter Roberson
on 10 Sep 2025 at 19:04
I speculate that you are converting 64 bits at a time to binary, constructing a 64 bit integer from that, dividing it by 2^64.
If so then you run into the problem that double precision numbers can only represent 53 bits.
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!