95
Colour an algorithmic approach Thomas Bangert [email protected] MSc in Computer Sciency by Research. Project Viva

C o lo ur an algorithmic approach

  • Upload
    hamlin

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

MSc in Computer Sciency by Research. Project Viva. C o lo ur an algorithmic approach. Thomas Bangert [email protected]. understanding how visual system process information. Visual system: about 30% of cortex most studied part of brain best understood part of brain. Image sensors. - PowerPoint PPT Presentation

Citation preview

Page 1: C o lo ur an algorithmic approach

Colouran algorithmic approach

Thomas [email protected]

MSc in Computer Sciency by Research. Project Viva

Page 2: C o lo ur an algorithmic approach

understanding how visual system process information

Visual system: • about 30% of cortex• most studied part of

brain• best understood part

of brain

Page 3: C o lo ur an algorithmic approach

Image sensors Binary sensor array

Luminance sensor array

Multi-Spectral sensor array

Page 4: C o lo ur an algorithmic approach

Where do we start?We first need a model of what light information means.

Any visual system starts with a sensor:

What kind of information do these sensors produce?

Let’s first look at sensors we have designed!

Page 5: C o lo ur an algorithmic approach

Sensors we buildX

Y

Page 6: C o lo ur an algorithmic approach

The Pixel

Sensors element may be:

Binary Luminance RGB

The fundamental unit of information!

Page 7: C o lo ur an algorithmic approach

The Bitmap

2-d space

represented by integer array

0 1 2

0

1

Page 8: C o lo ur an algorithmic approach

What information is produced?

2-d array of pixels:

Black & White Pixel:– single luminance

value, usually 8 bit Colour Pixel

– 3 colour values, usually 8-bit

Page 9: C o lo ur an algorithmic approach

Where we need to start: the fundamentals of the sensor

?

Page 10: C o lo ur an algorithmic approach

Human Visual

System (HVS)

The fundamentals!

Page 11: C o lo ur an algorithmic approach

The Sensor2 systems: day-sensor & night-sensor

To simplify: we ignore night sensor system

Cone Sensors very similar to RGB sensors we design for cameras

Page 12: C o lo ur an algorithmic approach

BUT: sensor array is not ordered

arrangement is random

note:very few blue sensors, none in the centre

Page 13: C o lo ur an algorithmic approach

sensor pre-processing circuitry

Page 14: C o lo ur an algorithmic approach

First Question: What information is sent from sensor array

to visual system?

Very clear division between sensor & pre-processing (Front of Brain) andvisual system (Back of Brain) connected with very limited communication link

Page 15: C o lo ur an algorithmic approach

Receptive Fields

All sensors in the retina are organized into receptive fields

Two types of receptive field.Why?

Page 16: C o lo ur an algorithmic approach

What does a receptive field look like?

In the central fovea it is simply a pair of sensors.

Always 2 types:• plus-centre• minus-centre

Page 17: C o lo ur an algorithmic approach

What do retinal receptive fields do?

Produce an opponent value:simply the difference between 2 sensors

This means:it is a relative measure, not an absolute measure

andno difference = no information to brain

Page 18: C o lo ur an algorithmic approach

Sensor Input

Luminance Levels

it is usual to code 256 levels of luminanceLinear: YLogarithmic: Y’

Page 19: C o lo ur an algorithmic approach

Receptive Field Function

- - -- - -- - -

+ + ++ + ++ + +

- - -- - -- - -

- - -- - -- - -

- - -- - -- - -

- - -- - -- - -

- - -- - -- - -

- - -- - -- - -

- - -- - -- - -

+ + ++ + ++ + +

- - -- - -- - -

+ + ++ + ++ + +

+ + ++ + ++ + +

+ + ++ + ++ + +

+ + ++ + ++ + +

+ + ++ + ++ + +

+ + ++ + ++ + +

+ + ++ + ++ + +

Min Zone

Max-Min Function

Output is difference between average of center and max/min of surround Max

Zone

Tip of Triangle

Page 20: C o lo ur an algorithmic approach

Dual Response to gradients

Why?

Often described assecond derivative/zero crossing

Page 21: C o lo ur an algorithmic approach

Abstracted

Neurons only produce positive values.Dual +/- produces positive & negative values.

Together: called a channelProduces signed values.

Co-ordinate

Y 0

Page 22: C o lo ur an algorithmic approach

Human Sensor Responseto monochromatic light stimuli

350 400 450 500 550 600 650 7000

10

20

30

40

50

60

70

80

90

100

Wavelength (nm)

Abso

rptio

n (%

)

RGB

Page 23: C o lo ur an algorithmic approach

HVS Luminance Sensor IdealizedSe

nsor

Valu

e

Wavelength(λ)λ

0.8

0.6

0.2

0.0

1.0

0.4

λ+δλ−

A linear response in relation to wavelength.Under ideal conditions can be used to measure wavelength.

Page 24: C o lo ur an algorithmic approach

Spatially Opponent

HVS:Luminance is always measured by taking the difference between two sensor values.Produces: contrast value

Sens

or V

alue

Wavelength(λ)λ

0.8

0.6

0.2

0.0

1.0

0.4

λ+δλ−

Sens

or V

alue

Wavelength(λ)λ

0.8

0.6

0.2

0.0

1.0

0.4

λ+δλ−

Which is done twice, to get a signed contrast value

Page 25: C o lo ur an algorithmic approach

Moving from Luminance to Colour

• Primitive visual systems were in b&w• Night-vision remains b&w

• Evolutionary Path– Monochromacy– Dichromacy (most mammals – eg. the

dog)– Trichromacy (birds, apes, some monkeys)

• Vital for evolution: backwards compatibility

Page 26: C o lo ur an algorithmic approach

Electro-Magnetic Spectrum

Visible Spectrum

Visual system must represent light stimuli within this zone.

Page 27: C o lo ur an algorithmic approach

Colour Vision Young-Helmholtz

Theory

Argument:Sensors are RGB thereforeBrain is RGB

3 colour model

Page 28: C o lo ur an algorithmic approach

Hering colour opponency model

Fact: we never see reddish green or yellowish blue.

Therefore:colours must be arranged in opponent pairs:

RedGreenBlueYellow

4 colour model

Page 29: C o lo ur an algorithmic approach

HVS Colour Sensorsresponse to monochromatic light

350 400 450 500 550 600 650 7000

10

20

30

40

50

60

70

80

90

100

Wavelength (nm)

Abso

rptio

n (%

)

RGB

Page 30: C o lo ur an algorithmic approach

How to calculate spectral frequency with 2 luminance sensors.

Sens

or V

alue

Wavelength

0.8

0.6

0.2

0.0

1.0

0.4

λ-δ λ λ+δ

RG

𝑓 =𝑅−𝐺Roughly speaking:

Page 31: C o lo ur an algorithmic approach

the ideal light stimulusSe

nsor

Val

ue

Wavelength

0.8

0.6

0.2

0.0

1.0

0.4

λ-δ λ λ+δ

RG Monochromatic Light

Allows frequency to be measured in relation to reference.

Page 32: C o lo ur an algorithmic approach

Problem:natural light is not ideal

Sens

or V

alue

Wavelength

0.8

0.6

0.2

0.0

1.0

0.4

λ-δ λ λ+δ

RG

• Light stimulus might not activate reference sensor fully.

• Light stimulus might not be fully monochromatic.

ie. there might be white mixed in

Page 33: C o lo ur an algorithmic approach

Sens

or V

alue

Wavelength(λ, in nm)400300 430 460 490 520 550 580 610 640 670 700

0.8

0.6

0.2

0.0

1.0

0.4

Solution:

A 3rd sensor is used to measure equiluminance.

Which is subtracted.

Then reference sensor can be normalized

Page 34: C o lo ur an algorithmic approach

Equiluminance & Normalization

Also called Saturation and Lightness.

• Must be removed first – before opponent values calculated.

• Then opponent value = spectral frequency

• Values must be preserved – otherwise information is lost.

Page 35: C o lo ur an algorithmic approach

a 4 sensor designSe

nsor

Val

ue

Wavelength(λ, in nm)400300 430 460 490 520 550 580 610 640 670 700

0.8

0.6

0.2

0.0

1.0

0.4

2 opponent pairs• only 1 of each pair can be active• min sensor is equiluminance

𝑓 =⟨𝑅−𝐺 ,𝐵−Ψ ⟩

Page 36: C o lo ur an algorithmic approach

What does a colour opponent channel look like?

luminance contrast opponent channel

each colour opponent channel codes for 2 primary colours

Total of 4 primary colours

Page 37: C o lo ur an algorithmic approach

What is Colour?Colour is calculated exactly the same as luminance contrast. The only difference is spectral range of sensors is modified.Colour channels are: RGBY

Uncorrected colour values are contrast values.But with white subtracted and normalized:Colour is Wavelength!

Page 38: C o lo ur an algorithmic approach

How many sensors?

4 primary colours require 4 sensors!

Page 39: C o lo ur an algorithmic approach

Human Retina only has 3 sensors!What to do?

Because of opponency when R=G, RG colour channel is 0.

Why not pair RG and reuse it as a Yellow sensor!

Yellow can be R=G

Page 40: C o lo ur an algorithmic approach

How do we abstract information from sensor array?

Luma (Y’)Red-Green (CB)Blue-Yellow (CR)

Page 41: C o lo ur an algorithmic approach

Luminance + 2 colour values+ 2 sensor correction values

Chroma BlueChroma Red

YC

C 0

B

R

0 + Lightness + Saturation

Page 42: C o lo ur an algorithmic approach

400 500 600 700 8000

1000

2000

3000

4000

Intensity(Counts)

Wavelength (nanomet res)

1

2

4

5 12

67

8 910

11 13 14

15 1617 18 19

20 21 22

3

Tri-Phosphor Lightingoptimised for perception of ‘white’

ROYGBV380

450

495

570

590

620

750

Page 43: C o lo ur an algorithmic approach

Primary Colours matched to spectrum

ROYGBV380

450

495

570

590

620

750

Page 44: C o lo ur an algorithmic approach

Testing Colour Opponent model

What we should see

What we do see

Unfortunately it does not matchThere is Red in our Blue

Page 45: C o lo ur an algorithmic approach

The strange case of Ultra-VioletLight with frequency of 400nm is ultra-blueRed sensor is at opposite of spectrum & not stimulated.Yet we see ultra-violet – which is Blue + Red…and the more we go into UV the more red

Page 46: C o lo ur an algorithmic approach

Colour Matching Data (CIE 1931)(indirect sensor response)

a very odd fact – a virtual sensor

response

Page 47: C o lo ur an algorithmic approach

350 400 450 500 550 600 650 7000

10

20

30

40

50

60

70

80

90

100

Wavelength (nm)

Abso

rptio

n (%

)RGB

Pigment Absorption Data of human cone sensors

350 400 450 500 550 600 650 7000

10

20

30

40

50

60

70

80

90

100

Wavelength (nm)

Abso

rptio

n (%

)

RGB

Red > Green

Page 48: C o lo ur an algorithmic approach

Therefore:HVS colour representation must be circular!

Which is not a new idea, but not currently in fashion.

540nm

620nm

480nm

Page 49: C o lo ur an algorithmic approach

Dual Opponency with Circularity

an ideal model using 2 sensor pairs

Sens

or V

alue

Wavelength(λ, in nm)400300 430 460 490 520 550 580 610 640 670 700

0.8

0.6

0.2

0.0

1.0

0.4

Page 50: C o lo ur an algorithmic approach

Colour Wheel

Goethe & Munsell

Colours are represented by a single value: Hue

Page 51: C o lo ur an algorithmic approach

RYB Colour Circle

no longer used

Yellow-orange

Yellow-green

Red-orange

Red-violet

Blue-violet

Blue-green

Red

Green

Violet

Blue

Orange

Yellow

Page 52: C o lo ur an algorithmic approach

HSL (Hue + S & L)Circular colour coding

Any colour represented by 1 number

Allows colour arithmetic 240°

120°60°

180°

300°

R=255G=0B=0

R=255G=255B=0

R=0G=255B=0

R=0G=255B=255

R=0G=0B=255

R=255G=0B=255

Page 53: C o lo ur an algorithmic approach

HSL & HSV

• Simple & Elegant• But it is flawed:

– simple transformation of RGB– colours do not match perception

• Why?

Because there are 4 primary colours, not 3!

Page 54: C o lo ur an algorithmic approach

gives us a 2-d colour space

CB

CR

Colour Information: 2 independent values

Page 55: C o lo ur an algorithmic approach

2-d space:

• Cartesian coordinates

or

• polar coordinates

Co-ordinate systems

BR CCr + arctan B

R

CC

(0,0)

(2,3)

CR

CB

0 1 L

θr

(3.6, 56.3º)

Page 56: C o lo ur an algorithmic approach

… requires 2 independent channels which give 4 primary colours

Yellow added as a primary!

Which allows a simple transform to circular representation

180°0°

90°45°

135°

315°

270°

225°

Page 57: C o lo ur an algorithmic approach

Opponent Values HueA simple transform from 2 opponent values to a single hue value

How might HVS do this?we keep 2 colour channels but link them

180°0°

90°45°

135°

315°

270°

225°

0

+64

+127

R = 255 G = 0 B = 128

Y - +

Ψ B

CG R

180°0°

90°45°

135°

315°

270°

225°

Page 58: C o lo ur an algorithmic approach

Travelling the Colour Wheel (Hue)

One Chroma channel is always at max or minThe other Chroma channel is incremented or decremented

Rules:if (CB==Max)CR--if (CR==Max)CB++if (CR==Min)CB--if (CB==Min)CR++

180°0°

90°45°

135°

315°

270°

225°

0

-127

+128

R = 255 G = 128 B = 0

Y - +

CB Ψ B

CR G R

0

-127

0

R = 255 G = 255 B = 0

Y - +

CB Ψ B

CR G R

+ -

Page 59: C o lo ur an algorithmic approach

Colour Wheel

Simple rule based system that cycles through the colour wheelAllows arithmetic operations on colour

180°0°

90°45°

135°

315°

270°

225°

0

0

+127

R = 255 G = 0 B = 0

Y - +

CB Ψ B

CR G R

0

+64

+127

R = 255 G = 0 B = 128

Y - +

CB Ψ B

CR G R

0

+127

+127

R = 255 G = 0 B = 255

Y - +

CB Ψ B

CR G R

0

+127

+64

R = 128 G = 0 B = 255

Y - +

CB Ψ B

CR G R

0

+127

0

R = 0 G = 0 B = 255

Y - +

CB Ψ B

CR G R

0

+127

-64

R = 0 G = 128 B = 255

Y - +

CB Ψ B

CR G R

0

+127

-127

R = 0 G = 255 B = 255

Y - +

CB Ψ B

CR G R

0

+127

-127

R = 0 G = 255 B = 0

Y - +

CB Ψ B

CR G R

0

+127

-127

R = 128 G = 255 B = 0

Y - +

CB Ψ B

CR G R

0

-127

0

R = 255 G = 255 B = 0

Y - +

CB Ψ B

CR G R

0

-127

+128

R = 255 G = 128 B = 0

Y - +

CB Ψ B

CR G R

0

-64

+127

R = 255 G = 128 B = 0

Y - +

CB Ψ B

CR G R

0

0

+127

R = 255 G = 0 B = 0

Y - +

CB Ψ B

CR G R

Page 60: C o lo ur an algorithmic approach

What is Hue?

Circular representation of spectrum

Its purpose is to provide a Spectrum Value

Primary Colours are the extreme ends of the 2 linked colour channels

0

0

+127

R = 255 G = 0 B = 0

Y - +

CB Ψ B

CR G R

0

0

-128

R = 0 G = 255 B = 0

Y - +

CB Ψ B

CR G R

0

+127

0

R = 0 G = 0 B = 255

Y - +

CB Ψ B

CR G R

0

-128

0

R = 255 G = 255 B = 0

Y - +

CB Ψ B

CR G R

180°0°

90°45°

135°

315°

270°

225°

Page 61: C o lo ur an algorithmic approach

Hue: 2 values or 12 linked values allow us to turn colour off.

(0,0) is not an allowed hue, used for no colour

Simple standard input pixel:– luminance value or – colour value

64

0

0

R = 128 G = 128 B = 128

Y - +

CB Ψ B

CR G R

Page 62: C o lo ur an algorithmic approach

Why do we need arithmetic on colour?

Colours are computed, not measured!

Page 63: C o lo ur an algorithmic approach

Colour is very useful for transparency

What is the colour?

Page 64: C o lo ur an algorithmic approach

Why do we need transparency?

otherwise we might have trouble with windows

Page 65: C o lo ur an algorithmic approach

… and difficulties with these kinds of tasks

Page 66: C o lo ur an algorithmic approach

Colour is very helpful in deciphering the layers

Aim: to reconstruct scenes with transparency

Page 67: C o lo ur an algorithmic approach

Y

X

It all must start with the right kind of sensor:

Format of ‘pixel’ as it enters visual area of brain for processing:

Y 0 Y C0

0

Luminance Information

Optional Colour Information• Where on spectrum• How colourful

Page 68: C o lo ur an algorithmic approach

visual systems with 4 sensors

• Birds• Reptiles• Dinosaurs• Therapsids (our

dinosaur-like ancestor)

about 60nm between sensors

evenly spaced frequencies narrowed

370 nm 445 nm 508 nm 565 nm

700 nm330 nm 400 nm 500 nm 600 nm

1.0

0.5

0.0

Page 69: C o lo ur an algorithmic approach

The Ideal Sensor

• Equally spaced on spectrum

• Overlap with linear transition

0.8

0.6

0.2

0.0

−5 −3 1 3 5

1.0

−1 0 2 4−2−4

y

0.8

0.6

0.2

0.0400 460 580 640

1.0

520 550 610 670490430

λ

0.4

0.8

0.6

0.2

0.0400 460 580 640

1.0

520 550 610 670490430

λ

0.4

0.8

0.6

0.2

0.0400 460 580 640

1.0

520 550 610 670490430

λ

0.4

colour channel 1: R - Gcolour channel 2: yellow - B

• No overlap of opponent pairs

Page 70: C o lo ur an algorithmic approach

spectrum is shifted toward more even spacing

445

555600

020406080100380 420 460 500 540 580 620 660 700

LMS

Absorption

424 530 560

Actual Sensor Response

Sensor Response calculated from CIE perceptual data

460 530 640

CRT RGB Phosphorsspectrum is shifted more towards even spacing

HVS Sensor

+ yellow almost equal distribution

Page 71: C o lo ur an algorithmic approach

a yellow sensor + a few tweaksmakes human vision equivalent to bird vision

• even spacing• 60nm between

primary colours• response

narrowed• intermediary

colours at half-way points

0.8

0.6

0.2

0.0

1.0

y0.4

400 460 580 640520 550 610 670490430

λrequires more processing, is less accurate, but is equivalent

Page 72: C o lo ur an algorithmic approach

How do we get a yellow sensor?

we re-use red & green sensors

0.8

0.6

0.2

0.0

1.0

y0.4

400 460 580 640520 550 610 670490430

&

but only when they are equal (R==G)This implies dividing by a measure of equality

( )f

R GyE+

Page 73: C o lo ur an algorithmic approach

Existing Circular Colour Systems:Munsell

colour wheel with5 primary colours

100 years oldquite close

Page 74: C o lo ur an algorithmic approach

Existing Circular Colour Systems:CIE L*a*b* & CIE L*C*h

L*a*b* is a colour opponent space

L*C*h is the transform to circular

4 primary coloursRed = 0°Yellow = 90 °Green = 180 °Blue = 270 °

Page 75: C o lo ur an algorithmic approach

Summary• Colour is based on contrast• HVS has a circular model of spectrum• Colour is a code for where on spectrum• 2 colour channels, bi-polar 4 primary

colours• 2 channels 2-d colour space• Simple transform to circular representation• Single variable represents all colours• Purpose is to allow systematic colour

transforms colour computation

Page 76: C o lo ur an algorithmic approach

References

Poynton, C. A. (1995). “Poynton’s Color FAQ”, electronic preprint.http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html

Bangert, Thomas (2008). “TriangleVision: A Toy Visual System”, ICANN 2008.

Goldsmith, Timothy H. (July 2006). “What birds see”. Scientific American: 69–75.

Neitz, Jay; Neitz, Maureen. (August 2008). “Colour Vision: The Wonder of Hue”. Current Biology 18(16): R700-r702.

Questions?

Page 77: C o lo ur an algorithmic approach

The problem with Yellow

Colour:an algorithmic

approach

Thomas [email protected]

Thomas BangertMSc in Computer Sciency by Research. Project Viva

Page 78: C o lo ur an algorithmic approach

Colour channels are pureOpponency means colour pairs are pure with respect to themselves.

It follows that a pure colour is achieved only when the other opponent channel is 0.

Reddest red only when B-RG is 0

Bluest blue only when R-G is 0and inversely

Page 79: C o lo ur an algorithmic approach

RGB is pureRed is reddest when G & B = 0 etc.

XYZ and LMS are not pure.

Sensors of visual system have a broad spectral response. They do not have a pure colour response.

Retinal processing produces pure colour channels from noisy and ambiguous data.

RGBRed: R=255, G=0, B=0Green: R=0, G=255, B=0Blue: R=0, G=0, B=255

Page 80: C o lo ur an algorithmic approach

YUV & YCBCR

Transforms

JPEG 2000 allows reversible simplification

Transform usually expressed in matrix form

JPEGwithout anything odd like ‘headroom’note: no negative numbers for JPEG, C+=128

(0.299 ) (0.587 ) (0.114 )(0.168736 ) (0.331264 ) (0.5 )(0.5 ) (0.418688 ) (0.081312 )

B

R

Y R G BC R G BC R G B

+ + + + +

2 ; ; ;4r b r

R G BY C B G C R G+ +

0.299 0.587 0.1140.147141 0.288869 0.43601

0.614975 0.514965 0.100010

Y RU GV B

Page 81: C o lo ur an algorithmic approach

Lets try some JPEG numbers:

not trivial ‘leakage’

0255

0

15084107R

B

RGB

YCC

25500

7643

127R

B

RGB

YCC

0255255

17943128R

B

RGB

YCC

00

255

29127

21R

B

RGB

YCC

Should be 127

Cyan

Page 82: C o lo ur an algorithmic approach

The Problem:

Colours channels are not pure.They should be!

Y 0 Y

CB R=G B

CR

200- 40+ 60G R

R = 80 G = 60

R255 0 0

G02550

B 0 0255

Magenta111127127

Cyan 195 127-128

RG255255 0

Cyan 0255255

Page 83: C o lo ur an algorithmic approach

YUV/YCRCB simplifiedA large number of transforms exist, most variations of YUV.Minor tweaks of transform from XYZ can lead to quite large differences. All of which work fine perceptually (meaning neurons are not that precise).Why not simplify?

1 23 3

Y R G +

12( )BC B Y

12( )RC R G

Page 84: C o lo ur an algorithmic approach

Chroma Blue

1 12 2

( )BC B yellow If there was a yellow sensor

We use R=G instead: which is (R+G)/2 but we want a value only when R=G

1 12 2

( )BC B RG

Page 85: C o lo ur an algorithmic approach

Yellow: the Chroma Blue correction factor

The less equal R and G are, the less yellow there should be.

So:Simply divide R by G to determine how close they are. The more equal they are the more active the ‘yellow’ sensor is.

12( )B BcfC B Y C

15

( 0)B Bif C Y Y C +

1 23 3

Y R G +

12( )RC R G

Bcf RC G

Page 86: C o lo ur an algorithmic approach

Transform back to RGB

Fully Reversible

Calculate R and G first, then Blue correction factor.

43

RR Y C +23

RG Y C

15

( 0)B Bif C Y Y C

Bcf RC G

2Bcf BB Y C C +

Page 87: C o lo ur an algorithmic approach

Samples of simple colour

transforms

Page 88: C o lo ur an algorithmic approach

Blue-Yellow set to 0

Page 89: C o lo ur an algorithmic approach

Red-Green inverted

Page 90: C o lo ur an algorithmic approach

Blue-Yellow

inverted

Page 91: C o lo ur an algorithmic approach

playing with colour

Page 92: C o lo ur an algorithmic approach

is easy

Page 93: C o lo ur an algorithmic approach

these are simple

transforms

Page 94: C o lo ur an algorithmic approach

not touched by

hand

Page 95: C o lo ur an algorithmic approach

YUV Summary

• Two simple tweaks allow us to correct conversion between RGB and YUV/YCRCB.

• Also allows conversion to be simplified.

15

( 0)B Bif C Y Y C Bcf RC G