图二：

[0, 1]之间, 程序的核心代码如下：

for(int row=0; row<256; row++) {

for(int col=0; col<256; col++) {

b = (int)(255.0d * Math.random());

rgbData[index]= ((clamp(a) & 0xff) << 24) |

((clamp(r)& 0xff) << 16)  |

((clamp(g)& 0xff) << 8)   |

((clamp(b)& 0xff));

index++;

}

}

图三：

y= (y1-y0) * cos(PI + (x-x0/x1-x0) * PI) + 1 + y0

`// bi-line interpolation algorithm here!!!     Double GetColor(int x, int y, int M, int colorType)     {        int x0 = x - (x % M);        int x1 = x0 + M;        int y0 = y - (y % M);        int y1 = y0 + M;           Double x0y0 = Noise(x0,y0, colorType);         Double x1y0 = Noise(x1,y0, colorType);         Double x0y1 = Noise(x0,y1, colorType);         Double x1y1 = Noise(x1,y1, colorType);           Double xx0 =Interpolate(x0, x0y0, x1, x1y0, x);         Double xx1 = Interpolate(x0,x0y1, x1, x1y1, x);           Double N =Interpolate(y0, xx0, y1, xx1, y);         return N;     }`

`return (1.0 + Math.cos(Math.PI +  (Math.PI / (x1-x0)) * (x-x0))) / 2.0  * (xx1-xx0) + xx0; `

`                for(int row=0; row<256; row++) { 			for(int col=0; col<256; col++) { 				// set random color value for each pixel 				r = (int)(255.0d * GetColor(row, col, intervalPixels, 1)); 				g = (int)(255.0d * GetColor(row, col, intervalPixels, 2)); 				b = (int)(255.0d * GetColor(row, col, intervalPixels, 4)); 				 				rgbData[index] = ((clamp(a) & 0xff) << 24) | 								((clamp(r) & 0xff) << 16)  | 								((clamp(g) & 0xff) << 8)   | 								((clamp(b) & 0xff)); 				index++; 			} 		} `

`import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.util.Random;  import javax.swing.JComponent; import javax.swing.JFrame;  public class RandomNoiseImage extends JComponent {  	/** 	 *  	 */ 	private static final long serialVersionUID = -2236160343614397287L; 	private BufferedImage image = null; 	private double[] blue_random; 	private double[] red_random; 	private double[] green_random; 	private int intervalPixels = 40; // default 	 	public RandomNoiseImage() { 		super(); 		this.setOpaque(false); 	} 	 	protected void paintComponent(Graphics g) { 		Graphics2D g2 = (Graphics2D)g; 		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 		g2.drawImage(getImage(), 5, 5, image.getWidth(), image.getHeight(), null); 	} 	 	private BufferedImage getImage() { 		if(image == null) { 			image = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); 			int[] rgbData = new int[256*256]; 			generateNoiseImage(rgbData); 			setRGB(image, 0, 0, 256, 256, rgbData); 		} 		return image; 	} 	 	private void generateNoiseImage(int[] rgbData) { 		int index = 0; 		int a = 255; 		int r = 0; 		int g = 0; 		int b = 0; 		int sum = 256 * 256; 		blue_random = new double[sum]; 		red_random = new double[sum]; 		green_random = new double[sum]; 		Random random = new Random(); 		for(int i=0; i< sum; i++) { 			blue_random[i] = random.nextDouble(); 			red_random[i] = random.nextDouble(); 			green_random[i] = random.nextDouble(); 		} 		 		 		for(int row=0; row<256; row++) { 			for(int col=0; col<256; col++) { 				// set random color value for each pixel 				r = (int)(255.0d * GetColor(row, col, intervalPixels, 1)); 				g = (int)(255.0d * GetColor(row, col, intervalPixels, 2)); 				b = (int)(255.0d * GetColor(row, col, intervalPixels, 4)); 				 				rgbData[index] = ((clamp(a) & 0xff) << 24) | 								((clamp(r) & 0xff) << 16)  | 								((clamp(g) & 0xff) << 8)   | 								((clamp(b) & 0xff)); 				index++; 			} 		} 		 	} 	 	private int clamp(int rgb) { 		if(rgb > 255) 			return 255; 		if(rgb < 0) 			return 0; 		return rgb; 	} 	 	// bi-line interpolation algorithm here!!! 	Double GetColor(int x, int y, int M, int colorType) 	{ 		int x0 = x - (x % M); 		int x1 = x0 + M; 		int y0 = y - (y % M); 		int y1 = y0 + M;  	    Double x0y0 = Noise(x0, y0, colorType); 	    Double x1y0 = Noise(x1, y0, colorType); 	    Double x0y1 = Noise(x0, y1, colorType); 	    Double x1y1 = Noise(x1, y1, colorType);  	    Double xx0 = Interpolate(x0, x0y0, x1, x1y0, x); 	    Double xx1 = Interpolate(x0, x0y1, x1, x1y1, x);  	    Double N = Interpolate(y0, xx0, y1, xx1, y); 	    return N; 	}  	// algorithm selection here !!! 	private Double Interpolate(double x0, double xx0, double x1, double xx1, double x) { 		 		return (1.0 + Math.cos(Math.PI +  			      (Math.PI / (x1-x0)) * (x-x0))) / 2.0 * (xx1-xx0) + xx0; 	}  	Double Noise(int x, int y, int colorType) 	{ 		if(colorType == 1) { 			if (x < 256 && y < 256) 		        return red_random[y * 256 + x]; 		    else 		        return 0.0; 		} else if(colorType == 2) { 			if (x < 256 && y < 256) 		        return green_random[y * 256 + x]; 		    else 		        return 0.0; 		} else { 			if (x < 256 && y < 256) 		        return blue_random[y * 256 + x]; 		    else 		        return 0.0; 		} 	}  	public void setRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) { 		int type = image.getType(); 		if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB ) 			image.getRaster().setDataElements( x, y, width, height, pixels ); 		else 			image.setRGB( x, y, width, height, pixels, 0, width );     } 	 	public static void main(String[] args) { 		JFrame frame = new JFrame("Noise Art Panel"); 		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 		frame.getContentPane().setLayout(new BorderLayout()); 		 		// Display the window. 		frame.getContentPane().add(new RandomNoiseImage(), BorderLayout.CENTER); 		frame.setPreferredSize(new Dimension(280,305)); 		frame.pack(); 		frame.setVisible(true); 	} } `