Comparison/Difference between two distinct plots I am making a project where I  can identify leaves by taking a picture of them and a database. I will use their widths to determine their shape. So, I worked across the stem of the leaf each width and plotted them onto the following graphs.

The data of my graphs are located at: https://docs.google.com/spreadsheets/d/1HnYYA9keX7jjkhp4tocd2gy-i8VtHzYaS28fax-Nofc/edit?usp=sharing

To compare two graphs, I take the minimum of two functions:


The sum of the absolute difference between two graphs for every X-axis  point
Reverse one graph, and then run another sum of absolute difference between the reversed and the other graph. This is in case if one of the two leaves is measured in an opposite direction from the other one.


i.e. min( sum(abs(a-b)), sum(abs(a’-b)), where n’ is the reverse plot of n (In case a plot is reversed).



So, the problem is, the difference between two very similar leaves is actually greater than two very distinct leaves.

(On top) I have three graphs, two of which are similar-pos,pos2 (which should return a smaller difference), both of which are the acer ginnala leaf and another is different-neg, the betula alleghaniensis (which should return a greater difference than the "similar"):

However, this is not the case. On the 2nd layer, the two graphs are very distinct. (one is acer, other is betula). However, running the above algorithm, the sums are 70648 and 27362, returning a result of 27362.

On the last layer, when two very similar graphs are compared, (both acer) they return a much higher difference, with 40084 (normal) and 85664 (reversed), and returns the minimum of 40084, which is a higher difference than the first comparison.

I’ve tried standard deviation of the differences, squaring differences, Intersection Correlation, but had no luck. So, since the current measurement metric doesn’t work on this, what is a concise, straightforward, and better way to measure the difference between two graphs?
One way to compare similarly-shaped data that is translated in time is to look at the correlation between them.

If I do this in scilab:

ddata = diff(data',1,'c');

XC = xcorr(ddata(1,:),ddata(2,:));
CC1 = xcorr(ddata(1,:),ddata(1,:));
CC2 = xcorr(ddata(2,:),ddata(2,:));

den = sqrt(max(CC1)*max(CC2))

clf
plot(XC/den);
plot(CC1/max(CC1),'r')
plot(CC2/max(CC2),'m')

disp(max(XC)/den)


then I get this:



where the blue plot is the (normalized) cross-correlation of the time-differenced data and the red and magenta plots are the (normalized) auto-correlation of each individual time series.

The result is that the "correlation" between them is 0.8416782.