summaryrefslogtreecommitdiffstats
path: root/upstream/debian-bookworm/man5/extendedopacity.5
blob: b31a082ce8f757e2949e29a6b59a622efed3aef3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
\
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
.\" Do not hand-hack it!  If you have bug fixes or improvements, please find
.\" the corresponding HTML page on the Netpbm website, generate a patch
.\" against that, and send it to the Netpbm maintainer.
.TH "Image Processing By Interp and Extrapolation" 5 "" "netpbm documentation"

Created: 17 April 2003
.SH NAME
extendedopacity - theory of netpbm interpolation and extrapolation
.SH DESCRIPTION
.PP
This page is a copy of http://www.sgi.com/misc/grafica/interp/ on
April 17, 2003, with some slight formatting changes, included in the
Netpbm documentation for convenience.  Since at least June 11, 2005,
the source page has been missing.

.SH Image Processing By Interpolation and Extrapolation
\fIPaul Haeberli and Douglas Voorhies\fP

.SS Introduction
.PP
Interpolation and extrapolation between two images offers a general,
unifying approach to many common point and area image
processing operations.  Brightness, contrast, saturation, tint, and
sharpness can all be controlled with one formula, separately or
simultaneously.  In several cases, there are also performance benefits.
.PP
Linear interpolation is often used to blend two images.
Blend fractions (alpha) and (1 - alpha) are used in a weighted average
of each component of each pixel:

.nf
      out = (1 - alpha)*in0 + alpha*in1

.fi
.PP
Typically alpha is a number in the range 0.0 to 1.0.  This is
commonly used to linearly interpolate two images.
What is less often considered is that alpha may range beyond the
interval 0.0 to 1.0.
Values above one subtract a portion of in0 while scaling in1.  Values
below 0.0 have the opposite effect.
.PP
Extrapolation is particularly useful if a degenerate version of the
image is used as the image to get "away from."  Extrapolating away from
a black-and-white image increases saturation.  Extrapolating away from a
blurred image increases sharpness.  The interpolation/extrapolation
formula offers one-parameter control, making display of a series of
images, each differing in brightness, contrast, sharpness, color, or
saturation, particularly easy to compute, and inviting hardware acceleration.
.PP
In the following examples, a single alpha value is used per image.
However other processing is possible, for example where alpha is a function
of X and Y, or where a brush footprint controls alpha near the cursor.

.SS Changing Brightness
.PP
To control image brightness, we use pure black as the degenerate (zero
alpha) image.  Interpolation darkens the image, and extrapolation
brightens it.  In both cases, brighter pixels are affected more.

.B brightness
.IMG -C blend1.gif

.SS Changing Contrast
.PP
Contrast can be controlled using a constant gray image with the average image
luminance.  Interpolation reduces contrast and extrapolation boosts it.
Negative alpha generates inverted images with varying contrast.  In
all cases, the average image luminance is constant.

.B contrast
.IMG -C blend3.gif
.PP
If middle gray or the average pixel color is used instead, contrast is
again altered, but with middle gray or the average color left unaffected.
Shades and colors far away from the chosen value are most affected.

.SS Changing Saturation
.PP
To alter saturation, pixel components must move towards or away from the
pixel's luminance value. By using a black-and-white image as the
degenerate version, saturation can be decreased using interpolation, and
increased using extrapolation.  This avoids computationally more
expensive conversions to and from HSV space.  Repeated update in
an interactive application is especially fast, since the luminance
of each pixel need not be recomputed.  Negative alpha preserves luminance
but inverts the hue of the input image.

.B saturation
.IMG -C blend4.gif

.SS Sharpening an Image
.PP
Any convolution, such as sharpening or blurring, can be adjusted by
this approach.
If a blurred image is used as the degenerate image,
interpolation attenuates high frequencies to varying degrees, and
extrapolation boosts them, sharpening the image by unsharp masking.
Varying alpha acts as a kernel scale factor, so a series of
convolutions differing only in scale can be done easily, independent of
the size of the kernel.  Since blurring, unlike sharpening, is often a
separable operation, sharpening by extrapolation may be far more
efficient for large kernels.

.B sharpening
.IMG -C blend6.gif
.PP
Note that global contrast control, local contrast control, and
sharpening form a continuum.
Global contrast pushes pixel components
towards or away from the average image luminance.  Local contrast is
similar, but uses local area luminance.  Unsharp masking is the extreme
case, using only the color of nearby pixels.

.SS Combined Processing
.PP
An unusual property of this interpolation/extrapolation approach is that
all of these image parameters may be altered simultaneously.  Here
sharpness, tint, and saturation are all altered.

.B combined
.IMG -C blend7.gif

.SS Conclusion
.PP
Image applications frequently need to produce multiple degrees of
manipulation interactively.
Image applications frequently need to interactively manipulate
an image by continuously changing a single parameter.
The best hardware mechanisms employ a
single "inner loop" to achieve a wide variety of effects.  Interpolation
and extrapolation of images can be a unifying approach, providing a single
function that can do many common image processing operations.
.PP
Since a degenerate image is sometimes easier to calculate, extrapolation
may offer a more efficient method to achieve effects such as sharpening
or saturation.  Blending is a linear operation, and so it must be
performed in linear, not gamma-warped space.  Component range must also be
monitored, since clamping, especially of the degenerate image, causes
inaccuracy.
.PP
These image manipulation techniques can be used in paint programs to
easily implement brushes that saturate, sharpen, lighten, darken,
or modify contrast and color.  The only major change needed is to work with
alpha values outside the range 0.0 to 1.0.
.PP
It is surprising and unfortunate how many graphics software packages
needlessly limit interpolant values to the range 0.0 to 1.0.  Application
developers should allow users to extrapolate parameters when practical.
.SS References
.PP
For a slightly extended version of this article, see:
P. Haeberli and D. Voorhies. \fIImage Processing by Linear 
Interpolation and Extrapolation\fP. 
IRIS Universe Magazine No. 28, Silicon Graphics, Aug, 1994.
.PP
.B 
.IMG -C gobot.gif
.SH DOCUMENT SOURCE
This manual page was generated by the Netpbm tool 'makeman' from HTML
source.  The master documentation is at
.IP
.B http://netpbm.sourceforge.net/doc/extendedopacity.html
.PP