Difference between Contrast and Intensity of an Image
On intensity

Simply said, it's hard to talk about "intensity" of an image. Every pixel has its intensity (for greyscale images, they are usual allowed range is [0, 255]), but the concept of image intensity does not exist. If you are doing some kind of image analysis, you could be interested in a parameter describing image intensities, e.g. mean intensity (like @geometrikal said) or distribution of image levels (which is related to contrast).

On contrast

If you presume an idealized situation where a greyscale image contains only pixels of two intensity values, one for background pixels and one for object pixels, the contrast of the object would be the difference of those values. What it means on the displayed image --> the higher the contrast, the easier it is to spot (find, locate) the object on the image (for the human eye). Again, you would usually talk about contrast of an object in an image, it's hard to talk about contrast of an image where it is not possible to define an object.

As an example, let's look at several 1-D signals (you can produce images similar to your examples from these):

1)   0   0   0   0  20  20   0   0  

2)   0   0   0   0 255 255   0   0

3) 200 200 200 200 255 255 200 200

4) 200 200 200 200   0   0 200 200


I'll assume that the two pixels different from the rest in each example are object pixels, and the rest are background. We have several cases here (and I could make more):


brighter object on dark background, all intensity values are low (i.e. the image is rather dark), contrast is low
bright object on dark background, most pixels have low intensity, contrast is high (it's a black-white image)
bright object on darker background, all intensity values are high (i.e. the image is bright), contrast is low (but higher then in the 1st example)
dark object on bright background, most pixels have high intensity, contrast is high (but not as high as in the 2nd example)


Here's another example supporting the fact that the contrast is usually an attribute describing an object, either in relation to itself or to the surrounding. Another important fact to notice from this example is that contrast generally describes the difference between the intensity levels, but the precise definition depends on the application (purpose for the measurement). Let me paraphrase the contrast definition used in hierarchical image segmentation from P. Soille, L. Najman: On morphological hierarchical representations for image processing and spatial data clustering as an example:


  The internal contrast of a connected component (object) corresponds to the largest intensity difference between two adjacent pixels belonging to this connected component. The external contrast is defined as the smallest intensity difference between a pixel of the considered connected component and an adjacent pixel not belonging to the considered component.


Of course, a different application could use a different measurement for contrast.

On imadjust

I don't usually work in MATLAB, but from the documentation, it is used to map intensity range (intensity levels in given range) of an input image, to an intensity range specified for the output image. The default, no-parameter call, will increase contrast of the image. But, you can get a brighter/darker image with imadjust with either increasing or decreasing the object contrast. Let me demonstrate this on my 3rd example:

imadjust(I3, [0.8; 1.0], [0.0; 1.0])


should output 0 0 0 0 255 255 0 0. You would get a white object on black background. In general, the image is darker (lower intensity), but contrast is higher (black-white).

imadjust(I3, [0.8; 1.0], [0.0; 0.2])


should output 0 0 0 0 51 51 0 0. Fairly dark object on a black background. The image is darker (lower intensity) and the contrast of the object did not change.

imadjust(I3, [0.8; 1.0], [0.85; 0.9])


should output 216 216 216 229 229 216 216. Very bright object on bright background. The image is brighter (higher intensity), and the contrast of the object decreased (object intensity levels are more similar to the intensity levels of the background).

You get the actual ranges the function is working with by multiplying them with the maximum gray level (255). For example, a range [0.2; 0.8] is actually intensity range [51; 204].

One more thing to take care of is that the function clips the values outside the first intensity range, and maps them to the new low if they're smaller or new high if they're larger then the range. All of my examples actually include this: the first range starts from 0.8 which maps to intensity 204, but the intensity of 200 from the input image is mapped to the output low in all the images.

So, it's actually just a simple scaling of image intensities (with cut-offs). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

On contrast enhancement

Quote from P. Soille: Morphological Image Analysis:


  Image contrast enhancement refers to accentuation or sharpening of image features so as to make a graphic display more useful for visualization or analysis of the image by the human eye.


He also emphasizes: with enhanced contrast image analysis by visual (human) inspection is easier. In idealized images like in my examples, a computer wouldn't gain much in term of image analysis difficulty.

E.g. for object extraction by thresholding, it would just mean different thresholds should be used to extract the object from the background. But, a human examiner would spot the object much easier on high-contrast images. This all changes some in real images (objects don't have uniform gray levels), so contrast enhancement becomes useful in image analysis.

There are several methods of contrast enhancement:


point-based techniques, where the local neighborhood is not important. They are based on the analysis of grey levels through the whole image
neighborhood based techniques, where local neighborhood of the pixel is important. Examples are white and black top-hat operators, and toogle contrast operator.
transform based techniques, where the filtering is done on a transformed image before using the inverse transform (e.g. filtering in the frequency domain after Fourier transform).


On intensity adjustment

In term of greyscale image, the intensity of the pixel corresponds to it's brightness. The greater the intensity, the greater the brightness. This also means that increasing intensity can be viewed as brightening the image (while decreasing intensity can be viewed as darkening the image).

I would describe the process of uniformly brightening the image as increasing intensity while leaving the contrast unchanged in the whole image.
This actually means adding a constant value to all the pixels.

Now, as the pixel intensity values have a predefined range, typically [0..255], this means that the maximum intensity exists. This inevitably means that some pixels (that were different from each other before) will become white (i.e. intensity 255).

This "naturally" happens when you take a photo aimed towards something very bright -- sun or other light. Away from the light, you might see some details, but at the position of the light/sun and around it, you will get only white pixels meaning that the intensity (amount of light when the image was taken) "hit" its maximum (displayable/storable) value.

The only way you wouldn't lose details by this operation would be if the original pixel intensities belong to only a part of possible intensity range, e.g. if original pixels are in the range [10, 150], the image could be brightened by up to 105 intensity levels before you start to loose details.

As imgadjust is meant to preform intensity scaling, it can do much more than just brighten/darken image. If you wanted to emulate brightening effect with imadjust, you could write something like:

imadjust(I, [0.0; x], [1.0-x; 1.0])


where x is any number between 0 and 1 (e.g. x=0.5 would brighten a [0..255] image by 127).

That said, this is an overkill for such a simple operation. I'm sure matlab has a elementary operation that adds a scalar to all elements of a matrix, so you could just use that :)