A grayscale histogram is a grayscale function that describes the number of pixels in an image with the gray level. If the Cartesian coordinate system is used for representation, the x-axis is the gray level, and the y-axis is the probability of the occurrence of the gray level (number of pixels ).
Histogram distribution function:
Plot histogram Information
// Draw the coordinate system Graphics g = e. graphics; Pen curPen = new Pen (Brushes. black, 1); g. drawLine (curPen, 50,240,320,240); g. drawLine (curPen, 50,240, 50, 30); g. drawLine (curPen, 100,240,100,242); g. drawLine (curPen, 150,240,150,242); g. drawLine (curPen, 200,240,200,242); g. drawLine (curPen, 250,240,250,242); g. drawLine (curPen, 300,240,300,242); g. drawString ("0", new Font ("New Timer", 8), Brushes. black, new PointF (46,242); g. drawString ("50", new Font ("New Timer", 8), Brushes. black, new PointF (92,242); g. drawString ("100", new Font ("New Timer", 8), Brushes. black, new PointF (139,242); g. drawString ("150", new Font ("New Timer", 8), Brushes. black, new PointF (189,242); g. drawString ("200", new Font ("New Timer", 8), Brushes. black, new PointF (239,242); g. drawString ("250", new Font ("New Timer", 8), Brushes. black, new PointF (289,242); g. drawLine (curPen, 48, 40, 50, 40); g. drawString ("0", new Font ("New Timer", 8), Brushes. black, new PointF (34,234); g. drawString (maxPixel. toString (), new Font ("New Timer", 8), Brushes. black, new PointF (18, 34); double temp = 0; for (int I = 0; I <256; I ++) {temp = 200.0 * countPixel [I]/maxPixel; g. drawLine (curPen, 50 + I, 240, 50 + I, 240-(int) temp);} curPen. dispose ();
Global variable definition and assignment
private System.Drawing.Bitmap bmpHist; private int[] countPixel; private int maxPixel; public Grey_ScaleMapForm(Bitmap bmp) { InitializeComponent(); bmpHist = bmp; countPixel = new int[256]; }
: DEMO