the mathematics of digital photography

Post on 12-Sep-2021

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Research Matters

February 25, 2009

Nick HighamDirector of Research

School of Mathematics

1 / 6

The Mathematics ofDigital Photography

Professor Nick HighamDirector of Research

School of Mathematics

nick.higham@manchester.ac.ukhttp://www.manchester.ac.uk/~higham/

What is Color?

Human perception; depends on light source.

Retina has 3 types of cones⇒ trichromatic theory.

Why does yellow appear so bright?

Nick Higham Digital Photography 2 / 46

What is Color?

Human perception; depends on light source.Retina has 3 types of cones⇒ trichromatic theory.

Why does yellow appear so bright?

Nick Higham Digital Photography 2 / 46

What is Color?

Human perception; depends on light source.Retina has 3 types of cones⇒ trichromatic theory.

Why does yellow appear so bright?

Nick Higham Digital Photography 2 / 46

Colour Blindness

John Dalton (1766–1844).Described his own c.b. inlecture to M/cr Lit & PhilSoc, 1794.He was a deuteranope.

Nick Higham Digital Photography 3 / 46

Vector Space Model of ColourModel responses of the 3 cones as

ci =

∫ λmax

λmin

si(λ)f (λ)dλ, i = 1 : 3,

where f = spectral distrib. of light, si = sensitivity of i thcone, [λmin, λmax] = wavelengths of visible spectrum.

Discretizing gives

c = ST f , c ∈ R3, S ∈ Rn×3, f ∈ Rn.

For standardized S, c is the tristimulus vector.

Nick Higham Digital Photography 4 / 46

Vector Space Model of ColourModel responses of the 3 cones as

ci =

∫ λmax

λmin

si(λ)f (λ)dλ, i = 1 : 3,

where f = spectral distrib. of light, si = sensitivity of i thcone, [λmin, λmax] = wavelengths of visible spectrum.Discretizing gives

c = ST f , c ∈ R3, S ∈ Rn×3, f ∈ Rn.

For standardized S, c is the tristimulus vector.

Nick Higham Digital Photography 4 / 46

StandardizationCommission Internationale de l’Éclairage (CIE) definedstandard colour matching functions si(λ) (1931, 1964).CIE RGB space.CIE XYZ space: nonnegative si(λ), Y corresponds toperceived brightness.

Nick Higham Digital Photography 5 / 46

Projective Transformation

Nick Higham Digital Photography 6 / 46

CIE Chromacity Coordinates

x =X

X + Y + Z, y =

YX + Y + Z

(z = 1− x − y).

(x , y) chromacity diagram:

Nick Higham Digital Photography 7 / 46

Perceptual Uniformity: LAB Space

XYZ and RGB far from perceptually uniform.Search for (non)linear transformations that give moreuniform colour spaces.CIE L*a*b* (LAB, 1976) is more uniform:L = lightness, A = green–magenta, B = blue–yellow.LAB supported by Adobe Photoshop, MATLAB ImageProcessing Toolbox.

Nick Higham Digital Photography 9 / 46

Dan Margulis on LAB (2006)

Nick Higham Digital Photography 10 / 46

CMYK

Printers use subtractive colour model: dyes absorb powerfrom spectrum. To produce wide range of colours need cyan,yellow, magenta primaries.

But C + M + Y = K = black : why do we need K?

Printing 3 layers makes the paper very wet.Black as 3 layers requires accurate registration.C + M + Y will not give a true, deep black due toimperfections.Coloured ink is more expensive.

Nick Higham Digital Photography 11 / 46

CMYK

Printers use subtractive colour model: dyes absorb powerfrom spectrum. To produce wide range of colours need cyan,yellow, magenta primaries.

But C + M + Y = K = black : why do we need K?

Printing 3 layers makes the paper very wet.Black as 3 layers requires accurate registration.C + M + Y will not give a true, deep black due toimperfections.Coloured ink is more expensive.

Nick Higham Digital Photography 11 / 46

Bayer Filter

Sensor has 2green filters foreach red andblue.

Raw files are the unprocessed data off the sensor.

Nick Higham Digital Photography 12 / 46

Demosaicing

Converts toRGB colourimage byinterpolation.

Nick Higham Digital Photography 13 / 46

Compression

Original number string1 2 0 0 0 0 8 7 7 7 7 7 6 13

Lossless compression1 2 0 *4 8 7 *5 6 8

Lossy compression0 *6 7 *7 4

Jpeg is a lossy compression scheme.

Nick Higham Digital Photography 14 / 46

Jpeg

Compressed RGB file.Filesizes reduced by orders of magnitude.Used by all digital cameras and imaging software.

tif (LZW) 12111 kjpg 12 1892 kjpg 8 917 kjpg 0 221 k

Nick Higham Digital Photography 15 / 46

Jpeg 200× 200 px

Quality 8 Quality 0

Nick Higham Digital Photography 16 / 46

Colour Space

Jpeg compression first converts from RGB to YCbCr colourspace where Y = luminance, Cb,Cr = blue, redchrominances, by Y

Cb

Cr

=

0.299 0.587 0.114−0.1687 −0.3313 0.5

0.5 −0.4187 −0.0813

RGB

.Vision has poor response to spatial detail in colouredareas of same luminance⇒ Cb, Cr can take greatercompression.Note:

∑row1 = 1,

∑row2 =

∑row3 = 0.

Nick Higham Digital Photography 17 / 46

Discrete Cosine Transform

Algorithm breaks image into 8× 8 blocks.For each block luminance values expressed as linearcombination of cosine functions of increasing frequency

`x ,y =7∑

i=0

7∑j=0

fij cos((2x + 1)iπ

16

)cos

((2y + 1)iπ

16

),

where fij computed by a discrete cosine transform:

fij =7∑

x=0

7∑y=0

`x ,y cos((2x + 1)iπ

16

)cos

((2y + 1)iπ

16

).

Coefficients rounded, higher freqs de-emphasized.Same for Cb,Cr but more aggressive compression done.

Nick Higham Digital Photography 18 / 46

Fingerprints—FBIDigitized at 500dpi⇒ 10Mb. Compression >∼ 10:1 req’d.Standardized on wavelet compression (1993).Jpeg: resonance of 8-pixel tiling w/ 500dpi scans, manyedges.Wavelets: gradual blurring as compression increased.

Nick Higham Digital Photography 19 / 46

Panoramic Stitching

Nonlinear least squares, Levenberg–Marquardt:

(JT J + λD)d = JT r , J ∈ R3200×32 for 8 images.

Nick Higham Digital Photography 20 / 46

Panoramic Stitching

Nonlinear least squares, Levenberg–Marquardt:

(JT J + λD)d = JT r , J ∈ R3200×32 for 8 images.

Nick Higham Digital Photography 20 / 46

Panoramic Stitching

Nonlinear least squares, Levenberg–Marquardt:

(JT J + λD)d = JT r , J ∈ R3200×32 for 8 images.

Nick Higham Digital Photography 20 / 46

Panoramic Stitching

Nonlinear least squares, Levenberg–Marquardt:

(JT J + λD)d = JT r , J ∈ R3200×32 for 8 images.

Nick Higham Digital Photography 20 / 46

Cloning/Healing

Photoshop blends the source into the target by solving thebiharmonic equation

∂4f∂x4 + 2

∂4f∂x2∂y2 +

∂4f∂y4 = 0.

Originally used in mapping, contouring (1950s).

Nick Higham Digital Photography 21 / 46

Cloning/Healing

Photoshop blends the source into the target by solving thebiharmonic equation

∂4f∂x4 + 2

∂4f∂x2∂y2 +

∂4f∂y4 = 0.

Originally used in mapping, contouring (1950s).

Nick Higham Digital Photography 21 / 46

Transformations to improve images

UoM turquoise is (L,A,B) ≈ (85,−12,−3).Convert to LAB then A← −A.

Now have (L,A,B) ≈ (85,12,−3).

Mean

Nick Higham Digital Photography 41 / 46

Median

Nick Higham Digital Photography 42 / 46

Max

Nick Higham Digital Photography 43 / 46

Min

Nick Higham Digital Photography 44 / 46

Variance

Nick Higham Digital Photography 45 / 46

Summary

Mathematics is intrinsic to digital imaging: modelling theeye’s response to colour, colour spaces, capturingimages, storing and processing them.Modern developments in Photoshop, Lightroom, etc., relyon clever mathematical algorithms as well as exploitingfaster processors—and, increasingly, GPUs.Most of the relevant mathematics is covered in ourhonours degree programme.

Talk, including references, available athttp://www.maths.manchester.ac.uk/~higham/talks/digphot.pdf

Nick Higham Digital Photography 46 / 46

Acknowledgements for Graphics

Wikipedia:http://en.wikipedia.org/wiki/Image:CIE1931_XYZCMF.pnghttp://upload.wikimedia.org/wikipedia/commons/b/b0/CIExy1931.pnghttp://en.wikipedia.org/wiki/Bayer_filter

http://www2.cmp.uea.ac.uk/Research/compvis/ColourIntro/ColourIntro.htm

Fraser [4].

Nick Higham Digital Photography 1 / 6

References I

D. Austin.What is . . . JPEG?Notices Amer. Math. Soc., 55(2):226–229, 2008.

C. M. Brislawn.Fingerprints go digital.Notices Amer. Math. Soc., 42(11):1278–1283, 1995.

J. B. Cohen.Visual Color and Color Mixture: The Fundamental ColorSpace.University of Illinois Press, Urbana and Chicago, USA,2001.

Nick Higham Digital Photography 2 / 6

References II

B. Fraser.Raw capture, linear gamma, and exposure.www.adobe.com/products/photoshop/pdfs/linear_gamma.pdf.

B. Fraser.Understanding digital raw capture.www.adobe.com/products/photoshop/pdfs/understanding_digitalrawcapture.pdf.

Nick Higham Digital Photography 3 / 6

References III

N. J. Higham.Color spaces and digital imaging.In N. J. Higham, M. R. Dennis, P. Glendinning, P. A.Martin, F. Santosa, and J. Tanner, editors, The PrincetonCompanion to Applied Mathematics, pages 808–813.Princeton University Press, Princeton, NJ, USA, 2015.

A. R. Hill.How we see colour.In R. McDonald, editor, Colour Physics for Industry, pages211–281. Society of Dyers and Colourists, Bradford,England, 1987.

Nick Higham Digital Photography 4 / 6

References IV

D. M. Hunt, K. S. Dulai, J. K. Bowmaker, and J. D. Mollon.The chemistry of John Dalton’s color blindness.Science, 267:984–988, 1995.

JPEG file interchange format, version 1.02.http://www.w3.org/Graphics/JPEG/jfif3.pdf.

D. Margulis.Photoshop LAB Color: The Canyon Conundrum andOther Adventures in the Most Powerful Colorspace.Peachpit Press, Berkeley, CA, USA, 2006.

C. Poynton.A guided tour of color space, 1997.www.poynton.com/PDFs/Guided_tour.pdf.

Nick Higham Digital Photography 5 / 6

References V

G. Sharma and H. J. Trussell.Digital color imaging.IEEE Trans. Image Processing, 6(7):901–932, 1997.

S. Westland and C. Ripamonti.Computational Colour Science Using MATLAB.Wiley, New York, 2004.

Nick Higham Digital Photography 6 / 6

top related