function d = otdist( t0,t1,M,N,rel )
%OTDIST Compute L2 optimal transport distance between
% two circular ADSN models.
%
% d = otdist( t0,t1,M,N,rel ) computes the L2 optimal transport
% distance between the color circular ADSN models of size [M,N]
% corresponding to the kernels t0 and t1.
% If the optional argument rel is set to 1, then the distance
% is renormalized by the modulus of the DFT of t0.
%
% NB : Inputs t0 and t1 can have multiple channels.
%
% WARNING !
% - The mean coefficient is ignored in the comparison.
% - It is assumed that the ADSN model on [M,N] is obtained
% by extending the shot by zero-padding.
%
% Author : Arthur Leclaire
% v. 1.0 (03/2014) : first public version
% v. 1.1 (10/2015) : 0-frequency must be included in the sum.
[m0,n0,D] = size(t0);
[m1,n1,C] = size(t1);
if (C~=D)
error('t0 and t1 must have the same number of channels');
end
if ((M4)&&(rel==1))
d = d/sqrt(d0);
else
d = d/(M*N);
end
end