code: public static BufferedImage recolorImage (BufferedImage image, Colorization[] zations)
      {
          ColorModel cm = image.getColorModel();
          if (!(cm instanceof IndexColorModel)) {
              throw new RuntimeException(Logger.format(
                  "Unable to recolor images with non-index color model", "cm", cm.getClass()));
          }
  
          // now process the image
          IndexColorModel icm = (IndexColorModel)cm;
          int size = icm.getMapSize();
          int zcount = zations.length;
          int[] rgbs = new int[size];
  
          // fetch the color data
          icm.getRGBs(rgbs);
  
          // convert the colors to HSV
          float[] hsv = new float[3];
          int[] fhsv = new int[3];
          for (int ii = 0; ii < size; ii++) {
              int value = rgbs[ii];
  
              // don't fiddle with alpha pixels
              if ((value & 0xFF000000) == 0) {
                  continue;
              }
  
              // convert the color to HSV
              int red = (value >> 16) & 0xFF;
              int green = (value >> 8) & 0xFF;
              int blue = (value >> 0) & 0xFF;
              Color.RGBtoHSB(red, green, blue, hsv);
              Colorization.toFixedHSV(hsv, fhsv);
  
              // see if this color matches and of our colorizations and recolor it if it does
              for (int z = 0; z < zcount; z++) {
                  Colorization cz = zations[z];
                  if (cz != null && cz.matches(hsv, fhsv)) {
                      // massage the HSV bands and update the RGBs array
                      rgbs[ii] = cz.recolorColor(hsv);
                      break;
                  }
              }
          }
  
          // create a new image with the adjusted color palette
          IndexColorModel nicm = new IndexColorModel(
              icm.getPixelSize(), size, rgbs, 0, icm.hasAlpha(),
              icm.getTransparentPixel(), icm.getTransferType());
          return new BufferedImage(nicm, image.getRaster(), false, null);
      }
docs: Recolors the supplied image using the supplied colorizations.