import processing.core.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import java.util.regex.*; public class Histogram extends PApplet { public void setup() {/** * Histogram. * * Calculates the histogram of an image. * A histogram is the frequency distribution * of the gray levels with the number of pure black values * displayed on the left and number of pure white values on the right. */ size(200, 200); colorMode(RGB, width); int[] hist = new int[width]; // Load an image from the data directory // Load a different image by modifying the comments PImage a; a = loadImage("cdi01_g.jpg"); image(a, 0, 0); // Calculate the histogram for (int i=0; i maxval) { maxval = hist[i]; } } // Normalize the histogram to values between 0 and "height" for (int i=0; i