Java examples for 2D Graphics:BufferedImage Effect
Image histogram
//package com.java2s; import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; public class Main { public static List<Point2D.Float> histogram(int[][] image) { int w = image[0].length; int h = image.length; int dV = 1; int L = (256 / dV); int[] histogram = new int[L]; List<Point2D.Float> points = new ArrayList<>(); for (int i = 0; i < L; i++) { histogram[i] = 0;//from w ww .j ava2 s .c o m } for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int b = image[y][x]; int index = b / dV; histogram[index]++; } } for (int i = 0; i < histogram.length; i++) { points.add(new Point2D.Float(i * dV, histogram[i])); } return points; } }