参考matlab:
%............................................
function [D]=dist(i,x)
% function: [D]=dist(i,x)
%
% Aim:
% Calculates the Euclidean distances between i and all objects in x
%
% Input:
% i - an object (1,n)
% x - data matrix (m,n); m-objects, n-variables
%
% Output:
% D - Euclidean distance (m,1)
[m,n]=size(x);
D=sqrt(sum((((ones(m,1)*i)-x).^2)'));
if n==1
D=abs((ones(m,1)*i-x))';
end
python
H_str,W_str = colorbar.shape[:2]
data = np.sqrt( np.sum( np.square( (np.ones((H_str, 1), np.int64) * temp) - colorbar), axis=1) ).T