void scaleUsingSplineFitting(byte[] reds, byte[] greens, byte[] blues, int newSize) {
        //IJ.log("scaleUsingSplineFitting: "+mapSize+" "+newSize);
        int[] reds2 = new int[mapSize];
        int[] greens2 = new int[mapSize];
        int[] blues2 = new int[mapSize];
        for(int i=0; i<mapSize; i++) {
            reds2[i] = reds[i]&255;
            greens2[i] = greens[i]&255;
            blues2[i] = blues[i]&255;
        }
        int[] xValues = new int[mapSize];
        for(int i = 0; i < mapSize; i++) {
           xValues[i] = (int)(i*(double)newSize/(mapSize-1));
           //IJ.log(i+" "+xValues[i]+" "+reds2[i]);
        }
        SplineFitter sfReds = new SplineFitter(xValues, reds2, mapSize);
        SplineFitter sfGreens = new SplineFitter(xValues, greens2, mapSize);
        SplineFitter sfBlues = new SplineFitter(xValues, blues2, mapSize);
        for(int i = 0; i < newSize; i++) {
             double v = Math.round(sfReds.evalSpline(xValues, reds2, mapSize, i));
             if (v<0.0) v=0.0; if (v>255.0) v=255.0; reds[i] = (byte)v;
             v = Math.round(sfGreens.evalSpline(xValues, greens2, mapSize, i));
             if (v<0.0) v=0.0; if (v>255.0) v=255.0; greens[i] = (byte)v;
             v = Math.round(sfBlues.evalSpline(xValues, blues2, mapSize, i));
             if (v<0.0) v=0.0; if (v>255.0) v=255.0; blues[i] = (byte)v;
        }
     }