Page MenuHomec4science

point_matching.py
No OneTemporary

File Metadata

Created
Wed, May 29, 08:44

point_matching.py

# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
from scipy.optimize import linear_sum_assignment as LSA
from rrompy.utilities.base.types import Np1D, Np2D
__all__ = ['pointMatching', 'chordalMetricTable']
def pointMatching(distanceMatrix:Np2D) -> Np1D:
return LSA(distanceMatrix)[1]
def chordalMetricTable(x:Np1D, y:Np1D) -> Np2D:
x, y = np.array(x), np.array(y)
xInf, yInf = np.where(np.isinf(x))[0], np.where(np.isinf(y))[0]
x[xInf], y[yInf] = 0., 0.
T = np.abs(np.tile(x.reshape(-1, 1), len(y)) - y.reshape(1, -1))
T[xInf, :], T[:, yInf] = 1., 1.
T[np.ix_(xInf, yInf)] = 0.
T = T.T * (np.abs(x) ** 2. + 1.) ** -.5
T = T.T * (np.abs(y) ** 2. + 1.) ** -.5
return T

Event Timeline