$$p(\hat{x}_i = x_i) \geq p(\hat{x}_i \neq x_i) \implies p(\hat{x}_i = x_i) + p(\hat{x}_i = x_i) \geq p(\hat{x}_i = x_i) + p(\hat{x}_i \neq x_i) = 1 \implies p(\hat{x}_i = x_i) \geq \frac{1}{2}$$
The median of a distribution $m$ is defined as the value which satisfies
$$p(x \geq m) \geq \frac{1}{2} \
p(x \leq m) \geq \frac{1}{2} $$
Thus $x_i$, the original pixel value, is the median of $\hat{x}_i$ since the following inequalities hold $$p(\hat{x}_i \geq x_i) = p(\hat{x}_i \gt x_i) + p(\hat{x}_i = x_i) \geq \frac{1}{2}\\ p(\hat{x}_i \leq x_i) = p(\hat{x}_i \lt x_i) + p(\hat{x}_i = x_i) \geq \frac{1}{2}$$
The image with pixel values normalised to such that $x_i \in [0,1]$ is perturbed according to the following distribution:
$$p(\hat{x}_i) = \left{\begin{array}{ll}
1-p \text{, }\text{ }\hat{x}_i = x_i \\
p \text{, }\text{ }\hat{x}_i \in [0,x_i) \cup (x_i,1] \
\end{array}
\right.$$
$$\int_0^1 p(\hat{x}_i)\cdot d\hat{x}_i = \int_0^{x_i} p \cdot d\hat{x}_i+ (1 - p) + \int_{x_i}^1 p\cdot d\hat{x}_i = px_i + (1 - p) + p(1 - x_i) = 1 - p + p = 1$$