euclidean-distance

Computing euclidean distance with multiple list in python

家住魔仙堡 提交于 2019-12-08 12:56:36
问题 I'm writing a simple program to compute the euclidean distances between multiple lists using python. This is the code I have so fat import math euclidean = 0 euclidean_list = [] euclidean_list_complete = [] test1 = [[0.0, 0.0, 0.0, 152.0, 12.29], [0.0, 0.0, 0.357, 245.0, 10.4], [0.0, 0.0, 0.10, 200.0, 11.0]] test2 = [[0.0, 0.0, 0.0, 72.0, 12.9], [0.0, 0.0, 0.0, 80.0, 11.3]] for i in range(len(test2)): for j in range(len(test1)): for k in range(len(test1[0])): euclidean += pow((test2[i][k]

relabeling pixels based on distance between object's centerline and boundary

怎甘沉沦 提交于 2019-12-08 02:53:56
问题 I've a binary image containing an object as illustrated in the figure below. The centerline of the object is depicted in red . For each pixel belonging to the object, I would like to relabel it with a color. For instance, pixels whose orthogonal distance to the centerline are half of the distance to the object boundary from the centerline, should be labeled blue , otherwise green . An illustration is given below. Any ideas? Also, how could I fit a 1D gaussian centered in the object centerline

Calculate overlap between two rectangles on x/y grid?

陌路散爱 提交于 2019-12-07 12:16:11
问题 I need to calculate the overlap (amount or yes/no) that two rectangles make on a special x/y grid. The grid is 500x500 but the sides and corners connect (are continuous). So the next point after 499 becomes 0 again. In a previous question I asked for a way to calculate the distance between two points in this grid. This turned out to be the Euclidean distance: sqrt(min(|x1 - x2|, gridwidth - |x1 - x2|)^2 + min(|y1 - y2|, gridheight - |y1-y2|)^2) What is the good mathematical way of calculating

How to calculate Euclidean length of a matrix without loops?

谁说胖子不能爱 提交于 2019-12-07 04:53:11
问题 It seems like the answer to this should be simple, but I am stumped. I have a matrix of Nx3 matrix where there 1st 2nd and 3rd columns are the X Y and Z coordinates of the nth item. I want to calculate the distance from the origin to the item. In a non vectorized form this is easy. distance = norm([x y z]); or distance = sqrt(x^2+y^2+z^2); However, in vectorized form its not so simple. When you pass a matrix to norm it no longer returns the Euclidean length. distance = norm(matrix); %doesn't

How to create a Large Distance Matrix?

孤街醉人 提交于 2019-12-06 16:07:33
How to allocate a huge distance matrix in an appropriate way to avoid " allocation is unable " error. Imagine you have a 100.000 points randomly spreaded over some space. How can one cleverly create a matrix or "dist"-object, which represents the the half of DistMatrix. Maybe it should be another object, which will be able efficiently allocate the large number of distances. You can get the polygonial object from the following link: https://www.dropbox.com/sh/65c3rke0gi4d8pb/LAKJWhwm-l # Load required packages library(sp) library(maptools) library(maps) # Load the polygonal object x <-

Distance between two sets of points [duplicate]

依然范特西╮ 提交于 2019-12-06 14:13:45
问题 This question already has answers here : How to calculate Euclidian distance between two points defined by matrix containing x, y? (4 answers) Closed last year . So after looking at various Questions asked here on stackoverflow I'm still not able to wrap my head around the dist function in R or maybe even a distance matrix in general. So I have two dataframes with xy-coordinates. df1 <- data.frame(x = runif(3,0,50), y = runif(3,0,50)) df2 <- data.frame(x = runif(20,0,50), y = runif(20,0,50))

Computing net distance (Euclidean distance) in R

元气小坏坏 提交于 2019-12-06 12:14:43
问题 I have asked about and receive great help for computing Euclidean distance in R before. Now, I need to compute the Euclidean distance from the first point relative to all the other points within the track data. Here is how my data looks like: dput(head(t1)) structure(list(A = c(0L, 0L, 0L, 0L, 0L, 0L), T = 0:5, X = c(668L, 668L, 668L, 668L, 668L, 668L), Y = c(259L, 259L, 259L, 259L, 259L, 259L), V = c(NA, 0, 0, 0, 0, 0)), .Names = c("A", "T", "X", "Y", "V"), row.names = c(NA, 6L), class =

relabeling pixels based on distance between object's centerline and boundary

旧街凉风 提交于 2019-12-06 11:51:23
I've a binary image containing an object as illustrated in the figure below. The centerline of the object is depicted in red . For each pixel belonging to the object, I would like to relabel it with a color. For instance, pixels whose orthogonal distance to the centerline are half of the distance to the object boundary from the centerline, should be labeled blue , otherwise green . An illustration is given below. Any ideas? Also, how could I fit a 1D gaussian centered in the object centerline and orthogonal to it? The image in full resolution can be found under: http://imgur.com/AUK9Hs9 Here

draw a graph where the distance between vertices correspond to the edge weights

余生长醉 提交于 2019-12-06 08:41:30
问题 Is there an algorithm that gives me coordinates of vertices in a graph, when I give him a weighted graph and the edge weights between vertices points to the distance between vertices ? Something like: public _ArrayOfCoordinatesForVertices_ **super_hyper_algorithm**(weighted_graph){ return _foo_; } 回答1: This is in general not possible: Imagine a graph with 3 nodes n1, n2, and n3. now consider the following distances: n1-n2: 4 n1-n3: 1 n2-n3: 1 (This violates the triangle inquality). 回答2: What

calculate Euclidean distance of two image in hsv color space in matlab

若如初见. 提交于 2019-12-06 06:33:44
问题 i use the code below to calculate the Euclidean distance for two rgb images: Im1 = imread(filename1); Im1 = rgb2gray(Im1); hn1 = imhist(Im1)./numel(Im1); Im2 = imread(filename2); Im2 = rgb2gray(Im2); hn2 = imhist(Im2)./numel(Im2); f = norm(hn1-hn2); and it gives me the correct answer but now i want to use the code for two images in hsv color mode but it wont work on it cause all of the above code is in a 2d space while hsv is 1d is there any specific code for calculating Euclidean distance of