extension joomla, template joomla,banner extension joomla,jomla slider,slider joomla
Contrast Stretching using C++ and OpenCV: Image Processing

Theory

Contrast Stretching is one of the piecewise linear function. Contrast Stretching increases the dynamic range of the grey level in the image being processed.

Points (r1, s1) and (r2, s2) control the shape of the transformation. The selection of control points depends upon the types of image and varies from one image to another image. If r1 = s1 and r2 = s2 then the transformation is linear and this doesn’t affect the image. In other case we can calculate the intensity of output pixel, provided intensity of input pixel is x, as follows

for 0 <= x <= r1
output = s1 / r1 * x
for r1 < x <= r2
output = ((s2 – s1)/(r2 – r1))*(x – r1) + s1
for r2 < x <= L – 1
output = ((L-1 – s2)/(L-1 – r2))*(x – r2) + s2

Source Code

Output

r1 = 70 s1 = 0 r2 = 140 s2 = 255

 



Related Article



destination source:https://www.programming-techniques.com/2013/01/contrast-stretching-using-c-and-opencv-image-processing.html