Graphics Reference
In-Depth Information
if (k == 0) return vec3 (v, t, p);
if (k == 1) return vec3 (q, v, p);
if (k == 2) return vec3 (p, v, t);
if (k == 3) return vec3 (p, q, v);
if (k == 4) return vec3 (t, p, v);
if (k == 5) return vec3 (v, p, q);
}
}
void main( )
{
vec3 irgb = texture( uImageUnit, vST ).rgb;
vec3 ihsv = convertRGB2HSV( irgb );
ihsv.x += uT;
if (ihsv.x > 360.) ihsv.x -= 360.; //add to hue
if (ihsv.x < 0.) ihsv.x += 360.; //add to hue
irgb = convertHSV2RGB( ihsv );
fFragColor = vec4( irgb, 1. );
}
This example includes an implicit conversion between the RGB color
representation and the HSV color representation, showing how more general
color conversions may be done.
Image Filtering
A number of image manipulations are based on filtering images. A filter is a
process that convolves a pixel with its neighbors by using a matrix to weight
neighboring pixels. The size of the filter, the values in the filter, and the mean-
ing of different values that are returned when a filter is applied, all vary from
algorithm to algorithm.
As two examples of filters, consider the following. One is a three-by-three
Sobel filter that is used to detect horizontal edges. The other is a five-by-five
blur filter that can be used to smooth (or blur) an image:
14741
41626164
72641267
41626164
14741
−−−
121
000
121
1
273
,
.
The filters are used as weights in creating a weighted sum of the values in
an adjacent set of pixels. For pixel values P ij and filter elements F ij and a filter
Search WWH ::




Custom Search