I am trying to follow this paper. In it they define a functional
$$J(f) = \sum_{x \in \Omega} \psi (f(x) - u(x)) + \beta \sum_{x \in N_x} \phi(f(x) - f(y)), $$
where, for my purposes, $f$ and $u$ are matrices of size $192 \times 192$ (images), and $\psi, \phi \in C^2(\mathbb{R})$. The goal is to find the matrix $f$ that minimizes $J$. I've been trying to minimize $J$ for the longest time and am really stuck. I'm trying to do newton's method, but am getting stuck on finding the gradient and hessian for $J$. Everywhere I look online has the gradient defined for vector functions. At first I had
$$\nabla J(f) = \sum_{x \in \Omega} \psi' (f(x) - u(x)) + \beta \sum_{x \in N_x} \phi'(f(x) - f(y)) $$ and $$\nabla^2 J(f) = \sum_{x \in \Omega} \psi'' (f(x) - u(x)) + \beta \sum_{x \in N_x} \phi''(f(x) - f(y)),$$
but then of course I can't iterate $f_{k+1} = f_k - \frac{\nabla J(f)}{\nabla^2 J(f)}$. Any help or pointers to resources online would be greatly appreciated.