$\DeclareMathOperator{\arccosh}{arccosh} \DeclareMathOperator*{\argmin}{arg\,min} \DeclareMathOperator{\Exp}{Exp} \newcommand{\geo}{\gamma_{\overset{\frown}{#1,#2}}} \newcommand{\geoS}{\gamma} \newcommand{\geoD}{\gamma_} \newcommand{\geoL}{\gamma(#2; #1)} \newcommand{\gradM}{\nabla_{\M}} \newcommand{\gradMComp}{\nabla_{\M,#1}} \newcommand{\Grid}{\mathcal G} \DeclareMathOperator{\Log}{Log} \newcommand{\M}{\mathcal M} \newcommand{\N}{\mathcal N} \newcommand{\mat}{\mathbf{#1}} \DeclareMathOperator{\prox}{prox} \newcommand{\PT}{\mathrm{PT}_{#1\to#2}#3} \newcommand{\R}{\mathbb R} \newcommand{\SPD}{\mathcal{P}(#1)} \DeclareMathOperator{\Tr}{Tr} \newcommand{\tT}{\mathrm{T}} \newcommand{\vect}{\mathbf{#1}}$

# gradient of the second order TV mid point model prior

For data $x\colon\Grid\to\M$ on a $m$-dimensional grid $\Grid$ this function returns the gradient $\gradM F$ of the absolute second order total variation prior. The prior is explained in detail here. In order to compute the gradient $\gradMComp{x_{\vect{k}}}$, one has to take into account all summands, where $x_{\vect{k}}$ appears, which are all neighbors besides those on diagonal direction with different signs, e.g. $\vect{k}+\vect{e}_j-\vect{e}_i$. For three successive points $x,y,z\M$ in one direction on the grid the gradient of $f=d_2(x,y,z)$ reads with $c=\geo{x}{z}(\tfrac{1}{2})$ the geodesic mid point nearest to $y$ as $\gradM f = \begin{pmatrix} J^*_{x,z}(\frac{1}{2},\log_cy) \\ \log_{y}c \\ J^*_{z,x}(\frac{1}{2},\log_cy) \end{pmatrix}$ and similarily for $w,x,y,z\in\M$ on a $2\times 2$ grid with nearest mid point $c=\geo{x}{z}(\tfrac{1}{2})$, $\tilde c = \geo{w}{y}(\tfrac{1}{2})$ reads

and the gradient is then optained by looking at the chain rule with respect to $p$ and taking into account all above mentioned occurences of $x_{\vect{k}}$ as $x,y,z$ and $w,x,y,z$ in the above gradients respectively.

### Optional Parameters

epsilon $(0)$
relax the TV (especially for $p=1$ by replacing any distance by $\sqrt{ d^2(\cdot,\cdot)+\varepsilon^2 }$ and for $p>1$ each inner sum (over $N_{\vect{k}}$) is relaxed to avoid subgradients in constant areas.
p $(1)$
denotes the outer coupling of the differences
weights $(1)$ for each item of $x$
introduces a weight that is muliplied to any term, i.e. if weights is zero this the corresponding data item is ignored.

### Matlab Documentation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
% gradTV2Midpoint(M,x) compute gradient of the second order mid point model
% INPUT
%   M      :  a manifold
%   x      : data (size [manDims,dataDims])
%
% OPTIONAL
%   'p'       : (p=1) compute TV with p-norm coupling in the dimensions of
%               the data, i.e. anisotropic TV for p=1 and isotropic for p=2
%  'epsilon'  : compute the gradient of the epsilon-relaxed TV
%  'weights'  : (ones(dataDims)) exclude certain data points from all