Here you can find the source of inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b)
public static float inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; import java.awt.image.DataBufferFloat; public class Main { public static float inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b) { int width = in[0].length; int height = in.length; int cvals = colormap.length; float[] bData = ((DataBufferFloat) b.getRaster().getDataBuffer()).getData(); for (int yy = 0; yy < height; yy++) { for (int xx = 0; xx < width; xx++) { int cmapIdx = (int) (cvals * (in[yy][xx] - min) / max); bData[yy * width + xx] = colormap[cmapIdx][0]; bData[yy * width + xx + 1] = colormap[cmapIdx][1]; bData[yy * width + xx + 2] = colormap[cmapIdx][2]; }//w ww .ja va 2 s . co m } return max; } }