| ImageEn, unit histogrambox |
|
IEDrawHistogramToBitmap
Declaration
procedure IEDrawHistogramToBitmap(Histogram: TIEHistogram;
DestBitmap: TIEBitmap; Width, Height: integer;
HistKind: THistogramKind; HistStyle: THistogramStyle = hsFilledLines; HistScale: THistogramScale = iehsLinear;
Labels: THistogramLabels = [hlVertical, hlHorizontal]; LabelFont: TFont = nil; TruncateLabels: Boolean = False;
GradientBar: boolean = True; BorderWidth: Integer = 5; BGColor: TColor = clWhite; GrayColor: TColor = clBlack);
Description
Draw a histogram to a bitmap.
| Parameter | Description |
| Histogram | The source histogram |
| DestBitmap | The bitmap to draw to |
| Width, Height | The size to create the histogram image |
| HistKind | Which channels are shown |
| HistStyle | The styling of the histogram: Solid bars, single lines or filled lines |
| HistScale | The histogram plot scale. Use iehsLinearClipped or iehsLogarithmic on images with a heavy background color, which may create flat histograms |
| Labels | Which labels are shown: hlHorizontal shows range, hlVertical shows values |
| LabelFont | The font of drawn labels, or NIL to use the default |
| TruncateLabels | When enabled, the vertical label will truncate values greater than 1,000, e.g. 455,000 will display as 455k |
| GradientBar | If True, a gradient bar is shown below the histogram graph showing the range |
| BorderWidth | The spacing around the histogram (in pixels) |
| BGColor | The background color of the image |
| GrayColor | The color of the line/bar for a gray histogram (i.e. when HistogramKind is [hkGray]) |
Specify which channels are shown (multiple can be specified):
| Value | Description |
| hkRed | Red channel |
| hkGreen | Green channel |
| hkBlue | Blue channel |
| hkGray | Gray-scale level |
| hkHue | Hue (of HSV values) |
Note:
◼You can get the histogram for an image using
GetHistogram
◼To display histograms you can use the
THistogramBox component
Image Testing
// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

// Output the histogram of the gray-scale level
hist := ImageEnView1.Proc.GetHistogram( [hkGray] );
IEDrawHistogramToBitmap( hist, bmp, ImageEnView2.ClientWidth, ImageEnView2.ClientHeight,
[hkGray], hsFilledLines, iehsLinearClipped );
ImageEnView2.Update();

// Output the histogram of the RGB level
hist := ImageEnView1.Proc.GetHistogram( [hkRed, hkGreen, hkBlue] );
IEDrawHistogramToBitmap( hist, bmp, ImageEnView2.ClientWidth, ImageEnView2.ClientHeight,
[hkRed, hkGreen, hkBlue], hsFilledLines, iehsLinearClipped );
ImageEnView2.Update();

// Output the histogram of the hue level
Hist := ImageEnView1.Proc.GetHistogram( [hkHue] );
IEDrawHistogramToBitmap( hist, bmp, ImageEnView2.ClientWidth, ImageEnView2.ClientHeight,
[hkHue], hsFilledLines, iehsLinearClipped );
ImageEnView2.Update();
