Here you can find the source of makeImage(double[][] levels)
public static BufferedImage makeImage(double[][] levels)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; public class Main { public static BufferedImage makeImage(double[][] levels) { BufferedImage image = new BufferedImage(levels.length, levels[0].length, BufferedImage.TYPE_BYTE_GRAY); WritableRaster writeableRaster = image.getRaster(); for (int i = 0; i < writeableRaster.getWidth(); ++i) { for (int j = 0; j < writeableRaster.getHeight(); ++j) { writeableRaster.setPixel(i, j, new double[] { levels[i][j] }); }// ww w. ja va2 s .c om } return image; } }