# Comparing two colored lines

I have two colored lines, which can be thought of as functions I1,I2:[0,1]->R. I want to check whether I1 and I2 'topologically' represent the same object. In other words, if I stretch some parts of I1 and squeeze some other parts, I want to get I2.

Obviously they have to have the same colors and 'in the same order'.

Is there a metric that measures this kind of similarity?

• maybe you could make a 'feature vector' that simply removes repetitions of values along x? So [r,g,g,b,b,r,b,b,b,g] becomes [r,g,b,r,b,g], now you can easily search both feature vectors for similarities (and even equality). – AlexanderBrevig Nov 23 '15 at 12:04

If I consider that your colored lines are multivariate signals (in Red, Green, Blue), that might be related through local offsets and scalings (stretch and squeeze), I would suggest the method in Correlation based dynamic time warping of multivariate time series, Expert Systems with Applications, 2012.

It combines Dynamic Time Warping (DTW), a widely used technique for comparison of time series data, and Principal Component Analysis (PCA) to address the correlation between the variables.

yet, you have to balance, in your metric, the 'shape' part and the 'color' part of the data. The associated quantities do not live in the same space.

Assumptions

You do not have any kind of noise in your data.

Suggested solution

#1

1. Convert the colors to single values, e.g. by recursive application of Cantor's Pairing function
2. Compute the mutual information between your two lines. If both lines are statistically independent, the mutual information between them should be 0.

#2

Plot the data against each other. If they only differ by offsets and global scaling, you should get a perfect line. Try to fit the line by means of linear least-squares and take an quality-of-fit measure of your choice (e.g. $R^2 > 0.99$) as a test criterion.