function tests = test_imDistanceMap(varargin)
% Test suite for function imDistanceMap.
%
%   output = test_imDistanceMap(input)
%
%   Example
%   test_imDistanceMap
%
%   See also
%

% ------
% Author: David Legland
% e-mail: david.legland@inra.fr
% Created: 2018-02-22,    using Matlab 2017b
% Copyright 2010 INRA - Cepia Software Platform.

tests = functiontests(localfunctions);


function test_TouchingParticles(testCase)
% Aim is to compute distance map within each label, even if some of them
% touch each other.
% Uses an image with a completely landlocked label region.

img = [...
    0 0 0 0 0 0 0 0 0 0 0; ...
    0 1 1 1 2 2 2 3 3 3 0; ...
    0 1 1 1 2 2 2 3 3 3 0; ...
    0 1 1 1 2 2 2 3 3 3 0; ...
    0 1 1 1 4 4 4 3 3 3 0; ...
    0 1 1 1 4 4 4 3 3 3 0; ...
    0 1 1 1 4 4 4 3 3 3 0; ...
    0 1 1 1 5 5 5 3 3 3 0; ...
    0 1 1 1 5 5 5 3 3 3 0; ...
    0 1 1 1 5 5 5 3 3 3 0; ...
    0 0 0 0 0 0 0 0 0 0 0; ...
];

exp = [...
    0 0 0 0 0 0 0 0 0 0 0; ...
    0 1 1 1 1 1 1 1 1 1 0; ...
    0 1 2 1 1 2 1 1 2 1 0; ...
    0 1 2 1 1 1 1 1 2 1 0; ...
    0 1 2 1 1 1 1 1 2 1 0; ...
    0 1 2 1 1 2 1 1 2 1 0; ...
    0 1 2 1 1 1 1 1 2 1 0; ...
    0 1 2 1 1 1 1 1 2 1 0; ...
    0 1 2 1 1 2 1 1 2 1 0; ...
    0 1 1 1 1 1 1 1 1 1 0; ...
    0 0 0 0 0 0 0 0 0 0 0; ...
];

dist = imDistanceMap(img, [3 4]);

assertEqual(testCase, dist, exp);
