0

I tried to understand what is image histogram but I'm stuck in it. I would appreciate an easy explanation for it and the meaning of intensity value because I don't know what is it.

Tonechas
  • 13,398
  • 16
  • 46
  • 80
  • have you even read https://en.wikipedia.org/wiki/Histogram??? I think the explaination is pretty understandable. – Piglet May 12 '17 at 07:05

3 Answers3

1

I guess the Matlab help function will have a pretty good explanation with some examples, so that should always be your first stop. But here's my attempt:

An image is composed of pixels. For simplicitly let's consider a grayscale image. Each pixel has a certain brightness to the eye, which is expressed in the intensity value of that pixel. For simplicity, let's assume the intensity value can be any (integer) value from 0 to 7, 0 being black, 7 being white, and values in between being different shades of gray.

The image histogram tells you how many pixels there are in your image for each intensity value (or for a range of intensity values). The horizontal axis shows the possible intensity values, and the vertical axis shows the number of pixels for each of these intensity values.

So, suppose you have a 2x2 image (only 4 pixels) that is completely black, in matlab this looks like [0 0; 0 0], so all intensity values are 0. The histogram for this image will show one bar with height 4 (vertical axis) at the intensity value 0 (horizontal axis). In the same way, if all pixels were white, [7 7; 7 7], you would get a single bar of height 4 at the intensity value 7. If half the pixels were white, the other half black, e.g. [0 0; 7 7] or [0 7; 7 0] or similar, you would get two bars of height 2 in you histogram, located at intensity values 0 and 7. If you have four different intensity values in the image, e.g. [2, 5; 0, 6], you will get four bars of height 1 at the respective intensity values.

It helps just to play around with a small image like this, in which you can easily count the number of pixels by hand. For example:

image=[2,5,3; 1,0,6; 3,2,1];
subplot(1,2,1)
imshow(image, [0 7]); % see: help imshow
subplot(1,2,2)
histogram(image, (0:8)-0.5)  % see: help histogram
djvg
  • 11,722
  • 5
  • 72
  • 103
0

A histogram displays a frequency distribution.

Let's say you have a group of 20 women. Now you want to get an idea about their hair colour. So you define the "bins" blonde, black, red, brown

So you increase the count in each bin for every woman that has the respective hair color.

You'll end up with something like this:

         x 
         x     x
   x     x     x 
   x     x     x
   x     x     x
   x     x     x    x
   x     x     x    x
blonde black brown red

So that's the histogram of hair colours in your group of women. You get a nice graphical representation that is easy to interpret. At a glance you know that there are very little women with read hair, black and brown are most common. Of course you could do this by just looking at the 20 women. But imagine you wanted to do this for 1000 women or maybe all women on earth?

Now say you wanted to know the distribution of intensity values in an image. We have 256 gray values in a byte image. So if we want to have maximum resolution we define 256 bins. Then increase each bin by 1 for every pixel of that particular value.

Of yourse you can have less bins. Let's say gray values [0-9][10-19]...

By just looking at an image's histogram you can tell a lot about its contrast, brigthness, ...

Piglet
  • 27,501
  • 3
  • 20
  • 43
0

Histogram is probability distribution and can be used for many things. With images there are 2 main usage for it:

  1. Grayscale image Histogram

    This tells you have big portion of image is filled with what color/intensity. By intensity I mean a grayscale shade "color". On 8 bit grayscale images 0 means black, 128 means gray and 255 means white. So histogram graph has on x axis is the color or intensity and on y is probability or pixel count for that color.

    This can be used for many things. For example you got black text on white paper photo but there are shades of gray caused by some blur and you want to binarize this to just BW for OCR. Those images usually got bimodal histograms which means there are 2 "big" bumps in histogram graph. One for black characters and one for white background. So if you find those bumps then the middle between them can be used as "safe" threshold for naive binarization.

    If there are just distinct colors (no curves or noise just few distinct colors) that mean image is rendered like cartoon or text or something non realistic.

    If you got higher counts on darker colors that means your image is dark... If you got higher counts for bright colors that means image is bright. If there is "uniform" distribution then your image is with "good" composition in the middle between dark and bright (see histogram equalization or automatic exposure time computation).

  2. Color image Histogram

    You can do also color histogram for example RGB or HSV. To visualy represent those you need to sort the colors somehow. For more info about this see:

    color histogram you can use similarly as grayscale. On top of that these are used for color quantization process to lower the color count without loosing too much information like this:

Here an example of histograms:

artificial real photo

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380