Image Processing – Contrast Enhancement Jack Tompkins Department of Computer Science tompkinsj@uncw.edu
What is Contrast Enhancement Original Image with low contrast Enhanced Image
Luminance While contrast enhancement can be accomplished across r, g, and b bands, often the image is first converted to gray scale. https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf When translating a color image to black and white (mode “L”), use the ITU-R 601-2 luma transform: L = R * 299/1000 + G * 587/1000 + B * 114/1000
Contrast Low contrast images with neighbors clustered on the low end of the intensity scale, closer to 0, are called low-key. Low contrast images that reside on the high end of the intensity scale, closer to 255, are called high-key. Normal contrast images are equalized. High contrast images will exhibit a full range of tones from black to white, with dark shadows and bright highlights.
How to Enhance Contrast Neighboring pixels with similar intensity are hard to distinguish. Low Contrast -> image values concentrated in a narrow range. Contrast enhancement -> distribute the pixel intensities across a broader range while maintaining relative brightness
Visualizing Pixel Counts Histograms A histogram is a display of statistical information representing the frequency of data items in successive numerical intervals of equal size. Histogram of a monochrome image with 256 possible gray levels or intensities ranging from 0 through 255. Each bin in the histogram represents a probability. P(i) = ni / n, where ni is the number of pixels with intensity i, n is the total number of pixels.
Pixel Counts - Histograms
Visualizing Pixel Counts Histograms histograms.xslx Bw1.jpg Luther Bell Lena Oira.jpg
By What Technique? Use a function, g, to generate a new image B from image A: B(x, y) = g(A(x, y)), x = 0,…, n-1, y = 0,…, m-1 The function, g, maps pixel intensities for each pixel in image A to a new intensity for that pixel in image B. Monotonically non-decreasing, (relative intensity relations remain) A short chapter excerpt with examples: TT92
Linear Transform Uniform linear transformation Say intensities are concentrated from 0 to 64, and we wish to map these to 0 to 255 g(f) = m f + b, where m = (t1 – t0)/(s1 - s0), b = t1 – m s1 g(f) = 255/64 * f + 255 – 255/64 * 64 = 255/64 f see histograms.xslx Easily adapted to piecewise transformations using multiple slope segments over sequential groups Can be fully automated
Histogram Equalization Digital Image Processing – Gonzalez & Woods, p 93 The probability of occurrence of gray level rk in an image is approximated by p(rk) = nk / n k = 0, 1, 2, …, L-1, where nk is the number of pixels with gray level rk, n is the number of pixels, and L is the total number of possible gray levels in the image (typically 256) A plot of pr(rk) is called a histogram, efficiently stored in an array with indices 0..255
Histogram Equalization Digital Image Processing – Gonzalez & Woods, p 93 A processed output image is obtained by mapping each pixel with level rk in the input image into a corresponding pixel with level sk in the output image sk = (L-1) 𝑗=0 𝑘 𝑝 (rj) = (L-1) 𝑗=0 𝑘 𝑛 𝑗 𝑛 = ((L-1)/n) 𝑗=0 𝑘 𝑛𝑗 Efficiently stored in an array with indices 0..255 - a look up table Histogram Equalization
Additional Techniques Image Contrast Enhancement Methods Log transform: g(f) = c log(1 + f) Power transform: g(f) = c f r, 0 < r < 1
Saving multiple image histograms to a single CSV file
Data gathering
Scanning in the Image Files