Graphics Reference
In-Depth Information
Contrast
The contrast in an image describes how much the colors stand out from gray.
To manipulate the contrast in an image, use as a base image a constant 50%
gray image, which is easily computed as
target = vec3(0.5,0.5,0.5);
Parameter values of T less than 1 will move each color component toward
0.5, reducing the contrast in the image, while values greater than 1 will move
each color component away from 0.5, increasing the contrast, as shown in
Figure 11.22.
Sample code for a very simple fragment shader that adjusts either bright-
ness or contrast is shown below. In effect, brightening the image is done by
subtracting black from it, and contrast is increased by subtracting 50% gray
from it.
#define BRIGHTNESS
#undef CONTRAST
uniform sampler2D uImageUnit;
uniform float uT;
in vec2 vST;
our vec4 fFragColor;
void main( )
{
vec3 irgb = texture( uImageUnit, vST ).rgb;
Figure 11.22. Contrast manipulation in a photograph of a ruined French abbey with T = 0.0 (left), 1.0 (middle),
and 2.5 (right).
Search WWH ::




Custom Search