Contrast stretching

One of the simplest piecewise linear functions is a contrast-stretching transformation. Low-contrast images can result from poor illumination, lack of dynamic range in the imaging sensor, or even wrong setting of a lens aperture during image acquisition. The idea behind contrast stretching is to increase the dynamic range of the gray levels in the image being processed.
Contrast stretching
Contrast stretching explanation
The locations of points (r1, s1) and (r2, s2) control the shape of the transformation function. If r1=s1 and r2=s2, the transformation is a linear function that produces no changes in gray levels. If r1=r2, s1=0 and s2=L-1, the transformation becomes a thresholding function that creates a binary image.

Intermediate values of (r1, s1) and (r2, s2) produce various degrees of spread in the gray levels of the output image, thus affecting its contrast. In general, r1 <= r2 and s1 <= s2 is assumed so that the function is single valued and monotonically increasing. This condition preserves the order of gray levels, thus preventing the creation of intensity artifacts in the processed image.

General Form

Contrast stretching ……………(i)


r the input image values
s is the output image values
m is the thresholding
E is the slope

Effect of the slope
Effect of the slope
above figure show the effect of the variable E, if E = 1 the stretching became a threshold transformation, if E > 1 the transformation its defined by the curve which is smoother when the E value is increase, and when E < 1 the transformation makes the negative and also stretching.

Contrast stretching flowchart

Contrast stretching flowchart


output_image_process = 1 ./ (1 + (m./input_image_process).^e);

subplot(1,2,1),imshow(input_image),title('Input image')
subplot(1,2,2),imshow(output_image),title('Output image')



You may also like...