restoration of old films using morphological operators · restoration of old films using...

48
Restoration of Old Films Using Morphological Operators Quôc Peyrot [email protected] LRDE seminar, September 25, 2002

Upload: trinhnhan

Post on 26-Aug-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of Old Films Using MorphologicalOperators

Quôc Peyrot [email protected]

LRDE seminar, September 25, 2002

Page 2: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Table des matières

Table des matières

Introduction .......................................................................................... 2

History background ............................................................................. 3

Mathematical morphology .................................................................. 4

Connexity............................................................................................ 6

Operators............................................................................................ 8

Restoration of vertical scratches ....................................................... 18

Restoration of local random defects ................................................. 31

Conclusion ........................................................................................... 47

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 1

Page 3: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Introduction

Introduction

• Invention of “Lumière Cinematograph” in 1895 by Lumière brothers

• Deterioration due to short life span of films used

. It is urgent to restore and preserve this cultural inheritance.

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 2

Page 4: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

History background

History background

• Classic way : physic and chemical restorations

. Time-consuming and money-consuming

European Commission created two projects:

• AURORA Project: AUtomated Restoration of ORiginal film and videoArchives(Ended in 1999)

• Brava Project: BRoadcast Archives Restoration Through VideoAnalyses(Feb 2000 - Nov 2002)

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3

Page 5: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology

Mathematical morphology

• Instantiated by G. Matheron and J. Serra in 1964

. Study geometric structures

• Etienne Decencière Ferrandière, Restauration automatique de filmsanciens, PhD, 1997

. Bases of this study

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 4

Page 6: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology

Implementation

• Language: C++

• Image processing and Mathematical morphology provided by Olena :a generic image processing library in C++ from EPITA Research andDevelopment Laboratory (LRDE1)

1http://www.lrde.epita.fr

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 5

Page 7: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Connexity

Connexity

Common connexity:

• 4-connexity

• 8-connexity

• 6-connexity (for hexagonal)

. we can have 3d-connexity and time connexity !

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 6

Page 8: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Connexity

Connexity sample

4−Connexity 6−Connexity 8−Connexity

Figure 1: Connexity

window2d win;win.add(0,0).add(1,0).add(0,1).add(-1,0).add(0,-1);

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 7

Page 9: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Operators

• Primitives : Dilation and erosion

• Closing - Opening

• Reconstruction

• Area filter

• White Top-hat / Black Top-hat

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 8

Page 10: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Image sample

Figure 2: Image sample

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 9

Page 11: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Dilation - Erosion

Figure 3: Dilation - Erosion

• Dilation : δS(A)

• Erode : εS(A)

image2d<int_u8> result = morpho::dilation(lena, win_c8p());image2d<int_u8> result = morpho::erosion(lena, win_c8p());

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 10

Page 12: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Closing - Opening

Figure 4: Closing - Opening

• Closing : γS(A) = (εS ◦ δS)(A)

• Opening : φS(A) = (δS ◦ εS)(A)

image2d<int_u8> result = morpho::closing(lena, win_c8p());image2d<int_u8> result = morpho::opening(lena, win_c8p());

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 11

Page 13: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Reconstruction

Figure 5: Reconstruction : mark and result

morpho::sure_geodesic_reconstruction_dilation(marker,mask,neighb_c8());

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 12

Page 14: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Area filters

Figure 6: Minima killing with area=9

level::fast_minima_killer(image, area, neighb_c8());

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 13

Page 15: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

White Tophat - Black Tophat

Figure 7: White Tophat - Black Tophat

• White Tophat : wthS(I) = I − γS(I)

• Black Tophat : bthS(I) = φS(I)− I

morpho::white_top_hat(lena, win_c8p());morpho::black_top_hat(lena, win_c8p());

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 14

Page 16: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Gray images

I =G−1∑g=1

Thresholdg(I)

op(I) =G−1∑g=1

op(Thresholdg(I))

. This is slow : there are other ways

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 15

Page 17: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Operators on Lena

Figure 8: Original Lena

Figure 9: Dilation and Erosion

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 16

Page 18: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Mathematical morphology Operators

Operators on Lena

Figure 10: Closing and Opening

Figure 11: Black and White Tophat

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 17

Page 19: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Restoration of vertical scratches

Characteristics :

• vertical lines

• long

• narrow

• brighter than neighbour

• do not move with time

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 18

Page 20: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Modelisation

• dx < Dx

• dy < Dy

• the artifact is a local maxima

• dt < Dt

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 19

Page 21: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 1

1. Horizontal white tophat with size Dx

2. Vertical opening with size Dy

3. Time opening with size Dt

4. Space-time reconstruction

5. Threshold

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 20

Page 22: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 1 : result

Figure 12: Image source

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 21

Page 23: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 1 : result

Figure 13: White tophat and 2D Opening

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 22

Page 24: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 1 : result

Figure 14: 3D opening and Threshold

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 23

Page 25: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 1 : drawbacks

• images are often noisy

. vertical scratches are discontinuted

• we can have near-vertical lines in the image

. false detections

• motion is often small

. Time opening is not so useful

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 24

Page 26: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 2

1. Horizontal white tophat with size Dx (a)

2. Column accumulator

3. Horizontal white tophat with size Dx on accumulator

4. Threshold on accumulator with g1 (b)

5. Threshold on (a) with g2, g2 < g1 (c)

6. Reconstruction of vertical lines using (b) as “column marker” on (c)

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 25

Page 27: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 2 : result

Figure 15: Vertical scratches - Algorithm 2

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 26

Page 28: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Detection - Algorithm 2 : result

Figure 16: Vertical scratches - Detection result

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 27

Page 29: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Restoration

• We don’t have time information

. we have to work only in 2D

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 28

Page 30: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Restoration - “algorithm”

1. Neighbour pixels can be deteriorate by the artifact. Dilation of mask using C8 connexity

2. Horizontal opening on original image with size Dx

3. “cut and paste” using mask

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 29

Page 31: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of vertical scratches

Restoration - sample

Figure 17: Restoration sample

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 30

Page 32: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Restoration of local random defects

Figure 18: Image sample

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 31

Page 33: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - first approach

1. Detect on each frame potential local random defects

2. Apply time criteria to reject false detections

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 32

Page 34: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Modelisation

Characteristics:

• Maximal area Smax

• Minimal area Smin

• Minimal constrast g

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 33

Page 35: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Algorithm

Input F:

1. Maxima killing with area Smax ⇒ F1

2. F2 = F − F1

. F2 has only maxima with area < Smax

3. Threshold F2 with g ⇒ F3

4. Reconstruction using F2 as mask and F3 as mark ⇒ F4

5. Binarize of F4 using glow ⇒ F5

6. Killing of area < Smin

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 34

Page 36: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 19: Original Image

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 35

Page 37: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 20: Maxima and Threshold

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 36

Page 38: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 21: Reconstruction and final frame detection

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 37

Page 39: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 22: Time analysis and final mask

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 38

Page 40: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Algorithm 1 drawback

• Time consuming

• False detections

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 39

Page 41: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Second approach

1. Space-Time analysis

2. Post-processing

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 40

Page 42: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Algorithm 2

1. Space-Time opening ⇒ I1

2. I2 = I − I1

3. Threshold I2 with glow ⇒ B1

4. Threshold I2 with ghigh ⇒ B2

5. Reconstruction using B1 as mask and B2 as mark

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 41

Page 43: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 23: Space-time opening and difference

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 42

Page 44: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 24: Threshold glow and ghigh

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 43

Page 45: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Detection - Results

Figure 25: Final detection mask

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 44

Page 46: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Restoration

• Tiny defects: gaussian for instance

• Medium defects: we can use Fourier domain

• Big defects: we have to use time informations

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 45

Page 47: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Restoration of local random defects

Restoration sample

Figure 26: Restoration sample

. Maybe we can adapt g1 and g2 for each frame

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 46

Page 48: Restoration of Old Films Using Morphological Operators · Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 3. Mathematical morphology

Conclusion

Conclusion

• Implementation of other time connexity criteria

• Implementation of Fourier domain restoration method

• Implementation of motion estimations

• Try to adapt glow and ghigh for each frame in local algorithm 2

Restoration of Old Films Using Morphological Operators, Quôc Peyrot - LRDE seminar, September 25, 2002 47