vc 15/16 tp3 digital images - dccmcoimbra/lectures/vc_15... · vc 15/16 - tp3 - digital images...

31
Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 TP3 Digital Images Miguel Tavares Coimbra

Upload: others

Post on 18-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

Mestrado em Ciência de Computadores

Mestrado Integrado em Engenharia de Redes e

Sistemas Informáticos

VC 15/16 – TP3

Digital Images

Miguel Tavares Coimbra

Page 2: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Outline

• Sampling and quantization

• Data structures for digital images

• Histograms

Acknowledgements: Most of this course is based on the excellent courses offered by Prof. Shree Nayar at

Columbia University, USA and by Prof. Srinivasa Narasimhan at CMU, USA. Please acknowledge the original

source when reusing these slides for academic purposes.

Page 3: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Topic: Sampling and quantization

• Sampling and quantization

• Data structures for digital images

• Histograms

Page 4: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Lighting

Scene

Camera

Computer

Scene Interpretation

Components of a Computer Vision System

Page 5: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Digital Images

What we see What a computer sees

Page 6: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Pinhole and the Perspective

Projection

(x,y)

screen

scene

Is an image being formed

on the screen?

YES! But, not a “clear” one.

image plane

effective focal length, f’ optical

axis

y

x

z

pinhole

),,( zyxr

z

y

f

y

z

x

f

x

'

'

'

'

zf

rr

'

')',','(' fyxr

Page 7: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Simple Image Model

• Image as a 2D light-

intensity function

• Continuous

• Non-zero, finite value Intensity

Position

[Gonzalez & Woods]

),(0 yxf

),( yxf

Page 8: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Analog to Digital

The scene is:

– projected on a 2D

plane,

– sampled on a regular

grid, and each

sample is

– quantized (rounded

to the nearest

integer) jifjif ,Quantize,

Page 9: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Images as Matrices

• Each point is a pixel

with amplitude:

– f(x,y)

• An image is a matrix

with size N x M

M = [(0,0) (0,1) …

[(1,0) (1,1) …

(0,0) (0,N-1)

(M-1,0)

Pixel

Page 10: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Sampling Theorem

Continuous signal:

Shah function (Impulse train):

xf

x

Sampled function:

n

s nxxxfxsxfxf 0

xs

x0x

n

nxxxs 0

Page 11: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Sampling Theorem

Sampled

function:

n

s nxxxfxsxfxf 0

FS u F u S u F u 1

x0 u

n

x0

n

uF

maxu

A

u

uFS

maxu

0xA

0

1x

u

Only if 0

max2

1

xu

Sampling

frequency 0

1

x

Page 12: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Nyquist Theorem

If

0

max2

1

xu

uFS

maxu

0xA

0

1x

u

Aliasing

Sampling frequency must be greater than max2u

Page 13: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Aliasing

Picket fence receding

into the distance will

produce aliasing…

Input signal:

x = 0:.05:5; imagesc(sin((2.^x).*x))

Matlab output:

WHY?

Page 14: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Quantization

• Analog:

• Digital: Infinite storage space per pixel!

• Quantization

),(0 yxf

Page 15: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Quantization Levels

• G - number of levels

• m – storage bits

• Round each value to

its nearest level

mG 2

Page 16: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Effect of quantization

Page 17: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Effect of quantization

Page 18: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Image Size

• Storage space

– Spatial resolution: N x M

– Quantization: m bits per pixel

– Required bits b:

• Rule of thumb:

– More storage space means more image

quality

mMNb

Page 19: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Image Scaling

This image is too big to

fit on the screen. How

can we reduce it?

How to generate a half-

sized version?

Page 20: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Sub-sampling

Throw away every other row and

column to create a 1/2 size image

- called image sub-sampling

1/4

1/8

Page 21: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Sub-sampling

1/4 (2x zoom) 1/8 (4x zoom) 1/2

Page 22: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Topic: Data structures for digital

images

• Sampling and quantization

• Data structures for digital images

• Histograms

Page 23: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Data Structures for Digital Images

• Are there other ways to represent digital

images?

What we see What a computer sees

Page 24: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Chain codes

• Chains represent the

borders of objects.

• Coding with chain

codes.

– Relative.

– Assume an initial

starting point for each

object.

• Needs segmentation!

Freeman Chain

Code

Using a Freeman Chain Code and

considering the top-left pixel as

the starting point:

70663422

Page 25: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Topological Data Structures

• Region Adjacency

Graph

– Nodes - Regions

– Arcs – Relationships

• Describes the

elements of an image

and their spatial

relationships.

• Needs segmentation!

Region Adjacency Graph

Page 26: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Relational Structures

• Stores relations

between objects.

• Important semantic

information of an

image.

• Needs segmentation

and an image

description (features)!

Relational Table

Page 27: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Topic: Histograms

• Sampling and quantization

• Data structures for digital images

• Histograms

Page 28: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Histograms

• “In statistics, a

histogram is a

graphical display of

tabulated

frequencies.”

[Wikipedia]

• Typically represented

as a bar chart:

Page 29: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Image Histograms

• Colour or Intensity distribution.

• Typically: – Reduced number of

bins.

– Normalization.

• Compressed representation of an image. – No spatial information

whatsoever!

Page 30: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Colour Histogram

• As many histograms

as axis of the colour

space.

Ex: RGB Colour space

- Red Histogram

- Green Histogram

- Blue Histogram

• Combined histogram.

Red

Green

Blue

Page 31: VC 15/16 TP3 Digital Images - DCCmcoimbra/lectures/VC_15... · VC 15/16 - TP3 - Digital Images Pinhole and the Perspective Projection (x,y) screen scene Is an image being formed on

VC 15/16 - TP3 - Digital Images

Resources

• R. Gonzalez, and R. Woods – Chapter 2