% closed curves - take difference of T values at appropriate points
c_beginning = round(c(end,:));
T_beginning = T(c_beginning(1), c_beginning(2));
% search for c_end
idx = size(c, 1);
while (idx > 0) & (floor(c(idx,1)) < m_)
    idx = idx-1;
end
c_end = round(c(idx,:));
T_end = T(c_end(1), c_end(2));
curve_distance = T_end - T_beginning;
% normalize distance to compensate for curve lengths
strT = curve_distance - valLambda*sqrt(m_*m_ + n_*n_) + abs(1 - min(m_,n_)/max(m_,n_));
