Image processing

In computer graphics, image scaling is the .... Def:'modify'the'pixels'in'an'image' .... Institut Pascal. T. Chateau. 68. Basic'operators:'closing. Before. After. 68 ...
4MB taille 11 téléchargements 628 vues
Image processing

Content

2011

1 Image representation 2 Image Filtering 3 Morphological transformations

1

T. Chateau

2

T. Chateau

Institut Pascal

1

Image Representation

2

Image Representation

The'image'model'used'here:

What'is'an'image?

f : [0, L

several'possible'defini/ons' • computer'point'of'view':'unsigned'char'table • Physicist:'observa/on'of'an'environment'by'an'op/cal'

1] ⇤ [0, M ]p I = f (x, y)

With':' • L:'number'of'lines'(height) • C:'number'of'columns'(width) ' 2 Np •M • p'='1'for'a'luminance'image'(grey'level) • p'='3'for'a'color'image'(RGB,'HSV,'...)

sensor'(2D'digi/zed'signal)

• Mathema/cian:'the'projec/on'of'a'3D'space'on'a' plane

• ...

T. Chateau

1] ⇥ [0, C

3

T. Chateau

Institut Pascal

3

4

Institut Pascal

4

Image Representation

Image Representation

Distance between two pixels

Pixels, neighbourhood, and distances

Each pixel can be localised by its co-ordinates (x,y) into the image plane. Distances between pixels may be defined A distance measure must have the following properties:

d(P, Q) > 0 d(P, Q) = d(Q, P ) Triangle

Square

Hexagonal

d(P, Q)  d(P, R) + d(R, Q)

5

T. Chateau

6

T. Chateau

Institut Pascal

Institut Pascal

5

Image Representation

6

Image Representation

Principal'distances • Manathan'distance'' d1 (P, Q) = |xp

• Euclidian'distance

d2 (P, Q) = (xp

Neighbourhood

xq | + |yp xq )2 + (yp

yq | yq )2

0.5

• Chessboard'distance d1 (P, Q) = max(|xp T. Chateau

xq |, |yp

Vk (p) = {Q : 0 < d(P, Q)  k}

yq |)

7

T. Chateau

Institut Pascal

7

8 Institut Pascal

8

Image Representation

Image Representation

Image'Scaling

Image'Scaling

bi-linear interpolation

Knn

In computer graphics, image scaling is the process of resizing a digital image 9

T. Chateau

10

T. Chateau

Institut Pascal

Institut Pascal

9

Image Representation

10

Image Representation

Image'Scaling

Image'Scaling

bi-linear interpolation

T. Chateau

bi-linear interpolation 11

T. Chateau

Institut Pascal

11

12 Institut Pascal

12

Image Representation

Image Representation

Image'Scaling Without

With

T. Chateau

bi-cubic interpolation

13

14

T. Chateau

Institut Pascal

Institut Pascal

13

Image Representation

14

Image Representation

Color'images

Addi/f'model'RGB'(Red,' Green,'Blue)

• Images'are'generaly'modelized'by'a'3'components' vector

• Many'color'spaces'exist'(RGB,'HSV,'Lab,'YCrCb,' YUV,'...)

• Only'two'of'them'are'presented'hereaXer' T. Chateau

15

T. Chateau

Institut Pascal

15

16 Institut Pascal

16

Image Representation

Image Representation

Addi/f'model'RGB'(Red,' Green,'Blue)

T. Chateau

Addi/f'model'RGB'(Red,' Green,'Blue)

17

18

T. Chateau

Institut Pascal

Institut Pascal

17

Image Representation

Image Representation

HSV'model:'[Hue,'Satura/on,'Value]

• • •

HSV'model:'[Hue,'Satura/on,'Value]

Value'is'the'grey'level' (luminance) Hue'(wavelength)'is'measured' by'the'angle'along'the'value' axis. Satura*on'is'the'module'of' the'normal'vector'along'the' value'axis

• T. Chateau

18

chroma/c'cube'observed'from' the'white'color Lateral'view'of'HSV'hexagon 19

T. Chateau

Institut Pascal

19

20 Institut Pascal

20

Image Representation

Image Representation

HSV'model:'[Hue,'Satura/on,'Value]

HSV'model:'[Hue,'Satura/on,'Value]

Constant'brightness

Constant'satura/on

21

T. Chateau

22

T. Chateau

Institut Pascal

Institut Pascal

21

Image Representation

22

Image Representation

HSV'decomposi/on

HSV'model:'[Hue,'Satura/on,'Value] Constant'hue

T. Chateau

23

T. Chateau

Institut Pascal

23

24 Institut Pascal

24

Image Representation

Content

Addi/onal'informa/on'on'color' images 1 Image representation 2 Image filtering 3 Morphological transformations

The Colour Image Processing Handbook Sangwine, Stephen J.; Horne, Robin E.N. (Eds.) 1998, 456 p. 1

Hardcover, ISBN 978-0-412-80620-9

P. Bonton et al. Lasmea ISBN : 2-10-006843-1 in French

T. Chateau

25

T. Chateau

Institut Pascal

26 Institut Pascal

25

Image Filtering

Image Filtering: Global Methods

The'same'func/on'is'applied'on'all'the' pixels H(x) = Card{p : I(p) = x}

methods'are'divided'into'two'main' categories

•Global'methods'(the'same'func/on'

Histogram:'a' basic'tool'for' global'filtering

is'applied'on'all'the'pixels)

•Local'methods'(the'func/on'applied' to'one'pixel'is'related'to'it' neighbourhood) T. Chateau

26

27

T. Chateau

Institut Pascal

27

28 Institut Pascal

28

Image Filtering: Global Methods

Image Filtering: Global Methods

Histogram:'some'examples

Global'transforma/ons filtered image 255

0

255 Input image

29

T. Chateau

30

T. Chateau

Institut Pascal

Institut Pascal

29

Image Filtering: Global Methods

30

Image Filtering: Global Methods

histogram'stretching'

histogram'stretching' filtered image 255

0 min

max 255 input image

T. Chateau

31

T. Chateau

Institut Pascal

31

32 Institut Pascal

32

Image Filtering: Global Methods

Image Filtering: Global Methods

histogram'equaliza/on'

histogram'equaliza/on'

33

T. Chateau

34

T. Chateau

Institut Pascal

Institut Pascal

33

Image Filtering: Global Methods binary image

binariza/on

34

Image Filtering: Global Methods

And'many'other'transforma/ons:

255

✓stretching 0

threshold

✓equaliza/on

255 Input image

✓Area'extrac/on' ✓Inverted'image' ✓Gamma'correc/on ✓…

T. Chateau



35

T. Chateau

Institut Pascal

35

36 Institut Pascal

36

Image Filtering: Spatial Methods

Image Filtering: Spatial Methods

Spatial Methods

Spatial Methods

Def:'modify'the'pixels'in'an'image' based'on'some'func/on'of'a'local' neighborhood'of'the'pixels'

Def:'modify'the'pixels'in'an'image' based'on'some'func/on'of'a'local' neighborhood'of'the'pixels'

I2 (x) = f (I1 (x), VI1 (x)) T. Chateau

I2 (x) = f (I1 (x), VI1 (x)) 37

T. Chateau

Institut Pascal

38 Institut Pascal

37

Image Filtering: Spatial Methods

38

Image Filtering: Spatial Methods

Linear'based'filters:

Spatial Methods

Two'categories:

✓The'simplest ✓Replace'each'pixel'by'a'linear'combina/on'of'its'

neighbors.'

✓linear'based'filters,

✓'The'prescrip/on'for'the'linear'combina/on'is'

called'the'“convolu/on'kernel”

✓non^linear'based'filters.

T. Chateau

39

T. Chateau

Institut Pascal

39

40 Institut Pascal

40

Image Filtering: Spatial Methods

Image Filtering: Spatial Methods

Some'classic'kernels'(average'operators) 0 1 1 1 1 1 W1 = @1 1 1A 9 0 1 1 1 1 1 1 1 1 @1 2 1A W1 = 10 0 1 1 1 1 1 2 1 1 @2 4 2A W1 = 16 1 2 1

Let'W'be'the'kernel'(matrix)'of'size' [^n,n]x[^m,m]' X I2 (x) = W (u)I1 (x + u) u2W

T. Chateau

41

42

T. Chateau

Institut Pascal

Institut Pascal

41

Image Filtering: Spatial Methods

42

Image Filtering: Spatial Methods

Some'classic'kernels'(average'operators)

Classic'kernels'(Gaussian'filter)

Average (neighbourhood) 5x5

W1 (i, j) = C exp

T. Chateau

43

T. Chateau

Institut Pascal

43

i +j 2 2 2

2

!

44 Institut Pascal

44

Image Filtering: Spatial Methods

Image Filtering: Spatial Methods

Classic'kernels'(Gaussian'filter)

Classic'kernels'(Shen^Castan)

Gaussian (sig = 3 and support = 5x5)

W1 (i, j) = C exp

45

T. Chateau

46

T. Chateau

Institut Pascal

! |i| + |j| b

Institut Pascal

45

Image Filtering: Spatial Methods

Image Filtering: Spatial Methods

Gradient'approxima/on'kernels'(Sobel' filter)

0

Horizontal

1 @ 0 W1 = 1 T. Chateau

2 0 2

1 1 0A 1

46

Gradient'approxima/on'kernels'(Sobel' filter)

Vertical

0

1 W2 = @ 2 1

1 1 2A 1

0 0 0

W2 = W1T

Horizontal 47

T. Chateau

Institut Pascal

47

23

Vertical 48 Institut Pascal

48

Image Filtering: Spatial Methods

Image Filtering: Spatial Methods

Gradient'approxima/on'kernels' (Laplacian'filter)

Gradient'approxima/on'kernels' (Laplacian'filter)

@2I @2I L(x, y) = + @x2 @y 2 Approximated'by: 0

0 @ 1 W1 = 0 T. Chateau

1 4 1

1 0 1A 0

0

1 @ 1 W1 = 1

1 1 1A 1

1 8 1 49

50

T. Chateau

Institut Pascal

Institut Pascal

49

Image Filtering: Spatial Methods

50

Image Filtering: Spatial Methods

Linear'filters:'Some'proper/es'(separable' filters)

Linear'filters:'Some'proper/es'(separable' filters)

I2 (x, y) = I1 (x, y) ⇤ Hxy (x, y) If Hx,y (x, y) = H1x (x) ⇤ H2y (y)

a b

Then I2 (x, y) = [I1 (x, y) ⇤ H1x (x)] ⇤ H2y (y) T. Chateau

51

T. Chateau

Institut Pascal

51

0 1 0 2 a a a ⇤ @ b A = @ab a a2

ab b2 ab

1 a2 abA a2 52

Institut Pascal

52

Image Filtering: Spatial Methods

Image Filtering: Spatial Methods

Linear'filters:'Some'proper/es'(separable' filters)

Non4linear4filters

Exercise:'show'that'the'following'filters' are'separable

^'Calcula/on'within'the'kernel'is'defined'by'non^ linear'mathema/cal'and''sta/s/cal'opera/ons'

^'Mathema/cal'Neighborhood'Operators

^'Sobel'filter'

•'Minimum''

^'Gaussian'filter

•'Median

•'Maximum'' •'Range •'Majority'' •'Standard'devia/on,'...

T. Chateau

53

54

T. Chateau

Institut Pascal

Institut Pascal

53

Image Filtering: Spatial Methods

54

Image Filtering: Spatial Methods

Median4filter Input

Mean

Median4filter ^'Robust'Filter

Can be computed using a quick sort algorithm

^'Non^linear'opera/on ^'Each'pixel'is'modified'according'to'the' median'value'of'it'neighbourhood'

T. Chateau

Median

55

T. Chateau

Institut Pascal

55

56 30

Institut Pascal

56

Image Filtering: Spatial Methods

Content

Median4filter

1 Image representation 2 Image filtering 3 Morphological transformations

58

T. Chateau

Institut Pascal

57

Binary image filtering: Mathematical morphology

58

Binary image filtering: Mathematical morphology What can we do with MM ?

MM'was'originally'developed'for'binary' images,'and'was'later'extended'to' grayscale'func/ons'and'images born'in'1964'from'the'collabora/ve'work' of'Georges4Matheron'and'Jean4Serra,'at' the'École&des&Mines'de'Paris,'France

Remove noise separate shapes compare shapes T. Chateau

59

T. Chateau

Institut Pascal

59

60 Institut Pascal

60

Binary image filtering: Mathematical morphology

Binary image filtering: Mathematical morphology

Main'idea:''probe'an'image'with'a'simple,'pre^ defined'shape,'drawing'conclusions'on'how'this' shape'fits'or'misses'the'shapes'in'the'image.'

Some structuring elements

This'simple'"probe"'is'called'structuring'element,' and'is'itself'a'binary'image'(i.e.,'a'subset'of'the' space'or'grid).

61

T. Chateau

62

T. Chateau

Institut Pascal

Institut Pascal

61

62

Binary image filtering: Mathematical morphology

Binary image filtering: Mathematical morphology

Basic'operators:'erosion

Basic'operators:'dila/on

Erosion of the binary image A by the structuring element B:

A

Before

SE

After

Dilation of the binary image A by the structuring element B:

B = {z 2 E|Bz ✓ A}

A

translation of B by z

T. Chateau

SE

Before

After

B = {z 2 E|(B s )z \ A 6= ?} symmetric of B

63

T. Chateau

Institut Pascal

63

64 Institut Pascal

64

Binary image filtering: Mathematical morphology

Binary image filtering: Mathematical morphology

Example

Example

Initial image

eroded 1 time

Initial image

dilated 1 time

eroded 2 times

eroded 3 times

dilated 2 times

dilated 3 times

65

T. Chateau

66

T. Chateau

Institut Pascal

Institut Pascal

65

66

Binary image filtering: Mathematical morphology

Binary image filtering: Mathematical morphology

Basic'operators:'opening

Basic'operators:'closing

Before

A B = (A

T. Chateau

B)

After

Before

A • B = (A

B

67

T. Chateau

Institut Pascal

67

B)

After

B

68 Institut Pascal

68

Binary image filtering: Mathematical morphology

Binary image filtering: Mathematical morphology

Basic'operators:'opening Initial image

Basic'operators:'closing opening

Initial image

69

T. Chateau

closing

70

T. Chateau

Institut Pascal

Institut Pascal

69

Binary image filtering: Mathematical morphology

Binary image filtering: Mathematical morphology

Some'proper/es

Basic'operators:'opening+closing Initial image

70

A

result

B⇢A⇢A

B

A B ⇢A⇢A•B

A (A B) = A B A • (A • B) = A • B

T. Chateau

71

T. Chateau

Institut Pascal

71

72 Institut Pascal

72

Binary image filtering: Mathematical morphology

Image Processing

Exercices

References

histogram stretching (0