protected static int matchColour(Color colour, Color[] palette, int paletteStart, int paletteEnd, double chromaWeight)
    {
	if (chromaWeight < 0.0)
	{
	    int bestI = paletteStart;
	    int bestD = 4 * 256 * 256;
	    for (int i = paletteStart; i < paletteEnd; i++)
	    {
		int ðr = colour.getRed()   - palette[i].getRed();
		int ðg = colour.getGreen() - palette[i].getGreen();
		int ðb = colour.getBlue()  - palette[i].getBlue();
		
		int ð = ðr*ðr + ðg*ðg + ðb*ðb;
		if (bestD > ð)
		{   bestD = ð;
		    bestI = i;
		}
	    }
	    return bestI;
	}
	
	Double _chroma = labMapWeight.get();
	HashMap<Color, double[]> _labMap = ((_chroma == null) || (_chroma.doubleValue() != chromaWeight)) ? null : labMap.get();
	if (_labMap == null)
	{   labMap.set(_labMap = new HashMap<Color, double[]>());
	    labMapWeight.set(new Double(chromaWeight));
	}
	
	double[] lab = _labMap.get(colour);
	/* if (lab == null) */ // FIXME Why does this not work!?
	    _labMap.put(colour, lab = Colour.toLab(colour.getRed(), colour.getGreen(), colour.getBlue(), chromaWeight));
	double L = lab[0], a = lab[1], b = lab[2];
	
	int bestI = -1;
	double bestD = 0.0;
	Color p;
	for (int i = paletteStart; i < paletteEnd; i++)
	{
	    double[] tLab = _labMap.get(p = palette[i]);
	    /* if (tLab == null) */ // FIXME Why does this not work!?
		_labMap.put(colour, tLab = Colour.toLab(p.getRed(), p.getGreen(), p.getBlue(), chromaWeight));
	    double ðL = L - tLab[0];
	    double ða = a - tLab[1];
	    double ðb = b - tLab[2];
	    
	    double ð = ðL*ðL + ða*ða + ðb*ðb;
	    if ((bestD > ð) || (bestI < 0))
	    {   bestD = ð;
		bestI = i;
	    }
	}
	
	return bestI;
    }