Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Computer Graphics

Lecture 2

Achromatic Light

intensity (quantity of light)


luminance if measure of lights energy
brightness
the psychophysical sense of perceived intensity
gray levels (e.g., from 0.0 to 1.0)
seen on black and white TV or display monitors
generally need 64 to 256 gray levels for
continuous-tone images without contouring

Selecting Intensity Linear Scale


Ii =i/(n-1), i=0,1,...n-1
eg. n=16: Ii=0, 0.07, 0.13, 0.2,..., 0.93,1

Selecting Intensity Logarithmic Scale


Weber-Fechner Law
The visual perception of an arithmetical
progression depends upon a physical
geometric progression
Eye sensitive to ratio: perceives intensities
0.10 and 0.11 as differing just as much as the
intensities 0.50 and 0.55
I0=I0, I1=r*I0, I2=r*I1=r2*I0, ... . In-1 = rn-1*I0=1
Ii = (I0)(n-1-i)/(n-1) i=0,1,...n-1

Selecting Intensity Logarithmic Scale


Dynamic range of a device: ratio of maximum
to minimum intensities, i.e., 1/I0
Typical on CRT anywhere from 40:1 to 200:1
=>
I0 = 0.005 - 0.025 for most monitors
eg. n=16 I0=0.01 Ii=0.010, 0.014, 0.018,...,
0.72,1

Selecting Intensity Logarithmic Scale


Dynamic range of a device: ratio of maximum
to minimum intensities, i.e., 1/I0
Typical on CRT anywhere from 40:1 to 200:1
=>
I0 = 0.005 - 0.025 for most monitors
eg. n=16 I0=0.01 Ii=0.010, 0.014, 0.018,...,
0.72,1

Selecting Intensity Logarithmic Scale

Gamma correction
We must consider the nonlinearities CRT monitors
Ii - intensity of pixel
Vi - value specified for the pixel

Gamma correction

Ui = K1*Vi
Ni = K1*Ui
Ii = K1*Nigamma
Ii =K*Vigamma
Vi = round((Ii/K)1/gamma)
K - depends on amount of bit planes in frame buffer
gamma = 2.2 ...2.5 for most CRT
Vi = round((2n-1)*(exp(lnIi/gamma)))

Mach bands
the intensity at the vicinities of the edges is
overestimated for light values and
underestimated for dark values.

Each small resolution


unit is imprinted with a
circle of blank ink
whose area is
proportional to the
blackness (1-I) of the
area in the original
photograph
Newspapers: 60-80
variable-sized dots per
inch (60-80 lpi)
Books: 100-200
variable-sized dots per
inch (100-200 lpi)
The pattern makes a
45deg angle with the
vertical for black, 90deg
for yellow, 75deg for
magenta and 105 for
cyan.

Halftoning

Traditional printing

Traditional printing

Digital printing

The Average Dithering


The Average Dithering is a basic two-level algorithm for
halftone image. It consists in choosing a certain
constant gray level, in particular the average value of
image pixels, and using it as a global threshold in
deciding whether a pixel should be quantized to 0 or to
1. All pixels whose intensity level lies above the
average value (the threshold) are quantized to 1; all
others get a value of 0.
This method is simple to implement but it has a
disadvantage: quantization contouring is quite
perceptible

The Average Dithering

Random Dithering
This is the bubble sort of dithering
algorithms. It is not really acceptable as a
production method, but it is very simple to
describe and implement. For each value in
the image, simply generate a random number
1..256; if it is greater than the image value at
that point, plot the point white, otherwise
plot it black.

Random Dithering

Ordered Dithering
1) Image Array is smaller than the display array
- multiply displays pixels are used for one image
pixel
- n x n - k-level pixels provide n2 *(k-1)+1
intensities

Ordered Dithering

Ordered Dithering cont.


A 4x4 dither matrix set of 17 patterns, used to interpolate between
black and white. The size of the patterns has been exaggerated
(scaled by ~3).
Dither matrix:
D2= |0 2 |
|3 1 |
D3= |6 8 4 |
|1 0 3 |
|527|
Larger dither matrices can be found by using recurrence relation:
D2n= 4*Dn 4*Dn+2*Un 4*Dn+3*Un 4*Dn+1*Un where Un - matrix nxn 1s

Ordered Dithering matrix usage


How to use those dithering matrices?
a) k=2
To display an intensity I we turn on all pixels, whose values
are less than I.
b) k>2
I(image) is in range <0,n2 *(k-1)>
col = I(image) div n2
re = I(image) mod n2
nxn device pixels are painted using col and col+1 colors due to
dither matrix Dn and re value.

Ordered Dithering cont.


b). Image Array is the same size as the display array
1 pixel in the image array controls 1 pixel in the display array
Ii = GetPixel(x,y); // Ii is in range <0,n2
*(k-1)>
col = Ii div n2
re = Ii mod n2
i = x mod n
j = y mod n
if re >Dn[i,j] col++
PutPixel(x,y,col);

Ordered Dithering cont.

Original image

Ordered dithering

Ordered Dithering cont.

Original image (256 grey


levels)

Ordered dithering (only B&W )

Error diffusion dithering


Error (i.e., the difference between the exact pixel value and the approximated value) is
added to the values of the image-array pixels to the right of and below the pixel.
K = Approximate(S[x][y]);
//Approximate S to the nearest
//displayable intensity
I[x][y] = K;
//Draw the pixel at (x,y)
error = S[x][y]-K;
//Error must be of type float
//error is diffused over several pixels in the image array
// using filter array
// float filter[2*f_x+1][2*f_y+1]
for (i=-f_x; i>+f_x; i++)
for (j=-f_y; j>+f_y; j++)
S[x+i][y+j] += error*filter[i][j];

Error diffusion - filters

Error Diffusion dithering

Original image

Floyd-Steinberg
dithering

You might also like