April 5, 2008
WikiHistogram
Histogram
A histogram shows how the 256 possible levels of brightness are distributed in an image. It could be compared to a horizontal line with 256 positions which represent all levels of brightness from pure black (0) on the left, to pure white (255) on the right.
Pixels of the same brightness are stacked together on the vertical axis. The higher the line coming up from the horizontal axis, the more pixels there are at that level of brightness.
![]()
A histogram that shows more weight at the left of the graph represents a dark image, also called a low-key image. A histogram with more weight to the right of the graph represents a bright, or high-key, image.
the histogram of an image is deifned as hi = ni/nt for i = 0 to (M-1) where ni is the number of pixels within the image at the ith graylevel value and nt is the total number of pixels in the image.
// The program computers the histogram of the image
// storing the histogram result in the floating point array HIST[
Histogram (struct Image *IMAGE, float HIST[]) {
int X,Y,I,J;
long int IHIST[256], SUM;
for (I=0; i<255; i++) {
IHIST[I] = 0;
SUM=0;
for(Y=0; y<IMAGE->Rows; Y++) {
for(X=0; X<IMAGE->Cols; X++) {
J = *(IMAGE->Data+X+(long)Y*IMAGE->Cols);
IHIST[J]= IHIST[J]+1;
SUM = SUM + 1;
}
}
for (I=0; I<255; I++) {
HIST[I] = (float)IHIST[I]/(float)SUM;
}
Continue Reading
Back to Archive