gtaylor/python-colormath — pull request #12 by ejlb (2014-01-17 16:11:57+00:00)
Title: add vectorised deltaE functions for LAB

This PR contains a new set of deltaE functions for calculating many distances at once.

I've added a new function to LabColor called delta_e_matrix which takes an (n,3) numpy matrix as a parameter. Each row of the matrix corresponds to one colour in Lab. The matrix must consist of floating point numbers, it cannot contains other LabColor objects (this would be too slow to convert). The return value is a matrix of distances.

The numpy code is a direct port of color_diff.py (it could probably be optimised even more).

I've included tests and benchmarks. For a large number of colour calculations, the vectorised deltaE functions are on average 80 times faster.

Apologies for the whitespace changes. I've have vim set up to automatically remove extraneous whitespace.