Inverse floor function

1.1k Views Asked by At

studying a scientific article**, I ran into something I cannot explain:

$$l := \left\lfloor{\frac{x+y}{2}}\right\rfloor ,\quad h := x - y \\ x = l + \left\lfloor{\frac{h+1}{2}}\right\rfloor, \quad y = l - \left\lfloor{\frac{h}{2}}\right\rfloor$$

can someone explain the $+1$ in $x$ ?

(Original:)enter image description here

** Tian, J., 2003. Reversible data embedding using a difference expansion. IEEE transactions on circuits and systems for video technology, 13(8), pp.890-896.

2

There are 2 best solutions below

0
On

If $x$ and $y$ share the same parity, then $$l+\big\lfloor \frac{h+1}2\big\rfloor=\frac{x+y}{2}+\frac{x-y}2=x$$

The $+1$ is not used.

However, if they do not share the same parity, then

$$l+\big\lfloor \frac{h+1}2\big\rfloor=\frac{x+y-1}{2}+\frac{x-y+1}2=x$$

0
On

Given that $\ s := \lfloor (x + y) /2 \rfloor, \ d := x - y \ $ where all the variables are integers. We also suppose that $\ x = a + b, \ y = a - c \ $ for some integers $\ a, b, c. \ $ Then $\ d = b + c, \ x + y = 2a + b - c, \ $ and $\ s = a + \lfloor (b - c) /2 \rfloor. \ $ We want $\ b = c \ $ but since all variables are integers, then $\ d \ $ would be even. If $\ d \ $ is even, then we can have $\ s = a $ and $\ b = c = d/2. \ $ If $\ d \ $ is odd, then $\ b \ $ and $\ c \ $ must differ by an odd integer which we choose to be $1$ in which case $\ 0 = \lfloor (b - c) /2 \rfloor \ $. We can also choose that $\ b > c \ $ which implies $\ c = \lfloor d / 2 \rfloor \ $ and $\ b = 1 + c = \lfloor (d + 1) / 2 \rfloor. \ $ In both even and odd cases $\ s = a \ $ and $\ c = \lfloor d / 2 \rfloor \ $ and $\ b = \lfloor (d + 1) / 2 \rfloor. \ $