cameras and image processing

41
Cameras and Image Processing Computational Photography CSE 291 Lecture 2

Upload: others

Post on 24-Jul-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cameras and Image Processing

Cameras and Image Processing

Computational Photography

CSE 291

Lecture 2

Page 2: Cameras and Image Processing

Announcements

โ€ข Assignment 1 will be released today

โ€“ Due Apr 8, 11:59 PM

CSE 291, Spring 2020 2

Page 3: Cameras and Image Processing

Traditional photography

โ€ข The acquisition of images by recording light (or other electromagnetic radiation) either electronically (using an image sensor) or chemically (using film)

โ€ข Typically, a lens is used to focus the light reflected or emitted from objects in the scene being imaged into an image on the light sensitive surface inside a camera during a timed exposure

CSE 291, Spring 2020 3

Page 4: Cameras and Image Processing

Geometric image formation

โ€ข How do 3D world points project to 2D image points?

CSE 291, Spring 2020 4

Page 5: Cameras and Image Processing

The projective camera

โ€ข Extrinsic Parameters: Since camera may not be at the origin, there is a rigid transformation between the world coordinates and the camera coordinates

โ€ข Intrinsic parameters: Since scene units (e.g., cm) differ image units (e.g., pixels) and coordinate system may not be centered in image, we capture that with a 3x3 transformation comprised of focal length, principal point, pixel aspect ratio, and skew

=

T

Z

Y

X

w

y

x

parameters extrinsic

by drepresente

tionTransforma Rigid

0100

0010

0001

parameters intrinsic

by drepresente

tionTransforma

3 x 3 4 x 4

CSE 291, Spring 2020 5

Page 6: Cameras and Image Processing

The reason for lenses

CSE 291, Spring 2020 6

We need light, but big pinholes cause blur

Page 7: Cameras and Image Processing

Thin lens, image of point

CSE 291, Spring 2020 7

O

All rays passing through lens and starting at Pconverge upon Pโ€™

So light gather capability of lens is given the area of the lens and all the rays focus on Pโ€™ instead of become blurred like a pinhole

F

P

Pโ€™

Page 8: Cameras and Image Processing

Thin lens, image plane

CSE 291, Spring 2020 8

OF

P

Pโ€™

Image Plane

Qโ€™

Q

A price: Whereas the image of P is in focus,the image of Q isnโ€™t.

Page 9: Cameras and Image Processing

Thin lens, aperture

CSE 291, Spring 2020 9

O

P

Pโ€™

Image Plane โ€ข Smaller Aperture-> Less Blur

โ€ข Pinhole -> No Blur

Page 10: Cameras and Image Processing

Lens distortion

โ€ข Radial distortion

โ€ข Tangential distortion

CSE 291, Spring 2020 10

Images of straight lines should be

straight

Page 11: Cameras and Image Processing

Photometric image formation

โ€ข What color is the projected point?

CSE 291, Spring 2020 11

Need bidirectional reflectance distribution function (BRDF) at

point on surface

Page 12: Cameras and Image Processing

Lighting, reflectance, and shading

CSE 291, Spring 2020 12

BRDF

Page 13: Cameras and Image Processing

Image acquisition

CSE 291, Spring 2020 13

Page 14: Cameras and Image Processing

Digitization, one row of image

CSE 291, Spring 2020 14

Page 15: Cameras and Image Processing

Digitization, whole image

CSE 291, Spring 2020 15

Page 16: Cameras and Image Processing

Number of quantization levels

CSE 291, Spring 2020 16

256 128

64 32

16 8

4 2

Page 17: Cameras and Image Processing

Image sensing pipeline

CSE 291, Spring 2020 17

Image processing

Page 18: Cameras and Image Processing

Image processing

โ€ข A discipline in which both the input and output of a process are images

โ€“ There are usually other input parameters to the process

CSE 291, Spring 2020 18

Page 19: Cameras and Image Processing

Demosaicing

CSE 291, Spring 2020 19

Image sensor

Color filter array (CFA)

Bayer pattern

CFA Interpolated (lower case)pixel values

Page 20: Cameras and Image Processing

Image processing

โ€ข Color spaces

โ€ข Gamut mapping

โ€ข White balancing and color balancing

CSE 291, Spring 2020 20

Page 21: Cameras and Image Processing

Image coding

โ€ข Common standardsโ€“ Video

โ€ข Recommendation ITU-R BT.601 (standard-definition television (SDTV))

โ€ข SMPTE standard 240M (precursor to Rec. 709)โ€ข Recommendation ITU-R BT.709 (high-definition television

(HDTV))

โ€“ Imageโ€ข sRGBโ€ข Adobe RGBโ€ข Wide gamut RGB (or Adobe Wide Gamut RGB)โ€ข ProPhoto RGB (or reference output medium metric (ROMM)

RGB)

CSE 291, Spring 2020 21

Page 22: Cameras and Image Processing

Different codings, different pixel values

CSE 291, Spring 2020 22

Page 23: Cameras and Image Processing

Color specification: chromaticity

โ€ข Chromaticity coordinates

โ€“ (x, y, z)

where x + y + z = 1

โ€“ Usually specified by (x, y)

where z = 1 โ€“ x โ€“ y

The CIE 1931 color space chromaticity diagram

CSE 291, Spring 2020 23

Page 24: Cameras and Image Processing

Chromaticities

โ€ข Set of chromaticities

โ€“ Red

โ€“ Green

โ€“ Blue

โ€“ White (point)

CSE 291, Spring 2020 24

Page 25: Cameras and Image Processing

Standard illuminantsHue of each white point, calculated with luminance Y = 0.54

CSE 291, Spring 2020 25

Page 26: Cameras and Image Processing

Chromaticities of common video standards

CSE 291, Spring 2020 26

Color CIE x CIE y CIE z

Red 0.6400 0.3300 0.0300

Green 0.3000 0.6000 0.1000

Blue 0.1500 0.0600 0.7900

White 0.3127 0.3290 0.3583

Recommendation ITU-R BT.709

Color CIE x CIE y CIE z

Red 0.6400 0.3300 0.0300

Green 0.2900 0.6000 0.1100

Blue 0.1500 0.0600 0.7900

White 0.3127 0.3290 0.3583

Recommendation ITU-R BT.601625 lines

Color CIE x CIE y CIE z

Red 0.6300 0.3400 0.0300

Green 0.3100 0.5950 0.0950

Blue 0.1550 0.0700 0.7750

White 0.3127 0.3290 0.3583

Recommendation ITU-R BT.601525 lines

Color CIE x CIE y CIE z

Red 0.6300 0.3400 0.0300

Green 0.3100 0.5950 0.0950

Blue 0.1550 0.0700 0.7750

White 0.3127 0.3290 0.3583

SMPTE standard 240M

D65

D65 D65

D65

Page 27: Cameras and Image Processing

Chromaticities of common image standards

CSE 291, Spring 2020 27

Color CIE x CIE y CIE z

Red 0.6400 0.3300 0.0300

Green 0.3000 0.6000 0.1000

Blue 0.1500 0.0600 0.7900

White 0.3127 0.3290 0.3583

sRGB

Color CIE x CIE y CIE z

Red 0.7347 0.2653 0.0000

Green 0.1152 0.8264 0.0584

Blue 0.1566 0.0177 0.8257

White 0.3457 0.3585 0.2958

Wide gamut RGB(or Adobe Wide Gamut RGB)

Color CIE x CIE y CIE z

Red 0.7347 0.2653 0.0000

Green 0.1596 0.8404 0.0000

Blue 0.0366 0.0001 0.9633

White 0.3457 0.3585 0.2958

ProPhoto RGB(or reference output media metric (ROMM RGB))

Color CIE x CIE y CIE z

Red 0.6400 0.3300 0.0300

Green 0.2100 0.7100 0.0800

Blue 0.1500 0.0600 0.7900

White 0.3127 0.3290 0.3583

Adobe RGB

D65

D50 D50

D65

Page 28: Cameras and Image Processing

Chromaticity diagrams

Rec. 709 and sRGB35.9% of visible colors

Adobe RGB52.1% of visible colors

CSE 291, Spring 2020 28

Page 29: Cameras and Image Processing

Chromaticity diagrams

Rec. 709 and sRGB35.9% of visible colors

Wide gamut RGB77.6% of visible colors

CSE 291, Spring 2020 29

Page 30: Cameras and Image Processing

Chromaticity diagrams

Rec. 709 and sRGB35.9% of visible colors

ProPhoto RGB90% of visible colors

CSE 291, Spring 2020 30

Page 31: Cameras and Image Processing

Academy Color Encoding Specification (ACES)

Color CIE x CIE y CIE z

Red 0.73470 0.26530 0.00000

Green 0.00000 1.00000 0.00000

Blue 0.00010 -0.07700 1.07690

White 0.32168 0.33767 0.34065

ACES

Approximately D60

100% of visible colors

CSE 291, Spring 2020 31

Page 32: Cameras and Image Processing

Nonlinear encoding

โ€ข All of these standards use nonlinear encoding (gamma encoding)โ€“ Video

โ€ข Recommendation ITU-R BT.601 (standard-definition television (SDTV))

โ€ข SMPTE standard 240M (precursor to Rec. 709)

โ€ข Recommendation ITU-R BT.709 (high-definition television (HDTV))

โ€“ Imageโ€ข sRGB

โ€ข Adobe RGB

โ€ข Wide gamut RGB (or Adobe Wide Gamut RGB)

โ€ข ProPhoto RGB (or reference output medium metric (ROMM) RGB)

CSE 291, Spring 2020 32

Page 33: Cameras and Image Processing

Nonlinear encoding and conversion to linear

โ€ข Typical CRT monitors have a transfer function of gamma = 2.2

โ€ข Image and video standards were designed to be directly displayed on CRTs

โ€“ Pixel values are encoded to approximate gamma = 2.2

โ€ข Nonlinear to linear (floating-point) using a lookup table

โ€ข Linear to nonlinear calculation

CSE 291, Spring 2020 33

LinearNonlinear

Page 34: Cameras and Image Processing

Nonlinear Rโ€™Gโ€™Bโ€™ color space and linear RGB color space

โ€ข Example: sRGB

CSE 291, Spring 2020 34

RGB linear

sRGB nonlinear

Slope of sRGB nonlinearin log-log space

Page 35: Cameras and Image Processing

XYZ color space

โ€ข Encompasses all color sensations the average person can experience

โ€ข Standard referenceโ€“ Many other color space definitions are based on XYZ

โ€ข Y is luminanceโ€ข Z is quasi-equal to blue stimulationโ€ข X is a linear combination of cone response curves chosen to be

nonnegativeโ€ข The plane parallel to the XZ plane and that Y lies on contains all

possible chromaticities at that luminance

CSE 291, Spring 2020 35

Page 36: Cameras and Image Processing

RGB color space to XYZ color space

๐‘‹๐‘Œ๐‘

=

๐‘Ÿ๐‘‹ ๐‘”๐‘‹ ๐‘๐‘‹๐‘Ÿ๐‘Œ ๐‘”๐‘Œ ๐‘๐‘Œ๐‘Ÿ๐‘ ๐‘”๐‘ ๐‘๐‘

๐‘…๐บ๐ต

๐‘‹๐‘Œ๐‘

=

๐‘Ÿ๐‘ฅ(๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘) ๐‘”๐‘ฅ(๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘) ๐‘๐‘ฅ(๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘)๐‘Ÿ๐‘ฆ(๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘) ๐‘”๐‘ฆ(๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘) ๐‘๐‘ฆ(๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘)

๐‘Ÿ๐‘ง(๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘) ๐‘”๐‘ง(๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘) ๐‘๐‘ง(๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘)

๐‘…๐บ๐ต

๐‘‹๐‘Œ๐‘

=

๐‘Ÿ๐‘ฅ ๐‘”๐‘ฅ ๐‘๐‘ฅ๐‘Ÿ๐‘ฆ ๐‘”๐‘ฆ ๐‘๐‘ฆ๐‘Ÿ๐‘ง ๐‘”๐‘ง ๐‘๐‘ง

๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘ 0 00 ๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘ 00 0 ๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘

๐‘…๐บ๐ต

CSE 291, Spring 2020 36

Page 37: Cameras and Image Processing

RGB color space to XYZ color space

โ€ข Substitute in RGB white and XYZ white

CSE 291, Spring 2020 37

๐‘Š๐‘…๐บ๐ต =111

๐‘Š๐‘‹๐‘Œ๐‘ =

๐‘ค๐‘ฅ๐‘ค๐‘ฆ1๐‘ค๐‘ง๐‘ค๐‘ฆ

๐‘ค๐‘ฅ๐‘ค๐‘ฆ1๐‘ค๐‘ง๐‘ค๐‘ฆ

=

๐‘Ÿ๐‘ฅ ๐‘”๐‘ฅ ๐‘๐‘ฅ๐‘Ÿ๐‘ฆ ๐‘”๐‘ฆ ๐‘๐‘ฆ๐‘Ÿ๐‘ง ๐‘”๐‘ง ๐‘๐‘ง

๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘ 0 00 ๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘ 00 0 ๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘

111

๐‘ค๐‘ฅ

๐‘ค๐‘ฆ

1๐‘ค๐‘ง

๐‘ค๐‘ฆ

=

๐‘Ÿ๐‘ฅ ๐‘”๐‘ฅ ๐‘๐‘ฅ๐‘Ÿ๐‘ฆ ๐‘”๐‘ฆ ๐‘๐‘ฆ๐‘Ÿ๐‘ง ๐‘”๐‘ง ๐‘๐‘ง

๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘

, solve for

๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘

M_RGB_to_XYZ =

๐‘Ÿ๐‘ฅ ๐‘”๐‘ฅ ๐‘๐‘ฅ๐‘Ÿ๐‘ฆ ๐‘”๐‘ฆ ๐‘๐‘ฆ๐‘Ÿ๐‘ง ๐‘”๐‘ง ๐‘๐‘ง

๐‘Ÿ๐‘‹ + ๐‘Ÿ๐‘Œ + ๐‘Ÿ๐‘ 0 00 ๐‘”๐‘‹ + ๐‘”๐‘Œ + ๐‘”๐‘ 00 0 ๐‘๐‘‹ + ๐‘๐‘Œ + ๐‘๐‘

Page 38: Cameras and Image Processing

Chromatic adaptation

โ€ข Estimating the appearance of a sample under a different illuminantโ€“ Convert between different

white points

โ€ข LMS color spaceโ€“ Response of the three types of

cones in the human eyeโ€ข Long, medium, and short

wavelengths

โ€ข XYZ to LMSโ€“ Bradford transformation

matrix

โ€ข Chromatic adaptationโ€“ Adaptation matrix

CSE 291, Spring 2020 38

Page 39: Cameras and Image Processing

Color mapping (using chromaticities)

โ€ข Image 1 to image 2โ€“ Calculate transformation matrix from image 1 RGB to XYZ

(M_RGB1_to_XYZ1) and transformation matrix from image 2 RGB to XYZ (M_RGB2_to_XYZ2)โ€ข White points in XYZ are the same as in RGB

โ€“ If white points are the sameโ€ข M_RGB1_to_RGB2 = inv(M_RGB2_to_XYZ2) * M_RGB1_to_XYZ1

โ€“ Else (white points are different, include chromatic adaptation)โ€ข Bradford transformation matrix (M_XYZ_to_LMS)โ€ข Map white points to LMS and calculate adaptation matrix

(M_LMS1_to_LMS2)โ€ข Compose transformation matrices

โ€“ M_RGB1_to_RGB2 = inv(M_RGB2_to_XYZ2) * inv(M_XYZ_to_LMS) * M_LMS1_to_LMS2 * M_XYZ_to_LMS * M_RGB1_to_XYZ1

CSE 291, Spring 2020 39

Page 40: Cameras and Image Processing

Note: luminance Y and luma Yโ€™

โ€ข Luminance is calculated from linear RGB

โ€“ Y coordinate of XYZ

โ€ข Luma is calculated from nonlinear Rโ€™Gโ€™Bโ€™

โ€ข Example: sRGBY = 0.21263903 * R + 0.71516871 * G + 0.072192319 * B

Yโ€™ = 0.21263903 * Rโ€™ + 0.71516871 * Gโ€™ + 0.072192319 * Bโ€™

(Coefficients are the middle row of M_RGB_to_XYZ)

CSE 291, Spring 2020 40

Page 41: Cameras and Image Processing

Remember

โ€ข Common video and image standards use nonlinear encoding and may use different chromaticities

โ€ข Chromaticities define gamuts that contain a percent of the visible colorsโ€“ Some contain more than others

โ€ข Mapping pixel data between these standards requires mapping to the XYZ color space and possibly the LMS color space

โ€ข Luminance is different than luma

CSE 291, Spring 2020 41