
Point Processing 77
FIGURE 4.16: The function used in Figure 4.15
A Piecewise Linear Stretching Function
We can easily write our own function to perform piecewise linear stretching as shown in
Figure 4.17. This is easily implemented by first specifying the points (a
i
, b
i
) involved and
a
1
a
2
a
3
a
4
b
1
b
2
b
3
b
4
FIGURE 4.17: A piecewise linear stretching function
then using the one-dimensional interpolation function
interp1 to join them. In this case,
we might have:
MATLAB/Octave
>> a = [0 100 150 255]
>> b = [40 100 220 255]
>> lin = interp1(a,b,0:255,’linear’);
Then it can be applied to the image with
MATLAB/Octave
>> cl = uint8(lin(c+1));
Python also provides easy