Point Operations

Point operations modify the intensity of a pixel using only that pixel’s own value, in isolation from its neighbours. May use statistical data relating to other pixels, such as the image histogram.

Homogeneous iff the operation is independent of pixel location.

Lookup Table

A lookup table (LUT) maps the current pixel value to an index, returning a new value from the table.

  • Enables on the fly processing, especially on hardware platforms
  • Changing table content changes the operation without changing any code

Examples:

  • Pseudo colouring, e.g. mapping thermal image temperature to RGB
  • Compensating for non-linearity in sensor elements

Grey Level Histogram

The grey level histogram shows the frequency of occurrence of each intensity level in an image, regardless of pixel position. Its shape describes overall brightness and contrast.

Normalized histogram:

P(k)=N(k)nP(k) = \frac{N(k)}{n}
Here:
N(k)N(k)
number of pixels with intensity kk
nn
total number of pixels

Defines the probability of intensity level kk in the image.

Accumulated histogram:

A(k)=∑j≤kP(j)A(k) = \sum_{j \le k} P(j)

Defines the accumulated probability of pixels with intensity level ≤k\le k.

Characteristics

  • Position independent
    The histogram ignores where pixels are. Rearranging the pixels leaves it unchanged, so different images can share one histogram.
  • Size independent
    The normalized histogram holds proportions, so images of different sizes can be compared.
  • Sums to 1
    ∑kP(k)=1\sum_k P(k) = 1. The accumulated histogram never decreases and reaches 1 at the highest level.
  • Gives mean and spread
    Brightness is the mean and contrast is the standard deviation of the distribution.
μ=∑kk P(k)σ2=∑k(k−μ)2P(k)\mu = \sum_k k\,P(k) \qquad \sigma^2 = \sum_k (k - \mu)^2 P(k)
Here:
μ\mu
mean intensity
σ2\sigma^2
variance of intensity
ShapeMeaning
Concentrated at low levelsDark image.
Concentrated at high levelsBright image.
NarrowLow contrast.
WideHigh contrast.
2 separated peaksObjects and background with different intensities. A threshold between the peaks separates them.

Effect of a point operation on the histogram:

  • A one-to-one mapping moves bins without changing their heights.
  • A many-to-one mapping merges bins and adds their heights. The merged levels cannot be told apart afterwards.
  • No point operation splits a bin, since all pixels with the same input level get the same output level. So a histogram can only be approximated, and unused levels appear as gaps.

Brightness and Contrast

Brightness and contrast are the position and the width of the same histogram. Both are described as point operations mapping input intensity rr to output intensity ss.

  • Brightness
    Mean intensity. A shift s=r+cs = r + c slides the histogram along the intensity axis, keeping its shape and width.
  • Contrast
    Spread of intensities. Histogram width, the gap between the darkest and brightest points, measures it. A gain s=ars = a r stretches the histogram wider.

Here:

s=ars = a r
Here:
rr
input intensity
ss
output intensity
cc
shift constant, added to move brightness
aa
gain constant, multiplied to change contrast

Shifting the histogram changes brightness only. Every pair of pixels keeps the same intensity gap, so contrast is unaffected.

Point Processing Functions

Common transformations applied to each pixel, typically implemented as a LUT mapping input intensity rr to output intensity ss.

FunctionEquation
Identity
Output equals input.
s=rs = r
Digital negative
Inverts intensity.
s=(L−1)−rs = (L-1) - r
Square root
Compresses bright values and expands dark ones. c=L−1c = \sqrt{L-1} maps the top level to itself.
s=crs = c\sqrt{r}
Contrast stretching
Piecewise linear expansion of a chosen intensity range.
s={s1r1 r0≤r<r1s1+s2−s1r2−r1(r−r1)r1≤r≤r2s2+L−1−s2L−1−r2(r−r2)r2<r≤L−1s = \begin{cases} \dfrac{s_1}{r_1}\,r & 0 \le r < r_1 \\ s_1 + \dfrac{s_2 - s_1}{r_2 - r_1}(r - r_1) & r_1 \le r \le r_2 \\ s_2 + \dfrac{L-1-s_2}{L-1-r_2}(r - r_2) & r_2 < r \le L-1 \end{cases}
Normalizing
Rescales intensities to use the full available range.
s=(L−1) r−rmin⁡rmax⁡−rmin⁡s = (L-1)\,\dfrac{r - r_{\min}}{r_{\max} - r_{\min}}
Clipping
Forces values outside a chosen range to the range boundary.
s={ar<ara≤r≤bbr>bs = \begin{cases} a & r < a \\ r & a \le r \le b \\ b & r > b \end{cases}
Intensity level slicing
Highlights a chosen intensity band, suppressing all others.
s={L−1a≤r≤b0otherwises = \begin{cases} L-1 & a \le r \le b \\ 0 & \text{otherwise} \end{cases}
Bit slicing
Extracts bit-plane kk of the pixel value. The result is 00 or 11.
s=⌊r2k⌋ mod 2s = \left\lfloor \dfrac{r}{2^k} \right\rfloor \bmod 2
Range stretching or compression
Maps a chosen input range onto a different output range. It stretches when the output range is wider than the input range, and compresses when it is narrower.
s=smin⁡+(smax⁡−smin⁡) r−rmin⁡rmax⁡−rmin⁡s = s_{\min} + (s_{\max} - s_{\min})\,\dfrac{r - r_{\min}}{r_{\max} - r_{\min}}
Histogram equalization
Redistributes intensities to make the histogram more uniform.
s=round⁡((L−1) A(r))s = \operatorname{round}\big((L-1)\,A(r)\big)

Here:

s=round⁡((L−1) A(r))s = \operatorname{round}\big((L-1)\,A(r)\big)
Here:
LL
number of grey levels
a,ba, b
lower and upper bounds of the chosen range
cc
scaling constant
(r1,s1),(r2,s2)(r_1, s_1), (r_2, s_2)

control points of the piecewise linear curve

rmin⁡,rmax⁡r_{\min}, r_{\max}
limits of the input range
smin⁡,smax⁡s_{\min}, s_{\max}
limits of the output range
kk
bit-plane index, with 00 the least significant bit
A(r)A(r)
accumulated histogram

Normalizing is range stretching with the output range [0,L−1][0, L-1] and the input range set to the image minimum and maximum.

Histogram Matching

Also known as histogram specification. The process of adjusting a test image so its grey level distribution follows a given reference distribution.

The reference is supplied as a 256-element array holding the reference CDF, one value per grey level.

Procedure:

  • Compute the test image histogram, then its CDF CtC_t
  • For each test level gg, find the reference level rr whose CDF value Cr(r)C_r(r) is closest to Ct(g)C_t(g)
  • Store g↦rg \mapsto r in a 256-entry LUT
  • Apply the LUT to every pixel
LUT(g)=arg⁡min⁡r ∣Cr(r)−Ct(g)∣\text{LUT}(g) = \arg\min_{r} \, \lvert C_r(r) - C_t(g) \rvert
Here:
Ct(g)C_t(g)
accumulated probability of test level ≤g\le g
Cr(r)C_r(r)
accumulated probability of reference level ≤r\le r

Histogram equalization is the special case where the reference CDF is linear. Matching 2 levels through equal CDF values preserves their relative ordering.

For a colour image, each channel is matched independently against the reference channel.

def cdf(pixels):
    # count how many pixels have each intensity
    hist = [0] * 256
    for v in pixels:
        hist[v] += 1
    # accumulate the counts and divide by the total to get the CDF
    total = len(pixels)
    running, out = 0, [0.0] * 256
    for i, c in enumerate(hist):
        running += c
        out[i] = running / total
    return out

def match(test_pixels, ref_cdf):
    ct = cdf(test_pixels)
    # build the LUT: for each test level g, pick the reference
    # level r whose CDF value is closest to the test CDF value
    lut = [0] * 256
    for g in range(256):
        best_r = 0
        best_diff = abs(ref_cdf[0] - ct[g])
        for r in range(1, 256):
            diff = abs(ref_cdf[r] - ct[g])
            if diff < best_diff:
                best_diff = diff
                best_r = r
        lut[g] = best_r
    # remap every pixel through the LUT
    out = []
    for v in test_pixels:
        out.append(lut[v])
    return out

For a colour image, match each channel against that channel’s reference CDF.

Multiple Images and Histograms

Each image has its own CtC_t, so every image needs its own LUT. The reference CDF is the only input shared between images.

  • 1 reference for all images
    Compute the reference CDF once, then build and apply one LUT per image. All outputs follow the same distribution, so brightness and contrast are consistent across the set.
  • 1 reference per image
    Pair each image with its reference CDF, then match each pair separately.
  • References not paired with images
    Give each image the reference whose CDF is closest, then match.

The distance between an image ii and a reference jj is the total absolute difference of their CDFs.

d(i,j)=∑g∣Ct,i(g)−Cr,j(g)∣d(i, j) = \sum_{g} \lvert C_{t,i}(g) - C_{r,j}(g) \rvert

Image ii takes the reference arg⁡min⁡jd(i,j)\arg\min_j d(i, j). When each reference may be used by only 1 image, solve an assignment problem on the matrix d(i,j)d(i, j), for example with the Hungarian algorithm.

def match_to_closest(images, ref_cdfs):
    out = []
    for pixels in images:
        ct = cdf(pixels)
        # pick the reference whose CDF differs least from the image CDF
        best = min(ref_cdfs, key=lambda rc: sum(abs(a - b) for a, b in zip(ct, rc)))
        out.append(match(pixels, best))
    return out

Worked Example

Match a 4-pixel test image to a reference CDF over 4 grey levels {0,1,2,3}\{0, 1, 2, 3\}.

Test pixels: 0,1,1,30, 1, 1, 3.

Test histogram: [1,2,0,1][1, 2, 0, 1], total 44.

Test CDF CtC_t: [0.25,0.75,0.75,1.0][0.25, 0.75, 0.75, 1.0].

Reference CDF CrC_r: [0.1,0.2,0.7,1.0][0.1, 0.2, 0.7, 1.0].

Solution Reveal Hide

Mapping:

  • g=0g = 0, Ct=0.25C_t = 0.25: closest is Cr(1)=0.2C_r(1) = 0.2, so 0↦10 \mapsto 1
  • g=1g = 1, Ct=0.75C_t = 0.75: closest is Cr(2)=0.7C_r(2) = 0.7, so 1↦21 \mapsto 2
  • g=2g = 2, Ct=0.75C_t = 0.75: 2↦22 \mapsto 2
  • g=3g = 3, Ct=1.0C_t = 1.0: Cr(3)=1.0C_r(3) = 1.0, so 3↦33 \mapsto 3

Output pixels: 1,2,2,31, 2, 2, 3.

Written by November 3, 2026 7 min read
Was this helpful?