-3

I would like to normalize the euclidean distance between two points so that it becomes between 0 & 1. The points are represented as follows: (x,y).

Any ideas?

Ðina YŏŜri
  • 55
  • 2
  • 10
  • 3
    My idea: what have you tried? Why do you want this? This question is way too broad. – Adriaan May 17 '16 at 11:08
  • To normalize, you either need to either: a) specify the reference on which you base the normalization, or b) base the normalization on the distance, in which case you just divide by the distance and your normalized distance then becomes 1. – jkazan May 17 '16 at 11:21
  • I use PSO for image processing. The fitness function has two parts: the first is normalized and the other has the distance between the pixels in the test image and training image. The distance is not normalized which makes the fitness function inconsistent. – Ðina YŏŜri May 17 '16 at 11:26

1 Answers1

1

Here's a solution, however, I urge you to read my comment on your question above. Also, consider @Adriaan 's comment as well for future reference!

% First point
x1 = 5;
y1 = -2;

% Second point
x2 = 12;
y2 = 9;

% Absolute distance between the points is your normalization factor
normFactor = sqrt((x1-x2)^2 + (x1-x2)^2);

Divide everything in your Euclidean space with the normFactor. If you divide your distance, you will of course get distance = 1

jkazan
  • 1,149
  • 12
  • 29
  • 1
    You don't need to take the absolute distances to compute dx and dy, since you are squaring them down below. – Caitlin Oct 07 '16 at 23:27