private BufferedImage setColors(BufferedImage image, double [] values, PaintType paintType) {
        int width = image.getWidth();
        int height = image.getHeight();
        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                for (int k = 1; k < criticalValues.length; ++k) {
                    if (values[y * width + x] < criticalValues[k]) {
                        image.setRGB(x, y, model.getColorByLevel(k - 1).getRGB());
                        break;
                    }
                }
                if (values[y * width + x] > criticalValues[criticalValues.length - 1]) {
                    image.setRGB(x, y, model.getColorByLevel(criticalValues.length - 2).getRGB());
                }
            }
        }

        if (paintType != PaintType.COLOR_MAP) {
            for (int y = 1; y < height - 1; ++y) {
                for (int x = 1; x < width - 1; ++x) {
                    image.setRGB(x, y, interpolator.getBilinearInterpolatedPixel(values[y * width + x], criticalValues, levelsColors));
                }
            }
        }

        if (paintType == PaintType.COLOR_MAP_WITH_INTERPOLATION_AND_DITHER) {
            interpolator.useDithering(image, levelsColors);
        }
        return image;
    }