public int calcPaletteDiffs(int pal)
    {
        int mostSimilar = -1;
        float bestDiff = Float.POSITIVE_INFINITY;
        for (int i = 0; i < palettes.length; i++)
        {
            if (paletteCounts[i] != 0)
                paletteDiffs[pal][i] = paletteDiffs[i][pal] = palDif(palettes[pal], palettes[i]);
            if (paletteDiffs[pal][i] < bestDiff)
            {
                bestDiff = paletteDiffs[pal][i];
                mostSimilar = i;
            }
        }
        return -1;
    }