For data on a -dimensional grid this function returns the gradient of the absolute second order total variation prior. The prior is explained in detail here. In order to compute the gradient , one has to take into account all summands, where appears, which are all neighbors besides those on diagonal direction with different signs, e.g. . For three successive points in one direction on the grid the gradient of reads with the geodesic mid point nearest to as and similarily for on a grid with nearest mid point , reads

and the gradient is then optained by looking at the chain rule with respect to and taking into account all above mentioned occurences of as and in the above gradients respectively.

### Optional Parameters

`epsilon`

- relax the TV (especially for by replacing any distance by and for each inner sum (over ) is relaxed to avoid subgradients in constant areas.
`p`

- denotes the outer coupling of the differences
`weights`

for each item of- 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
% gradient terms
%
% OUTPUT
% eta : the gradient
% ---
% MVIRT, R. Bergmann, 2017-12-08