• Aucun résultat trouvé

A FASTER INTRODUCTION TO IMAGE PROCESSING

N/A
N/A
Protected

Academic year: 2022

Partager "A FASTER INTRODUCTION TO IMAGE PROCESSING"

Copied!
85
0
0

Texte intégral

(1)

A FASTER INTRODUCTION TO IMAGE PROCESSING

… than early « »

thomas.grenier@insa-lyon.fr

(2)

IMAGE PROCESSING

(3)

WHAT IS AN IMAGE?

• Image definition

An image may be defined as a two-dimensional function, f(x,y)

x and y are spatial (plane) coordinates

the amplitude of f at any pair of coordinates (x,y) is called intensity or gray level of the image at that point

(4)

WHAT IS AN IMAGE?

• Digital Image definition

The definition of f may be extended:

as a n-dimensional function,

i.e. 3D: f(x,y,z) or image sequence f(x,y,t)

with amplitudes composed as a vector of data,

i.e. Color image: 3 components at each point, Complex number

f(x

1

,y

1

)= {217, 182, 167}

= { , , }

= { , , }

RGB

=

x

y

RBG image

(5)

FUNDAMENTAL STEPS IN DIP

Acquisition

Pre-processing

Low- and mid- level

Processing

Mid- and high- level

Problem domain

Extracted attributes

Image Image

Reconstruction Image restoration

Image filtering and enhancement Multiresolution processing

Segmentation

Morphological processing Image compression

Representation and description Measurements

Object recognition Image classification

Sensors

Lighting

Image formation

(6)

COMPONENTS OF AN IMAGE PROCESSING SYSTEM

Processor

DSP, computer

Problem domain

Image sensors

Image displays

Image processing

software

Mass Storage

Specialized image processing

hardware

network

JAI

6

(7)

LINEAR AND NONLINEAR OPERATIONS

• Important classification of an image-processing method

Is it a linear or a a nonlinear method ?

• Let H be a general operator

H is said to be a linear operator if

Tools: vector-matrix, PDE, set, and related operators (+,*, convolution)…

f ( x , y )g ( x , y )

H

     

) , ( )

, (

) , ( )

, ( )

, ( )

, (

y x g a y

x g a

y x f H a y

x f H a y

x f a y

x f a H

j j i

i

j j

i i

j j i

i

(8)

OPERATIONS ON IMAGES

• Arithmetic Operations

Application: Corrupted image g obtained by adding the noise η to a noiseless image f

assumptions :

at every pair of coordinates (x,y) the noise is uncorrelated

the noise has zero average value

Noise reduction by summing (averaging) a set of noisy images

 , , ,

) , ( )

, ( )

,

( x y f x y x y

g   

) , ( )

,

(

1 .

y x y

x

g

K

 

(9)

55 ,

3

45 ,

25

  18,3

5 ,

13

  11,6

1 2

6 4

Original

Application :

Noise Reduction

(10)

OPERATIONS ON IMAGES

• Spatial Operations - Single pixel operations

r: original intensity,

s: new intensity,

T: a transformation function

) ( r T s

Some basic grey-levels transformation functions used for image

enhancement

Range of intensities:

[0,L-1]

(11)

OPERATIONS ON IMAGES

• Spatial Operations - Single pixel operations

Example T(r)

r

255

0 255

Negative Original

(12)

• Examples

12

Mean = 100 Mean = 130

 20

Operations on images : Histogram

(13)

HISTOGRAM MANIPULATION

13

v=f(u) v

0 255 u

v=f(u)

(14)

OPERATIONS ON IMAGES

• Spatial Operations - Neighborhood operations

Sxy: set of coordinates of a neighborhood centered on a point (x,y) in an image f.

Neighborhood processing generates one corresponding pixel in the output image g at the same (x,y) coordinates.

The value of that pixel in g is determined by a operation involving the pixels in Sxy.

14

(15)

OPERATIONS ON IMAGES

• Spatial Operations - Neighborhood operations

-1, -1, -1, -1, -1 -1, -1, -1, -1, -1 -1, -1, 24, -1, -1 -1, -1, -1, -1, -1 -1, -1, -1, -1, -1

Mean of Sxy Sxy

Sxy

FIR filters…

Sxy

c r

c r n f

y m x g

) , (

) , . (

) 1 , (

(16)

OPERATIONS ON IMAGES

• Convolution



H l k

l j

k i

f l k h j

i g

) , (

) ,

( ) , ( )

, (

Output image

Convolution mask

Impulse response Input image

g(x,y) = h(x,y)*f(x,y)

(two-dimensional convolution)

i

j j

i

j+1 h i+1

f g

(17)

IMAGES TRANSFORMATION

• Previous methods work in spatial domain

• In some cases, image processing tasks are best formulated in a transform domain.

i.e. frequency  Fourier

 Many transformations exist

Transform Operation

R

Inverse transform

f(x,y) T(u,v) R[T(u,v)] g(x,y)

Spatial domain

Spatial domain Transform domain

(18)

IMAGES TRANSFORMATION

• A particularly important class of 2D linear transforms can be expressed in the general form



1

0 1

0

) ,

; , ( ).

, ( )

, (

M

x N

y

v u y x r y x f v

u T

Forward transformation kernel

Input image forward transform



1

0 1

0

) ,

; , ( ).

, ( )

, (

M

u N

v

v u y x s v u T y

x f

inverse transformation kernel

Forward transform Recovered image

Separable kernel:

Symmetric kernel:

) , ( ).

, ( )

, , ,

(x y u v r1 x u r2 y v

r

) , ( ).

, ( )

, , ,

(x y u v r1 x u r1 y v

r

(19)

IMAGES TRANSFORMATION, DFT

2-D Discrete Fourier Transform (DFT)

) / /

(

) 2

, , ,

(x y u v e j ux M vy N

r

) / /

(

1 2

) , , ,

( ej ux M vy N

v MN u

y x

s

Forward kernel Inverse kernel



1 0

1

0

) / /

(

).

2

, ( )

, (

M

x

N

y

N vy M ux

e

j

y x f v

u

T



1 0

1

0

) / /

(

).

2

, 1 (

) , (

M

x

N

y

N vy M ux

e

j

v u MN T

y x

f

Complex numbers…

Modulus and phase (angle)

(20)

f

i

f

j

High

frequency Sine images 2 Dirac delta functions

f

i

f

j

Low

frequency

(21)

Image example:

2-D Fourier transform

DFT modulus

phase DFT-1

(22)

Some basic DFTs

gauss

grid Weighted 2D Dirac comb

(23)

Notes on Phase influence

modulus phase modulus phase

DFT

(24)

GEOMETRIC AND SPATIAL TRANSFORMATIONS

• Spatial transformations

Example

Shrink image to half its size

Affine transform:

Homographic transform

Two cameras looking points on a plane : x,y,…z !

Higher order

( , )

( /2, /2)

) ' , '

(x yT x yx y

 

 

 

1 0 0 ].

1 , , [ 1 , ' , '

32 31

22 21

12 11

t t

t t

t t

y x y

x

x ' , y ' , 1 [ x , y , x ², y ², xy ,..., 1 ]. T

(25)

Affine transform

y y

x x

' ' 1

0 0

0 1 0

0 0 1

y c y

x c c x

c

y x y

x

. '

. ' 1

0 0

0 0

0 0

y x

y x

t y y

t x x t

t '

' 1

0 1 0

0 0 1 identity

scaling

translation

y y

y s x

sx x x

'

. '

1 0 0

0 1

0 0 1 Shear

(vertical)

x s y y

x s x

y y

. '

' 1

0 0

0 1 0

0 Shear 1

(horizontal)

x’= x

y’= y+0.5 x y’

x’

identity

scaling

translation

horizontal shearing y’

x’

y’

x’

y’

x’

(26)

Affine transform: rotation

35° degrees rotation (from image center)

1 0

0

0 cos

sin

0 sin

cos

Rotation T

Remark : interpolation is necessary to avoid aliasing

(27)

Higher order transforms

Applications :

Lens distortion correction, perspective

Orthoscopic projection

Barrel distortion

Pincushion distorsion

(28)

APPLICATION : IMAGE FILTRERING

(29)

NOISE CLEANING

• Many types of noise…

Gaussian Noise (sd 25)

Salt and pepper noise

(30)

LINEAR FILTERING

• Mean filter g i j h k l f i k j l

k l W

( , ) ( , ) ( , )

( , )

 

W: 25 neighbors H=(1/25).I

Result on Gaussian noise Result on Salt & Pepper noise

(31)

NON LINEAR FILTERING

• Median filter

Result on salt & pepper noise Result on Gaussian noise W=25 W=9

(32)

32

Mean Filter width = 3

Median Filter

neighborhood = 3

NON LINEAR FILTERING

• Median filter

Advantage of median filtering over linear filtering: edges are preserved

(33)

33

(34)

34

Adaptive Median filter : Input

Noisy image (S&P, 0.35)

(35)

35

(36)

36

Result of Adaptive Median filter

Reference Noisy image (S&P, 0.35)

Median Filter (5x5) Adaptive Median (Smax9x9)

(37)

37

• By frequency domain filtering

Bandreject filter

Notch filter  optimum notch

RESTORATION: PERIODIC NOISE REDUCTION

) , ( )

, ( )

,

( x y f x y x y

g   

Build HNP (Notch Pass) by placing a notch pass filter at the location of each spike.

Interference noise pattern is:

 

y) (x, ).

, ( )

, ( )

, ˆ(

) , ( FT

y) (x,

v) v).G(u, (u,

H )

, (

1 - NP

y x w y

x g y

x f

v u N v

u N

then

Weighted function (minimizes the effect of components not present in the estimate of η)

thus

How to select w(x,y) ? Estimate of f(x,y)

(38)

RESTORATION

38

+ =

Corrupted image I Shift filter

Reference Image L

f

Noise

n

( I, f ) L ?

(39)

HOW TO ‘DECONVOLUTION’?

• Inverse filtering

Without noise

With noise

We have to known N!

What happen for small values of H(u,v) ?

Solutions

Minimum Mean Square Error (Wiener) Filtering

Constrained Least Squares Filtering

When H is unknown : blind deconvolution

) , (

) , ) (

, ˆ(

v u H

v u v G

u

F

) , (

) , ) (

, ( )

, ˆ(

v u H

v u v N

u F v

u

F  

Many others approaches exist, ie the ‘blind’ ones

(40)

WIENER (MINIMUM MSE) AND CLS

• Wiener (Fourier), Minimum MSE

• Constrained Least Square (Fourier)

f(u,v) = degradation function in the Fourier space

|f(u,v)|2 = f*(u,v).f(u,v), with f*(u,v) the complex conjuagte of f Sn(u,v) = |N(u,v)|2 = noise power spectrum

SL(u,v) = |L(u,v)|2 = power spectrum of undegraded image ɣ = parameter to tune

(41)

APPLICATION : IMAGE SEGMENTATION

(42)

SEGMENTATION

• Visualization

• Counting

• Identification

• Measurements (shape, volumes …)

• Tracking

HDR mode

IRM SEP

[Comaniciu 2003]

(43)

Ostu Thresholding: 1 et 2 seuils

116

104 192

134

1 threshold (116)

2 thresholds (104 ; 192)

(44)

REGION GROWING

• Algorithm

Determine C neigbhoors of region R

Add neigboors similar to region R

Iterate while R is growing

Spatial proximity

« Ressemblance »

( )

E R

μ I

Mean of intensities of R

Ressemblance …

dμ I x  ( )

Critère : x is similar to R if :

dseuil

Exemple

(45)

MACHINE LEARNING

As fast as image introduction

(46)

ARTIFICIAL INTELLIGENCE AND SOCIETY

Today : leaders on personnal data use it extensively

… Until few years ago only science fiction…

(47)

… BUT ALSO

• Why is it so exciting for value creation?

Proposes solutions to (all) problems that have been partially solved or not

Obtain better performances than conventional approaches (quality and/or use of resources)  2012

Intrinsically allows to have a usable solution after the 'research' and development phase

(48)

https://pjreddie.com/darknet/

(49)

MACHINE LEARNING APPROACHES

Supervised approaches (non ANN)

Bayes, kNN, Support Vector Machine, Random Forest, LDA, Regression Logistique, …

Un-supervised approaches (non ANN)

K-means, GMM, Hierarchical approach, DBScan, Laio-Rodriguez, …

 ANN (Artificial Neural Network)

« DNN » (Deep Neural Network) MLP/ CNN / RNN / BM

CNN

(50)

NOTATIONS : DATA

Instance of all features values : x

The corresponding predicted label : û

Examples x : û

• Bank statement : solvency

• Flower picture : identification (rose, dendelion, iris…)

• Address, surface, year , … : apartment price

a Dataset consists of N instances (x, u)  X, u

Training set, validation set

Test set (assessment)

(51)

CLASSIFICATION PROBLEM

• Objective : split the space to identify new incomming

instance

scikit-learn.org

(52)

SCHEMA

model

input output

û u

L(u,û)

loss

(53)

BRIEFLY, ANN ARE

Collection of connected neurons, structured by layers

https://cs231n.github.io/neural-networks-1/

weight: wi

bias : b Activation function:

f()

(54)

BRIEFLY, ANN ARE

Collection of connected neurons, structured by layers

https://cs231n.github.io/neural-networks- 1/

16 + 10 = 26 variables 16 + 20 + 4 = 40 variables

(55)

PLAYGROUND TENSORFLOW

• Demo

One : simple example

Two : XOR case

http://playground.tensorflow.org

(56)

MODELING ANN TOWARD MATRIX/VECTOR

MANIPULATION

Neuron with bias : wk, bk input : xk output : zk

zk = wT xk + b x of size Kl-1

A layer l (without activation) : Wl, bl

zl=Wl x +bl Wl of Kl-1 row by Kl lines With x+ and W+are [1,x] and [b, W]

zl= W+lx+

• Activation layer

yl = fl( zl)

(57)

ACTIVATION FUNCTIONS (LOCAL)

Rectified Linear Unit (reLU )

and Leaky reLU (one parameter) Exponential Linear Unit (eLU )

Activation Google (swish) Sigmoid

(58)

ACTIVATION FUNCTIONS (OUTPUT LAYER)

softmax

x1 x2

xK,l-1 1 w0

Layer l Input

… …

w1 w2

wK,l-1

z0 z1

zK,l

softmax

y0 y1

yK,l

(59)

SCHEMA

Model

input output

û u

L(u,û)

loss

(60)

SCHEMA, TRAINING

input output

û u

L(u,û)

loss

Back propagation

Forward propagation

(61)

OPTIMIZATION OF W : TRAINING

• Loss function must be minimized and will drive the evolution of W: gradient descent

• In the perceptron case, Novikoff (1962) prove the convergence in (D/g)2 iterations

||xi||2 < D

yiuTxi ≥g with ||u||2 =1

D and g in R+*

Learning rate

(62)

OPTIMIZATION W : DERIVATION?

To update the wlq,k the weight of neuron q of layer l-1 to neuron k of layer l we need to compute

• Usage of chain rule

(63)

OPTIMIZATION W : DERIVATION?

• Matrice view chain rule

Hadamard product

(element wise multiplication) Derivative computed for layer l+1

(wrt to its input xl+1)

Matrix transpose

(64)

BACKPROPAGATION EXAMPLE

f(3,4) and

Aurélien Géron:

Hands-on

(65)

GRADIENT DESCENT

• Iterative process

Can be regularized (momentum, Adam)

• 3 ways of using data

Use the whole dataset

Long, small update

Use one instance (Stochastic)

Fast but noisy

Use a couple of instances

mini batch

Quite fast, less noisy

= 0 ?  minimum

(66)

LOSSES EVOLUTION DURING TRAINING

• Loss on training set  learning the problem

• Loss on validation set  generalization ability Loss

Epoch or iterations Validation Loss Training Loss From here, the network performs

worst on unseen data

(67)

REAL EVOLUTION CURVES…

• https://www.tensorflow.org/tutorials/keras/overfit_and_underfit

Tiny : 16

Small : 16, 16

Medium:64,64,64

Large: 512, 512, 512, 512 Dense networks

(68)

MLP : CLASSIFICATION EXAMPLE

https://ml4a.github.io/ml4a/neural_networks/

(69)

MLP : CLASSIFICATION EXAMPLE

https://ml4a.github.io/ml4a/neural_networks/

784

(70)

MLP: LIMITATIONS

160M parameters for the first layer!

(71)

MLP LIMITATIONS AND SOLUTION!

Fully connected Not fully connected Sharing weights

(72)

II – CONVOLUTIONAL NEURAL NETWORK : ELEMENTS

Convolution and related dedicated layers

(73)

CNN, YANN LECUN

1000

1000

x1 x2 x3 x4

x1000000

Input Hidden

We have to reduce the number of dimensions if we don’t want some influence on result

2 properties of natural and numeric data (link to human)

 Multiscale hierarchic organization

Symetries

 Too much dimnesions!

Use carrefully the fully connected

« malédiction de la grande dimension »

Le nombre d’exemples

d’apprentissage doit augmenter exponentiellement avec le nombre de dimensions

tinyurl.com/cours-Mallat

>-

(74)

ARTIFICIAL…

https://neuwritesd.files.wordpress.com/2015/10/visual_stream_small.png

https://fr.mathworks.com/solutions/deep-learning/convolutional-neural-network.htm

… vs natural

(75)

TYPICAL CNN (CLASSIFICATION)

https://web.eecs.umich.edu/~honglak/icml09-ConvolutionalDeepBeliefNetworks.pdf

convolution

pooling flatten softmax

convolution

convolution

(76)
(77)

CONVOLUTION FOR NEURAL NETWORK

Convolution

• Pad

border condition

• Stride

jump

• Atrous

empty pixels in mask

http://deeplearning.net/software/theano/tutorial/conv_arithme

tic.html#zero-padding-unit-strides

(78)

CONVOLUTION, FILTERS AND CHANNELS

convolution

One input channel

Three filters Three output channels Filters have the same

number of channels than the inputs

(79)

PRE-PROCESSING ‘LAYERS’

Intensity values of input data are critical: how to warrant that the dynamic and statistic are similar on all inputs ?  pre-process all data!

Mean-substraction

Normalizatation

Local contrast normalisation

(size adaptation and interpolation)

(80)

Half size padding (‘same’ size) Unit stride

No zero padding, unit stride

No zero padding,

Non-unit stride Half size padding (‘same’ size)

Non-unit stride Atrous or dilated filter Full padding, Unit stride

(81)

POOLING

• Down sampling

max,

mean

• Up sampling

Nearest Neighbour,

deconvolution – transposed convolution

https://cs231n.github.io/convolutional-networks/

Max pooling

(82)

DON’T MISS IT

• Convolution works on all channels

Generaly 3 by 3, 5 by 5, 7 by 7 or 1 by 1

At a given layer, many channels are obtained, one per convolution

• Pooling works on channel per channel

Generaly size is decreased by 4 (2 by 2)

(it can be increased)

• Receptive field

Input channels

Same number of channels

(83)

APPLICATIONS: CLASSIFICATION AND

SEGMENTATION

(84)

1. CNN

• Classification, détection, régression

[Krizhevsky 12]

96 filtres (ImageNET)

Filtres Gabor

(85)

2. U-NET (2015)

• Segmentation

• Filtering

Output

Same support as input

Références

Documents relatifs

S'il y a deux valeurs, alors la première valeur s'applique pour la marge du haut et celle du bas, et la seconde pour la marge droite et celle de gauche. Code

Exemple : pour convertir 314,5 m, on place le chiffre des unit´es (4) dans la colonne ”m`etre” puis celui des dizaines `a gauche (1) et des centaines (3) encore ` a gauche... Une

A new criterion for the determination of the drop contour is proposed here based on the recent developments made by the author on the imaging model for application to spray sizing

Duty paid storage in Davy's Cellars in Greenwich, SE10 on minimum stockholding.. Storage charge of 1 case will

Any procedure that gives an estimate of the rejection probability of a bootstrap test allows one to compute a corrected P value.. This is just the estimated rejection probability for

We can easily frustrate this feature by implementing a “length equality check bomb oracle” in a very same way: if we want to check whether or not the padding length is equal to n,

Access to file systems for resource connection, network browsing, and for Access to file systems for resource connection, network browsing, and for remote file and device I/O

Notification window receives FD_READ or FD_OOB events Notification window receives FD_READ or FD_OOB events Respond by calling ReadFile(), read(), recv(), or recvfrom() Respond