Java BufferedImage Operation inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b)

Here you can find the source of inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b)

Description

in Colormap

License

Open Source License

Declaration

public static float inColormap(float[][] in, float min, float max, float[][] colormap, BufferedImage b) 

Method Source Code


//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;
    }
}

Related

  1. grid(BufferedImage image, int between)
  2. height(BufferedImage image, Double measurementLatitude, Double measurementLongitude)
  3. highlight(BufferedImage img, Color source, Color dest)
  4. hitTest(BufferedImage image, int x, int y)
  5. hueShift(BufferedImage image, int hue)
  6. indexToDirectColorModel(BufferedImage image)
  7. intBuffer2BufferedImage(IntBuffer ib, BufferedImage img)
  8. intensityArrayToBufferedImage(byte[] array, int w, int h)
  9. interp(BufferedImage img1, BufferedImage img2, int weight1, int weight2)