I meet a confusing thing in image processing recently....
Assume the image $x \in \mathbb{R}^n$, with its derivative (difference) matrix: $D^+ = \begin{bmatrix} D_h \\ Dv \end{bmatrix} \in \mathbb{R}^{2n\times n}$ ($+$ means forward difference), also equal to $\nabla$. Therefore, it is natural to define the divergence: $\triangle = \nabla \cdot \nabla$.
I have seen some papers use $div = \triangle = D_h^-D_h^+ + D_v^-D_v^+ \in \mathbb{R}^{n\times n}$, where $-$ denotes the backward difference.
Here is my question: assume I want to calculate the $\frac{\partial\|\nabla x -p\|_2^2}{\partial x}$ where $p\in \mathbb{R}^{2n\times 1}$ is a vector not related to $x$, what is the result? I have seen some authors use $\nabla\cdot (\nabla x -p)$.
However, if writing the $\nabla$ as matrix form $D$ as I have introduced before, $D^T$ is exactly adjoint of gradient, not backward difference. Hence $-\triangle x$ would appear! So what is the right formula? Could anyone tell me?