Precision Loss in Arithmetic Encoding of Binary Vectors for Reversible Data Hiding in 3D Meshes

29 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

John D'Errico
John D'Errico el 10 de Sept. de 2025 a las 13:08
Editada: John D'Errico el 10 de Sept. de 2025 a las 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
ans = '10001000101000100110001001011101001111110010100001001111111100010111111111100100010001000110010001110'
Dsym = str2sym(['0b',B0])
Dsym = 
14611690343717375200400357400107036275415015496725933576134918237834901647940740585995756352999316797921735288900965114219238024671569654677301802518163788575925670985181467763675548486450613472861793673098331282770537639172204589934066774262876291609323921898054464824878511713017115714633527222869958768118301734772121479768938595083620565664018830387947311164421307924134879720249699553070463938451418938834286993345545422798213815664300353975814873823112482704649676967886411827473286760562163071173221989971254627299341335621232481623738223353514457478976716332935407253253776916026931675718539353353659211525861377322250295670782929355821989063267670949368047937784048480235592033643345371296060447464935304687710410422142018445948571654191800879946387971906479977554787313656253431023022127148896828720318732019558523287751891616115294080795887002735180705112273246617073618356411211754114706036845370717211029274692155821492890685295738930580139872447601731725455691063843070742213621710195970346498953164491201561364980919910754012869020516284470341669061267875396802005165121901030248473882579892140933417940290908401964551363419118889378786386551962965700847356144256336949687280507911112292115199752647852289063985823404690933456448405783068127714680056179589509039069460163251531210868112293545126242124546785372177192004418223845507944717077318132288083412659129878658765433344955750819904348661242078905800691833410304176841586877820590152976768047427486114810761820679803703507493663022249869263736632518946632220037228556144067789771372731829409632644367090723717589831248781493354195224208457105427035657539178250219810783177636336112544920409078292027384600561708418792276101150568555791292629977964763080742586024159267208272287953922662812217874882068051310389585313582238592364368728994738876936781292644015645191458191533628238272735030384798996738032796211660650626848888720741230702123104375304747451716895921833034519911360070203112187708011139600622127226333302379922126855908079303787081275884264758175819239209429090420919850031951942092770190454837477775521898639478087869828238
B1 = dec2bin(Dsym);
isequal(B0,B1)
ans = logical
1
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.

Más respuestas (1)

Walter Roberson
Walter Roberson el 10 de Sept. de 2025 a las 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.

Categorías

Más información sobre Numbers and Precision en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by