Vous êtes sur la page 1sur 184

DE MONTREAL UNIVERSITE

PERFORMANCE APPLICABLE A ` LA METHODOLOGIE ORIENTEE ET DE LEUR VALIDATION DALGORITHMES DE TRAITEMENT VIDEO IMPLEMENTATION MATERIELLE

SERGE CATUDAL DEPARTEMENT DE GENIE ELECTRIQUE ECOLE POLYTECHNIQUE DE MONTREAL

EN VUE DE LOBTENTION MEMOIRE PRESENT E ` SCIENCES APPLIQUEES DU DIPLOME DE MA ITRISE ES (MICROELECTRONIQUE) JUILLET 2005

c Serge Catudal, 2005.

DE MONTREAL UNIVERSITE

ECOLE POLYTECHNIQUE DE MONTREAL

Ce m emoire intitul e:

PERFORMANCE APPLICABLE A ` LA METHODOLOGIE ORIENTEE ET DE LEUR VALIDATION DALGORITHMES DE TRAITEMENT VIDEO IMPLEMENTATION MATERIELLE

pr esent e par: CATUDAL Serge en vue de lobtention du dipl ome de: Ma trise ` es sciences appliqu ees a et e d ument accept e par le jury dexamen constitu e de:

M. NICOLESCU Gabriela, Ph.D., pr esident M. SAVARIA Yvon, Ph.D., membre et directeur de recherche M. BOIS Guy, Ph.D., membre et codirecteur de recherche M. KHOUAS Abdelhakim, Ph.D., membre

iv

Il est rare de trouver un homme qui se livre trois ans ` a l etude, sans avoir en vue un salaire. - Confucius

v REMERCIEMENTS

Je tiens a ` remercier Monsieur Yvon Savaria, mon directeur de ma trise, pour sa disponibilit e, ses conseils et son analyse qui mont permis de mener a ` terme mes travaux de recherche sous les meilleurs conditions. Je tiens de plus a ` remercier mon co-directeur Guy Bois. Je tiens a ` souligner le support nancier de Micronet ainsi que de Gennum Corporation et je tiens a ` remercier Jean-Marc Tremblay et Arnold Veenstra de Gennum Corporation pour leurs conseils techniques apport es lors des conf erences t el ephoniques tout au long de ma recherche. Jen prote pour remercier tous mes camarades du GRM (Groupe de Recherche en Micro electronique) et en particulier Bruno Tanguay, Louis-Pierre Lafrance, Tien Hung Bui, Alexandre Chureau, Mame Maria Mbaye, Ghyslain Provost, Robert Grou ainsi que tous mes camarades du CIRCUS, soit Francis St-Pierre, Fran coit Deslauriers, Simon Provost et Jean-Fran cois Thibeault. Je tiens aussi a ` remercier S ebastien Regimbal pour son aide dans le domaine de la v erication de design mat eriel, sans oublier les techniciens du GRM Alexandre Vesey et R egeant Lepage et notre secr eraire Ghyslaine Ethier Carrier. Je terminerai par remercier ma soeur Marcelle Catudal pour son support moral et nancier dans les moments opportuns. Je tiens de plus a ` remercier mon cousin Francis et mon ami Oktay Ali Yildiz et sa anc ee Am elie pour leur support moral tout au long de mes etudes.

vi RESUM E

Les architectures de traitement vid eo sont g en eralement d eriv ees a ` partir dalgorithmes valid es auparavant a ` laide de langage de haut niveau comme le C/C++ ou Matlab/Simulink. Elles sont g en eralement simul ees en r esolution

virgule-ottante qui est une r esolution tr` es co uteuse a ` utiliser pour la mise en oeuvre de mat eriels d edi es. Une bonne fa con de minimiser ou doptimiser la complexit e dune impl ementation mat erielle en ce qui a trait a ` sa performance de calcul et a ` sa consommation de puissance, est dutiliser une pr ecision en virgule-xe. De plus, certains algorithmes de traitement vid eo contiennent des param` etres devant etre x es an dobtenir une performance optimale. Ces param` etres sont g en eralement d etermin es empiriquement. La traduction dune formulation en virgule-ottante vers une formulation en virgule-xe, pour une impl ementation mat erielle, peut causer certains probl` emes. Par exemple, la pr ecision de chaque op erande et la valeur de chaque param` etre contenu dans lalgorithme devraient etre s electionn ees minitieusement an de pr eserver la stabilit e de lalgorithme ainsi que lacuit e de son calcul. De plus, cette s election peut d et eriorer le comportement dun algorithme de traitement vid eo en produisant des art efacts visuels d eplaisant pour un observateur humain. Une nouvelle m ethode syst ematique et automatique fut d evelopp ee an de valider des algorithmes de traitement vid eo. Le but de cette m ethode est de pousser la t ache de la validation dalgorithme de traitement vid eo a ` un niveau dabstraction plus elev e pour un concepteur mat eriel. An datteindre ce but, la nouvelle

m ethode propos ee utilise une plateforme de validation automatique dalgorithmes de traitement vid eo prenant avantage dune nouvelle m etrique mesurant la qualit e dimage. Lutilisation de m etriques objectives mesurant la qualit e dimage permet

vii de retirer un observateur humain du processus d evaluation de la qualit e dimage. Les r esultats exp erimentaux obtenus a ` laide de trois ltres spatiaux ainsi que deux algorithmes de d e-entrelacement vid eo sont pr esent es an dillustrer la validit e de cette approche.

viii ABSTRACT

Video Processing architectures are usually derived from algorithms previously validated with C/C++ or Matlab/Simulink implementations. They are usually simulated in oating-point resolution, which is very expensive in terms of hardware cost. A good way to minimize or optimize hardware implementation complexity, computational performance, and power consumption is to use xed-point precision. Furthermore, some video processing algorithms contain parameters that need to be set for optimal performance. These parameters are usually determined empirically. The translation from a oating-point to a xed-point formulation, for a hardware implementation, may cause some problems. For instance, the precision of each operand and the value of each parameter contained in the algorithm should be carefully selected to preserve algorithm stability and processing accuracy. Furthermore, this selection can deteriorate the behavior of a video processing algorithm to produce visual eects annoying to human observers. A new systematic and automatic method was developed to validate video processing algorithm. The aim of this method is to push the task of video processing algorithm validation at a higher level of abstraction for a hardware designer. In order to achieve this goal, the new method proposed uses an automatic video processing validation platform that takes advantage of new objective image quality metrics. The use of objective image quality metrics allows removing human observers from the process of evaluating image quality. Experimental results obtained with three spatial lters and two de-interlacing algorithms are presented to illustrate the validity of this approach.

ix ` TABLE DES MATIERES

DEDICACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . REMERCIEMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RESUM E

iv v vi

ABSTRACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii ` TABLE DES MATIERES . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

LISTE DES FIGURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii LISTE DES NOTATIONS ET DES SYMBOLES . . . . . . . . . . . . . . . xvii LISTE DES TABLEAUX . . . . . . . . . . . . . . . . . . . . . . . . . . . xix LISTE DES ANNEXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx CHAPITRE 1 1.1 1.2 1.3 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . 1 1 3 3 5 5 7 8 9 11 11

ements de la probl El ematique . . . . . . . . . . . . . . . . . . . . Objectifs de recherche . . . . . . . . . . . . . . . . . . . . . . . . Organisation du m emoire . . . . . . . . . . . . . . . . . . . . . . CONCEPTS DE BASE . . . . . . . . . . . . . . . . . .

CHAPITRE 2 2.1

M etriques objectives pour la mesure de la qualit e dimage . . . . . 2.1.1 2.1.2 Mesure de lerreur dans limage . . . . . . . . . . . . . . . Mesure des similarit es a ` lint erieur dune image . . . . . . . 2.1.2.1 Structural SIMilarity Index . . . . . . . . . . . . . .

2.2 2.3

Di erence entre validation formelle et v erication fonctionnelle

Algorithmes de traitement vid eo . . . . . . . . . . . . . . . . . .

x 2.3.1 M ethodes de r eduction du bruit vid eo . . . . . . . . . . . . 2.3.1.1 2.3.1.2 2.3.1.3 2.3.1.4 2.3.2 Types de bruit vid eo . . . . . . . . . . . . . . . . Algorithme du ltre Hybride . . . . . . . . . . . 12 12 15 16 17 18 20 22

Algorithme du ltre SUSAN . . . . . . . . . . . . Filtre adaptatif de Wiener . . . . . . . . . . . . . . . . . . . . . . . . .

M ethodes de d e-entrelacement vid eo 2.3.2.1

Algorithme de d e-entrelacement ELA modi e . . .

2.4

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CHAPITRE 3 3.1

24 VALIDATION DE MODULES DE TRAITEMENT VIDEO . . . . 25 27 28 30 31 32 34 34 35 37 41 43 45 46 47

Plateforme de validation dalgorithmes de traitement vid eo 3.1.1

Composantes de la plateforme . . . . . . . . . . . . . . . . 3.1.1.1 3.1.1.2 3.1.1.3 Repr esentation bas niveau de lalgorithme . . . . . M etrique de performance . . . . . . . . . . . . . Fichier de simulation . . . . . . . . . . . . . . .

3.1.2

Anomalies observ ees . . . . . . . . . . . . . . . . . . . . . 3.1.2.1 3.1.2.2 3.1.2.3 Pixels n egatifs . . . . . . . . . . . . . . . . . . . Pixels divergeant de leur voisin . . . . . . . . . . Instabilit es num eriques . . . . . . . . . . . . . .

3.1.3 3.2

Utilisation dun seuil

. . . . . . . . . . . . . . . . . . . .

Validation de param` etres . . . . . . . . . . . . . . . . . . . . . . 3.2.1 3.2.2 3.2.3 Modication de la m ethodologie . . . . . . . . . . . . . . . Fichier de simulation . . . . . . . . . . . . . . . . . . . . R esultats obtenus . . . . . . . . . . . . . . . . . . . . . .

3.3

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ERATION TECHNIQUES DACCEL DE LA VALIDATION . . . . . DALGORITHMES DE TRAITEMENT VIDEO

CHAPITRE 4

50 50

4.1

Algorithme de d e-entrelacement adaptatif au mouvement

. . . . .

xi 4.1.1 4.1.2 4.1.3 4.2 Algorithme de d etection de mouvement . . . . . . . . . . . Algorithme de d e-entrelacement ELA modi e . . . . . . . . Algorithme de d e-entrelacement AMPDF . . . . . . . . . . 51 57 58 60 61 63 66

R esultats obtenus . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 4.2.2 Premi` ere technique dacc el eration de lanalyse . . . . . . . Deuxi` eme technique dacc el eration de lanalyse . . . . . . .

4.3

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CHAPITRE 5 5.1 5.2

CONCLUSION . . . . . . . . . . . . . . . . . . . . . . . 68 68 70 72 77

Synth` ese du travail accompli . . . . . . . . . . . . . . . . . . . . Travaux futurs et am eliorations . . . . . . . . . . . . . . . . . . .

BIBLIOGRAPHIE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ANNEXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xii LISTE DES FIGURES

Figure 2.1

Diagramme de la structure g en erale des m etriques bas ees sur la mesure derreur. . . . . . . . . . . . . . . . . . . . . . 8 9 13

Figure 2.2 Figure 2.3 Figure 2.4

Diagramme d ecrivant le fonctionnement de la m etrique SSIM. Image Lena ne contenant pas de bruit. . . . . . . . . . . . Image Lena contenant du bruit gaussien. (a) = 0, 01, MSSIM = 0,629718; (b) = 0, 02, MSSIM = 0,522856; (c) = 0, 05, MSSIM = 0,384799. . . . . . . . . . . . . . . .

13

Figure 2.5

Image Lena contenant du bruit sel et poivre. (a) 10% de bruit, MSSIM = 0,804710; (b) 20% de bruit, MSSIM = 0,664750; (c) 50% de bruit, MSSIM = 0,409215. . . . . . . 14

Figure 2.6

Image Lena contenant du bruit de compression. (a) niveau de qualit e = 35, MSSIM = 0,879585; (b) niveau de qualit e= 15, MSSIM = 0,817463; (c) niveau de qualit e = 10, MSSIM = 0,777333. . . . . . . . . . . . . . . . . . . . . . . . . . 15

Figure 2.7

Sch ema illustrant le fonctionnement de lalgorithme du ltre Hybride. . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Figure 2.8

Sch ema illustrant le fonctionnement de lalgorithme du ltre Wiener. . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Figure 2.9

Sch ema illustrant la t ache rattach e au d e-entrelacement tir e de [33]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 20 21

Figure 2.10 Figure 2.11 Figure 3.1

Sch ema du fonctionnement de lalgorithme ELA modi e. . . Patron de pixels utilis e dans lalgorithme ELA modi e. . . . Diagramme du fonctionnement de la plateforme de validation dalgorithmes de traitement vid eo. . . . . . . . . . . . . .

28

Figure 3.2

DFG ordonnanc e de la moyenne locale j pour le ltre Wiener (voir equation (2.18)) . . . . . . . . . . . . . . . . 29

xiii Figure 3.3 Figure 3.4 Diagramme de l evaluation de lobjectif de performance. . . Section de limage Lena ltr ee en r esolution virgule-xe provenant du tableau 3.1. . . . . . . . . . . . . . . . . . . Figure 3.5 R esultats de simulation contenant des pixels n egatifs. (a) Image ltr ee Lena en virgule-ottante, MSSIM = 0,834480; (b) Image ltr ee Lena en virgule-xe, MSSIM = 0,822677; (c) Carte des indices SSIM comparant limage Lena ltr ee en virgule-ottante et virgule-xe. . . . . . . . . . . . . . . Figure 3.6 R esultats de simulation obtenus avec des pixels divergeant de leurs voisins. (a) Image ltr ee Boat en virgule-ottante, MSSIM = 0,807659; (b) Image ltr ee Boat en virgule-xe, MSSIM = 0,776457; (c) Carte des indices SSIM comparant limage Boat ltr ee en virgule-ottante et virgule-xe. . . . Figure 3.7 R esultats de simulation obtenus avec des pixels divergeant de leurs voisins. (a) Image ltr ee Cameraman en virguleottante, MSSIM = 0,739830; (b) Image ltr ee Cameraman en virgule-xe, MSSIM = 0,711923; (c) Carte des indices SSIM comparant limage Cameraman ltr ee en virguleottante et virgule-xe. . . . . . . . . . . . . . . . . . . . Figure 3.8 R esultats de simulation obtenus avec des pixels divergeant de leurs voisins. (a) Image ltr ee Lena en virgule-ottante, MSSIM = 0,811397; (b) Image ltr ee Lena en virgule-xe, MSSIM = 0,775641; (c) Carte des indices SSIM comparant limage Lena ltr ee en virgule-ottante et virgule-xe. . . . Figure 3.9 Zone critique du chemin de donn ees du ltre de Wiener. . . 38 38 37 36 35 33 31

xiv Figure 3.10 R esultats de simulation obtenus avec la nouvelle OIQM. (a) Image ltr ee Boat en virgule-ottante, MSSIM = 0,807659; (b) Image ltr ee Boat en virgule-xe, MSSIM = 0,795193; (c) Carte des indices SSIM comparant limage Boat ltr ee en virgule-ottante et virgule-xe. . . . . . . . . . . . . . . . Figure 3.11 R esultats de simulation obtenus avec la nouvelle OIQM. (a) Image ltr ee Cameraman en virgule-ottante, MSSIM = 0,739830; (b) Image ltr ee Cameraman en virgule-xe, MSSIM = 0,729231; (c) Carte des indices SSIM comparant limage Cameraman ltr ee en virgule-ottante et virgule-xe. 40 Figure 3.12 R esultats de simulation obtenus avec la nouvelle OIQM. (a) Image ltr ee Lena en virgule-ottante, MSSIM = 0,811397; (b) Image ltr ee Lena en virgule-xe, MSSIM = 0,788909; (c) Carte des indices SSIM comparant limage Lena ltr ee en virgule-ottante et virgule-xe. . . . . . . . . . . . . . . Figure 3.13 Section de limage Lena ltr ee en r esolution virgule-xe et ne contenant aucune anomalie. . . . . . . . . . . . . . . . Figure 3.14 Indice de Qualit e Q pour lestimation des param` etres du ltre Hybride. . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 4.1 Sch ema de lalgorithme de d e-entrelacement adaptatif au mouvement. . . . . . . . . . . . . . . . . . . . . . . . . . Figure 4.2 Figure 4.3 52 48 42 41 39

D etection de mouvement a ` laide de quatre champs de r ef erence. 52 Sch ema de de la classiation de lalgorithme de d etection de mouvement. . . . . . . . . . . . . . . . . . . . . . . . . . 53

Figure 4.4

D e-entrelacement du champ 9 de la s equence football, par lalgorithme (a) ELA modi e, (b) AMPDF, (c) adaptatif au mouvement, et carte des indices SSIM pour lalgorithme (d) ELA modi e, (e) AMPDF, (f) adaptatif au mouvement. . . 55

xv Figure 4.5 D e-entrelacement du champ 9 de la s equence stennis par lalgorithme (a) ELA modi e, (b) AMPDF, (c) adaptatif au mouvement, et carte des indices SSIM pour lalgorithme (d) ELA modi e, (e) AMPDF, (f) adaptatif au mouvement. . . Figure 4.6 Figure 4.7 Figure 4.8 D e-entrelacement a ` laide de trois champs de r ef erence. . . . Sch ema du fonctionnement de lalgorithme AMPDF. . . . . DFG ordonnanc e illustrant un exemple du regroupement dop erandes. . . . . . . . . . . . . . . . . . . . . . . . . . Figure 4.9 R esultats de simulation pour lalgorithme de d etection de mouvement et variation des (a) temps de simulation et (b) co ut mat eriel en fonction du nombre dop erandes et de param` etres. . . . . . . . . . . . . . . . . . . . . . . . . . Figure 4.10 R esultats de simulation pour lalgorithme ELA modi e et variation des (a) temps de simulation et (b) co ut mat eriel en fonction du nombre dop erandes et de param` etres. . . . . . Figure 4.11 R esultats de simulation pour lalgorithme de d e63 62 61 56 58 58

entrelacement adaptatif au mouvement,

variation du

(a) temps de simulation, (b) co ut mat eriel, et (c) de la performance, en fonction du nombre dop erandes et param` etres. . . . . . . . . . . . . . . . . . . . . . . . . . Figure A.1 Arctichare ltered in xed-point resolution causing numerical instability. . . . . . . . . . . . . . . . . . . . . . . . . . . Figure A.2 Figure A.3 Flow Diagram of the Video Processing Validation Platform . Section of Lena ltered image in xed-point resolution from Table A.4. . . . . . . . . . . . . . . . . . . . . . . . . . . 85 79 81 67

xvi Figure A.4 Simulation results with negative pixels. (a) Lena ltered image in oating-point, MSSIM = 0.834480; (b) Lena ltered image in xed-point, MSSIM = 0.822677; (c) SSIM map comparing the Lena ltered image in oating and xed-point. . Figure A.5 Simulation results obtained with dark pixels. (a) Cameraman ltered image in oating-point, MSSIM = 0.739830; (b) Cameraman ltered image in xed-point, 87

MSSIM = 0.711923; (c) SSIM map comparing the Cameraman ltered image in oating and xed-point. . . . . . . . Figure A.6 Simulation results obtained with dark pixels. (a) Lena ltered image in oating-point, MSSIM = 0.811397; (b) Lena ltered image in xed-point, MSSIM = 0.775641; (c) SSIM map comparing the Lena ltered image in oating and xedpoint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure A.7 Simulation (a) results obtained ltered with image the in new OIQM. 89 88

Cameraman

oating-point,

MSSIM = 0.739830; (b) Cameraman ltered image in xed-point, MSSIM = 0.729231; (c) SSIM map comparing the Cameraman ltered image in oating and xed-point; (d) Lena ltered image in oating-point, MSSIM = 0.811397; (e) Lena ltered image in xed-point, MSSIM = 0.788909; (f) SSIM map comparing the Lena ltered image in oating and xed-point. . . . . . . . . . . . . . . . . . . . . . . . Figure A.8 Section of Lena ltered image in xed-point resolution without anomalies. . . . . . . . . . . . . . . . . . . . . . . . . Figure B.1 Figure B.2 Figure B.3 91 90

Flow diagram of the performance assessment method. . . . 100 Flowchart of the modied ELA deinterlacing algorithm. . . 104 Pattern of pixels used in the modied ELA algorithm. . . . 104

xvii Figure B.4 Quality index Q of the Hybrid lter parameter estimation. . 106

xviii LISTE DES NOTATIONS ET DES SYMBOLES

AMPDF: Adapdive Minimum Pixel Dierence Filter ASIC: Application Specic Integrated Circuit

AWLDT: Automatic Word Length Determination Tool CDFG: CTL: DCT: DSP: DVD: ELA: FR: HDTV: HVS: HW: IEEE: Control Data Flow Graph Computational Tree Logic Discrete Consine Transform Digital Signal Processing Digital Versatile Disc Edge-based Line Average Full Refernce metric High Denition Television Human Visual System Hardware Institute of Electrical and Electronics Engineers

IRATIO: Inverse Ratio JPEG: LTL: MMSE: MSSIM: MPEG: NR: PT: OIQM: RR: RTL: Joint Photographic Experts Group Linear Temporal Logic Minimum Mean Square Error Mean Structural SIMilarity Moving Picture Experts Group No Reference metric Pixel Threshold Objective Image Quality Metric Reduced Reference metric Register Transfer Level

xix

SDTV: SoC: SUSAN: VHDL:

Standard Denition Television System-on-a-Chip Smallest Univalue Segment Assimilating Nucleus Very high speed integrated circuit Hardware Description Language

xx LISTE DES TABLEAUX

Tableau 3.1

Valeurs de m etriques objectives mesurant la qualit e globale dimage, pour di erentes images contenant du bruit gaussien avec un niveau de variance de 0,01, ainsi que pour les images correspondantes ltr ees a ` laide du ltre de Wiener en r esolution virgule-ottante et virgule-xe. . . . . . . . . . . 33

Tableau 3.2 Tableau 3.3

Comparaison entre la premi` ere solution et la nouvelle OIQM. 40 R esultats obtenus pour trois algorithmes de traitement vid eo di erents. . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Tableau 4.1

Qualit e des images obtenues avec di erents algorithmes de d e-entrelacement. . . . . . . . . . . . . . . . . . . . . . . 57 64 64

Tableau 4.2 Tableau 4.3 Tableau A.1

Di erentes combinaisons danalyse de lalgorithme. . . . . . Tailles des op erandes et param` etres des algorithmes. . . . . Comparison of global image metrics for dierent images containing noise with a variance level of 0.01 and corresponding images processed by the Wiener lter in xed and oatingpoint. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

85 92

Tableau A.2 Tableau B.1

Comparison between the rst solution and the new OIQM. .

Results obtained for three dierent video processing algorithms.105

xxi LISTE DES ANNEXES

ANNEXE A

PERFORMANCE DRIVEN VALIDATION APPLIED TO VIDEO PROCESSING . . . . . . . . . . . . . . . . . . 77 78 80 80 82 82 83 84 86 86 87 88 91 92

A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.2 Video Processing Validation . . . . . . . . . . . . . . . . . . . .

A.2.1 Video Processing Validation Platform . . . . . . . . . . . . A.2.2 Objective Image Quality Metric . . . . . . . . . . . . . . . A.2.2.1 Structural Similarity Index . . . . . . . . . . . . A.3 Wiener Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.4 Anomalies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.4.1 Negative Pixels . . . . . . . . . . . . . . . . . . . . . . . A.4.2 Dark Pixels . . . . . . . . . . . . . . . . . . . . . . . . . A.4.3 Numerical instabilities . . . . . . . . . . . . . . . . . . . . A.5 Problem Solution . . . . . . . . . . . . . . . . . . . . . . . . . . A.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.7 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . ANNEXE B PARAMETERS ESTIMATION APPLIED TO AUTOMATIC VIDEO PROCESSING ALGORITHMS VALIDA-

TION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 B.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B.2 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . B.2.1 Determining the optimum values of the parameters . . . . . B.2.2 Determining the optimum set of parameters values and combination of word lengths . . . . . . . . . . . . . . . . . . . 100 B.3 Video Processing Algorithms . . . . . . . . . . . . . . . . . . . . 101 95 97 98

xxii B.3.1 SUSAN lter . . . . . . . . . . . . . . . . . . . . . . . . 101

B.3.2 Hybrid lter . . . . . . . . . . . . . . . . . . . . . . . . . 102 B.3.3 ELA deinterlacing algorithm . . . . . . . . . . . . . . . . 103

B.4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 B.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 ANNEXE C CODE SOURCE DE LA METRIQUE SSIM INDEX . . . 109

C.1 Fichier ssim index.h . . . . . . . . . . . . . . . . . . . . . . . . . 109 C.2 Fichier ssim index.cc . . . . . . . . . . . . . . . . . . . . . . . . 110 ANNEXE D . . . . . . . . . . . . 115 REDUCTEUR DE BRUIT VIDEO

D.1 Code source du ltre Hybride . . . . . . . . . . . . . . . . . . . . 115 D.1.1 Fichier hybrid lter.h . . . . . . . . . . . . . . . . . . . . 115 D.1.2 Fichier hybrid lter.cc . . . . . . . . . . . . . . . . . . . . 116 D.2 Code source du ltre SUSAN . . . . . . . . . . . . . . . . . . . . 120 D.2.1 Fichier susan lter.h . . . . . . . . . . . . . . . . . . . . . 120 D.2.2 Fichier susan lter.cc . . . . . . . . . . . . . . . . . . . . 121 D.3 Code source du ltre adaptatif Wiener . . . . . . . . . . . . . . . 125 D.3.1 Fichier wiener lter.h . . . . . . . . . . . . . . . . . . . . 125 D.3.2 Fichier wiener lter.cc . . . . . . . . . . . . . . . . . . . . 126 ANNEXE E FICHIERS DE SIMULATIONS . . . . . . . . . . . . . . 132

E.1 Code source pour simuler les ltres num eriques . . . . . . . . . . . 132 E.1.1 Fichier Ximage.c . . . . . . . . . . . . . . . . . . . . . . 132

E.1.2 Fichier Ximage error.c . . . . . . . . . . . . . . . . . . . . 134 E.2 Code source pour simuler les ltres num eriques avec param` etres . . 138 E.2.1 Fichier Xparam.c . . . . . . . . . . . . . . . . . . . . . . 138 E.2.2 Fichier Xparam error.c . . . . . . . . . . . . . . . . . . . 140 E.3 Code source pour simuler les s equences vid eo . . . . . . . . . . . . 144

xxiii E.3.1 Fichier Xvideo.c . . . . . . . . . . . . . . . . . . . . . . . 144 E.3.2 Fichier Xvideo error.c . . . . . . . . . . . . . . . . . . . . 147 ANNEXE F ALGORITHME DE DE-ENTRELACEMENT . . . . . . 152

F.1 Code source de lalgorithme de d e-entrelacement adapatatif au mouvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 F.1.1 Fichier motion.h . . . . . . . . . . . . . . . . . . . . . . . 152 F.1.2 Fichier motion.cc . . . . . . . . . . . . . . . . . . . . . . 153

1 CHAPITRE 1

INTRODUCTION

La conception de modules de traitement vid eo peut etre divis ee en deux composantes compl ementaires associ ees au contr ole et au ot de donn ees respectivement. Le but principal du contr ole est dalimenter le chemin de donn ees avec les bonnes donn ees au bon moment, ainsi que de collecter les r esultats sortant de celui-ci. Le but principal du chemin de donn ees est deectuer la transformation de donn ees sp eci ee par lalgorithme de traitement vid eo. Les architectures mat erielles dalgorithmes de traitement vid eo impl ementant la transformation de donn ees sont g en eralement d eriv ees a ` partir dalgorithmes pr ealablement valid es a ` laide dimpl ementations C/C++ ou Matlab/Simulink. Ces algorithmes sont g en eralement simul es a ` laide dune r esolution en virgule-ottante. Comme les impl ementations en r esolution virgule-ottante sont relativement tr` es co uteuses en terme de co ut mat eriel, une excellente m ethode an de minimiser ou doptimiser la complexit e dune impl ementation mat erielle, sa performance ainsi que sa consommation de puissance, est dutiliser une pr ecision en virgule-xe.

1.1

ements de la probl El ematique

La traduction dune formulation en virgule-ottante vers une formulation en virgule-xe, une etape du processus qui conduit a ` une impl ementation mat erielle, peut causer quelques probl` emes. Par exemple, la pr ecision de chaque op erande devrait etre attentivement s electionn ee an de pr eserver la stabilit e de lalgorithme ainsi que lexactitude de son traitement. La sensibilit e de la taille des mots sur

2 lalgorithme vis e nest pas claire a priori. De plus, cette traduction peut d et eriorer le comportement dun algorithme de traitement vid eo en produisant des art efacts visuels d eplaisant pour un observateur humain. Une m ethode syst ematique an de valider limpl ementation dun algorithme de traitement vid eo devient alors tr` es int eressante. La validation aide un concepteur de mat eriel a ` concevoir et a ` impl ementer des syst` emes complexes en assurant, avec un haut niveau de conance, que ces derniers sont conformes a ` leur sp ecication dans toutes les circonstances. Il existe des techniques formelles an de valider des syt` emes, mais celles-ci sont applicables seulement pour la validation du contr ole dun syst` eme, i.e. ne sont pas applicables pour la validation du chemin de donn ees dun syst` eme. De plus, la majorit e des travaux concernant la validation dalgorithmes de traitement vid eo portent sur des techniques de v erication formelle de transformation de boucle a ` lint erieur dun algorithme [14] et sur la validation au niveau syst` eme de la sp ecication dalgorithmes de traitement dimages dans leur environnement cible a ` laide d emulation [20]. Cependant, ces techniques de validation ne sont pas utiles pour conrmer automatiquement labsence dart efacts visuels d eplaisant pour un observateur humain a ` lint erieur dune impl ementation pratiquement correcte. Par la suite, un grand nombre dalgorithmes de traitement vid eo sont contr ol es par des param` etres devant etre x es an de pouvoir les utiliser. Un bon ajustement de ces param` etres peut avoir, encore une fois, un impact signicatif sur la performance et le comportement de lalgorithme. Ces param` etres sont habituellement d etermin es empiriquement par les concepteurs de mat eriel [22] [29] [37]. Il y a donc ici un besoin pour une m ethodologie an dautomatiser la d etermination et la validation des param` etres contr olant les algorithmes de traitement vid eo.

3 1.2 Objectifs de recherche

Le but de ce m emoire est de d evelopper une m ethode automatique et syst ematique pour la validation dalgorithmes de traitement vid eo. Cette m ethode doit pousser a ` un niveau dabstraction plus elev e le processus de validation dalgorithme de traitement vid eo pour un concepteur de mat eriel. De plus, cette m ethode doit etre robuste, et doit id ealement evaluer automatiquement la performance des algorithmes de traitement vid eo, et toujours produire des images valides, sans avoir recours a ` un observateur humain pour la t ache de l evaluation des images r esultantes. Par la suite, la m ethodologie d evelopp ee devra etre etendue an destimer automatiquement lensemble des param` etres contr olant un algorithme de traitement vid eo. Bref, cette extension doit permettre, dans un premier temps, d evaluer les valeurs optimales des param` etres de lalgorithme lorsque toutes ses op erandes sont en r esolution virgule-ottante. Dans un deuxi` eme temps, cette extension doit automatiquement optimiser et valider limpl ementation mat erielle de lalgorithme en r esolution virgule-xe et ajuster a ` la valeur optimale les param` etres de contr ole en tenant compte de la pr ecision nie du chemin de donn ees.

1.3

Organisation du m emoire

Le chapitre 2 de ce m emoire pr esente une revue de litt erature sur les di erents aspects concernant la m ethodologie automatique et syst ematique an de valider des algorithmes de traitement vid eo. Ce chapitre passe en revue les m etriques objectives pour la mesure de la qualit e dimage. Par la suite, la di erence entre la validation formelle et la v erication fonctionnelle est pr esent ee. Il se termine par la pr esentation des algorithmes de traitement vid eo servant a ` valider la m ethodologie pr esent ee au prochain chapitre.

4 Ensuite, le chapitre 3 pr esente la plateforme de validation dalgorithmes de traitement vid eo et ses di erentes composantes. La composante cl e de cette plateforme repose sur la combinaison dun outil de d etermination automatique de la taille de mot dune op erande (AWLDT) [7] [8] avec une nouvelle m etrique pouvant rejeter des solutions g en erant des images distortionn ees. Cette nouvelle m etrique est pr esent ee dans ce chapitre, ainsi que les modications apport ees a ` loutil AWLDT an destimer automatiquement les param` etres dun algorithme de traitement vid eo. Le chapitre 4 pr esente deux techniques an dacc el erer la validation dalgorithme de traitement vid eo. An deectuer cette etude, ce chapitre utilise comme mod` ele de r ef erence un algorithme de d e-entrelacement adaptatif au mouvement. Ce dernier est compos e de trois algorithmes distincts fonctionnant en parall` ele. Le chapitre 5 pr esente la conclusion de ce m emoire. Un r esum e des travaux accomplis est pr esent e, suivi par la suite dindications sur des travaux de recherche futurs pertinent sur le sujet de ce m emoire.

5 CHAPITRE 2

CONCEPTS DE BASE

Le but de ce travail est de d evelopper une m ethodologie automatique et syst ematique an de valider des algorithmes de traitement vid eo et leur impl ementation en mat eriel. Une revue des concepts de base sur les di erents aspects de cette m ethodologie devient donc n ecessaire an de bien comprendre les concepts sur lesquels celle-ci est bas ee. Ce chapitre est divis e en quatre sections principales. La section 2.1 pr esente les m etriques objectives pour la mesure de la qualit e dimage, alors que la section 2.2 pr esente la di erence entre la validation et la v erication fonctionnelle. Ensuite, la section 2.3 pr esente les algorithmes de traitement vid eo utilis es a ` lint erieur de ce travail et la section 2.4 conclut le chapitre.

2.1

M etriques objectives pour la mesure de la qualit e dimage

Le but recherch e avec la mesure objective de qualit e dimages et de ots vid eo vise a ` elaborer des m etriques pouvant estimer de fa con quantitative et automatique leur qualit e telle que per cue par un observateur humain [45]. En g en eral, il existe trois situations possibles pour lesquelles une m etrique de mesure de qualit e dimages serait employ ee. La premi` ere situation consiste a ` surveiller la qualit e des images pour des syt` emes de contr ole de qualit e. Ensuite, la deuxi` eme situation consiste a ` utiliser une telle m etrique comme crit` ere de r ef erence pour des algorithmes de traitement dimages. La troisi` eme et derni` ere situation consiste a ` incorporer une m etrique mesurant la qualit e dimages a ` lint erieur dun syst` eme de traitement

6 dimage qui optimise automatiquement des algorithmes et leurs param` etres. Par la suite, les m etriques objectives mesurant la qualit e dimage (OIQM, objective image quality metric) peuvent etre classi ees en trois cat egories [9] [42] [45]. La premi` ere cat egorie est nomm ee r ef erence compl` ete (FR, full reference) [44]. Les OIQM faisant partie de la cat egorie FR, soit la majorit e des m etriques se trouvant dans la litt erature, utilisent une image de r ef erence, consid er ee comme etant non d eform ee, an de la comparer avec limage distortionn ee. Donc, dans le cas des m etriques FR, comme toute linformation de limage originale est disponible, la mesure de la qualit e retourn ee est alors plus pr ecise et robuste [9]. La deuxi` eme cat egorie est nomm ee sans r ef erence (NR, no reference). Cette cat egorie est tr` es pratique dans le cas o` u limage de r ef erence nest pas disponible. En eet, les m etriques NR extraient des caract eristiques de limage an de proc eder a ` la mesure de la qualit e de limage distortionn ee. Cependant, les m etriques de cette cat egorie sont pr esentement ecaces seulement dans le cas o` u le type de bruit a ` lint erieur des images distortionn ees est connu a priori [39]. La troisi` eme et derni` ere cat egorie est nomm ee r ef erence r eduite (RR) [46] et elle provient dune solution se situant entre les mod` eles FR et NR. Ces m etriques sont con cues an de pr edire la qualit e per cue dune image distortionn ee a ` partir uniquement dinformations partielles de limage de r ef erence. La motivation de lutilisation de m etriques objectives mesurant la qualit e dimages a ` lint erieur de ce m emoire provient du fait que la plateforme de validation dalgorithmes de traitement vid eo, pr esent ee au Chapitre 3, utilise les mesures de qualit e dimage comme crit` ere de r ef erence pour des algorithmes de traitement vid eo. Comme le but premier de cette plateforme est de retirer un observateur humain du processus de mesure de la qualit e dimage, celle-ci a donc besoin dune m etrique de qualit e objective an de faire une di erence coh erente entre une image originale et une image distortionn ee. De plus, comme limage de r ef erence

7 est disponible a ` lint erieur de la plateforme de validation dalgorithmes de traitement vid eo et que celle-ci doit etre g en erique, seules les m etriques de la cat egorie FR ont et e consid er ees. Celles-ci peuvent etre divis ees en deux groupes. La section 2.1.1 pr esente le premier groupe, soit celui mesurant les erreurs entre une image de r ef erence et une image distortionn ee. Par la suite, la section 2.1.2 pr esente le deuxi` eme groupe, soit celui mesurant les similarit es entre une image de r ef erence et une image distortionn ee.

2.1.1

Mesure de lerreur dans limage

Une image ou un signal vid eo, dont la qualit e est evalu ee, peut etre repr esent ee comme la somme dun signal de r ef erence et dun signal derreur. Dans ce cas, la perte de qualit ea ` lint erieur de limage proviendrait directement de lintensit e du signal derreur. Une m ethode naturelle an de mesurer la qualit ea ` lint erieur dune image est de quantier lerreur entre un signal distortionn e et son signal de r ef erence. Les OIQM de la cat egorie FR les plus largement utilis ees et impl ementant ce concept sont la m etrique Mean Square Error (MSE) et la m etrique Peak Signalto-Noise Ratio (PSNR). Ces m etriques sont d ecrites par les equations (2.1) et (2.2) respectivement. 1 M SE = N
N i=1

(x i y i ) 2 , L2 . M SE

(2.1) (2.2)

P SN R = 10 log10

o` u xi et yi repr esentent les pixels de limage source et de limage distortionn ee respectivement, N repr esente le nombre total de pixels dans limage et L repr esente lintensit e maximale que peut prendre un pixel, soit la valeur 255 dans le cas de lutilisation dune r esolution a ` 8-bits par pixel.

8 Cependant, ces m etriques ne corr` elent pas tr` es bien avec la perception de la qualit e dimage dun observateur humain [38] [45]. Il a et e d emontr e dans [45] que di erents types de bruits appliqu es sur une image, per cus par un observateur humain comme ayant des niveaux de s ev erit e variables, pouvaient donner le m eme valeur de m etrique MSE. Cest pourquoi plusieurs m etriques mesurant la sensibilit e aux erreurs a ` lint erieur dune image furent d evelopp ees en se basant sur des mod` eles math ematiques du Syst` eme Visuel Humain (HVS). En g en eral, ces m etriques utilisent une structure algorithmique, illustr ee a ` la gure 2.1, bas ee sur cinq etapes. Lors de l etape un, des op erations de pr e-traitement telles que la transformation de lespace de couleur, la calibration des appareils de visualisation, etc, sont eectu ees. Par la suite, un ltrage des fonctions de sensibilit e de contraste est efectu e lors de l etape deux. L etape trois de cette structure sert a ` s eparer les stimulis visuels en sous-domaines de fr equence a ` partir de di erents mod` eles de d ecomposition de fr equence, e.g. Daly [15], Lubin [30], Wavelet [46], Tranform ee en Cosinus Discr` ete (DCT) [1], etc. Suite a ` cette d ecomposition, l etape quatre normalise chaque canal et l etape cinq de cette structure combine les signaux derreur, provenant des dif erents canaux, en un seul signal.
Normalisation D ecomposition en Canaux derreur et Masquage

Signal de R ef erence Signal Distortionn e

Pr eTraitement

Filtrage des Fonctions de Sensibilit es de Contraste

Mesure de

Groupement derreurs

Distortion / Qualit e

Figure 2.1 Diagramme de la structure g en erale des m etriques bas ees sur la mesure derreur.

2.1.2

Mesure des similarit es ` a lint erieur dune image

Le deuxi` eme groupe base sa philosophie sur lhypoth` ese que le syst` eme visuel humain est hautement adapt ea ` lextraction dinformations structurelles a ` partir de

9 son champ de vision [43]. Donc, la mesure du changement dinformation structurelle a ` lint erieur dune image pourrait fournir une bonne approximation de la distortion per cue de celle-ci. Cest la raison pour laquelle ce type de m etriques est bas ee sur la mesure de la perte dinformation structurelle per cue a ` lint erieur dune image distortionn ee, au lieu destimer lerreur per cue an de repr esenter la d egradation de celle-ci. La section 2.1.2.1 pr esente une m etrique de ce type que nous avons utilis e dans le cadre de ce travail.

2.1.2.1

Structural SIMilarity Index

Lindice de similarit e struturelle (SSIM, Structural SIMilarity) [43], est bas e sur la mesure des similarit es entre une image de r ef erence et une image bruit ee. Cette m erique consid` ere que la d egradation a ` lint erieur dune image provient de la variation de linformation structurelle per cue. Lindice SSIM est une m etrique FR evaluant la qualit e dimage qui est bas ee sur les caract eristiques psychophysiques du Syst` eme Visuel Humain (HVS) [16] [42]. La gure 2.2 illustre le fonctionnement de cette m etrique.
Signal x

Mesure de la Luminance
+

Mesure du Contraste Comparaison de la Luminance

/
Signal y

Mesure de la Luminance
+

Comparaison du Contraste

Combinaison

Measure de Similarit e

Mesure du Contraste

Comparaison de la Structure

Figure 2.2 Diagramme d ecrivant le fonctionnement de la m etrique SSIM. Lindice SSIM combine les indices de comparaisons provenant de la luminance (voir equation (2.4)), du contraste (voir l equation (2.5)), et de la structure (voir

10 l equation (2.6)), dune image. Cette m etrique compare une image de r ef erence x avec une image distortionn ee y an d evaluer une mesure de similarit e structurelle. SSIM (x, y ) = [l(x, y )] [c(x, y )] [s(x, y )] , 2x y + C1 l(x, y ) = , 2 2 x + y + C 1 2x y + C2 , c(x, y ) = 2 2 + C x 2 y xy + C3 s(x, y ) = , x y + C 3 (2.3) (2.4) (2.5) (2.6)

o` u C1 = (K1 L)2 , et C2 = (K2 L)2 . Bas e sur [43], nous adoptons = = = 1, C3 = C2 /2, K1 = 0.01, et K2 = 0.03. L repr esente la valeur dynamique dun pixel, et puisquun signal monochrome de 8-bits/pixel est utilis e, L = 255. Les variables x et y repr esentent lintensit e moyenne des images x et y , et les variables x et y repr esentent la d eviation standard, i.e. la racine carr ee de la variance, des images x et y . Lindice SSIM est calcul e localement pour chaque pixel a ` laide dune fonction de pond eration circulaire sym etrique Gaussienne, utilisant une matrice 11x11. Les indices SSIM calcul es pour chaque position sont combin es an de produire une image repr esentant une carte dindice SSIM. La moyenne de la carte des indices SSIM est utilis ee an d evaluer le valeur globale de la qualit e de limage evalu ee: 1 M SSIM (X, Y ) = M
M

SSIM (x, y ).
j =1

(2.7)

o` u M repr esente le nombre de pixels dans limage. Un code source C/C++ qui impl emente cette m etrique se trouve en r ef erence a ` lannexe C.

11 2.2 Di erence entre validation formelle et v erication fonctionnelle

Il existe une grande ambigu t e pour ce qui a trait a ` la di erence entre les d enitions et les r oles de la v erication fonctionnelle et de la validation dans le domaine de la micro electronique. Comme le chapitre 3 porte sur la validation de modules de traitement vid eo, di erencier ces deux activit es demeure donc important. La validation repr esente lensemble des activit es r ealis ees an dassurer la coh erence et la qualit e des sp ecications [3], i.e. les activit es qui tentent de comparer les requis avec le mod` ele provenant dune sp ecication textuelle ou ex ecutable. La validation permet de d etecter les erreurs a ` lint erieur dune sp ecication et les activit es li ees a ` la validation se d eroule lors de la sp ecication du mod` ele. Par contre, la v erication repr esente lensemble des activit es r ealis ees an de montrer la conformit e dune r ealisation vis-` a-vis de ses sp ecications [34]. Un syst` eme de v erication nest pas en mesure de d etecter une erreur provenant des sp ecications, contrairement a ` la validation. Un tel syst` eme vise plut ot a ` d etecter les erreurs fonctionnelles a ` lint erieur dun design. Les activit es reli ees a ` la v erication se d eroulent a ` la suite de la validation de la sp ecication du mod` ele.

2.3

Algorithmes de traitement vid eo

An de valider la m ethodologie de validation de modules de traitement vid eo, pr esent ee dans le chapitre 3, ce m emoire utilise des algorithmes de traitement vid eo provenant de deux classes dapplications, soit les algorithmes r educteur de bruits et les algorithmes de d e-entrelacement dimages. La section 2.3.1 pr esente les m ethodes de r eduction du bruit a ` lint erieur dune image, alors que la section 2.3.2 pr esente les m ethodes de d e-entrelacement vid eo.

12 2.3.1 M ethodes de r eduction du bruit vid eo

En g en eral, le but dun r educteur de bruit dans le domaine du traitement vid eo vise a ` am eliorer le rendu visuel de limage pour un observateur humain [29]. Les ltres r educteurs de bruit vid eo peuvent etre divis es en trois cat egories di erentes [23], soit les ltres spatiaux, les ltres temporels et les ltres spatio-temporels. La section 2.3.1.1 pr esente les types de bruit vid eo exp eriment es dans ce m emoire. Par la suite, les sections 2.3.1.2, 2.3.1.3, et 2.3.1.4 pr esentent respectivement le ltre Hybride, le ltre SUSAN, ainsi que le ltre de Wiener qui sont tous les trois des ltres r educteur de bruit vid eo faisant partie de la cat egorie des ltres spatiaux.

2.3.1.1

Types de bruit vid eo

Trois types de bruit furent impl ement es an dobserver les performances des algorithmes r educteur de bruits vid eo, soit le bruit gaussien, le bruit sel et poivre, et le bruit d ua ` la compression dimage. Ces types de bruit furent s electionn es parce quils sont grandement retrouv es dans les applications de traitement dimages. An dobserver leet de chacun des types de bruit, limage Lena, pr esent ee a ` la gure 2.3, sera utilis ee a ` titre dexemple. Le premier bruit consid er e, soit le bruit gaussien, est souvent ajout ea ` lint erieur dune image durant une transmission analogique perturb ee par du bruit al eatoire ou des interf erences electromagn etiques. Ce m emoire utilise la m ethode Box-

Muller [4], d ecrite par l equation (2.8), an de g en erer des valeurs al eatoires de bruit gaussien. La valeur du bruit est ajout ee a ` chacun des pixels de limage. n = 2 ln a cos(2b), (2.8)

13

Figure 2.3 Image Lena ne contenant pas de bruit. o` u a et b sont deux variables al eatoires uniformes ind ependantes comprises dans lintervalle ]0, 1[. Le niveau de la variance du bruit gaussien est contr ol e par la variable d enot ee . La gure 2.4 illustre trois exemples de limage Lena contenant du bruit gaussien avec di erents niveaux de variance.

(a)

(b)

(c)

Figure 2.4 Image Lena contenant du bruit gaussien. (a) = 0, 01, MSSIM = 0,629718; (b) = 0, 02, MSSIM = 0,522856; (c) = 0, 05, MSSIM = 0,384799. Le deuxi` eme bruit consid er e, soit le bruit sel et poivre, appara t comme des points noirs et blancs distribu es al eatoirement a ` lint erieur de limage. Ce type de bruit est souvent caus e par le processus de capture de limage. Le niveau de s ev erit e de

14 ce type de bruit dans limage est d etermin e par une fraction de pixels, exprim ee en pourcentage, aect ee par lalgorithme. La gure 2.5 illustre trois exemples de limage Lena contenant du bruit sel et poivre avec di erents pourcentages de bruit.

(a)

(b)

(c)

Figure 2.5 Image Lena contenant du bruit sel et poivre. (a) 10% de bruit, MSSIM = 0,804710; (b) 20% de bruit, MSSIM = 0,664750; (c) 50% de bruit, MSSIM = 0,409215. Le troisi` eme et dernier type de bruit consid er e, soit le bruit de compression, appara t dans limage sous forme deet de bloc suite a ` lapplication dun algorithme de compression dimage. Pour les besoins de ce m emoire, loutil de compression JPEG fut utilis e an de cr eer une d et erioration r ealiste [41]. Loutil de compression JPEG fut donc utilis e an dobtenir des images bruit ees. Le niveau de s ev erit e de ce type de bruit est directement li ea ` la qualit e de la compression de limage [21] g en er e par loutil JPEG. Plus le niveau de qualit e est elev e, moins limage est compress ee, i.e. contient moins de bruit de compression. La gure 2.6 illustre trois exemples de limage Lena contenant du bruit de compression avec di erents niveaux de qualit e.

15

(a)

(b)

(c)

Figure 2.6 Image Lena contenant du bruit de compression. (a) niveau de qualit e= 35, MSSIM = 0,879585; (b) niveau de qualit e = 15, MSSIM = 0,817463; (c) niveau de qualit e = 10, MSSIM = 0,777333. 2.3.1.2 Algorithme du ltre Hybride

Lalgorithme du ltre Hybride [29] provient de la combinaison du ltre Minimum Mean Square Error (MMSE) [26] et du ltre Sigma [24]. Limage ltr ee g , a ` la sortie du ltre Hybride, est calcul ee comme suit: g (x, y ) = g + Kg (g (x, y ) g ), (2.9)

o` u Kg est un gain non-lin eaire et g est la moyenne locale autour de chaque pixel: Kg = M AX 0,
2 g = 2 2 g n , 2 g

(2.10) (2.11) (2.12)

1 MN 1 MN
0

i,j

(Wg (g (x i, y j )) g )2 , Wg (g (x i, y j )), ,

g =

i,j

2 o` u g repr esente la variance locale autour de chaque pixel, Wg repr esente le masque

Wg =

1 if |g (x i, y j ) g (x, y )| < Ts

if |g (x i, y j ) g (x, y )| Ts

(2.13)

16 adaptatif pour la segmentation a ` lint erieur du ltre, et repr esente la matrice N par-M du voisinage local de chaque pixel se trouvant dans limage bruit ee g . Pour les besoins de ce m emoire et an de r eduire le temps de calcul, nous avons choisi
2 dans l equation (2.11) et le seuil M = N = 7. La variance du bruit d ecrit par n

de segmentation d ecrit par Ts dans l equation (2.13) sont deux param` etres devant etre estim es an dutiliser cet algorithme. Le code source C/C++ du ltre Hybride se trouve en r ef erence a ` lannexe D dans la section D.1 et la gure 2.7 illustre le fonctionnement de lalgorithme.
Segmentation

Ts

g (x, y )

Moyenne Locale
+

+ +

g (x, y )

Variance Locale

1 0

2 n

2 n

Figure 2.7 Sch ema illustrant le fonctionnement de lalgorithme du ltre Hybride.

2.3.1.3

Algorithme du ltre SUSAN

Le ltre spatial Smallest Univalue Segment Assimilating Nucleus (SUSAN) [36] [37] est un ltre adaptatif pr eservant la structure dune image en appliquant un lissage par rapport au voisinage faisant partie de la m eme r egion quun pixel. Ce ltre adaptatif peut- etre d ecrit par l equation: J (x, y ) =
i=0,j =0

I (x + i, y + j ) S (i, j ),

(2.14)

17 o` u S (i, j ) = e
(I (x+i,y +j )I (x,y ))2 i 2 +j 2 2 2 2 (I (x+i,y +j )I (x,y ))2 i 2 +j 2 2 2 2

(2.15)

e
i=0,j =0

et o` u J repr esente limage ltr ee et I repr esente limage bruit ee. Lalgorithme r educteur de bruit SUSAN est contr ol ea ` laide de deux param` etres. Le premier param` etre, d enot e dans l equation (2.15), contr ole la r esolution spatiale qui a un eet sur le lissage de limage ltr ee. Le second param` etre, d enot e dans l equation (2.15), xe le seuil dintensit e de luminosit e. Le code source C/C++ du ltre SUSAN se trouve en r ef erence a ` lannexe D dans la section D.2

2.3.1.4

Filtre adaptatif de Wiener

Le ltre adaptatif de Wiener est un estimateur lin eaire minimisant la racine carr ee de la moyenne de lerreur entre une image estim ee et une image originale [17].
2 2 2 Lorsque n < j ou bien que j = 0, limage ltr ee F par le ltre de Wiener est

calcul ee comme suit: F (k, l) = j +


2 2 j n (G(k, l) j ), 2 j

(2.16)

2 2 o` u n repr esente la variance du bruit, j et j repr esentent respectivement la

variance et la moyenne locale autour dun pixel j :


2 n = 2 j =

1 S

S 2 j , j =1

(2.17) G(k, l)2 2 j, G(k, l), (2.18) (2.19)

1 NM 1 NM

k,l

j =

k,l

18 o` u S repr esente la taille de limage, et repr esente la matrice N -par-M du voisinage


2 2 local autour de chaque pixel de limage bruit ee G. Par contre, lorsque n j

2 = 0, le ltre de Wiener retourne F (k, l) = j . Ce m emoire utilise ou bien que j

les valeurs suivantes pour les param` etres de cet algorithme: N = 3; M = 3. Le code source C/C++ du ltre de Wiener se trouve en r ef erence a ` lannexe D dans la section D.3 et la gure 2.8 illustre le fonctionnement de lalgorithme.
G(k, l)
Moyenne Locale
(j )
+ + +

F (k, l)

Variance Locale
2 ) (j

2 2 j 2 j

Variance du bruit
( 2 )

Figure 2.8 Sch ema illustrant le fonctionnement de lalgorithme du ltre Wiener.

2.3.2

M ethodes de d e-entrelacement vid eo

Le d e-entrelacement est un processus important qui convertit des s equences pour lesquelles le balayage est entrelac e en s equences pour lesquelles le balayage est progressif. La gure 2.9 illustre la t ache queectue le d e-entrelacement vid eo [18]. Les champs a ` lentr ee du signal vid eo, contenant les echantillons des lignes verticales paires ou impaires dune image, doivent etre convertis en des images enti` eres. Ces derni` eres repr esentent les m emes images correspondant aux champs a ` lentr ee, mais elles contiennent tous les echantillons des lignes de limage. Certains eets visuels incomfortables pour loeil humain peuvent appara tre lors dun mauvais d eentrelacement. Fondamentalement, les algorithmes de d e-entrelacement peuvent etre caract eris es par quatre cat egories [27]: le d e-entrelacement intra-champ, le d e-entrelacement inter-champ, le d e-entrelacement adaptatif au mouvement, et le

19 d e-entrelacement avec compensation de mouvement.


Interlaced Progressive

n1 field n Hz, 2:1

n1 frame n Hz, 1:1

Figure 2.9 Sch ema illustrant la t ache rattach e au d e-entrelacement tir e de [33]. Les algorithmes de d e-entrelacement de la cat egorie intra-champ sont plus ecaces pour des s equences contenant beaucoup de mouvement, alors que les algorithmes de la cat egorie inter-champ sont plus ecaces pour les s equences contenant plusieurs r egions statiques dans limage. Par contre, les algorithmes de d e-entrelacement de la cat egorie adaptatif au mouvement combinent les avantages des algorithmes de d e-entrelacement intra-champ et inter-champ. Ils utilisent un algorithme de d etection de mouvement appliquant lalgorithme de type intra-champ dans le cas dune r egion avec mouvement, ce qui permet d eviter les art efacts spatiaux a ` lint erieur de limage. Lalgorithme de type inter-champ est appliqu e dans le cas de la d etection dune r egion statique, ce qui permet d eviter une perte de r esolution [33]. Finalement, les algorithmes de d e-entrelacement du type compensation de mouvement poss` edent un plus grand potentiel de produire de meilleurs r esultats, mais ces derniers sont plus complexes par le fait quils requi` erent un module destimation de mouvement tr` es exigeant en terme de puissance de calcul. La section 2.3.2.1 pr esente les d etails du fonctionnement dun algorithme du type intra-champ qui fut s electionn e parce que les d etails math ematiques de son impl ementation sont disponibles dans la litt erature.

20 2.3.2.1 Algorithme de d e-entrelacement ELA modi e

Lalgorithme Edge-based Line Average (ELA) modi e [22] [27] est un algorithme de d e-entrelacement intra-champ largement utilis e dans le domaine du traitement vid eo. Un sch ema illustrant les di erentes etapes de cet algorithme an dinterpoler les pixels des lignes manquantes, d enot es ZELA , est pr esent ea ` la gure 2.10. Les variables contenues dans ce sch ema sont d ecrites plus loins a ` lint erieur de cette section.
Deux lignes balay ees

Calcul directionnel des di erences de fronti` ere (a,b,c,d,e)


(Fronti` ere dominante) Non Dv T v (Zone fronti` ere) Oui (Zone plane) Dd1 > Td Dd2 > Td Oui Non

Interpolation directionnelle

(Fronti` ere non-dominante)

Interpolation bilin eaire verticale

Interpolation directionnelle

Filtre m edian

ZELA

Figure 2.10 Sch ema du fonctionnement de lalgorithme ELA modi e. Lalgorithme reconstruit la ligne k a ` partir des lignes k 1 et k + 1. Dans la gure 2.11, a, b, c, d, et e repr esentent les di erences directionnelles autour du pixel x(k, n) qui doit etre interpol e. Ces cinq di erences directionnelles sont d enies par: a = |x(k 1, n 2) x(k + 1, n + 2)| b = |x(k 1, n 1) x(k + 1, n + 1)| c = |x(k 1, n) x(k + 1, n)| d = |x(k 1, n + 1) x(k + 1, n 1)| e = |x(k 1, n + 2) x(k + 1, n 2)| (2.20) (2.21) (2.22) (2.23) (2.24)

21
n2 k1 a k Nouvelle ligne Ligne Originale b c d e Ligne Originale n1 n n+1 n+2

k+1

Figure 2.11 Patron de pixels utilis e dans lalgorithme ELA modi e. La plus petite di erence, parmis les cinq di erences directionnelles, repr esente la meilleure corr elation. Les equations des interpolations directionnelles sont d enies par:

x(k1,n2)+x(k+1,n+2) 2 x(k1,n1)+x(k+1,n+1) 2 x(k1,n)+x(k+1,n) 2 x(k1,n+1)+x(k+1,n1) 2 x(k1,n+2)+x(k+1,n2) 2

si min(a, b, c, d, e) = a si min(a, b, c, d, e) = b si min(a, b, c, d, e) = c si min(a, b, c, d, e) = d si min(a, b, c, d, e) = e (2.25)

x(k, n) =

Par la suite, lalgorithme calcule si la direction estim ee est une fronti` ere dominante ou non. An de d eterminer si une direction estim ee est une fronti` ere

non-dominante, lalgorithme utilise les di erences entre la di erence directionnelle provenant de la meilleur corr elation et les di erences directionnelles oppos ees a ` la meilleur corr elation. Ces di erences sont d enot ees Dd1 et Dd2 :
Dd1 = |a d| Dd1 = |b d|

si min(a, b, c, d, e) = a

(2.26)

Dd2 = |a e| Dd2 = |b e|

si min(a, b, c, d, e) = b

(2.27)

22
Dd1 = |d a| Dd1 = |e a|

si min(a, b, c, d, e) = d

(2.28)

Dd2 = |d b|

si min(a, b, c, d, e) = e

(2.29)

Dd2 = |e b|

Lalgorithme de d e-entrelacement ELA modi e utilise deux param` etres d enot e Tv et Td . Le param` etre Tv repr esente le seuil vertical utilis e pour la di erence directionnelle d enot ee c dans la gure 2.11. Le param` etre Td repr esente le seuil de di erence directionnelle utilis e pour les deux di erences Dd1 et Dd2 , repr esent ees par les equations (2.26), (2.27), (2.28), et (2.29), an de d eterminer si la r egion est une fronti` ere dominante. Pour terminer, le calcul du ltre m edian, se trouvant dans le sch ema du fonctionnement de lalgorithme ELA modi ea ` la gure 2.10, est d ecrit par l equation (2.30). ZELA = M edian[x(k, n 1), x(k, n + 1), x(k, n)] (2.30)

2.4

Conclusion

Dans ce chapitre, les di erents concepts et aspects concernant la m ethodologie pr esent ee dans le Chapitre 3 de ce M emoire furent elabor ees. Cette m ethodologie concerne la validation automatique dalgorithme de traitement vid eo. Comme il est expliqu ea ` la section 2.2, les activit es reli ees a ` la validation se d eroulent lors de la sp ecication du mod` ele et permettent de d etecter les erreurs a ` lint erieur de celleci, ce que la v erication fonctionnelle ne peut accomplir. Une m etrique objective mesurant la qualit e dimage, nomm ee indice MSSIM, fut s electionn ee an de permettre le retrait dobservateur humain de la t ache d evaluation de la qualit e dimage a ` lint erieur de la m ethodologie de validation pr esent ee dans ce m emoire. Pour terminer, les algorithmes de traitement vid eo, provenant de la classe dapplication

23 des algorithmes r educteur de bruit et de la classe dapplication des algorithmes de d e-entrelacement, furent d ecrits a ` la section 2.3. Trois ltres num eriques dimage ainsi quun algorithme de d e-entrelacement vid eo furent s electionn es an de valider la m ethodologie de validation automatique dalgorithme de traitement vid eo propos ee et pr esent ee au chapitre 3. Il est a ` noter que la r etine de loeil humain est compos ee de 100 million de cellules appel es b atonnets, sensibles a ` lintensit e lumineuse, et de 5 million de cellules appel es c ones, sensibles a trois longueurs donde de lumi` ere, soit approximativement les couleur rouge, bleue et verte [33]. Les algorithmes de traitement vid eo sont g en eralement appliqu es dans le domaine de couleur Y U V , o` u le signal Y repr esente la luminance et les signaux U et V repr esentent la chrominance. Comme loeil humain est beaucoup plus sensible a ` la variation de la luminosit e, les algorithmes de traitement vid eo sont appliqu es seulement sur le signal de la luminance. Par contre, dans le cas du d e-entrelacement vid eo, une m ethode nomm ee duplication de lignes est appliqu ee pour les signaux de la chrominance [19].

24 CHAPITRE 3

VALIDATION DE MODULES DE TRAITEMENT VIDEO

Les architectures de modules de traitement vid eo sont g en eralement d eriv ees a ` partir dalgorithmes valid es ant erieurement utilisant une impl ementation C/C++ ou Matlab/Simulink. Elles sont g en eralement simul ees en r esolution virguleottante qui est une r esolution tr` es co uteuse en termes de co ut mat eriel. Une bonne approche an de minimiser ou doptimiser la complexit e dune impl ementation mat erielle, sa performance et sa consommation de puissance, est lutilisation de la pr ecision en virgule-xe. De plus, certains algorithmes de traitement vid eo contiennent des param` etres ayant besoin d etre x es an dobtenir une performance optimale. Ces param` etres sont g en eralement d etermin es empiriquement. La traduction dune formulation en virgule-ottante a ` une formulation en virgulexe, pour une impl ementation mat erielle, peut causer quelques probl` emes. Par exemple, la pr ecision de chaque op erande et la valeur de chaque param` etre contenu dans un algorithme doivent etre minutieusement s electionn ees an de pr eserver la stabilit e de lalgorithme, ainsi que lacuit e de son traitement. De plus, cette s election peut d et eriorer le comportement dun algorithme de traitement vid eo en produisant des art efacts visuels d eplaisant pour un observateur humain. Une nouvelle m ethode syst ematique et automatique est pr esent ee an de valider des algorithmes de traitement vid eo. Le but de cette m ethode est de pousser a ` un niveau dabstraction plus elev e le processus de validation dalgorithmes de traitement vid eo pour un concepteur mat eriel. An datteindre ce but, la nouvelle m ethode propos ee utilise une plateforme de validation automatique dalgorithmes

25 de traitement vid eo prenant avantage de nouvelles m etriques objectives mesurant la qualit e des images. Le fait dutiliser des m etriques objectives mesurant la qualit e des images permet de retirer un observateur humain du processus d evaluation de cette qualit e ou den augmenter sa productivit e. Ce chapitre est divis e en trois sections principales. La section 3.1 pr esente la plateforme de validation dalgorithmes de traitement vid eo. Un article de revue [10], concernant cette section, est disponible a ` lannexe A. Par la suite, la section 3.2 pr esente les modications apport ees a ` la plateforme de validation an destimer automatiquement des param` etres pour un algorithme de traitement vid eo. Un article de conf erence [11], concernant cette section, est disponible a ` lannexe B. Pour terminer, la section 3.3 formule les conclusions de ce chapitre.

3.1

Plateforme de validation dalgorithmes de traitement vid eo

Le passage dun algorithme de traitement vid eo en r esolution virgule-ottante vers une impl ementation en r esolution virgule-xe, une etape du processus qui conduit a ` une impl ementation mat erielle, peut causer certains probl` emes. Par exemple, la pr ecision de chaque op erande devrait etre m eticuleusement choisie an de pr eserver la stabilit e et lacuit e du comportement de lalgorithme. La sensibilit e de leet que peut avoir la taille de mots dune op erande, a ` lint erieur dun algorithme de traitement vid eo, nest pas tr` es claire a priori. De plus, ce passage peut d et eriorer le comportement dun algorithme de traitement vid eo en produisant des art efacts visuels d eplaisant pour un observateur humain. La validation aide un concepteur de mat eriel a ` concevoir et a ` impl ementer des syst` emes complexes en assurant, avec un haut niveau de conance, que ces derniers sont conformes dans toutes les circonstances [13]. La technique la plus commune

26 en validation de syst` emes est bas ee sur les tests et les simulations. Des techniques plus formelles, comme le model checking, d evelopp ees an dexplorer de mani` ere exhaustive toutes les possibilit es de comportement a ` lint erieur dun syst` eme, sont applicables pour la validation de la partie de contr ole dun syst` eme, mais ne sont pas applicables pour la validation des chemins de donn ees dun syst` eme. En effet, ces techniques utilisent une logique bool eenne temporelle an de valider les propri et es dun mod` ele provenant dune sp ecication ex ecutable. Cependant, ces techniques ne permettent dans aucun cas de valider la qualit e dune image produite par limpl ementation dun algorithme de traitement vid eo. La m ethode introduite dans [6] permet doptimiser automatiquement les chemins de donn ees a ` lint erieur dune impl ementation dun algorithme de traitement vid eo. Cette m ethode exploite un outil de d etermination automatique de la taille de mots (AWLDT) [7] [8] qui fut choisi pour deux raisons principales. Tout dabord, cet outil fut d evelopp e au sein du groupe de recherche en micro electronique (GRM) de lEcole Polytechnique de Montr eal et son impl ementation etait donc disponible. Par la suite, cet outil est le seul, se trouvant dans la litt erature, pouvant d eterminer automatiquement la taille de mots a ` laide de simulations. Cette m ethode fut ran ee an de faciliter la validation orient ee performance applicable a ` limpl ementation mat erielle dalgorithmes de traitement vid eo. En eet, les exp eriences conduites a ` laide dune premi` ere m ethode ont d emontr e que d ependamment de la m etrique utilis ee, celle-ci peut produire des anomalies dans les images r esultantes. Cest ce qui a motiv e le d eveloppement dune m ethode plus robuste qui evalue automatiquement la performance dalgorithmes de traitement vid eo tout en produisant des images valides, et cela, sans lintervention dun observateur humain qui aurait pour t ache de valider les r esultats. La composante cl ee de cette nouvelle m ethodologie repose sur la combinaison de loutil AWLDT avec une nouvelle m etrique pouvant rejeter des solutions g en erant des images distortionn ees. Les composants dont se

27 compose la plateforme de validation dalgorithmes de traitement vid eo, d evelopp es an daccomplir cette t ache, sont d ecrits plus en profondeur dans la section 3.1.1.

3.1.1

Composantes de la plateforme

La plateforme de validation dalgorithmes de traitement vid eo, illustr ee a ` la gure 3.1, utilise les m emes trois etapes que le model checking [13], i.e. la

mod elisation, la sp ecication et la v erication, m eme si la m ethodologie employ ee est tr` es di erente. Lors de la premi` ere etape, le concepteur de mat eriel doit produire un mod` ele de haut niveau de lalgorithme en langage C/C++ ou SystemC. Ce mod` ele doit etre modi e en une repr esentation Control Data Flow Graph (CDFG) an de d eterminer quelles seront les op erandes a ` analyser dans lalgorithme de traitement vid eo. Lors de la deuxi` eme etape, le concepteur de mat eriel doit d enir des objectifs de performances qui deviendront eventuellement des propri et es de la sp ecication du mod` ele. Lobjectif de performance de notre application, qui est d ecrite dans la section 3.1.1.2, utilise des m etriques objectives de mesure de la qualit e dimages, contrairement a ` la validation classique qui utilise de la logique temporelle, e.g. la logique temporelle lin eaire (LTL) ou les arbres de calculs logiques (CTL), an de d ecrire les propri et es de la sp ecication du mod` ele [13]. Lors de la troisi` eme etape, le concepteur de mat eriel doit valider le fait que chaque objectif de performance est rencontr e par le mod` ele. An de proc eder a ` cette derni` ere etape, la plateforme de validation dalgorithmes de traitement vid eo utilise loutils AWLDT, ` contrairement a ` lutilisation dun model checker pour la validation classique. A partir dobjectifs de performance et dune banque dimages, loutil AWLDT g en` ere un mod` ele optimis e du chemin de donn ees de lalgorithme qui rencontre les performances cibl ees pour limpl ementation mat erielle de lalgorithme de traitement vid eo.

28

Mod elisation

C/C++ / SystemC

CDFG Mod` ele bas niveau

Sp ecication

Objectif de Performance

V erication

Banques dimages

AWLDT

Mod` ele Optimis e avec Param` etres Estim es

Figure 3.1 Diagramme du fonctionnement de la plateforme de validation dalgorithmes de traitement vid eo. 3.1.1.1 Repr esentation bas niveau de lalgorithme

An de d eterminer les op erandes a ` analyser a ` lint erieur de lalgorithme de traitement vid eo, il faut proc eder a ` une conversion manuelle de la mod elisation de lalgorithme. Il faut que le concepteur passe dun mod` ele haut niveau C/C++, ou SystemC, vers un mod` ele bas niveau, en langage C, sous la forme dun DFG ordonnanc e [12] ou dun CDFG [28]. La gure 3.2 illustre lexemple du DFG or donnanc e pour le calcul de la moyenne locale, d enot e j dans lEquation (2.18) du ltre de Wiener d ecrit a ` la section 2.3.1.4. Il est possible dy observer que son DFG comporte 9 op erandes a ` analyser, soit 8 additions ainsi quune division. Voici le code haut niveau C/C++, de lexemple illustr ea ` la gure 3.2, calculant la moyenne locale j :
/ / L o c a l Mean

29
p00 p01 p02 p10 j p12

ou j G(k, l)

p20 p21 p22

p00

+
p01 p02

r0 r4

+ +
r1

p10 p11

+ +
r2 r5

r6

p12 p20

+ +
r3

+
9

r7

p21 p22 C1 C2 C3

C4

C5

Figure 3.2 DFG ordonnanc e de la moyenne locale j pour le ltre Wiener (voir equation (2.18))
for ( y = 1 ; y < = 1 ; y++){ for ( x = 1 ; x < = 1 ; x++){ mu j += G[ l + y ] [ k + x ] ; } } mu j = mu j / 9 ;

Voici maintenant le code bas niveau en langage C, bas e sur la repr esentation du DFG ordonnanc e illustr ea ` la gure 3.2, calculant la moyenne locale j :
/ / L o c a l Mean / / Cycle 1 R0 = P00 + P01 ;

30
R1 = P02 + P10 ; R2 = P11 + P12 ; R3 = P20 + P21 ; / / Cycle 2 R4 = R0 + R1 ; R5 = R2 + R3 ; / / Cycle 3 R6 = R4 + R5 ; / / Cycle 4 R7 = R6 + P22 ; / / Cycle 5 mu j = R7 / 9 ;

3.1.1.2

M etrique de performance

Loutil AWLDT, a ` laide dune heuristique appliquant une descente de gradient, cherche la combinaison de tailles de mot {W Li } minimisant le co ut de limpl ementation mat erielle de lalgorithme de traitement vid eo. An deectuer sa recherche dune solution optimale, loutil AWLDT est guid e par une m etrique de performance repr esent ee par linverse dun rapport (IRATIO). La m etrique globale IRATIO, illustr ee a ` la gure 3.3, calcule le rapport de la m etrique de qualit e dimage (OIQM) obtenue pour le chemin de donn ees en pr ecision nie (OIQM virgule-xe) sur la m eme m etrique obtenue pour la pr ecision compl` ete (OIQM virgule-ottante). La m etrique objective de mesure de qualit e dimages (OIQM) utilis ee dans la plateforme de validation dalgorithmes de traitement vid eo se nomme MSSIM et est d ecrite dans la section 3.1.1.2. La m etrique IRATIO se calcule donc comme suit:

31
Bruit
(Gaussien, Sel et Poivre, Compression, ou Entrelace)

Image Filtree
(VirguleFixe)

Image Originale

Image Bruitee

IRATIO = 1

VirguleFixe OIQM > VirguleFlottante OIQM

Objectif

Image Filtree
(VirguleFlottante)

Figure 3.3 Diagramme de l evaluation de lobjectif de performance.

IRAT IO =

m=0,M 1

max

o p M SSIM (Im , Im ) f o ,I ) M SSIM (Im m

(3.1)

o o` u M repr esente le nombre dimages a ` traiter, Im repr esente la mieme image origp inale (I o ), Im repr esente la mieme image ltr ee en r esolution virgule-xe (I p ) par f lalgorithme de traitement vid eo, Im repr esente la mieme image ltr ee en r esolution

virgule-ottante (I f ) par lalgorithme de traitement vid eo, et max repr esente la fonction maximum.

3.1.1.3

Fichier de simulation

Comme loutil AWLDT est bas e sur la simulation de lalgorithme an de trouver les tailles optimales des op erandes, ce dernier a besoin dun chier de simulation. Ce chier est g en er e par la plateforme de validation dalgorithmes de traitement vid eo a ` laide dune banque dimages [47]. Pour chacune des images s electionn ees par le concepteur, le chier contiendra la valeur de la m etrique calcul ee pour limage courante ltr ee en r esolution virgule-ottante, la taille de limage courante, limage courante de r ef erence et limage courante bruit ee. Le type de bruit, ainsi que son niveau dintensit e, est s electionn e par le concepteur. Le chier mod` ele C/C++ qui sert a ` simuler un algorithme r educteur de bruit dans loutil AWLDT se trouve a `

32 lannexe E dans la section E.1. De plus, le chier mod` ele C/C++ an de calculer lobjectif de performance dans loutil AWLDT se trouve dans la m eme section.

3.1.2

Anomalies observ ees

An de tester notre m ethodologie de validation dalgorithmes de traitement vid eo, le ltre adaptatif de Wiener, d ecrit dans la section 2.3.1.4, fut s electionn e en tant ` la suite de loptimisation du chemin de donn que mod` ele de r ef erence. A ees du ltre de Wiener en repr esentation virgule-xe, a ` laide de la plateforme de validation dalgorithmes de traitement vid eo propos ee, des r esultats furent obtenus avec deux types danomalies. Certaines solutions optimis ees, g en er ees par loutil AWLDT, contenaient des pixels n egatifs, alors que dautres contenaient des pixels ayant une intensit e lumineuse qui divergeait totalement de celle de leurs voisins. Ces r esultats furent obtenus m eme si la solution de limpl ementation en virgule-xe de lalgorithme, trouv ee par la plateforme de validation dalgorithmes de traitement vid eo, rencontrait les crit` eres de performance s ev` eres qui avaient et e x es. Le tableau 3.1 pr esente les r esultats, obtenus pour les m etriques Mean Square Error (MSE), Peak Signal-to-Noise Ratio (PSNR) et pour lindice MSSIM. Ces r esultats sont rapport es pour neuf images di erentes [47]. Chaque image originale contient du bruit gaussien avec un niveau de variance de 0,01. Les images bruit ees furent ltr ees a ` laide du ltre de Wiener en r esolution virgule-ottante et virgule-xe. Limpl ementation du ltre de Wiener en virgule-xe fut g en er ee par la plateforme de validation dalgorithmes de traitement vid eo utilisant la m etrique MSSIM ainsi quun objectif de performance de 0,95. Limpl ementation optimis ee en virgulexe du ltre de Wiener provenant de la plateforme de validation dalgorithmes de traitement vid eo g en` ere des anomalies visuelles. La gure 3.4 illustre un exemple, provenant du tableau 3.1, dune section de limage Lena ltr ee en r esolution virgule-

33 xe. Tableau 3.1 Valeurs de m etriques objectives mesurant la qualit e globale dimage, pour di erentes images contenant du bruit gaussien avec un niveau de variance de 0,01, ainsi que pour les images correspondantes ltr ees a ` laide du ltre de Wiener en r esolution virgule-ottante et virgule-xe.
Image Arctichare Boat Cameraman Cat Couple Fruits Goldhill Lena Peppers MSE 373,29 189,18 300,67 207,38 164,78 273,73 145,21 172,32 166,65 Bruit Gaussien PSNR MSSIM 22,410 0,292278 25,362 0,644498 23,350 0,541062 24,963 0,755108 25,962 0,729978 23,758 0,450619 26,511 0,753261 25,767 0,629845 25,913 0,620603 Filtre Wiener (virgule-ottante) MSE PSNR MSSIM 103,76 27,971 0,732639 81,08 29,041 0,807659 112,06 27,636 0,739830 128,70 27,035 0,844317 116,78 27,457 0,767334 69,81 29,692 0,766572 90,32 28,573 0,770426 66,37 29,911 0,811397 48,42 31,281 0,868091 Filtre Wiener (virgule-xe) MSE PSNR MSSIM 141,40 29,626 0,711137 97,51 28,240 0,795193 135,10 26,824 0,729231 147,08 26,455 0,832029 128,54 27,041 0,773001 91,73 28,506 0,745399 110,31 27,705 0,754731 87,31 28,720 0,788909 64,72 30,021 0,849463

Figure 3.4 Section de limage Lena ltr ee en r esolution virgule-xe provenant du tableau 3.1. M eme si lobjectif de performance est atteint pour la solution optimale de limpl ementation du ltre Wiener g en er ee par loutil AWLDT, celle-ci contient des anomalies visuelles et cette solution aurait due etre rejet ee. Les sections 3.1.2.1 et 3.1.2.2 elaborent plus en profondeur sur les deux types danomalies, g en er ees par la plateforme de validation dalgorithmes de traitement vid eo, quil faut absolument eviter.

34 3.1.2.1 Pixels n egatifs

Loptimisation du chemin de donn ees g en` ere des solutions contenant des op erandes optimis ees qui propagent des r esultats n egatifs jusqu` a la sortie du ltre num erique. Comme la plateforme de validation dalgorithmes de traitement vid eo utilise une m etrique objective calcul ee globalement, quelques pixels negatifs nont quune tr` es faible inuence sur le r esultat nal. Cela explique le fait quil est donc possible dobtenir une solution satisfaisant le crit` ere de performance x e a priori et g en erant des images contenant ce type danomalie. Les images illustr ees dans la gure 3.5 furent obtenues a ` partir de simulations du ltre Wiener fonctionnant en r esolution virgule-xe. Cette impl ementation du ltre num erique rencontre un objectif de performance de 0,9832, qui est une valeur relativement elev ee pour cette m etrique, ce qui nemp eche pas lapparition de ce type danomalie. Limage originale contient 85% de bruit de compression JPEG. Les pixels n egatifs sont repr esent es par des pixels blancs dans limage ltr ee en virgule-xe, illustr ee a ` la gure 3.5(b), et sont rapport ees par des taches noires dans la carte des indices SSIM, illustr ee a ` la gure 3.5(c).

3.1.2.2

Pixels divergeant de leur voisin

Des r esultats furent aussi obtenus avec des solutions optimis ees contenant des pixels poss edant un tr` es bas niveau dintensit e lumineuse. M eme un nombre restreint de pixels contenant ce type danomalie dans une image peuvent etre d etect es par un observateur humain. Cela est d u au fait que lintensit e lumineuse des pixels contenant cette anomalie di` ere signicativement de celle de leurs voisins. Les images contenues dans les gures 3.6, 3.7, et 3.8, obtenues a ` partir de la simulation de limpl ementation du ltre de Wiener provenant dune repr esentation en virgulexe qui atteint un objectif de performance de 0,9832, illustre ce type danomalie.

35

(a)

(b)

(c)

Figure 3.5 R esultats de simulation contenant des pixels n egatifs. (a) Image ltr ee Lena en virgule-ottante, MSSIM = 0,834480; (b) Image ltr ee Lena en virgulexe, MSSIM = 0,822677; (c) Carte des indices SSIM comparant limage Lena ltr ee en virgule-ottante et virgule-xe. Chaque image source contient du bruit gaussien avec un niveau de variance de 0,01. Les pixels divergeant de leurs voisins sont rapport es par des taches noires dans les cartes dindices SSIM des gures 3.6(c), 3.7(c). et 3.8(c). Le fait que loutil AWLDT accepte des solutions avec des pixels divergeant de leurs voisins peut etre encore expliqu e par lutilisation dune m etrique calcul ee globalement.

3.1.2.3

Instabilit es num eriques

Ces anomalies, retrouv ees dans les solutions optimales, peuvent etre expliqu ees par le fait que le ltre de Wiener devient instable num eriquement lorsque certaines op erandes sont trop optimis ees. En particulier, dans limpl ementation du ltre de Wiener, le r esultat dune des op erandes consiste a ` calculer lop eration G(k, l) j dans lEquation (2.16). Cette op eration sp ecique peut g en erer des r esultats n egatifs qui sont propag es vers trois autres op erandes dans le ltre. La gure 3.9 illustre la zone critique du chemin de donn ees du ltre de Wiener et la propagation des valeurs n egatives est repr esent ee par des traits pointill es. Ces valeurs

36

(a)

(b)

(c)

Figure 3.6 R esultats de simulation obtenus avec des pixels divergeant de leurs voisins. (a) Image ltr ee Boat en virgule-ottante, MSSIM = 0,807659; (b) Image ltr ee Boat en virgule-xe, MSSIM = 0,776457; (c) Carte des indices SSIM comparant limage Boat ltr ee en virgule-ottante et virgule-xe. n egatives peuvent se pr esenter autant en r esolution virgule-ottante que virgulexe. Cependant, le r esultat de cette op eration sert de num erateur a ` lint erieur dune op eration eectuant une division. Si la valeur du d enominateur est trop tronqu ee en r esolution virgule-xe, lop eration eectuant la division g en` ere un r esultat plus grand quen temps normal. La derni` ere op eration consiste a ` additionner ce r esultat n egatif, possiblement ampli e, avec la variance locale du pixel courant, ce qui explique la g en eration de pixels n egatifs. Ces anomalies dans les images r esultant de limpl ementation virgule-xe nous ont motiv es a ` d evelopper une nouvelle m etrique objective mesurant la qualit e dimage (OIQM). Cette OIQM est pr esent ee dans la section 3.1.3 et elle est capable de d etecter automatiquement des instabilit es num eriques a ` lint erieur dun algorithme de traitement vid eo calcul ee en virgulexe.

37

(a)

(b)

(c)

Figure 3.7 R esultats de simulation obtenus avec des pixels divergeant de leurs voisins. (a) Image ltr ee Cameraman en virgule-ottante, MSSIM = 0,739830; (b) Image ltr ee Cameraman en virgule-xe, MSSIM = 0,711923; (c) Carte des indices SSIM comparant limage Cameraman ltr ee en virgule-ottante et virgule-xe. 3.1.3 Utilisation dun seuil

Une premi` ere solution fut utilis ee an de r esoudre lanomalie pr esentant des pixels n egatifs illustr ee a ` la gure 3.5. Tous les r esultats produit par loutil AWLDT contenant des pixels n egatifs devaient etre automatiquement rejet es. Malgr e cette nouvelle mesure, des r esultats contenant le deuxi` eme type danomalie, soit des pixels ayant une intensit e lumineuse divergeant de celle de leurs voisins, furent quand m eme obtenus (voir gure 3.8). An de rem edier a ` lanomalie des pixels divergeant de leurs voisins, la m etrique MSSIM fut compl ement ee par un test additionnel bas e sur une variable nomm ee Pixel Threshold (PT). Ce test xe un seuil pour la valeur absolue maximale de la di erence entre lintensit e lumineuse des pixels produits par limpl ementation en virgule-ottante et celle en virgule-xe. Le seuil Pixel Threshold est une m etrique non-lin eaire locale qui permet de rejeter une solution si un seul pixel de limage ne satisfait pas le crit` ere de performance. La nouvelle OIQM, g en er ee a ` partir dune m etrique globale et dune m etrique locale,

38

(a)

(b)

(c)

Figure 3.8 R esultats de simulation obtenus avec des pixels divergeant de leurs voisins. (a) Image ltr ee Lena en virgule-ottante, MSSIM = 0,811397; (b) Image ltr ee Lena en virgule-xe, MSSIM = 0,775641; (c) Carte des indices SSIM comparant limage Lena ltr ee en virgule-ottante et virgule-xe. enl` eve les instabilit es num eriques a ` lint erieur des impl ementations mat erielles optimis ees dalgorithme de traitement vid eo. Les gures 3.10, 3.11, et 3.12 illustrent les r esultats obtenus a ` partir de la simulation du ltre de Wiener en r esolution virgule-xe r epondant a ` un objectif de performance de 0,95 et ayant un seuil PT maximal de 34. Chaque image originale contient du bruit gaussien avec un niveau de variance de 0,01. Les images produites par limpl ementation du ltre de Wiener en r esolution point-xe, valid ee a ` laide de la nouvelle OIQM, ne contiennent pas
2 j

SUB

MAX
0

MUL

DIV

ADD

F (k, l)

G(k, l)

SUB

Figure 3.9 Zone critique du chemin de donn ees du ltre de Wiener.

39 danomalie, m eme si lobjectif global de performance est plus bas que celui utilis e pour produire les r esultats pr esent es aux gures 3.6, 3.7, et 3.8.

(a)

(b)

(c)

Figure 3.10 R esultats de simulation obtenus avec la nouvelle OIQM. (a) Image ltr ee Boat en virgule-ottante, MSSIM = 0,807659; (b) Image ltr ee Boat en virgule-xe, MSSIM = 0,795193; (c) Carte des indices SSIM comparant limage Boat ltr ee en virgule-ottante et virgule-xe. La gure 3.13 illustre la m eme section de limage Lena ltr ee en r esolution virgulexe, que celle illustr ee a ` la gure 3.4. Cette image fut obtenue a ` laide dune impl ementation du ltre de Wiener ex ecut ee en r esolution virgule-xe, provenant de la plateforme de validation dalgorithmes de traitement vid eo utilisant la nouvelle OIQM combinant les m etriques globale et locale. Les images, produites par la nouvelle impl ementation du ltre, ne contiennent pas danomalie visuelle, a ` loppos e de limage de la gure 3.4. Dans le tableau 3.2, les r esultats, obtenus a ` laide de la premi` ere solution, ainsi qu` a laide de la nouvelle OIQM, sont rapport es pour neuf images di erentes [47]. Pour le cas de la premi` ere solution, lobjectif de performance etait de 0,9832, alors que pour le cas de la nouvelle OIQM, lobjectif de performance etait de 0,95. Finalement, lobjectif du seuil PT maximal etait de 34. Chaque image originale contient du bruit gaussien avec un niveau de variance de 0,01. Les r esultats obtenus d emontrent que la m etrique globale OIQM utilis ee, soit la m etrique MSSIM dans le cas pr esent, fournit des scores naux tr` es similaires.

40

(a)

(b)

(c)

Figure 3.11 R esultats de simulation obtenus avec la nouvelle OIQM. (a) Image ltr ee Cameraman en virgule-ottante, MSSIM = 0,739830; (b) Image ltr ee Cameraman en virgule-xe, MSSIM = 0,729231; (c) Carte des indices SSIM comparant limage Cameraman ltr ee en virgule-ottante et virgule-xe. Par contre, les di erences maximales observ ees entre les pixels (DMOP) sont tr` es di erentes. Il est a ` sp ecier que les r esultats obtenus avec la nouvelle OIQM ne contiennent pas danomalies visuelles (voir les gures 3.10, 3.11, et 3.12) alors que la premi` ere solution en produit toujours (voir les gures 3.6, 3.7, et 3.8). Tableau 3.2 Comparaison entre la premi` ere solution et la nouvelle OIQM. Image Arctichare Boat Cameraman Cat Couple Fruits Goldhill Lena Peppers Premi` ere solution MSSIM DMOP 0,702804 48 0,776457 51 0,711923 81 0,807311 72 0,745483 56 0,731802 69 0,746624 67 0,775641 52 0,835310 43 Nouvelle OIQM MSSIM DMOP 0,711137 33 0,795193 32 0,729231 31 0,832029 33 0,773001 27 0,745399 28 0,754731 28 0,788909 26 0,849463 25

41

(a)

(b)

(c)

Figure 3.12 R esultats de simulation obtenus avec la nouvelle OIQM. (a) Image ltr ee Lena en virgule-ottante, MSSIM = 0,811397; (b) Image ltr ee Lena en virgule-xe, MSSIM = 0,788909; (c) Carte des indices SSIM comparant limage Lena ltr ee en virgule-ottante et virgule-xe. 3.2 Validation de param` etres

Un grand nombre dalgorithmes de traitement vid eo sont contr ol es par des param` etres devant etre x es an de pouvoir les utiliser. Un bon ajustement de ces param` etres peut avoir un impact signicatif sur la performance et le comportement de lalgorithme. Ces param` etres sont habituellement d etermin es empiriquement par les concepteurs de mat eriel [37] [29] [22]. Il y a donc ici le besoin dune m ethodologie an dautomatiser la d etermination et la validation des param` etres contr olant les algorithmes de traitement vid eo. La m ethodologie de validation dalgorithmes de traitement vid eo fut donc modi ee an de rencontrer deux objectifs principaux. Le premier objectif consiste a ` d eterminer lensemble des param` etres de contr ole dun algorithme de traitement vid eo maximisant la qualit e des images produites par cet algorithme. Trouver cet ensemble de param` etres est un processus doptimisation complexe. An de bien saisir la complexit e de ce processus doptimisation, prenons a ` titre dexemple le

42

Figure 3.13 Section de limage Lena ltr ee en r esolution virgule-xe et ne contenant aucune anomalie. ltre Hybride d ecrit dans la section 2.3.1.2 et ayant 2 param` etres a ` optimiser. Le premier param` etre, d enot e Ts , peut prendre 75 valeurs di erentes et le sec2 ond param` etre, d enot e n , peut prendre 256 valeurs di erentes. Donc, il y a

75 256 = 19200 possibilit es pour lensemble des param` etres an dimpl ementer le ltre Hybride. Comme une simulation logicielle de ltre Hybride, evaluant 4 images, prend 81,3 secondes de temps de calcul sur une station SPARC SunFire V440, ayant 8 Go de m emoire RAM, il faudrait 18,07 jours pour simuler lensemble des param` etres an de d eterminer la combinaison de param` etres optimale avec cette base de donn ees restreinte dimages. Le second objectif consiste a ` d eterminer la combinaison des tailles de mots an de minimiser le co ut de limpl ementation mat erielle de lalgorithme de traitement vid eo selon un objectif de performance d etermin e par le concepteur. Dans lexemple du ltre Hybride, il y a 23 op erandes a ` optimiser, et chacune dentre elles poss` ede 32 possibilit es de congurations di erentes. Donc, il y a 3223 = 4, 2 1034 di erentes fa cons dimpl ementer le ltre Hybride. Dans ce cas, en utilisant la m eme station UNIX sous les m emes conditions, il faudrait 1, 1 1029 ann ees pour simuler toutes les possibilit es an de d eterminer la combinaison optimale des tailles de mot du

43 chemin de donn ees de lalgorithme. Les modications apport ee a ` loutil AWLDT, an que la m ethodologie puisse automatiquement estimer les param` etres dun algorithme de traitement vid eo tout en optimisant et validant son impl ementation mat erielle, sont d ecrites dans la section 3.2.1. Par la suite, la section 3.2.3 pr esente les r esultats obtenus a ` laide de la nouvelle plateforme de validation dalgorithmes de traitement vid eo.

3.2.1

Modication de la m ethodologie

Le probl` eme concernant loptimisation de fonctions contenant plusieurs param` etres et selon de multiples objectifs est bien connu dans la litt erature et plusieurs ` partir des algorithmes m ethodes sont propos ees an dadresser ce dernier [2] [31]. A de traitement vid eo analys es pour cette section, il fut observ ea ` laide de multiples simulations sur di erentes images et s equences vid eo que le domaine des solutions dint er et des param` etres de chaque algorithme ne contenait pas de multiples minimum locaux. Donc, une approche simple, bas ee sur une descente de gradient, fut s electionn ee an de d eterminer lensemble des valeurs optimales de chacun des param` etres. Il est clair que la m ethode propos ee pourrait b en ecier grandement de m ethodes doptimisation plus complexes comme les algorithmes g en etiques ou le recuit simul e si, et seulement si, il existe des minimums locaux a ` des endroits non pr evisibles. Dans le cas contraire, leur utilisation ralentirait grandement la m ethodologie propos ee, car ces algorithmes sont tr` es co uteux en termes de temps de calcul logiciel. An de guider loutil AWLDT vers la solution optimale, deux indices de qualit e sont calcul es. Le premier indice de qualit e, d enot e Q1 , est calcul e comme suit: Q1 = 1 M
M 1 m=0 o n M SSIM (Im , Im ) f o ,I ) M SSIM (Im m

(3.2)

44
o o` u M repr esente le nombre dimages a ` traiter, Im repr esente la mieme image orign inale (I o ), Im repr esente la mieme image dentr ee bruit ee aect ee par un type de f repr esente la mieme image de sortie ltr ee (I f ) par lalgorithme bruit d eni (I n ), Im

de traitement vid eo, et M SSIM () repr esente la m etrique objective de mesure de la qualit e dimages d ecrite dans la section 2.1.2.1. Le deuxi` eme indice de qualit e, d enot e Q2 , est calcul e comme suit: Q2 = min
o n M SSIM (Im , Im ) f o ,I ) M SSIM (Im m

m=0,M 1

(3.3)

o` u min() repr esente la fonction minimum. Le but de la premi` ere phase est de trouver la solution maximisant la somme des indices de qualit e en utilisant un poids egal pour chacun dentre eux. Pour chacun des param` etres Pl , l = 0, 1, . . . , L 1 o` u Pl repr esente la valeur dun param` etre consid er e et L repr esente le nombre de param` etres a ` estimer, le concepteur de mat eriel doit d enir les valeurs des limites sup erieures Plmax et inf erieures Plmin . De plus, le concepteur doit d enir le pas de r esolution minimum Slmin pour chacun des param` etres. La seconde phase est eectu ee pratiquement de la m eme fa con que celle d ecrite dans la section 3.1.1.2, avec pour particularit e que les param` etres sont trait es en tant quop erandes. De plus, au lieu de modier la taille de mot, comme pour chaque op erande, en additionnant ou en soustrayant un bit, loutils AWLDT modie la valeur de chaque param` etre en augmentant ou en r eduisant ce dernier par sa valeur Slmin . Cette phase utilise deux m etriques de mesure de qualit e dimage, soit la m etrique globale IRATIO et la m etrique locale PT. Le fait doptimiser simultan ement (i.e. dans un seul processus) la taille de mot de chaque op erande et la valeur de chaque param` etre permet dajuster pr ecis ement chaque valeur an de r eduire lerreur due a ` la pr ecision nie du chemin de donn ees.

45 Cette m ethodologie, combinant deux phases doptimisation, fut impl ement ee et appliqu ee avec succ` es sur trois algorithmes de traitement vid eo. La sec-

tion 3.2.3 pr esente les r esultats obtenus, a ` laide de la m ethodologie destimation de param` etres et de la validation dimpl ementation mat erielle dalgorithme de traitement vid eo, pour ces trois algorithmes.

3.2.2

Fichier de simulation

Comme loutil AWLDT est bas e sur la simulation de lalgorithme an destimer et de trouver les tailles optimales des op erandes, ce dernier a besoin dun chier de simulation. Ce chier est g en er e par la plateforme de validation dalgorithmes de traitement vid eo. Dans le cas dun r educteur de bruit avec param` etres, le chier contiendra, pour chacune des images, la taille de limage courante, limage courante de r ef erence et limage courante bruit ee. Le type de bruit, ainsi que son niveau dintensit e, doit etre s electionn e par le concepteur. Le chier mod` ele C/C++ qui permet de simuler un algorithme r educteur de bruit avec ses param` etres dans loutil AWLDT se trouve a ` lannexe E dans la section E.2. De plus, le chier mod` ele C/C++ qui permet de calculer lobjectif de performance dans loutil AWLDT se trouve dans la m eme section. Par la suite, dans le cas dun algorithme de d e-entrelacement vid eo, le concepteur doit fournir les images enti` eres de chacune des s equences. La plateforme de validation dalgorithmes de traitement vid eo transforme par la suite ces s equences en champs pairs et impairs, i.e. en s equences dimages entrelac ees. Finalement, le chier de simulation qui sera g en er e contiendra, pour chacune des s equences, la taille de limage courante, le nombre de champs de la s equence courante, limage de r ef erence et chacun des champs de la s equence courante. Le chier mod` ele C/C++ qui permet de simuler un algorithme de d e-entrelacement vid eo dans loutil

46 AWLDT se trouve a ` lannexe E de la section E.3. De plus, le chier mod` ele C/C++ qui permet de calculer lobjectif de performance pour ce type dalgorithme dans loutil AWLDT se trouve dans la m eme section.

3.2.3

R esultats obtenus

An de tester notre m ethodologie, trois algorithmes de traitement vid eo, partiellement d enis par des param` etres, furent s electionn es en tant que mod` eles de r ef erence. Le premier et le second algorithme, d ecrits dans les section 2.3.1.2 et 2.3.1.3 respectivement, sont des ltres spatiaux. Le troisi` eme algorithme, d ecrit dans la section 2.3.2.1, est un algorithme de d e-entrelacement de s equences vid eo. Les r esultats obtenus pour ces trois algorithmes sont rapport es dans le tableau 3.3. Les r esultats pour le ltre Hybride furent obtenus a ` partir de quatre images, provenant de la banque dimages de [47]. De plus, lalgorithme poss` ede deux param` etres a ` estimer ainsi que vingt-trois op erandes a ` optimiser. Les r esultats pour le ltre SUSAN furent obtenus a ` partir de neuf images, provenant de la banque dimages de [47]. De plus, lalgorithme poss` ede deux param` etres a ` estimer ainsi que sept op erandes a ` optimiser. Finalement, les r esultats pour lalgorithme de d e-entrelacement du type intra-champ ELA modi e furent obtenus a ` partir de la huiti` eme image de la s equence vid eo Football. Cet algorithme poss` ede deux param` etres a ` estimer ainsi que quatre op erandes a ` optimiser. Tableau 3.3 R esultats obtenus pour trois algorithmes de traitement vid eo di erents.
Algorithmes Param` etres ` a estimer 2 2 2 Op erandes ` a optimiser 23 7 4 Co ut mat eriel Objectif de Performance IRATIO 0,03000 0,05000 0,05000 PT 34 34 34 Performance Obtenue IRATIO 0,025248 0,003128 0,035429 PT 28 31 29 Temps de calcul (s) 505605 17040 576

Filtre Hybrid Filtre SUSAN ELA modi e

140 65 23

Les valeurs optimales estim ees des param` etres du ltre Hybride, obtenues a ` laide

47 de la plateforme de validation dalgorithme de traitement vid eo, sont Ts = 46


2 et n = 186.845776. La gure 3.14 illustre les courbes de contour de lindice

de qualit e Q1 (voir lEquation (3.2)) pour les param` etres du ltre Hybride. Ces courbes furent obtenues manuellement a ` laide de simulations C/C++ du ltre Hybride en repr esentation virgule-ottante et en xant les limites du param` etre T s dans lintervalle [15, 75], avec un pas de 2, et en xant les limites du param` etre
2 dans lintervalle [10, 255], avec un pas de 5. Un total de 1550 simulations de n

lalgorithme furent obtenues pour chacune des images. La gure 3.14 fut calcul ee a ` laide du logiciel Matlab, en interpolant les solutions possibles an de produire des courbes de contour plus faciles a ` visualiser. An de conclure cette section, il est possible dobserver dans le tableau 3.3 que les objectifs de performance furent atteints avec une marge confortable et que le temps de calcul, an de valider limpl ementation dun algorithme de traitement vid eo, est d ependant du nombre de param` etres a ` estimer et dop erandes a ` optimiser. Deux techniques pour acc el erer lanalyse des algorithmes de traitement vid eo seront pr esent ees au chapitre 4. Il est est tout de m eme possible de remarquer que dans le cas du ltre hybride, une solution fut obtenue en 5,81 jours. Ce temps pour obtenir un r esultat valide est beaucoup plus rapide que de simuler toutes les possibilit es pour les valeurs des param` etres de lalgorithme, soit 18,07 jours, et pour la taille optimale des op erandes, soit 1, 1 1029 ann ees.

3.3

Conclusion

Dans ce chapitre, une approche pour estimer les param` etres dalgorithmes de traitement vid eo et pour valider leur impl ementation mat erielle fut pr esent ee. Le but de cette approche est de pousser la t ache destimation de param` etres optimaux pour des algorithmes de traitement vid eo et de validation de leur impl ementation

48
Hybrid filter Parameter Estimation (Mean RATIO)
0.7477
70

Ts (Segmentation Threshold)

50

40

0.7 48 2

60

0.7475
0.7477
0.7497 0.7507

0.7536
0.7629
30

0.7576
0.7689

0.7771
0.7877

0.8
0.8211
20

0.8337

0.855

0.8756
50 100 150 200 250

2 (Noise Variance) g

Figure 3.14 Indice de Qualit e Q pour lestimation des param` etres du ltre Hybride. a ` un niveau dabstraction plus elev e pour un concepteur mat eriel. An datteindre notre but, une m ethodologie, prenant avantage dun outil de d etermination automatique de la longueur de mots dun algorithme (AWLDT) et dune nouvelle m etrique objective mesurant la qualit e dimage (OIQM), fut propos ee. Lutilisation dOIQM permet de retirer un observateur humain du processus d evaluation de la qualit e dimage et guide loutil AWLDT vers la solution optimale. Les r esultats exp erimentaux obtenus d emontrent que la combinaison dun objectif de performance globale et local permet d eviter lobtention dimpl ementation dalgorithmes de traitement vid eo produisant des erreurs locales dues aux instabilit es num eriques. La m etrique locale adopt ee eectue une comparaison pixel a ` pixel fonctionnant bien avec les ltres spatiaux ainsi que les algorithmes de d eentrelacement classique. Loutil AWLDT fut modi e an de d eterminer automatiquement, en un seul processus doptimisation, la combinaison des tailles de mot minimales an de minimiser le co ut de limpl ementation mat erielle, tout en rencontrant la qualit e dimage

49 sp eci ee par le concepteur, en identiant les valeurs optimales pour les param` etres de contr ole selon la pr ecision nie du chemin de donn ees. Cette m ethodologie doptimisation syst ematique et de validation automatique fut appliqu ee sur trois algorithmes de traitement vid eo. Les r esultats exp erimentaux obtenus a ` laide de ces algorithmes d emontrent que lensemble des param` etres obtenus du processus doptimisation concordent avec lensemble des valeurs optimales obtenues manuellement en simulation. Ces r esultats d emontrent de plus que la m ethodologie propos ee peut automatiquement d eterminer et valider les param` etres contr olant les algorithmes de traitement vid eo.

50 CHAPITRE 4

ERATION TECHNIQUES DACCEL DE LA VALIDATION DALGORITHMES DE TRAITEMENT VIDEO

Dans ce chapitre, il sera question de deux techniques dacc el eration de la validation dalgorithmes de traitement vid eo. Tout dabord, la premi` ere technique concerne le regroupement dop erandes eectuant la m eme op eration math ematique et recevant des donn ees de m eme taille. Cette technique est abord ee dans [40] sur la base dune analyse math ematique formelle, alors que lanalyse pr esente sera faite a ` laide de simulations. Par la suite, la deuxi` eme technique concerne lanalyse autonome du regroupement dop erandes en sous-ensembles faisant partie dune structure parall` ele. Ce chapitre pose comme hypoth` ese que lanalyse des op erandes et des param` etres dun algorithme de traitement vid eo, a ` laide des deux techniques propos ees, est moins co uteuse en terme de temps de simulation, tout en procurant sensiblement le m eme co ut mat eriel. Ce chapitre est divis e en trois sections. La section 4.1 pr esente lalgorithme de d e-entrelacement adaptatif au mouvement servant de mod ele de r ef erence pour l etude eectu ee dans ce chapitre. Par la suite, la section 4.2 pr esente les r esultats obtenus a ` laide des deux techniques dacc el eration de lanalyse. Pour terminer, la section 4.3 formule les conclusions concernant ce chapitre et propose quelques travaux futurs.

4.1

Algorithme de d e-entrelacement adaptatif au mouvement

Lalgorithme utilis e, an de proc eder a ` lanalyse propos ee, provient dun algorithme de d e-entrelacement adaptatif au mouvement [25]. Ce dernier est compos e

51 de trois algorithmes distincts fonctionnant en parall` ele. Le code source C/C++ de lalgorithme de d e-entrelacement adaptatif au mouvement se trouve en r ef erence a ` lannexe F. La gure 4.1 illustre le sch ema bloc des trois algorithmes qui le composent. Lalgorithme de d e-entrelacement adaptatif au mouvement re coit a ` lentr ee quatres champs, d enot es Ti , Tj , Tk et Tl , repr esentant respectivement le champ qui pr ec` ede le pr ec edant, le champs pr ec edant, le champ courant, ainsi que le champ suivant. Tout d ependamment de la nature du champ courant, cesta `-dire un champ contenant seulement des lignes paires ou seulement des lignes impaires, lalgorithme interpole les lignes manquantes du champ courant an de reconstituer limage en entier. Les trois composantes de cet algorithme seront d ecrites aux sections 4.1.1, 4.1.2 et 4.1.3. La premi` ere composante de lalgorithme consiste a ` d etecter le mouvement a ` lint erieur du champ courant an dappliquer soit lalgorithme intra-champ, dans le cas dune r egion dynamique, soit lalgorithme inter-champ, dans le cas dune r egion statique. La deuxi` eme composante de

lalgorithme consiste en un algorithme de d e-entrelacement de type intra-champ qui est plus ecace pour les s equences vid eo contenant beaucoup de mouvement. Pour terminer, la troisi` eme composante de lalgorithme consiste en un algorithme de d e-entrelacement de type inter-champ qui est plus ecace pour les s equences vid eo poss edant peu ou pas de mouvement.

4.1.1

Algorithme de d etection de mouvement

Cet algorithme a pour principale t ache de d eterminer, pour chacun des pixels a ` interpoler, si la zone courante est une r egion avec du mouvement, une r egion avec fronti` ere ou une r egion statique. An de d eterminer linformation relative au mouvement, lalgorithme utilise les r esultats de calculs de trois di erences dintensit e entre des pixels provenant de quatre champs, illustr e par la gure 4.2. Ces trois di erences dintensit e entre les pixels des quatre champs sont d enies par les

52
Algorithme de d etection de mouvement
Ti Tj Tk Tl BDa D etection BDb de mvt BDc D etection MED maximale Filtre M EDM Seuil de m edian d ecision

Commuta teur

Pixel Interpol e Z

Algorithme IntraChamp
Filtre Edge-based Line Average Modi e (ELA modifi e)

Algorithme InterChamp
Adaptive Minimum Pixel Dierence Filter (AMPDF)

Figure 4.1 Sch ema de lalgorithme de d e-entrelacement adaptatif au mouvement. equations (4.1), (4.2) et (4.3).

ai cj bi Ti Tj

ak Z bk Tk

cl

Tl

Figure 4.2 D etection de mouvement a ` laide de quatre champs de r ef erence.

BDa = |ak ai |, BDb = |bk bi |, BDc = |cl cj |.

(4.1) (4.2) (4.3)

Lorganigramme de lalgorithme qui eectue la classication du pixel Z a ` interpoler,

53 a ` laide des trois di erences dintensit e BDa , BDb , et BDc , est illustr ea ` la gure 4.3 et son r esultat est d ecrit par l equation (4.4). Lorsque lalgorithme classie la zone comme etant une r egion en mouvement, la variable prend la valeur 1 et le r esultat de lalgorithme ELA modi e (voir section 2.3.2.1) est appliqu e au pixel a ` interpoler Z . Dans le cas o` u lalgorithme classie la zone comme etant une r egion statique, la variable prend la valeur 0 et le r esultat de lalgorithme Adapdive Minimum Pixel Dierence Filter (AMPDF), pr esent ea ` la section 4.1.3, est appliqu e au pixel a ` interpoler Z . Dans le cas contraire, lalgorithme classie la zone comme etant une r egion avec fronti` ere. Les valeurs possibles que peuvent prendre la variable sont d ecrites par l equation (4.5).
BDa , BDb , BDc

Di erence dintensit e lumineuse Maximale M BDt M BDt1 M BDt2 Filtre m edian

M BDM

No
M BDM > Tmov M BDM > Tbak

No

Yes

Yes

Zone dynamique

Zone fronti` ere

Zone statique

Figure 4.3 Sch ema de de la classiation de lalgorithme de d etection de mouvement.

Z = (1 ) ZAM P DF + ZELA ,

(4.4)

54
1 0

, r egion avec mouvement , r egion avec fronti` ere , r egion statique (4.5)

M BDM Tbak Tmov Tbak

Les gures 4.4 et 4.5 illustrent le d e-entrelacement du champ 9 des s equences football et stennis respectivement. Pour ces deux s equences, lalgorithme de

d etection de mouvement emploie le param` etre Tmov = 34 et le param` etre Tbak = 7, d etermin es chacun par notre plateforme de validation dalgorithmes de traitement vid eo. Les gures 4.4(a) et 4.5(a) repr esentent les deux images enti` eres d e-entrelac ees a ` laide de lalgorithme AMPDF et les gures 4.4(b) et 4.5(b) repr esentent les r esultats locaux de la m etrique objective de qualit e dimage MSSIM. Par la suite, les gures 4.4(c) et 4.5(c) repr esentent les images enti` eres d e-entrelac ee a ` laide de lalgorithme ELA modi e et les gures 4.4(d) et 4.5(d) repr esentent les images des r esultats locaux de la m etrique MSSIM. Finalement, les gures 4.4(e) et 4.5(e) repr esentent les images enti` eres d e-entrelac ee a ` laide de lalgorithme de d e-entrelacement adaptatif au mouvement, an dillustrer le comportement de lalgorithme de d etection de mouvement, et les gures 4.4(f) et 4.5(f) repr esentent les images des r esultats locaux de la m etrique MSSIM. Dans le cas des r esultats locaux de la m etrique MSSIM, les valeurs varient dans lintervalle [0, 1]. An de repr esenter chacun des r esultats sous la forme de pixels an dobtenir une image enti` ere, ceux-ci sont multipli es par la valeur 255. Les r egions blanches repr esentent alors des valeurs de m etriques elev ees, tandis que les r egions noires repr esentent des valeurs de m etriques faibles. Le tableau 4.1 fournit les r esultats de la qualit e des images, calcul es avec la m etrique de qualit e vid eo MSSIM, par les di erents sous algorithmes de d e-entrelacement faisant partie de lalgorithme de d e-entrelacement adaptatif au mouvement, appliqu es aux s equences pr esent ees aux gures 4.4 et 4.5. La s equence football con-

55

(a)

(b)

(c)

(d)

(e)

(f)

Figure 4.4 D e-entrelacement du champ 9 de la s equence football, par lalgorithme (a) ELA modi e, (b) AMPDF, (c) adaptatif au mouvement, et carte des indices SSIM pour lalgorithme (d) ELA modi e, (e) AMPDF, (f) adaptatif au mouvement.

56

(a)

(b)

(c)

(d)

(e)

(f)

Figure 4.5 D e-entrelacement du champ 9 de la s equence stennis par lalgorithme (a) ELA modi e, (b) AMPDF, (c) adaptatif au mouvement, et carte des indices SSIM pour lalgorithme (d) ELA modi e, (e) AMPDF, (f) adaptatif au mouvement.

57 tient plusieurs el ements de mouvement, alors que la s equence stennis contient plut ot plusieurs el ements statiques. Cest la raison pour laquelle il est logique dobserver dans le tableau 4.1 que lalgorithme ELA modif e est plus ecace pour la premi` ere s equence, alors que lalgorithme AMPDF est plus ecace pour la deuxi` eme s equence. Les r esultats de lalgorithme de d etection de mouvement d emontrent que lalgorithme de d e-entrelacement adaptatif au mouvement est ecace pour les deux s equences. Par contre, lalgorithme de d etection de mouvement peut eectuer une mauvaise d etection r esultant a ` lapplication du mauvais algorithme de d e-entrelacement pour le pixel courant. Cela explique le r esultat inf erieur de lindice MSSIM pour lalgorithme de d etection de mouvement lors de la s equence footbal par rapport a ` lalgorithme ELA modi e. Tableau 4.1 Qualit e des images obtenues avec di erents algorithmes de d eentrelacement. Algorithme S equence football S equence stennis AMPDF 0.647615 0.942922 ELA modi e 0.952369 0.715651 D etection de mouvement 0.860798 0.951585

4.1.2

Algorithme de d e-entrelacement ELA modi e

La description de lalgorithme de d e-entrelacement ELA modi e se trouve dans la section 2.3.2.1. Cet algorithme utilise le champ d enot e Tk an dinterpoler les pixels des lignes manquantes. Pour les deux s equences, pr esent ees par les gures 4.4 et 4.5, lalgorithme emploie les param` etres Td = 50 et Tv = 102, d etermin es chacun par notre plateforme de validation dalgorithmes de traitement vid eo.

58 4.1.3 Algorithme de d e-entrelacement AMPDF

Lalgorithme AMPDF [25] est un algorithme de d e-entrelacement de type interchamp. An de proc eder a ` linterpolation des pixels des lignes manquantes, cet algorithme utilise trois champs de r ef erences d enot es Tj , Tk et Tl , illustr es a ` la gure 4.6, et passe a ` travers trois etapes. Le sch ema d ecrivant les di erentes etapes an dinterpoler le pixel courant Z est illustr ea ` la gure 4.7.
m1 m m1

Zj

Z
m+1

Zl

m+1 n2 n n+2 n n

m+1

Tj

Tk

Tl

Figure 4.6 D e-entrelacement a ` laide de trois champs de r ef erence.


Tj , T k , T l Recherche grossi` ere (Etape 1) Zstep1

ADstep1 < Tstep1

no

Recherche ran ee (Etape 2)

Zstep2

ADstep2 < Tstep1

no

Recherche ran ee (Etape 3)

yes

yes

Filtre M edian (Zj , Zstep1 , Zl )

ZAM P DF

Figure 4.7 Sch ema du fonctionnement de lalgorithme AMPDF. La premi` ere etape de lalgorithme consiste a ` calculer la di erence absolue entre 5 pixels provenant du champ Tj et le pixel de r ef erence Zl , provenant du champ Tl . Le

59 pixel ayant la plus petite di erence absolue est s electionn e et est d enot e Zstep1 . Si la di erence minimale est plus petite que le seuil Tstep1 , un ltre m edian est utilis e an dobtenir la valeur nale du pixel a ` interpoler. La recherche de la di erence absolue minimale est d ecrite par l equation (4.6).

ADstep1 = min |Zl (n, m) Zj (n, m)|,

|Zl (n, m) Zj (n, m 1)|, |Zl (n, m) Zj (n 2, m)|, |Zl (n, m) Zj (n + 2, m)|, |Zl (n, m) Zj (n, m + 1)|

(4.6)

Si la di erence minimale de la premi` ere etape est plus grande que le seuil Tstep1 , lalgorithme passe a ` la deuxi` eme etape. Celle-ci consiste au calcul de la di erence absolue entre 4 pixels provenant du champs Tk et le pixel de r ef erence Zl . Les positions verticale et horizontale, d enot ees respectivement x1 et y1 , proviennent du pixel nomm e Zstep1 . Le pixel ayant la plus petite di erence absolue est s electionn e et est d enot e Zstep2 . La recherche de la di erence absolue minimale est d ecrite par l equation (4.7).

ADstep2 = min

|Zl (n, m) Zk (x1 1, y1 )|, |Zl (n, m) Zk (x1 1, y1 ) + 1|,

|Zl (n, m) Zk (x1 + 1, y1 )|,

|Z (n, m) Z (x + 1, y + 1)| l k 1 1

(4.7)

Si la di erence minimale est plus grande que le seuil Tstep2 , lalgorithme rane sa

60 recherche une seconde fois et passe a ` l etape 3. La troisi` eme et derni` ere etape de lalgorithme consiste a ` calculer la di erence absolue entre 4 pixels provenant des champs Tj et Tk et le pixel de r ef erence Zl . Les positions verticale et horizontale, d enot ees respectivement x2 et y2 , proviennent du pixel nomm e Zstep2 . Le pixel ayant la plus petite di erence absolue devient alors la valeur du pixel a ` interpoler. La recherche de la di erence absolue minimale est d ecrite par l equation (4.8).

ADstep3 = min

|Zl (n, m) Zj (x2 , y2 1)|, |Zl (n, m) Zj (x2 , y2 )|,

|Zl (n, m) Zk (x2 1, y2 )|, |Z (n, m) Z (x + 1, y )| l k 2 2

(4.8)

Pour les deux s equences, pr esent ees par les gures 4.4 et 4.5, lalgorithme emploie les param` etres Tstep1 = 55 et Tstep2 = 85, d etermin es chacun par notre plateforme de validation dalgorithmes de traitement vid eo.

4.2

R esultats obtenus

Les r esultats, pr esent es aux sections 4.2.1 et 4.2.2, ont et e obtenus a ` laide de deux s equences vid eo, soit les champs 7, 8, 9, et 10 de la s equence football, ainsi que les champs 7, 8, 9, et 10 de la s equence stennis. Dans les deux cas, les champs 7 et 9 sont de type paire, et les champs 8 et 10 sont de type impaire. Donc, lalgorithme de d e-entrelacement doit reconstituer limage 9 en entier, i.e. interpoler les lignes impaires de limage. Les impl ementations de lalgorithme de d e-entrelacement adaptatif au mouvement en r esolution virgule-xe proviennent de notre plateforme de validation dalgorithmes de traitement vid eo avec comme objectifs de performance

61 IRATIO x ea ` 0.05 et PT x ea ` 34. La premi` ere technique dacc el eration consiste a ` regrouper des op erandes eectuant la m eme op eration math ematique et recevant des donn ees de m eme taille. La ` lint gure 4.8 illustre un exemple du regroupement dop erandes. A erieur du DFG ordonnanc e de cette gure, les quatres op erations daddition se trouvant dans le rectangle en lignes pointill ees rouges qui peuvent etre regroup ees en une seule op erande a ` analyser. Par la suite, la deuxi` eme technique dacc el eration consiste a ` analyser de fa con autonome le regroupement dop erandes en sous-ensemble faisant partie dune structure parall` ele. Par exemple, lalgorithme de d e-entrelacement adaptatif au mouvement, illustr ea ` la gure 4.1, peut etre d ecompos e en trois sousensembles.
p00

+
p01 p02

r0 r4

+ +
r1

p10 p11

+ +
r2 r5

r6

p12 p20

+ +
r3

+
9

r7

p21 p22 C1 C2 C3

C4

C5

Figure 4.8 DFG ordonnanc e illustrant un exemple du regroupement dop erandes.

4.2.1

Premi` ere technique dacc el eration de lanalyse

Pour la premi` ere technique dacc el eration, lalgorithme de d etection de mouvement, d ecrit a ` la section 4.1.1, fut utilis e en tant que mod` ele de r ef erence. Lors de la

62 premi` ere etape de lalgorithme, trois di erences dintensit es sont eectu ees (voir equations (4.1), (4.2) et (4.3)). Celles-ci peuvent etre divis ees en 2 op erations, soit une soustraction et une valeur absolue. Les r esultats obtenus a ` laide de cet algorithme sont illustr es a ` la gure 4.9.
Cot matriel
70 69
450

Temps de simulation
500

68
400

67 Unit de cot HW
350

66 65 64 63 62 61 60 11

Nb ditration

300

250

200

150

100

50 11

11.5

12

12.5

13

13.5

14

14.5

15

11.5

12

12.5

13

13.5

14

14.5

15

Nb doprandes + paramtres

Nb doprandes + paramtres

(a)

(b)

Figure 4.9 R esultats de simulation pour lalgorithme de d etection de mouvement et variation des (a) temps de simulation et (b) co ut mat eriel en fonction du nombre dop erandes et de param` etres. Un deuxi` eme mod` ele de r ef erence fut utilis e, soit lalgorithme ELA modi e. La premi` ere etape de cet algorithme consiste a ` eectuer cinq di erences directionnelles (voir equations (2.20), (2.21), (2.22), (2.23) et (2.24)). Comme pour lalgorithme de d etection de mouvement, celles-ci peuvent etre divis ees en 2 op erations, soit une soustraction et une valeur absolue. Les r esultats obtenus a ` laide de cet algorithme sont illustr es a ` la gure 4.10. Pour les deux algorithmes, on peut clairement observer, a ` laide des courbes des graphiques 4.9(a) et 4.10(a), que le temps de simulation augmente avec le nombre de param` etres et op erandes a ` analyser. Par contre, pour ce qui est du co ut mat eriel, mesur e en nombre de bits de largeur totaux dans lensemble des

63

Temps de simulation
500 120

Cot matriel

450

110

400

100

300

Unit de cot HW
7 8 9 10 11 12 13 14 15

350

90

Nb ditration

80

250

70

200

60

150

50

100

40

10

11

12

13

14

15

Nb doprandes + paramtres

Nb doprandes + paramtres

(a)

(b)

Figure 4.10 R esultats de simulation pour lalgorithme ELA modi e et variation des (a) temps de simulation et (b) co ut mat eriel en fonction du nombre dop erandes et de param` etres. op erandes, les deux algorithmes nont pas les m emes tendances. Dans le cas de lalgorithme de d etection de mouvement, la courbe du graphique 4.9(b) d emontre que le co ut mat eriel augmente sensiblement avec un nombre croissant de param` etres et dop erandes a ` analyser. Cependant, dans le cas de lalgorithme ELA modi e, la courbe du graphique 4.10(b) d emontre que le co ut mat eriel d ecro t avec le nombre de param` etres et dop erandes a ` analyser. Cette tendance peut etre expliqu ee par le fait que la quantication dop erandes a ` lint erieur dun chemin de donn ees peut annuler lerreur engendr ee par dautres op erandes pr ec edant ces derni` eres. Il est a ` noter que cette tendance fut d ej` a observ ee dans [5].

4.2.2

Deuxi` eme technique dacc el eration de lanalyse

Pour la deuxi` eme technique dacceleration, toutes les combinaisons danalyse, a ` partir des trois sous-algorithmes composants lalgorithme de d e-entrelacement adap-

64 tatif au mouvement, furent eectu ees, i.e. les sept combinaisons possibles d ecrites au tableau 4.2. Par exemple, pour la combinaison 4 de ce tableau, les algorithmes ELA modi e et AMPDF sont analys es ensemble alors que lalgorithme de d etection de mouvement est analys e s epar ement. Lorsque les algorithmes ELA modi e et AMPDF sont analys es, lalgorithme de d etection de mouvement demeure en r esolution virgule-ottante. Par la suite, lorsque lalgorithme de d etection de mouvement est analys e, les algorithmes ELA modi e et AMPDF demeurent en r esolution virgule-ottante. Les tailles des op erandes et des param` etres des trois sous-algorithmes et de lalgorithme en entier sont donn ees au tableau 4.3. Tableau 4.2 Di erentes combinaisons danalyse de lalgorithme. Combinaisons 1 2 3 4 5 6 7 D etection de mouvement ELA AMPDF Modi e X X X X X X X X Op erandes et param` etres 7 8 11 15 18 19 26

X X X X

Tableau 4.3 Tailles des op erandes et param` etres des algorithmes. Algorithme de d e-entrelacement D etection de mouvement ELA modi e AMPDF Adaptatif au mouvement Op erandes Param` etres 9 2 5 2 6 2 20 6

La gure 4.11 illustre les r esultats obtenus pour cette deuxi` eme technique dacc el eration de la validation dalgorithme de traitement vid eo. Les r esultats obtenus pour le temps de simulation, illustr es par le graphique 4.11(a), d emontrent que le temps de simulation augmente lin eairement lorsque le nombre dop erandes et de param` etres a ` analyser devient plus grand. Sur ce graphique, le temps de simulation

65 est exprim e en terme du nombre dit erations que prend loutil AWLDT. Chaque it eration prend un temps dex ecution de 11,52 secondes lorsque loutil est ex ecut e sur un Sun Fire V890 / 16 processeurs ayant 32 Go de m emoire et roulant avec le syst` eme dexploitation Solaris 9. La simulation de chacune des composantes de lalgorithme s epar ement, i.e. lalgorithme ELA modi e prenant 103 it erations, lalgorithme AMPDF prenant 127 it erations et lalgorithme de d etection de mouvement prenant 245 it erations, pour un total de 475 it erations, prennent moins de temps de simulation que lanalyse de lalgorithme de d e-entrelacemnt adaptatif au mouvement en entier, car ce dernier prend 1224 it erations. La courbe du graphique 4.11(b) d emontre que le co ut mat eriel reste sensiblement le m eme, soit entre 88 et 97. Il y a une l eg` ere tendance vers la hausse du co ut mat eriel avec plus dop erandes et de param` etres a ` analyser. Cette tendance est normale car lorsque certaines op erandes ne sont pas analys ees, elles demeurent en r esolution virgule-ottante, i.e. elles gardent leur pleine r esolution, ce qui entra ne que les tailles des op erandes analys ees peuvent etre davantage r eduites. Ceci a une r epercussion sur la performance de lalgorithme. En eet, lorsque chacun des sous-algorithmes est analys e s epar ement, les objectifs de performance sont atteints. Cependant, lorsque les impl ementations en r esolution virgule-xe de ces sous-algorithmes sont combin ees ensemble pour former lalgorithme en entier, il y a une baisse de performance qui peut etre observ ee sur la courbe du graphique 4.11(c). Cette baisse de performance de lalgorithme provenant de la combinaison des analyses vient conrmer lhypoth` ese de d epart, a ` savoir que lanalyse des op erandes et des param` etres dun algorithme de traitement vid eo, a ` laide des deux techniques propos ees, est moins co uteuse en terme de temps de simulation, tout en procurant sensiblement le m eme co ut mat eriel. Pour terminer, il est normal de trouver, sur les courbes des graphiques de la gure 4.11, certains points ne suivant pas la tendance des autres donn ees. En eet, loutil AWLDT utilise une heuristique an

66 doptimiser les param` etres ainsi que la taille des op erandes a ` analyser a ` lint erieur de lalgorithme. Donc, loutil AWLDT, en tentant de minimiser le co ut mat eriel, tout en respectant les objectifs de performance, fournit non pas la solution optimale de limpl ementation en r esolution virgule-xe, mais bien une des solutions localement optimales.

4.3

Conclusion

Dans ce chapitre, deux techniques an dacc el erer lanalyse pour la validation dalgorithmes de traitement vid eo ont et e pr esent ees. La premi` ere technique dacc el eration de lanalyse porte sur le regroupement dop erandes eectuant la m eme op eration math ematique et recevant des donn ees de m eme taille. Par la suite, la deuxi` eme technique dacc el eration de lanalyse porte sur le regroupement dop erandes en sous-ensemble provenant dune structure en parall` ele faisant partie du m eme ensemble. Les r esultats obtenus a ` laide de lalgorithme de d e-entrelacement adaptatif au mouvement ont conrm e les hypoth` eses pos ees au d epart. En eet, de mani` ere globale, lanalyse des op erandes et param` etres de cet algorithme est moins co uteuse en terme de temps de simulation. Le co ut mat eriel demeure sensiblement le m eme, mais par contre, il y a une l eg` ere baisse au niveau de la per formance de lalgorithme. Evidemment, il ne sagit que dun exemple. An de g en eraliser ces tendances, il faudrait pousser plus loins la pr esente analyse a ` laide, entre autre, dalgorithmes provenant de di erentes classes dapplication. De plus, il serait probablement possible dautomatiser la segmentation de lalgorithme en sous-ensembles distincts a ` laide dune m ethodologie plus formelle utilisant des mod` eles math ematiques an danalyser les d ependances de donn ees.

67

Temps de simulation
2000 120

Cot matriel

1800

115

1600

110

1400

105

Unit de cot HW

Nb ditration

1200

100

1000

95

800

90

600

85

400

80

200

75

70 6 8 10 12 14 16 18 20 22 24 26

10

12

14

16

18

20

22

24

26

Nb doprandes + paramtres

Nb doprandes + paramtres

(a)
Performance
1

(b)

RATIO (MSSIM virgulefixe/ MSSIM virguleflottante)

0.99

0.98

0.97

0.96

0.95

0.94

0.93

0.92

0.91

0.9

10

12

14

16

18

20

22

24

26

Nb doprandes + paramtres

(c)

Figure 4.11 R esultats de simulation pour lalgorithme de d e-entrelacement adaptatif au mouvement, variation du (a) temps de simulation, (b) co ut mat eriel, et (c) de la performance, en fonction du nombre dop erandes et param` etres.

68 CHAPITRE 5

CONCLUSION

` lint A erieur de ce chapitre, la section 5.1 pr esente une synth` ese des travaux pr esent es dans les chapitres 2, 3, et 4. Par la suite, la section 5.2 termine ce chapitre et propose des am eliorations ainsi que des possibilit es pour des travaux futurs sur la validation dalgorithme de traitement vid eo.

5.1

Synth` ese du travail accompli

Dans le chapitre 2,

les di erents concepts concernant la m ethodologie

doptimisation applicable a ` la mise en oeuvre dalgorithmes de traitement vid eo furent enonc es. Comme cette m ethodologie doit etre syst ematique et automatique, une m etrique objective mesurant la qualit e dimage, soit lindice MSSIM, fut s electionn e an de permettre le retrait dobservateur humain de la t ache d evaluation de la qualit e dimage. Cette m etrique est bas ee sur la mesure des similarit es entre une image de r ef erence et une image distortionn ee. Lindice MSSIM est une m etrique mesurant la variation de linformation structurelle per cue a ` lint erieur dune image et est une m etrique FR bas ee sur des caract eristiques du syst` eme visuel humain. Par la suite, les di erents algorithmes servant a ` valider la m ethodologie pr esent ee dans ce m emoire, ainsi que les types de bruit vid eo furent pr esent es. Trois ltres num eriques de la cat egorie des ltres spatiaux furent d ecrits, soit le ltre Hybride, le ltre SUSAN, ainsi que le ltre adapatatif de Wiener. Ce chapitre a aussi couvert les m ethodes de d e-entrelacement vid eo ainsi que lalgorithme de type intra-champ ELA modi e.

69 Le chapitre 3 a pr esent e la plateforme de validation dalgorithme de traitement vid eo d evelopp ee dans le cadre des travaux de ce m emoire. Cette plateforme supporte une m ethodologie qui permet destimer les param` etres dalgorithmes de traitement vid eo et de valider leur impl ementation mat erielle. Cette m ethodologie, propos ee dans ce chapitre, prend avantage dun outil de d etermination automatique de la longueur de mot dun algorithme (AWLDT) et dune nouvelle m etrique objective mesurant la qualit e dimage. Cette nouvelle m etrique fut d evelopp ee a ` lint erieur de ce chapitre. Il a et e

d emontr e que lutilisation dOIQM permet de retirer un observateur humain du processus d evaluation dimage. De plus, cet OIQM guide loutil AWLDT vers la solution optimale de limpl ementation mat erielle de lalgorithme de traitement vid eo produisant des images valides. Les r esultats exp erimentaux obtenus dans ce chapitre d emontrent que la combinaison dobjectifs global et local permet d eviter lobtention dimpl ementation mat erielle produisant des erreurs locales dues aux instabilit es num eriques de lalgorithme ex ecut e en virgule-xe. Par la suite, les modications apport ees a ` loutil AWLDT, an de d eterminer automatiquement, en un seul processus doptimisation, la combinaison de la taille de mot minimale an de minimiser le co ut de limpl ementation mat erielle, ainsi que les valeurs optimales pour les param` etres de contr ole, furent pr esent ees dans ce chapitre. Les r esultats exp erimentaux pr esent es a ` laide de trois algorithmes de traitement vid eo, soit le ltre Hybride, le ltre SUSAN, et lalgorithme de d eentrelacement vid eo ELA modi e, ont d emontr e que lensemble des param` etres obtenus de la plateforme de validation dalgorithme de traitement vid eo concordent avec les valeurs optimales th eoriques. Finalement, dans le chapitre 4, deux techniques an dacc el erer lanalyse de la validation dalgorithmes de traitement vid eo furent pr esent ees. La premi` ere tech-

70 nique dacc el eration de lanalyse pr esent ee porte sur le regroupement dop erandes eectuant la m eme op eration math ematique et recevant des donn ees de m eme taille. La deuxi` eme technique dacc el eration de lanalyse pr esent ee porte sur le regroupement dop erandes en sous-ensembles provenant dune structure en parall` ele faisant partie du m eme ensemble. Les r esultats obtenus a ` laide de lalgorithme de d e-entrelacement adaptatif au mouvement ont conrm e les hypoth` eses pos ees au d epart. En eet, de mani` ere globale, ces techniques font en sorte que lanalyse des op erandes et param` etres de cet algorithme devient moins co uteuse en terme de temps de simulation. De plus, le co ut mat eriel demeure sensiblement le m eme, mais par contre, une l eg` ere baisse au niveau de la qualit e des images produites par lalgorithme fut observ ee.

5.2

Travaux futurs et am eliorations

Ce m emoire utilise la combinaison dune m etrique globale, ainsi que dune m etrique locale an de guider loutil AWLDT vers des solutions produisant des images valides, soit des impl ementations sans instabilit e num erique. Cette m etrique globale est une OIQM nomm ee indice MSSIM. Cette m etrique fut choisie, car au moment o` u cette recherche a et e eectu ee, elle semblait etre la meilleure disponible dans la litt erature. Une nouvelle m etrique mesurant la qualit e dimage et la qualit e vid eo est maintenant disponible [35]. Cette OIQM est nomm ee Visual Information Fidelity (VIF). Cest une m etrique du type FR bas ee sur des carat eristiques du syst` eme visuel humain. Cette m etrique se distingue des autres OIQM traditionnelles par le fait quen am eliorant le contraste dune image de fa con lin eaire sans ajouter de bruit, la m etrique VIF retourne un r esultat plus elev e que le r esultat dune image sans bruit. Cela signie donc que limage r esultante peut etre plus attrayante en regard de crit` ere subjectif vis-` a-vis de limage de r ef erence. Bref, la

71 m etrique VIF est capable de capturer lam elioration de la qualit e visuelle dans une image. Il serait donc int eressant de remplacer la m etrique globale MSSIM par la m etrique VIF an d etudier si les r esultats produits par la plateforme de validation dalgorithme de traitement vid eo seraient sup erieurs a ` ceux obtenus dans ce M emoire. Pour terminer, une approche g en erique fut utilis ee dans ce m emoire pour ce qui est de lutilisation des m etriques de qualit e dimage. En eet, la m eme m etrique fut utilis ee pour di erents types de bruit, ainsi que pour deux classes dapplications dalgorithme de traitement vid eo. Une etude sur les OIQM pourrait etre eectu ee pour des cas plus sp eciques, i.e. faire lutilisation de m etriques sp ecialis ees. Par exemple, une m etrique du type NR, se trouvant dans la litt erature, est sp ecialis ee dans la mesure dart efacts de compression dans une image ou dans une s equence vid eo, plus pr ecis ement elle se sp ecialise dans la mesure de leet de bloc [32]. Donc, il serait tr` es int eressant dutiliser une telle m etrique a ` lint erieur de la plateforme de validation dalgorithme de traitement vid eo an de valider limpl ementation dun r educteur de bruit se sp ecialisant dans le retrait de leet de bloc dans une image. Cela permettrait dobserver si lutilisation dune m etrique sp ecialis ee fournit une meilleure impl ementation mat erielle que lutilisation dune m etrique plus g en erale.

72 BIBLIOGRAPHIE

[1] Agostini, L., Silva, I., and Bampi, S. Pipelined fast 2D DCT Architecture for JPEG Image Compression. IEEE International Conference on ApplicationSpecic Systems, Architectures, and Processors (2003), 378388. [2] Belegundu, A. Optimization Concepts and Applications in Engineering. Prentice Hall, 1999. [3] Borrione, D. La simulation et les m ethodes de v erication formelle.

Lavoisier, 2002, ch. 5, pp. 139174. [4] Box, G., and Muller, M. A note on the generation of normal random deviates. Annals of Mathematical Statistics vol. 29 (1958), 610611. [5] Cantin, M.-A. M ethode de D etermination Automatique de la Taille

des Chemins de Donn ees. PhD thesis, Ecole Polytechnique de Montr eal, D epartment de G enie Electrique, 2005. [6] Cantin, M.-A., Regimbal, S., Catudal, S., and Savaria, Y. An Unied Environment to Assess Image Quality in Video Processing. Journal of Circuits, Systems and Computers vol. 13, no. 6 (December 2004), 12891306. [7] Cantin, M.-A., Savaria, Y., and Lavoie, P. A Comparison of Automatic Word Length Optimization Procedures. IEEE International Symposium on Circuits and Systems vol. 2 (2002), 612615. [8] Cantin, M.-A., Savaria, Y., Prodanos, D., and Lavoie, P. An Automatic Word Length Determination Method. IEEE International Symposium on Circuits and Systems vol. 5 (2001), 5356. [9] Carnec, M., Le Callet, P., and Barba, D. Full Reference and Reduced Reference Metrics for Image Quality Assessment. IEEE Symposium on Signal Processing and Its Applications vol. 1 (July 2003), 477480.

73 [10] Catudal, S., Cantin, M.-A., and Savaria, Y. Performance Driven Validation Applied to Video Processing. WSEAS Transaction on Electronics vol. 1, no. 3 (July 2004), 568575. [11] Catudal, S., Cantin, M.-A., and Savaria, Y. Parameter Estimation Applied to Automatic Video Processing Algorithms Validation. IEEE International Symposium on Circuits and Systems (May 2005), 34393442. [12] Cesario, W., and Jerraya, A.-A. Lavoisier, 2002, ch. 3, pp. 65108. [13] Clarcke, E., Grumberg, O., and Peled, D. Model Checking. The MIT Press, January 2002. [14] Cupak, M., Catthoor, F., and De Man, H. Ecient System-Level Functional Verication Methodology for Multimedia Applications. IEEE Design and Test of Computers vol. 20 (March-April 2003), 5664. [15] Daly, S. The visible dierence predictor: An algorithm for the assessment of image delity. The MIT Press, 1993, pp. 179206. [16] Furth, B., and Marqure, O. The Handbook of Video Databases: Design and Applications. CRC Press, September 2003. [17] Granger, E., Catudal, S., Grou, R., Mbaye, M. M., and Savaria, Y. On Current Strategies for Hardware Acceleration of Digital Image Restoration Filters. WSEAS Transaction on Electronics vol. 1, no. 3 (July 2004), 551557. [18] Haan, G. D., and Bellers, E. De-Interlacing An Overview. Procedings of the IEEE vol. 86, no. 9 (September 1998), 18391857. [19] Jack, K. Video Demystied: A Handbook for the Digital Engineer. Elsevier, 1996. La conception comportementale.

74 [20] Kraljic, I., Verdier, F. S., Quenot, G., and Zavidovique, B. Investigating Real-Time Validation of Real-Time Image Processing. IEEE International Workshop on Computer Architecture for Machine Perception vol. 20 (October 1997), 116125. [21] Lane, T. The Independant JPEG Groups Software, Release 5b, 1990-1995. Archive site: ftp.uu.net/graphics/jpeg/. [22] Lee, H., Park, J., Bae, T., Choi, S., and Ha, Y. Adaptive Scan Rate Up-Conversion System Based on Human Visual Characteristics. IEEE Transactions on Consumer Electronics vol. 46, no. 4 (2000), 9991006. [23] Lee, J. Digital Image Enhancement and Noise Filtering by use of Local Statistics. IEEE Transactions on Pattern Analysis and Machine Intelligence vol. 2 (1980), 165168. [24] Lee, J. Digital Image Smoothing and the Sigma Filter, vol. vol. 24. Computer Vision, Graphics and Image Processing, 1983. [25] Lee, S.-G., and Lee, D.-H. A Motion-Adaptive De-Interlacing Method Using an Ecient Spatial and Temporal Interpolation. IEEE Transactions on Consumer Electronics vol. 49, no. 4 (November 2003), 12661271. [26] Lim, J. Two-Dimensional Signal and Image Processing. Prentice Hall, 1990. [27] Lin, S.-F., Chang, Y.-L., and Chen, L.-G. Motion Adaptive Interpolation with Horizontal Motion Detection for De-Interlacing. IEEE Transactions on Consumer Electronics vol. 49, no. 4 (2003), 12561265. [28] Lis, J., and Gajski, D. Synthesis from VHDL. IEEE International Conference on Computer Design: VLSI in Computers and Processors (1998), 378 381.

75 [29] Loiseau, L. M ethode de Conception pour la R eutilisation et Optimisation Architecturale Applique ees a ` un R educteur de Bruit Vid eo. Masters thesis, Ecole Polytechnique de Montr eal, 2001. [30] Lubin, J. The use of psychophysical data and models in the analysis of display system performance. The MIT Press, 1993, pp. 163178. [31] Onwubiki, C. Introduction to Engineering Design Optimization. Prentice Hall, 2000. [32] Pan, F., Lin, X., Rahardja, S., Lin, W., Ong, E., Yao, S., Lu, Z., and Yang, X. A Locally-Adaptive Algorithme for Measuring Blocking Artifacts in Images and Videos. IEEE Symposium on Circuits and Systems vol. 3 (May 2004), 925928. [33] Poynton, C. Digital Video and HDTV Algorithms and Interfaces. Morgan Kaufmann Publishers, 2003. [34] Regimbal, S. M ethode de R eutilisation et de Couverture pour la V erication Fonctionnelle de Circuits Num eriques. Masters thesis, Ecole Polytechnique de Montr eal, 2003. [35] Sheikh, H., and Bovik, A. Image Information and Visual Quality. IEEE Transactions on Image Processing (2005). [36] Skocir, P., Marusic, B., and Tasic, J. A Three-Dimensional Extension of the SUSAN Filter for Wavelet Video Coding Artifact Removal. IEEE Mediterranean Electrotechnical Conference (May 2002), 395398. [37] Smith, S., and Brady, J. SUSAN - A New Approach to Low Level Image Processing. International Journal of Computer Vision vol. 23 (1997), 4578. [38] Teo, P., and Heeger, D. Perceptual Image Distortion. IEEE International Conference on Image Processing vol. 2 (November 2004), 982986.

76 [39] Tong, H., Li, M., Zhang, H.-J., He, J., and Ma, W.-Y. Learning No-Reference Quality Metric by Examples. IEEE International Conference on Multimedia Modelling (January 2005), 247254. [40] Wadekar, S., and Parker, A. Accuracy Sensitive Word-Length Selection for Algorithm Optimization. IEEE International Conference on Computer Design: VLSI in Computers and Processors (October 1998), 5461. [41] Wallace, G. The JPEG Still Picture Compression Standard. Communications of the ACM vol. 34, no. 4 (1991), 3044. [42] Wang, Z., and Bovik, A. Why is Image Quality Assessment so Dicult? IEEE International Conference on Acoustics, Speech, and Signal Processing vol. 4 (May 2002), 33133316. [43] Wang, Z., Bovik, A., Sheikh, H., and Simoncelli, E. Image Quality Assessment: From Error Visibility to Structural Similarity. IEEE Transactions on Image Processing vol. 13, no. 4 (April 2004), 600612. [44] Wang, Z., Bovik, A., and Simoncelli, E. Structural Approaches to Image Quality Assessment. Academic Press, June 2005, ch. 8.3. [45] Wang, Z., Sheikh, H., and Bovik, A. Objective Video Quality Assessment. CRC Press, September 2003, ch. 41, pp. 10411078. [46] Wang, Z., and Simoncelli, E. Reduced-Reference Image Quality Assessment Using A Wavelet-Domain Natural Image Statistic Model. SPIE Proceeding on Human Vision and Electronic Imaging vol. 5666 (March 2005), 149159. [47] Weber, A. The USC-SIPI Image Database: Version 5. Tech. rep., Signal and Image Processing, Institute University of Southern California, October 1997.

77 ANNEXE A

PERFORMANCE DRIVEN VALIDATION APPLIED TO VIDEO PROCESSING

Cantin, and Yvon Savaria Serge Catudal, Marc-Andre Electrical Engineering Department, Ecole Polytechnique de Montr eal C.P. 6079, succursale Centre-ville, Montr eal (Qu ebec), H3C 3A7 Canada, {catudal, cantin, savaria}@grm.polymtl.ca http://www.grm.polymtl.ca Abstract This paper presents a systematic method to validate implementations of video processing algorithms. This is useful when translating algorithms implementations from a oating-point to xed-point precision. The method takes advantage of an automatic word length determination tool and an Objective Image Quality Metric (OIQM) to implement a performance driven validation. Since results obtained with existing OIQM show anomalies inside images due to numerical instabilities, a new OIQM is proposed. It combines a global and a local metric to remove anomalies inside the resulting images. Experimental results obtained with the Wiener lter are presented to illustrate the validity of our approach. Key-Words Objective Image Quality Metric, Validation, Video Processing, Wiener Filter.

78 A.1 Introduction

Design of video processing modules can be split in two complementary components that relate to control and data-ow respectively. The main goal of the control is to feed the datapath with the right data at the right time and to collect results. The main goal of the datapath is to perform data transformations required by the algorithm. Video processing architectures that implement the data transformations are usually derived from algorithms previously validated with C/C++ or Matlab/Simulink implementations. They are usually simulated in oating-point resolution. Since oating-point implementations are relatively expensive in terms of hardware cost, a good way to minimize or optimize hardware implementation complexity, pure performance and power consumption is to use xed-point precision. The translation from a oating-point to a xed-point formulation, a step towards implementation through a Register Transfer Level (RTL) hardware description, may cause some problems. For instance, the precision of each operand should be carefully selected to preserve algorithm stability and processing accuracy. The sensitivity of target algorithms to word widths of various operands is not clear a priori. Furthermore, this translation can deteriorate the behavior of a video processing algorithm by producing visual eects annoying to a human observer. Design validation helps the designer implementing complex systems with suciently high degree of condence in their correctness under all circumstances. Most previous work on video processing validation deals with formal loop verication techniques [1] and system level image processing specications validation in their target environment by emulation [2]. But these validation techniques are not useful to conrm the absence of visual artifacts in almost correct implementations.

79 A method for automatic sizing of video processing algorithm implementations was developed by the authors [3]. This method exploits an Automatic Word Length Determination Tool (AWLDT) [4] [5]. However, experiments conducted with the previously reported method showed that depending on the metric used, the method can produce anomalies in the resulting images. Fig. A.1 illustrates an example of a result image containing anomalies appearing as dark pixels that are due to numerical instabilities in the algorithm implementation.

Figure A.1 Arctichare ltered in xed-point resolution causing numerical instability. This motivated our quest of a more robust method. Ideally, the method should automatically assess algorithms performance, and always produce valid images, with no need for a human observer checking the result. Key components of a performance driven validation method is to combine the AWLDT with a metric that can suppress solutions that generate distorted images. The purpose of this paper is to propose a new performance driven validation method applicable to video processing. It is based on a new Objective Image Quality Metric (OIQM). The rest of the paper is organized as follows. In Section A.2, our video processing validation methodology is introduced. Section A.3 briey reviews the

80 Wiener Filtering algorithm used as a benchmark. Section A.4 presents results obtained with our video processing validation platform using previously published OIQM. Section A.5 proposes a new OIQM that prevent numerical instabilities while translating an algorithm to a xed-point implementation. Finally, Section A.6 formulates conclusions and proposes some future work.

A.2

Video Processing Validation

Design validation helps designing and implementing complex systems to ensure with suciently high degree of condence that they are correct under all circumstances [6]. The most common technique for design validation is based on tests and simulations. However, features not explored during these simulations may lead to fatal errors [6]. Formal techniques such as model checking were developed to enable exhaustive exploration of all possible behaviors of a design. However, these formal techniques are applicable to control validation [7] and generally not applicable to datapath validation. By contrast, the method introduced in [3] automatically optimizes datapath of video processing algorithm implementation. This method is now rened to accomplish performance driven validation of video processing algorithm implementations using a platform described in Section A.2.1.

A.2.1 Video Processing Validation Platform

Our video processing validation platform (see Fig. A.2) uses the same three general steps as model checking [6], i.e. modeling, specication and verication, even if the methodology employed is very dierent. In the rst step, the designer produces a

81 high level model of the algorithm datapath in the C or SystemC languages. This model can be compiled to a Control Data Flow Graph (CDFG) representation. In the second step, the designer denes performance objectives that will become properties of the model specication. In our application, the performance objective is represented has a target ratio between the OIQM of the xed-point ltered image over the OIQM of the oating-point ltered image. By contrast, classical validation uses logics such as Linear Temporal Logic (LTL) or Computational Tree Logic (CTL), to describe the design specication properties [6]. In the third step, the designer must validate that the performance objectives specied are met by the model. In order to achieve this last step, our video processing validation platform exploits the AWLDT as opposed to a model checker for classical validation. From performance objectives and an image database, the AWLDT generates an optimized model of the algorithm datapath that meets specied performance targets for the implementation of the video processing algorithm.
C/C++ / SystemC CDFG High Level Model

Modeling

Specification

Performance Objective

Verification

Images Database

AWLDT

Optimized Model

Figure A.2 Flow Diagram of the Video Processing Validation Platform

82 A.2.2 Objective Image Quality Metric

In our previous work [3], we used an OIQM named Universal Image Quality Index (UIQI) [8]. This metric led our optimization method to produce implementations generating unstable results when the algorithm contained steps such as division by zero. Analysis of the source of these unstable results led us to use a dierent OIQM that is described in Section A.2.2.1. Even with this second OIQM, we still obtained some unstable results producing visual anomalies. These anomalies are presented in Section A.4 and the new OIQM proposed to resolve this problem is described in Section A.5.

A.2.2.1 Structural Similarity Index

The second OIQM we chose for our video processing validation platform, the Structural SIMilarity (SSIM) Index [9], is based on the measurement of similarities between a reference and a distorted image. It considers image degradation as perceived structural information variation [10] [11]. The SSIM index is a full-reference image quality assessment metric based on psychophysical Human Visual System (HVS) features. By contrast, the most common OIQM employed in the literature, such as the Mean Square Error (MSE) and the Peak Signal-to-Noise Ratio (PSNR), use error sensitivity measurements by quantifying the error between the distorted image and the reference image. It has been reported that the MSE and the PSNR do not correlate well with subjective image quality measures [12]. The SSIM index combines the luminance, Eq. A.2, contrast, Eq. A.3, and structure, Eq. A.4, comparative indices. They compare a reference image x and the distorted image y to evaluate their structural similarity.

83

SSIM (x, y ) = [l(x, y )] [c(x, y )] [s(x, y )] , 2x y + C1 l(x, y ) = , 2 2 x + y + C 1 2x y + C2 c(x, y ) = , 2 2 + C x 2 y xy + C3 , s(x, y ) = x y + C 3

(A.1) (A.2) (A.3) (A.4)

where C1 = (K1 L)2 , and C2 = (K2 L)2 . Based on [9], we set in this paper = = = 1, C3 = C2 /2, K1 = 0.01, and K2 = 0.03. L represents the dynamic range of pixels value, and since wue use and 8-bit/pixel monotonic signal, L = 255. The SSIM index is computed locally for each pixel with an 11x11 circular symmetric Gaussian weighting function. The SSIM indices computed for each position are combined to produce an SSIM index map. The mean of this SSIM index map is used to evaluate the overall image quality:

M SSIM (X, Y ) =

1 M

SSIM (x, y ).
j =1

(A.5)

A.3

Wiener Filter

In order to test our video processing validation methodology, the adaptive Wiener lter [13], also known as the Minimum Mean Square Error (MMSE) algorithm was selected as benchmark. When 2 < 2 and 2 = 0, the ltered output image F of the Wiener lter is computed as follows:

84

F (k, l) = +

2 2 j (G(k, l) j ), 2 j

(A.6)

where 2 is the noise variance, and 2 are respectively the local mean and variance around a pixel j :

2 =
2 j =

1 S

S 2 j , j =1

(A.7) G(k, l)2 2 j, G(k, l), (A.8) (A.9)

1 NM 1 NM

k,l

j =

k,l

where S represents the image size, and represents the N -by-M local neighborhood
2 2 of each pixel in the noisy image G. However, when 2 j or j = 0, the Wiener

lter returns F (k, l) = j . In this paper, we use the following parameters settings: N = 3; M = 3.

A.4

Anomalies

After optimizing the datapath of the Wiener lter in xed-point representation with the proposed video processing validation platform, we obtained results with two dierent types of anomalies. Some optimized solutions generated by the AWLDT contained negatives pixels while others contained dark pixels, even if the xed-point solution of the algorithm implementation found by our video processing validation platform meet relatively stringent quality criteria.

85 In Table A.4, results obtained from the MSE, PSNR and the MSSIM index are reported for nine dierent images [14]. Each source image contains Gaussian noise with a variance level of 0.01. The noisy images were ltered with the Wiener Filter in oating- and xed-point resolution. The xed-point implementation of the Wiener Filter was generated by our video processing validation platform with the MSSIM Index and a performance objective of 0.95. The Wiener Filter optimized xed-point implementation obtained from the video processing validation platform generates results with visual anomalies. Fig. 3 illustrates an example taken from Table A.4 of a section of the Lena ltered image in xed-point resolution. Tableau A.1 Comparison of global image metrics for dierent images containing noise with a variance level of 0.01 and corresponding images processed by the Wiener lter in xed and oating-point.
Image Arctichare Boat Cameraman Cat Couple Fruits Goldhill Lena Peppers MSE 373.29 189.18 300.67 207.38 164.78 273.73 145.21 172.32 166.65 Gaussian Noise PSNR MSSIM 22.410 0.292278 25.362 0.644498 23.350 0.541062 24.963 0.755108 25.962 0.729978 23.758 0.450619 26.511 0.753261 25.767 0.629845 25.913 0.620603 Wiener Filter (oating-point) MSE PSNR MSSIM 103.76 27.971 0.732639 81.08 29.041 0.807659 112.06 27.636 0.739830 128.70 27.035 0.844317 116.78 27.457 0.767334 69.81 29.692 0.766572 90.32 28.573 0.770426 66.37 29.911 0.811397 48.42 31.281 0.868091 Wiener Filter (xed-point) MSE PSNR MSSIM 141.40 29.626 0.711137 97.51 28.240 0.795193 135.10 26.824 0.729231 147.08 26.455 0.832029 128.54 27.041 0.773001 91.73 28.506 0.745399 110.31 27.705 0.754731 87.31 28.720 0.788909 64.72 30.021 0.849463

Figure A.3 Section of Lena ltered image in xed-point resolution from Table A.4.

86 Even if the performance objective is achieved with the Wiener lter xed-point implementation, the optimal solution generated by the AWLDT contains visual anomalies and that solution should have been rejected. Sections A.4.1 and A.4.2 elaborate on two types of anomalies generated by the video processing validation platform that we wish to avoid.

A.4.1 Negative Pixels

Datapath optimization generates solutions with optimized operands that propagate negative results through the end of the digital lter. Since we use a metric based on an overall score, these few negative pixels have only a small inuence over the nal score, thus it is possible to obtain a solution satisfying the performance criteria and generating this type of anomaly. Images shown in Fig. A.4 that were obtained from simulations of the Wiener lter processed in xed-point resolution that reached a performance objective of 0.9832, a relatively high score, exhibit this type of anomaly. The source image contains 85% of JPEG compression noise. The negative pixels are shown as white pixels in the ltered image, see Fig. A.4(b), and are reported as black spots in the SSIM index map; see Fig. A.4(c).

A.4.2 Dark Pixels

We also obtained optimized solutions containing pixels with very low brightness level. Even a small number of such pixels can be detected by a human observer because their brightness diers signicantly from the one of their neighbors. Images shown in Fig. A.5 and Fig. A.6 that were obtained from the simulation of an implementation of the Wiener lter processed in xed-point resolution, and that reaches a performance objective of 0.9832, illustrate this type of anomaly. Each

87

(a)

(b)

(c)

Figure A.4 Simulation results with negative pixels. (a) Lena ltered image in oating-point, MSSIM = 0.834480; (b) Lena ltered image in xed-point, MSSIM = 0.822677; (c) SSIM map comparing the Lena ltered image in oating and xed-point. source image contains gaussian noise with a variance level of 0.01. The dark pixels are reported as black spot in the SSIM index map, see Fig. A.5(c) and Fig. A.6(c). The fact that the AWLDT accepts solutions with dark pixels can also be explained by the use of a metric based on an overall score.

A.4.3 Numerical instabilities

These anomalies in the optimal solutions can be explained by the fact that the Wiener lter becomes numerically instable when some operands are optimized too much. In particular, in our implementation of the Wiener lter, one of the operand results consists of computing the operation G(k, l) j in A.6. This specic operation may generate negative results that are propagated to three other operands of the lter. These negative results may appear either in oating-point or in xedpoint resolution. However, the result from this operation serves has a numerator inside a division operation. If the value of the denominator is truncated too much in xed-point resolution, the division opera-tion generates a result much higher

88

(a)

(b)

(c)

Figure A.5 Simulation results obtained with dark pixels. (a) Cameraman ltered image in oating-point, MSSIM = 0.739830; (b) Cameraman ltered image in xed-point, MSSIM = 0.711923; (c) SSIM map comparing the Cameraman ltered image in oating and xed-point. than normal. The last operation consists of adding this possibly amplied negative result with the current pixel local mean, which explains the generation of negative pixels. These anomalies in the resulting images motivated us to develop a new OIQM presented in Section A.5 and which is able to automatically detect numerical instabilities inside a video processing algorithm in xed point resolution.

A.5

Problem Solution

A rst solution was used in order to solve the negative pixels anomaly shown in Fig. A.4. Any result produced by the AWLDT that contained negative pixels was automatically rejected. In spite of this new measure, we still encountered results with dark pixels anomalies, see Fig. A.6. In order to remove the dark pixel anomaly, we complemented the SSIM index with an additional test based on a variable called the Pixel Threshold (PT). This test sets a threshold for the maximum absolute value of the dierence between the brightness of pixels produced by oating- and

89

(a)

(b)

(c)

Figure A.6 Simulation results obtained with dark pixels. (a) Lena ltered image in oating-point, MSSIM = 0.811397; (b) Lena ltered image in xed-point, MSSIM = 0.775641; (c) SSIM map comparing the Lena ltered image in oating and xed-point. a xed-point processing. The Pixel Threshold is a nonlinear metric providing a local score, which may reject a solution if one pixel of the image does not satisfy the performance criteria. The new OIQM generated from the combination of the global and local metrics removes the numerical instability inside the optimized implementations of video processing algorithm. Fig. A.7 illustrates results obtained from the simulation of the Wiener lter in xed-point resolution with a performance objective of 0.95 and a maximum pixel threshold of 34. Each source image contains gaussian noise with a variance level of 0.01. It is signicant that the images produced by the Wiener lter validated with our new OIQM do not contain anomalies, even if the performance objective is lower than the one used in Fig. A.4 and Fig. A.6. Fig. A.8 illustrates the same section of Lena ltered image in xed-point resolution as shown in Fig. A.3. This image was obtained with the Wiener lter processed in xed-point resolution on an implementation derived with the new OIQM combining the global and local metric. These images do not contain dark

90

(a)

(b)

(c)

(d)

(e)

(f)

Figure A.7 Simulation results obtained with the new OIQM. (a) Cameraman ltered image in oating-point, MSSIM = 0.739830; (b) Cameraman ltered image in xed-point, MSSIM = 0.729231; (c) SSIM map comparing the Cameraman ltered image in oating and xed-point; (d) Lena ltered image in oating-point, MSSIM = 0.811397; (e) Lena ltered image in xed-point, MSSIM = 0.788909; (f) SSIM map comparing the Lena ltered image in oating and xed-point.

91 pixels, by contrast to images in Fig. A.8. In Table A.5, results obtained with our rst solution and our new OIQM are reported for nine dierent images [14]. In the case of the rst solution, the performance objective was 0.9832, whereas with the new OIQM, the performance objective was 0.95 and the maximum pixel threshold objective was 34. Each source image contains gaussian noise with a variance level of 0.01. The results show that according to the global OIQM, the MSSIM in our case, nal scores are very similar. However, the observed maximum pixel dierence (OMPD) are very dierent. Results obtained with the new OIQM did not contain visual anomalies (see Fig. A.7) that the rst solution still produced (see Fig. A.5 and Fig. A.6).

Figure A.8 Section of Lena ltered image in xed-point resolution without anomalies.

A.6

Conclusion

In this paper, an approach to validate video processing algorithms and their implementations is presented. The aim of this approach is to push the task of video processing algorithm validation at a higher level of abstraction for a hardware designer. In order to achieve this goal, our methodology uses an automatic video

92 Tableau A.2 Comparison between the rst solution and the new OIQM. Image Arctichare Boat Cameraman Cat Couple Fruits Goldhill Lena Peppers First solution MSSIM OMPD 0.702804 48 0.776457 51 0.711923 81 0.807311 72 0.745483 56 0.731802 69 0.746624 67 0.775641 52 0.835310 43 New OIQM MSSIM OMPD 0.711137 33 0.795193 32 0.729231 31 0.832029 33 0.773001 27 0.745399 28 0.754731 28 0.788909 26 0.849463 25

processing validation platform that takes advantage of a new objective image quality metric and an AWLDT. The use of objective image quality metrics allows removing human observers from the process of evaluating image quality. Experimental results demonstrated that a metric combining a global and a local performance objective avoids implementations of video processing algorithms producing large local errors due to numerical instability. The adopted local metric is a pixel to pixel comparison that works well with spatial lter. However, since we want to optimize motion adaptive de-interlacing algorithms, we investigate extensions to the method.

A.7

Acknowledgments

The authors would like to thank Micronet and Gennum Corporation for their nancial support, and A. Veenstra and J.-M. Tremblay from Gennum Corporation for their technical guidance.

93 References

[1] M. Cupak, F. Catthoor, and H.J. De Man. Ecient System-Level Functional Verication Methodology for Multimedia Applications. IEEE Design and Test of Computers, vol. 20:5664, March-April 2003. [2] I.C. Kraljic, F. S. Verdier, G.M. Quenot, and B. Zavidovique. Investigating Real-Time Validation of Real-Time Image Processing. IEEE International Workshop on Computer Architecture for Machine Perception, vol. 20:116125, October 1997. [3] M.-A. Cantin, S. Regimbal, S. Catudal, and Y. Savaria. An Unied Environment to Assess Image Quality in Video Processing. Journal of Circuits, Systems and Computers, vol. 13, no. 6:12891306, December 2004. [4] M.-A. Cantin, Y. Savaria, D. Prodanos, and P. Lavoie. An Automatic Word Length Determination Method. IEEE International Symposium on Circuits and Systems, vol. 5:5356, 2001. [5] M.-A. Cantin, Y. Savaria, and P. Lavoie. A Comparison of Automatic Word Length Optimization Procedures. IEEE International Symposium on Circuits and Systems, vol. 2:612615, 2002. [6] E.M. Clarcke, O. Grumberg, and D.A. Peled. Model Checking. The MIT Press, January 2002. [7] E. Brinksma and A. Mader. Model Checking Embedded System Designs. Proceeding of the Sixth International Workshop on Discrete Event Systems, pages 151158, October 2002. [8] Z. Wang and A.C. Bovik. A Universal Image Quality Index. IEEE Signal Processing Letters, vol. 9, no. 3:8184, March 2002.

94 [9] Z. Wang, A.C. Bovik, H.R. Sheikh, and E.P. Simoncelli. Image Quality Assessment: From Error Visibility to Structural Similarity. IEEE Transactions on Image Processing, vol. 13, no. 4:600612, April 2004. [10] B. Furth and O. Marqure. The Handbook of Video Databases: Design and Applications. CRC Press, September 2003. [11] Z. Wang and A.C. Bovik. Why is Image Quality Assessment so Dicult? IEEE International Conference on Acoustics, Speech, and Signal Processing, vol. 4:33133316, May 2002. [12] A.M. Eskicioglu and P.S. Fisher. Image Quality Measures and Their Performance. IEEE Transactions on Communications, vol. 43, no. 12:29592965, December 1995. [13] J.S. Lim. Two-Dimensional Signal and Image Processing. Prentice Hall, 1990. [14] A.G. Weber. The USC-SIPI Image Database: Version 5. Technical report, Signal and Image Processing, Institute University of Southern California, October 1997.

95 ANNEXE B

PARAMETERS ESTIMATION APPLIED TO AUTOMATIC VIDEO PROCESSING ALGORITHMS VALIDATION

Serge Catudal, Marc-Andr e Cantin, and Yvon Savaria Electrical Engineering Department, Ecole Polytechnique de Montr eal C.P. 6079, succursale Centre-ville, Montr eal (Qu ebec), Canada, H3C 3A7 Email: {catudal, cantin, savaria}@grm.polymtl.ca Abstract An automatic and systematic method to estimate parameters and to validate implementations of video processing algorithms is presented. Correctly adjusting video processing parameters can have a signicant impact on the algorithm performance and behavior. Since video processing algorithms parameters are often determined empirically, a new method to automatically estimate parameters is proposed. The method takes advantage of an automatic word length determination tool embedded into a performance driven validation platform that was modied in order to automatically compute optimum parameter values. Experimental results obtained with two spatial lters and an intra-eld deinterlacing algorithm are presented to illustrate the validity of our approach.

B.1

Introduction

An abundant number of video processing algorithms are controlled by parameters that must be set prior to the processing. Correctly adjusting these parameters can

96 have a signicant impact on their performance and behavior. Such parameters are often determined empirically by the designer [1][2][3] thus an automatic method to determine and validate parameters that control video processing algorithms is needed. This paper presents a systematic and automatic parameter determination strategy that has two main objectives. The rst objective is to nd a set of parameter for an analyzed DSP algorithm, values that maximize the quality of images processed by this algorithm. Finding this parameter set is a complex optimization process. Let us consider an example that helps understand the complexity of that optimization process : the Hybrid lter [2] has 2 parameters to optimize. The rst parameter can be set to 60 dierent values and the second parameter can be set to 2450000 dierent values. Thus, there are 60 2450000 = 1.47 108 possible sets of parameters to implement the Hybrid lter. Since a software simulation of the Hybrid lter evaluated on four images takes 81.3 seconds to compute on a SPARC SunFire V440 station with 8Go of RAM, it would take 378.97 years to try out all the possible sets in order to determine which combination of parameter values is optimal on the selected small image data base. The second objective of our systematic optimization and automatic validation process is to nd a combination of word lengths that minimizes hardware implementation costs for a given image quality. As for the rst objective, it is a necessary step for implementing algorithms in image processing systems. The complexity of this second objective is also a challenging problem. In the Hybrid lter example, there are 23 hardware data paths to optimize, and each of them has 32 dierent possible congurations (in terms of bits) to implement it. Thus, there are 3223 = 4.2 1034 dierent ways to implement the considered Hybrid lter. In this case, using the same computer under the same load conditions, 1.1 1029 years would be required to exhaustively characterize all possibilities in order to establish which combination

97 of word lengths is optimal. Thus, to obtain a solution for these two objectives in a realistic time, a powerful word length and parameter optimization tool is required. A method for automatic sizing of video processing algorithm implementations was developed by the authors [4]. It was then extended to become a performance driven validation methodology applicable to video processing by taking advantage of a new Objective Image Quality Metric (OIQM) [5] and an Automatic Word Length Determination Tool (AWLDT) [6][7]. The purpose of this paper is to propose a new method applicable to video processing that can automatically optimize video processing algorithm parameters while optimizing and validating its hardware implementation. The paper is organized as follows. In Section B.2, a modied Automatic Word Length Determination Tool which is used in our video processing validation platform is presented. Section B.3 briey reviews the three video processing algorithms used as benchmarks. Section B.4 presents results obtained with our modied video processing validation platform. Finally, Section B.5 formulates conclusions.

B.2

Methodology

The proposed method determines the optimum set of parameter values and combination of word lengths through two optimization phases. During the rst phase, the method evaluates the optimal values of the parameters when all operands have oating-point resolution. The second phase searches, through a single process, i) the minimum word length combination that minimizes implementation costs, while meeting image quality targets specied by the user, and ii) the optimum value of control parameters according to the nite precision of the datapath. In

98 the followings sub-sections, these two phases are presented.

B.2.1

Determining the optimum values of the parameters

The problem of optimizing functions (or DSP algorithms) that contain many parameters according to multiple objectives is well-known in the literature and several methods are proposed to address it [8][9]. From image processing algorithms analyzed in our application, it was observed that the domain of solutions for the parameters of interest does not contain multiple local minima. Thus, a simple search-based approach was selected to nd the optimal parameter values. The proposed method would benet from more complex optimization method such as genetic or simulated annealing techniques if, and only if, multiple local minima exist. Otherwise their use would waste ressources because these techniques are computationally more demanding. In order to guide the search-based approach toward the optimal solution, two quality indices are computed. The rst quality index, Q is computed as follow:

Q=

1 M

M 1 m=0

o n M SSIM (Im , Im ) o , If M SSIM Im m

(B.1)

o n where M is the number of images processed, Im is the mth original image (I o ), Im f is the mth noisy input image (I n ) aected by a given noise level, Im is the mth

output image ltered (I f ) by the DSP algorithm, and M SSIM () is an objective image quality metric found in [10]. The second quality index denoted W is computed as follow

99

M SSIM (I o , I n ) m m W = min m=0,M 1 M SSIM I o , I f


m m

(B.2)

where min () is the minimum function. The goal of the rst phase is to nd a solution that maximizes the sum of the quality indices with an equal weight on each of them. For each parameter Pl , the upper Plmax and the lower Plmin limit values of each parameter. Furthermore, the user denes the minimum resolution step Slmin of each parameter. Our search-based approach proceeds as follows. The optimization process starts with initial parameter values set to Plmax Plmin /2. Also, the step size Sl of each allowed by the AWLDT. The two quality indices are computed and results are kept for reference. Then, iteratively, each parameter is considered as a candidate to increase or decrease its value by one step Sl when all other parameters remain unchanged. The candidate that oers the best increase of the sum of two indices is retained. When no further improvement is obtained, the step size Sl is reduced by a factor of two and the iterative search continues from the best previously available solution. The search ends when none of the modications tried increases the sum of the indices, and when each step value Sl is equal to the minimum value specied by the user Slmin . l = 0, 1, . . . , L 1 where L is the number of parameters to optimize, the user sets

operand Pl is set to Plmax Plmin /K , where K is the maximum number of steps

100 B.2.2 Determining the optimum set of parameters values and combination of word lengths

Once the optimum set of parameters values is found, the second optimization phase searches a combination of word lengths {W Li } and parameters that minimizes the implementation costs and meets the target image quality specied by the user. This second optimization phase directly exploits the AWLDT presented in [6]. As proposed in [5], the automatic validation of image processing algorithms requires the computation of two quality metrics (i) to obtain good quality images and (ii) to guide the AWLDT toward the optimal solution. The metrics used are the Inverse Ratio (IRATIO) and the Pixel Threshold (PT). The global metric IRATIO, as illustrated in Fig. B.1, computes the ratio of the image quality metric (OIQM as dened in [5]) obtained with nite precision data paths (xed-point OIQM) over the same metric obtained by the rst optimization phase (oating-point OIQM).
Noise
(Gaussian, Salt and pepper, Compression, or Interlaced)

Filtered Image
(fixedpoint)

Original Image

Noisy Image

IRATIO = 1

FixedPoint OIQM > Objective FloatingPoint OIQM

Filtered Image
(floatingpoint)

Figure B.1 Flow diagram of the performance assessment method. The PT metric is computed for each pixel of each image as the maximum absolute dierence in intensity between the pixel obtained by the solution of the rst optimization phase and the one obtained with nite precision data path. It was shown in [5] that a local metric such as the PT must be computed to avoid visual anomalies. For each metric, the user sets a target quality specication. In [5] the

101 IRATIO was set to 0.02 and the PT was set to 34. In the original formulation of the AWLDT in [6], a procedure searches for a combination of minimum word lengths that meets the quality criteria specied by modifying appropriate word lengths. Here, the parameters are treated as operands with the exception that instead of modifying the word length of the operand by adding or removing one bit, the procedure modies the value of the parameter by increasing and decreasing its value by Slmin . The proposed method optimizes simultaneously (i.e. in a single process) the word lengths of the operands and the values of the parameters dening the algorithm. This allows adjusting precisely the values of these parameters while reducing the error due to the nite precision of the data path. The proposed method was implemented and was successfully applied to three video processing algorithms as presented in the next section.

B.3

Video Processing Algorithms

In order to test our methodology, three dierent video processing algorithms that are partly dened by parameters were selected as benchmarks. The rst and the second algorithm, described in Section B.3.1 and B.3.2 respectively, are spatial lters. The third algorithm, described in Section B.3.3, is a video deinterlacing algorithm.

B.3.1

SUSAN lter

The Smallest Univalue Segment Assimilating Nucleus (SUSAN) spatial lter [1] is described by equation:

102

J (x, y ) =
i=0,j =0

I (x + i, y + j ) S (i, j ),

(B.3)

where

S (i, j ) =

(I (x+i,y +j )I (x,y ))2 i 2 +j 2 2 2 2 (I (x+i,y +j )I (x,y ))2 i 2 +j 2 2 2 2

(B.4)

e
i=0,j =0

and where J is the ltered image and I is the noisy image. The SUSAN noise ltering algorithm is controlled by two parameters. The rst parameter, in Eq. (B.4), is the spatial control parameter that sets the scale of the spatial smoothing. The second parameter, in Eq. (B.4), is the brightness control parameter that sets the brightness threshold.

B.3.2

Hybrid lter

The Hybrid lter algorithm [2] comes from the combination of the Minimum Mean Square Error (MMSE) lter [11] and the Sigma lter [12]. The output ltered image g of the Hybrid lter is computed as follows:

g (x, y ) = g + Kg (g (x, y ) g ), where Kg is a non-linear gain and g is the local mean around a pixel:

(B.5)

103

Kg = M AX 0,
2 g =

2 2 g n , 2 g

(B.6) (B.7) (B.8)

1 MN 1 MN
0 1

i,j

(Wg (g (x i, y j )) g )2 , Wg (g (x i, y j )), ,

g =

i,j

Wg =

if |g (x i, y j ) g (x, y )| < Ts

if |g (x i, y j ) g (x, y )| Ts

(B.9)

2 represents the local variance around a pixel, Wg represents the lter where g

adaptive segmentation mask, and represents the N -by-M local neighborhood of each pixel in the noisy image g . In this paper, we use the following parameters settings: M = N = 7 xed to reduce computation time in Section B.4. The noise
2 variance described as g in Eq. (B.6) and the segmentation threshold described as

Ts in Eq. (B.9) are two parameters that need to be estimated.

B.3.3

ELA deinterlacing algorithm

The modied Edge-base Line Average (ELA) [3] is a widely used intra-eld deinterlacing algorithm. The modied ELA is computed as illustrated in Fig. B.2 and uses two parameters described as Tv and Td . The ELA algorithm reconstructs line k from lines k 1 and k + 1. It is dened as a function of dierences specied by labeled arrows between pixel values in these lines. Parameter Tv is the vertical threshold used in the directional dierence labeled c in Fig. B.3. The parameter Td is the directional dierence threshold used for the four directional dierences illustrated as a, b, d and e in Fig. B.3.

104
Two scan lines

Difference of edge Directional calculation (a,b,c,d,e)


(Dominant edge) No
Dv T v

No
Dd1 > Td Dd2 > Td

(Edge Region)

Directional interpolation

Yes (Smooth Region)

Yes

(NonDominant edge)

Vertical bilinear interpolation

Directional interpolation

Median filter

ZELA

Figure B.2 Flowchart of the modied ELA deinterlacing algorithm.


n2 k1 a k New line Original Scan line b c d e Original Scan line n1 n n+1 n+2

k+1

Figure B.3 Pattern of pixels used in the modied ELA algorithm. The median lter shown in the owchart of the modied ELA algorithm in Fig. B.2 is computed as follows:

Y = M edian[X (n, k 1), X (n, k + 1), ELA(n, k )]

(B.10)

B.4

Results

Results obtained with the SUSAN lter, the Hybrid lter and the ELA deinterlacing algorithm are reported in Table B.1. The results from the SUSAN lter were obtained for nine dierent images from the image database of [13] and the algorithm

105 has two parameters to estimate and seven operands to optimize. The results from the Hybrid lter were obtained for four dierent images from the image database of [13] and the algorithm has two parameters to estimate and twenty-three operands to optimize. Finally, the results from the ELA deinterlacing algorithm were obtained with the eighth frame of the Football video sequence. The ELA deinterlacing algorithm has two parameters to estimate and four operands to optimize. Tableau B.1 Results obtained for three dierent video processing algorithms.
Algorithms Parameters to estimate 2 2 2 Operands to optimize 23 7 4 HW Cost units 140 65 23 Performance Objective IRATIO PT 0.03000 0.05000 0.05000 34 34 34 Performance Obtained IRATIO PT 0.025248 0.003128 0.035429 28 31 29 Computational time (s) 505605 17040 576

Hybrid lter SUSAN lter ELA deinterlacer

The parameter estimations obtained with our video processing validation platform
2 for the Hybrid lter algorithm were Ts = 46 and n = 186.845776. Fig. B.4

shows the contour curves of the quality index Q (see Eq. B.1) for the Hybrid lter parameters. These curves were obtained manually from C/C++ simulations of the Hybrid lter in oating-point representation by setting the parameter T s
2 in the range [15, 75], with a step of 2, and by setting the parameter n in the

range [10, 255], with a step of 5. A total of 1550 simulations of the algorithm were obtained for each image. Fig. B.4 was computed in Matlab by interpolating the feasible solutions to produce contour plot that are easier to visualize. To conclude this section, we can observe in Table B.1 that the computational time for validating the video processing algorithm implementation is dependent on the number of operands that need to be optimized and that the performance are met with a comfortable margin.

106
Hybrid filter Parameter Estimation (Mean RATIO)
0.7477
70

Ts (Segmentation Threshold)

50

40

0.7 48 2

60

0.7475
0.7477
0.7497 0.7507

0.7536
0.7629
30

0.7576
0.7689

0.7771
0.7877

0.8
0.8211
20

0.8337

0.855

0.8756
50 100 150 200 250

2 (Noise Variance) g

Figure B.4 Quality index Q of the Hybrid lter parameter estimation. B.5 Conclusion

In this paper, an approach to estimate video processing algorithm parameters and to validate their implementations is presented. The aim of this approach is to push the task of video processing algorithm parameter estimation and implementation validation to a higher level of abstraction for a hardware designer. In order to achieve this goal, a methodology, which takes advantage of an Automatic Word Length Determination Tool (AWLDT) and an Objective Image Quality Metric (OIQM), was proposed. The use of the OIQM allows the removal of a human observer from the process of evaluating image quality, and guiding the AWLDT toward the optimal solution. The AWLDT tool was modied in order to automatically determine, in a single optimization process, the minimum word length combination that minimizes implementation costs, while meeting image quality targets specied by the user, and to determine the optimum value of control parameters according to the nite

107 precision of the data path. The systematic optimization and automatic validation methodology was applied on three image processing algorithms. Experimental results obtained with these algorithms show that the set of parameters obtained from the optimization process concurs with the set of optimal values. They also demonstrate that the proposed methodology can automatically determine and validate parameters that regulate video processing algorithms. References

[1] S.M. Smith and J.M. Brady. SUSAN - A New Approach to Low Level Image Processing. International Journal of Computer Vision, vol. 23:4578, 1997. [2] L. Loiseau. M ethode de Conception pour la R eutilisation et Optimisation Architecturale Applique ees a ` un R educteur de Bruit Vid eo. Masters thesis, Ecole Polytechnique de Montr eal, 2001. [3] H.Y. Lee, J.W. Park, T.M. Bae, S.U. Choi, and Y.H. Ha. Adaptive Scan Rate Up-Conversion System Based on Human Visual Characteristics. IEEE Transactions on Consumer Electronics, vol. 46, no. 4:9991006, 2000. [4] M.-A. Cantin, S. Regimbal, S. Catudal, and Y. Savaria. An Unied Environment to Assess Image Quality in Video Processing. Journal of Circuits, Systems and Computers, vol. 13, no. 6:12891306, December 2004. [5] S. Catudal, M.-A. Cantin, and Y. Savaria. Performance Driven Validation Applied to Video Processing. WSEAS Transaction on Electronics, vol. 1, no. 3:568575, July 2004. [6] M.-A. Cantin, Y. Savaria, D. Prodanos, and P. Lavoie. An Automatic Word Length Determination Method. IEEE International Symposium on Circuits and Systems, vol. 5:5356, 2001.

108 [7] M.-A. Cantin, Y. Savaria, and P. Lavoie. A Comparison of Automatic Word Length Optimization Procedures. IEEE International Symposium on Circuits and Systems, vol. 2:612615, 2002. [8] C. Onwubiki. Introduction to Engineering Design Optimization. Prentice Hall, 2000. [9] A.D. Belegundu. Optimization Concepts and Applications in Engineering. Prentice Hall, 1999. [10] Z. Wang, A.C. Bovik, H.R. Sheikh, and E.P. Simoncelli. Image Quality Assessment: From Error Visibility to Structural Similarity. IEEE Transactions on Image Processing, vol. 13, no. 4:600612, April 2004. [11] J.S. Lim. Two-Dimensional Signal and Image Processing. Prentice Hall, 1990. [12] J.S. Lee. Digital Image Smoothing and the Sigma Filter, volume vol. 24. Computer Vision, Graphics and Image Processing, 1983. [13] A.G. Weber. The USC-SIPI Image Database: Version 5. Technical report, Signal and Image Processing, Institute University of Southern California, October 1997.

109 ANNEXE C

CODE SOURCE DE LA METRIQUE SSIM INDEX

C.1 Fichier ssim index.h


/ / // Title : SSIM I n d e x // Project : Video P r o c e s s i n g Module / / // File : ssim index . h / / Author : Serge Catudal // Created : 17/11/2003 // Last modified : 2 8 / 0 1 / 2 0 0 4 / / // Description : S t r u c t u r a l S I M i l a r i t y Index / / / / C o p y r i g h t ( c ) 2 0 0 3 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 17/11/2003 : created / / / / @ d e f g r o u p o i q m p a c k OIQM : O b j e c t i v e Image Q u a l i t y M e t r i c T h i s l i b r a r y i s t h e OIQM l i b r a r y u t i l i t y . @ingroup v p v e c o r e @author S e r g e C a t u d a l @version 1 . 0 @date 2 8 / 0 1 / 2 0 0 4

#i f n d e f #d e f i n e

SSIM INDEX SSIM INDEX

/ / STL i n c l u s i o n s #include < s t r i n g > / / C/C++ i n c l u s i o n s #include < i o s t r e a m . h> #include < f s t r e a m . h> #include < s t d i o . h> #include < s t d l i b . h> #include < u n i s t d . h> / / POSIX . 4 i n c l u s i o n s #include < s y s / t y p e s . h> #include < s y s / w a i t . h> using namespace s t d ; // S i z e of the c i r c u l a r #d e f i n e s i z e w i n d o w 1 1 symmetric g a u s s i a n weighting function

/ / C o n s t a n t s i n t h e SSIM i n d e x f o r m u l a #d e f i n e K1 0 . 0 1 #d e f i n e K2 0 . 0 3 #d e f i n e L 255 / / C i r c u l a r symmetric g a u s s i a n w e i g h t i n g f u n c t i o n const double window [ s i z e w i n d o w ] [ s i z e w i n d o w ] = { {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0003,0.0020,0.0096,0.0291,0.0567,0.0708,0.0567,0.0291,0.0096,0.0020,0.0003}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000},

110
{0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000} }; / @ingroup o i q m p a c k @ b r i e f This c l a s s i s the S t r u c t u r a l S I M i l a r i t y @author S e r g e C a t u d a l @version 1 . 0 @date 0 4 / 1 2 / 2 0 0 3 / class ssim index { public : /// Constructor ssim index ( ) ; / / / Copy c o n s t r u c t o r s s i m i n d e x ( const s s i m i n d e x & ) ; /// Overload the equal ( = ) o p e r a t o r s s i m i n d e x & operator =( const s s i m i n d e x & ) ; /// Destructor ssim index ( ) ;

Index

// Access f u n c t i o n s double g e t s s i m m a p ( void ) { return ssim map ; } void s e t i m a g e h e i g h t ( int h ) { height = h ;} void set image width ( int w) { width = w; } void s e t s s i m m a p ( void ) ; // U t i l i t y functions double compute ssim index ( int , int ) ; void write ssim map ( s t r i n g ) ; private : /// F i r s t time i n c r e a t i n g bool first time ; / / / Image h e i g h t int height ; / / / SSIM map double ssim map ; / / / SSIM map int s s i m m a p i m g ; / / / Image w i d t h int width ; }; #e n d i f t h e SSIM Map

C.2 Fichier ssim index.cc


/ / // Title : SSIM I n d e x // Project : Video P r o c e s s i n g Module / / // File : ssim index . cc / / Author : Serge Catudal // Created : 17/11/2003 // Last modified : 2 8 / 0 1 / 2 0 0 4 / / // Description : S t r u c t u r a l S I M i l a r i t y Index / / / / C o p y r i g h t ( c ) 2 0 0 3 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 17/11/2003 : created / / #include < s s i m i n d e x . h> / / // Default Constructor / @brief / / / ssim index : : ssim index (){ f i r s t t i m e = true ; } / / / / Copy C o n s t r u c t o r /

111
@brief / / / s s i m i n d e x : : s s i m i n d e x ( const s s i m i n d e x & I ) { first time = I . first time ; height = I . height ; width = I . width ; = I . ssim map ; ssim map ssim map img = I . ssim map img ; } / / // = Operator Overloading / @brief / / / s s i m i n d e x & s s i m i n d e x : : operator =( const s s i m i n d e x & I ) { i f ( t h i s != & I ){ first time = I . first time ; height = I . height ; width = I . width ; ssim map = I . ssim map ; ssim map img = I . ssim map img ; } return t h i s ; } / / // Destructor / @brief / / / ssim index : : ssim index (){ i f ( ! f i r s t t i m e ){ f o r ( i n t j = 0 ; j < (( h e i g h t s i z e w i n d o w ) + 1 ) ; j ++){ d e l e t e [ ] ssim map [ j ] ; delete [ ] ssim map img [ j ] ; } d e l e t e [ ] ssim map ; delete [ ] ssim map img ; = NULL ; ssim map s s i m m a p i m g = NULL ; } } / / // Access f u n c t i o n s / / / @ b r i e f S e t t h e S t r u c t u r a l S I M i l a r i t y I n d e x Map / void s s i m i n d e x : : s e t s s i m m a p ( void ) { int j ; / / F r e e t h e memory i f ( ! f i r s t t i m e ){ f o r ( i n t j = 0 ; j < (( h e i g h t s i z e w i n d o w ) + 1 ) ; j ++){ d e l e t e [ ] ssim map [ j ] ; delete [ ] ssim map img [ j ] ; } d e l e t e [ ] ssim map ; delete [ ] ssim map img ; ssim map = NULL ; s s i m m a p i m g = NULL ; } else { first time = false ; } ssim map = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s s i m m a p i m g = new i n t [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; f o r ( j = 0 ; j < ( h e i g h t s i z e w i n d o w ) + 1 ; j ++){ ssim map [ j ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s s i m m a p i m g [ j ] = new i n t [ ( w i d t h s i z e w i n d o w ) + 1 ] ; } } / / // U t i l i t y functions / / / @ b r i e f Compute t h e S t r u c t u r a l S I M i l a r i t y I n d e x / double s s i m i n d e x : : c o m p u t e s s i m i n d e x ( i n t o r i g i n a l , i n t d i s t o r t e d ) { int border ;

112
double double double double int int int int double double double double double double double double double double C1 , C2 ; denominator1 , denominator2 ; numerator1 , numerator2 ; numerator3 , denominator3 ; i,j; max ssim map = 0 ; m, n ; i m g 1 i m g 2 , i m g 1 s q , i m g 2 s q ; mu1 mu2 , mu1 , mu2 ; mu1 sq , mu2 sq ; sigma12 , sigma1 sq , sigma2 sq ; result = 0.0; contrast ; mean contrast = 0 . 0 ; luminance ; mean luminance = 0 . 0 ; structure ; mean structure = 0.0;

// Variable i n i t i a l i z a t i o n border = (( size window 1 ) / 2 ) ; // Constants i n i t i a l i a z a t i o n C1 = ( K1 L ) ( K1 L ) ; C2 = ( K2 L ) ( K2 L ) ; // Calculate the square f o r the i m g 1 i m g 2 = new i n t [ h e i g h t ] ; img1 sq = new i n t [ h e i g h t ] ; = new i n t [ h e i g h t ] ; img2 sq f o r ( j = 0 ; j < h e i g h t ; j ++){ i m g 1 i m g 2 [ j ] = new i n t [ w i d t h ] ; img1 sq [ j ] = new i n t [ w i d t h ] ; img2 sq [ j ] = new i n t [ w i d t h ] ; f o r ( i = 0 ; i < w i d t h ; i ++){ img1 img2 [ j ] [ i ] = o r i g i n a l [ j img1 sq [ j ] [ i ] = original [ j = distorted [ img2 sq [ j ] [ i ] } } o r i g i n a l and d i s t o r t e d image

] [ i ] distorted [ j ] [ i ] ; ][ i ] original [ j ][ i ]; j ] [ i ] distorted [ j ] [ i ] ;

/ / Apply t h e 2D F i l t e r on t h e mean i n t e n s i t y and t h e v a r i a n c e mu1 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu2 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; sigma12 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu1 mu2 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu1 sq mu2 sq = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; f o r ( j = ( 0 + b o r d e r ) ; j < ( h e i g h t b o r d e r ) ; j ++){ mu1 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu1 mu2 [ j b o r d e r ] mu1 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; f o r ( i = ( 0 + b o r d e r ) ; i < ( w i d t h b o r d e r ) ; i ++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = 0; mu2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; / / Apply t h e c i r c u l a r s y m m e t r i c g a u s s i a n w e i g h t i n g f u n c t i o n on e a c h f o r ( n = ( 0 b o r d e r ) ; n < ( s i z e w i n d o w b o r d e r ) ; n++){ f o r (m = ( 0 b o r d e r ) ; m < ( s i z e w i n d o w b o r d e r ) ; m++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( o r i g i n a l [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; mu2 [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( d i s t o r t e d [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] + m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; ( ( double ) ( i m g 1 i m g 2 [ j+n ] [ i+ s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 1 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 2 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; } }

pixel

113
/ / SSIM ( x , y ) = [ l ( x , y ) ] [ c ( x , y ) ] [ s ( x , y ) ] // // where // // l ( x , y ) i s the luminance comparison // l ( x , y ) = ( 2 mu x mu y + C1 ) / ( mu x 2 + mu y 2 + C1 ) // // c ( x , y ) i s the c o n t r a s t comparison // c ( x , y ) = ( 2 s i g m a x s i g m a y + C2 ) / ( s i g m a x 2 + s i g m a y 2 + C2 ) // // s ( x , y ) i s the s t r u c t u r e comparison // s ( x , y ) = ( s i g m a x y + C3 ) / ( s i g m a x s i g m a y + C3 ) // / / SSIM ( x , y ) = [ ( 2 mu x mu y + C1 ) ( 2 s i g m a x s i g m a y + C2 ) ] / // [ ( mu x 2 + mu y 2 + C1 ) ( s i g m a x 2 + s i g m a y 2 + C2 ) ] // mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; mu1 sq [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu1 [ j b o r d e r ] [ i b o r d e r ] ; mu2 sq [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] mu1 sq [ j b o r d e r ] [ i b o r d e r ] ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] mu2 sq [ j b o r d e r ] [ i b o r d e r ] ; n u m e r a t o r 1 = ( ( 2 mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) + C1 ) ; n u m e r a t o r 2 = ( ( 2 s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] ) + C2 ) ; d e n o m i n a t o r 1 = ( mu1 sq [ j b o r d e r ] [ i b o r d e r ] + mu2 sq [ j b o r d e r ] [ i b o r d e r ] + C1 ) ; d e n o m i n a t o r 2 = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + C2 ) ; ssim map [ j b o r d e r ] [ i b o r d e r ] = ( n u m e r a t o r 1 n u m e r a t o r 2 ) / ( d e n o m i n a t o r 1 d e n o m i n a t o r 2 ) ; s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] = ( i n t ) ( 2 5 5 ssim map [ j b o r d e r ] [ i b o r d e r ] ) ; i f ( s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] < 0 ) s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] = 0 ; e l s e i f ( s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] > 2 5 5 ) s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] = 2 5 5 ; i f (255 s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] > max ssim map ) max ssim map = 255 s s i m m a p i m g [ j b o r d e r ] [ i b o r d e r ] ; r e s u l t = r e s u l t + ssim map [ j b o r d e r ] [ i b o r d e r ] ; } } / / A mean SSIM i n d e x ( MSSIM ) i s u s e d t o e v a l u a t e t h e o v e r a l l image q u a l i t y // / / MSSIM(X , Y) = ( 1 /M)SUM( SSIM ( x , y ) ) // r e s u l t = r e s u l t / ( ( ( h e i g h t s i z e w i n d o w ) + 1 ) ( ( width s i z e w i n d o w ) + 1 ) ) ; / / F r e e t h e memory f o r ( j = 0 ; j < h e i g h t ; j ++){ delete [ ] img1 img2 [ j ] ; delete [ ] img1 sq [ j ] ; delete [ ] img2 sq [ j ] ; i f ( ( j > (0 + border 1)) && ( j < ( height border ) ) ) { d e l e t e [ ] mu1 mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 [ j b o r d e r ] ; d e l e t e [ ] mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 sq [ j b o r d e r ] ; d e l e t e [ ] mu2 sq [ j b o r d e r ] ; d e l e t e [ ] s i g m a 1 2 [ j b o r d e r ] ; d e l e t e [ ] s i g m a 1 s q [ j b o r d e r ] ; d e l e t e [ ] s i g m a 2 s q [ j b o r d e r ] ; } } delete [ ] img1 img2 ; delete [ ] img1 sq ; delete [ ] img2 sq ; d e l e t e [ ] mu1 mu2 ; d e l e t e [ ] mu1 ; d e l e t e [ ] mu2 ; d e l e t e [ ] mu1 sq ; d e l e t e [ ] mu2 sq ; delete [ ] sigma12 ; delete [ ] sigma1 sq ; delete [ ] sigma2 sq ; i m g 1 i m g 2 = NULL ; img1 sq = NULL ; img2 sq = NULL ; mu1 mu2 = NULL ; mu1 = NULL ; mu2 = NULL ; mu1 sq = NULL ; mu2 sq = NULL ; sigma12 = NULL ; s i g m a 1 s q = NULL ; s i g m a 2 s q = NULL ;

114

return }

result ;

/ @ b r i e f Write t h e SSIM map h a s a Raw PGM image f i l e / void s s i m i n d e x : : w r i t e s s i m m a p ( s t r i n g f i l e n a m e ) { ofstream EcrireBin ; char int unsigned i n t ctmp = new char [ 1 0 ] ; i,j; itr ;

/ / C r e a t e raw PGM image f i l e h e a d e r char h e a d e r t m p = new char [ 2 0 ] ; s t r c a t ( h e a d e r t m p , P5 \ n ) ; s p r i n t f ( ctmp , %d , ( ( w i d t h s i z e w i n d o w ) + 1 ) ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( header tmp , ) ; s p r i n t f ( ctmp , %d , ( ( h e i g h t s i z e w i n d o w ) + 1 ) ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( h e a d e r t m p , \ n255 \ n ) ; / / Write raw PGM image f i l e p i x e l E c r i r e B i n . open ( f i l e n a m e . c s t r ( ) , i o s : : b i n a r y ) ; E c r i r e B i n . s e e k p ( 0 , i o s : : beg ) ; f o r ( i t r = 0 ; i t r < s t r l e n ( h e a d e r t m p ) ; i t r ++) E c r i r e B i n . w r i t e ( ( char ) & h e a d e r t m p [ i t r ] , s i z e o f ( char ) ) ; f o r ( j = 0 ; j < ( ( h e i g h t s i z e w i n d o w ) + 1 ) ; j ++){ f o r ( i = 0 ; i < ( ( w i d t h s i z e w i n d o w ) + 1 ) ; i ++){ E c r i r e B i n . w r i t e ( ( char ) & ( unsigned char ) s s i m m a p i m g [ j ] [ i ] , s i z e o f ( unsigned char ) ) ; } } EcrireBin . close ( ) ; d e l e t e ctmp ; }

115 ANNEXE D

REDUCTEUR DE BRUIT VIDEO

D.1 Code source du ltre Hybride

D.1.1 Fichier hybrid lter.h


/ / // Title : Hybrid image f i l t e r // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : hybrid filter .h / / Author : S e r g e CATUDAL // Created : 26/04/2004 // Last modified : 0 5 / 0 5 / 2 0 0 4 / / // Description : Combination o f t h e Sigma f i l t e r w i t h t h e MMSE f i l t e r / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 26/04/2004 : created / / #i f n d e f #d e f i n e HYBRID FILTER HEADER HYBRID FILTER HEADER

/ / VPVE i n c l u s i o n s #include < i m a g e f i l t e r . h> / / @ingroup f i l t e r p a c k @ b r i e f T h i s c l a s s i s t h e Hybrid @author S e r g e C a t u d a l @version 1 . 0 @date 2 6 / 0 4 / 2 0 0 4

Filter

c l a s s h y b r i d f i l t e r : public i m a g e f i l t e r { public : /// Constructor hybrid filter (); / / / Copy C o n s t r u c t o r h y b r i d f i l t e r ( const h y b r i d f i l t e r & ) ; /// Overload the equal ( = ) o p e r a t o r h y b r i d f i l t e r & operator =( const h y b r i d f i l t e r & ) ; /// Destructor hybrid filter (); // Access f u n c t i o n s void s e t m a s k s i z e x ( i n t x ) { m a s k s i z e x = x ; } void s e t m a s k s i z e y ( i n t y ) { m a s k s i z e y = y ; } void s e t n u ( f l o a t ne ) { nu = ne ; } void s e t t h r e s h o l d ( i n t t ) {threshold = t ;} / / Hybrid f i l t e r f u n c t i o n s int a p p l y f i l t e r ( int img in ) ; void generate matlab file ( string parameter filename , string matlab filename , int img src , int img noisy , float n o i s y q u a l i t y ) ; / / Other f u n c t i o n s f l o a t compute mean ( i n t ) ; float compute variance ( int , float ) ; private :

116
/ / / Mask s i z e w i d t h int mask size x ; / / / Mask s i z e h e i g h t int mask size y ; / / / MSSIM i n d e x ssim index my ssim index ; /// Noise Estimation float nu ; /// Brightness threshold int threshold ; }; #e n d i f

D.1.2 Fichier hybrid lter.cc


/ / // Title : Hybrid image f i l t e r // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : h y b r i d f i l t e r . cc / / Author : S e r g e CATUDAL // Created : 26/04/2004 // Last modified : 0 5 / 0 5 / 2 0 0 4 / / // Description : Combination o f t h e Sigma f i l t e r w i t h t h e MMSE f i l t e r / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 26/04/2004 : created / / #include < h y b r i d f i l t e r . h> / / // Default Constructor / @brief / / / h y b r i d f i l t e r : : h y b r i d f i l t e r ( ) : i m a g e f i l t e r (VPVE HYBRID FILTER) { mask size x = 0; mask size y = 0; nu = 0; threshold = 0; m y s s i m i n d e x = new s s i m i n d e x ( ) ; } / / / / Copy C o n s t r u c t o r / @brief / / / h y b r i d f i l t e r : : h y b r i d f i l t e r ( const h y b r i d f i l t e r & h f ) : i m a g e f i l t e r ( h f ) { mask size x = hf . mask size x ; mask size y = hf . mask size y ; nu = h f . nu ; threshold = hf . threshold ; } / / // = Operator Overloading / @brief / / / h y b r i d f i l t e r & h y b r i d f i l t e r : : operator =( const h y b r i d f i l t e r & h f ) { i f ( t h i s != & h f ){ mask size x = hf . mask size x ; mask size y = hf . mask size y ; nu = h f . nu ; threshold = hf . threshold ; } return t h i s ; } / / // Destructor

117
/ @brief / / / h y b r i d f i l t e r : : h y b r i d f i l t e r (){ delete my ssim index ; } / / / / Hybrid F i l t e r F u n c t i o n s / / / @ b r i e f Apply t h e Hybrid F i l t e r / int h y b r i d f i l t e r : : a p p l y f i l t e r ( int img in ){ double mu ; double s i g m a ; double K; int e n l a r g e i m g ; int i m g o u t ; int s e g ; int image size ; int i,j; int x,y; int nb active pix ; / / F i l t e r e d image i n i t i a l i z a t i o n i m g o u t = new i n t [ i m g h e i g h t ] ; mu = new double [ i m g h e i g h t ] ; sigma = new double [ i m g h e i g h t ] ; f o r ( j = 0 ; j <i m g h e i g h t ; j ++){ i m g o u t [ j ] = new i n t [ i m g w i d t h ] ; mu [ j ] = new double [ i m g w i d t h ] ; sigma [ j ] = new double [ i m g w i d t h ] ; f o r ( i = 0 ; i <i m g w i d t h ; i ++){ img out [ j ] [ i ] = 0 ; mu [ j ] [ i ] = 0; sigma [ j ] [ i ] = 0; } } s e g = new i n t [ ( 2 m a s k s i z e y ) + 1 ] ; f o r ( j = 0 ; j < ((2 m a s k s i z e y ) + 1 ) ; j ++){ s e g [ j ] = new i n t [ ( 2 m a s k s i z e x ) + 1 ] ; f o r ( i = 0 ; i < ((2 m a s k s i z e x ) + 1 ) ; i ++) seg [ j ] [ i ] = 0 ; } // Variables i n i t i a l i z a t i o n i m a g e s i z e = img height img width ; // Enlarge img in e n l a r g e i m g = new i n t [ i m g h e i g h t + ( 2 m a s k s i z e y ) ] ; f o r ( j = 0 ; j <i m g h e i g h t + ( 2 m a s k s i z e y ) ; j ++) e n l a r g e i m g [ j ] = new i n t [ i m g w i d t h + ( 2 m a s k s i z e y ) ] ; f o r ( j=m a s k s i z e y ; j <( i m g h e i g h t + m a s k s i z e y ) ; j ++) / / Copy i m g i n f o r ( i=m a s k s i z e x ; i <( i m g w i d t h + m a s k s i z e x ) ; i ++) enlarge img [ j ] [ i ] = img in [ j mask size y ] [ i mask size x ] ; f o r ( j = 0 ; j < m a s k s i z e y ; j ++) / / Copy t o p and bottom rows f o r ( i=m a s k s i z e x ; i <( i m g w i d t h + m a s k s i z e x ) ; i ++){ e n l a r g e i m g [ j ] [ i ] = e n l a r g e i m g [ ( ( 2 m a s k s i z e y ) + 1) j ] [ i ] ; e n l a r g e i m g [ j+i m g h e i g h t+m a s k s i z e y ] [ i ] = e n l a r g e i m g [ ( i m g h e i g h t + m a s k s i z e y 2) j ] [ i ] ; } f o r ( i = 0 ; i < m a s k s i z e x ; i ++) / / Copy l e f t and r i g h t columns f o r ( j = 0 ; j <( i m g h e i g h t + ( 2 m a s k s i z e y ) ) ; j ++){ e n l a r g e i m g [ j ] [ i ] = e n l a r g e i m g [ j ] [ ( ( 2 m a s k s i z e x ) + 1) i ] ; e n l a r g e i m g [ j ] [ i+i m g w i d t h+m a s k s i z e x ] = e n l a r g e i m g [ j ] [ ( i m g w i d t h + m a s k s i z e x 2) i ] ; } / / Compute t h e S e g m e n t a t i o n , L o c a l Mean , L o c a l V a r i a n c e / / and t h e N o i s e E s t i m a t i o n f o r ( j=m a s k s i z e y ; j <( i m g h e i g h t + m a s k s i z e y ) ; j ++){ f o r ( i=m a s k s i z e x ; i <( i m g w i d t h + m a s k s i z e x ) ; i ++){ // Segmentation nb active pix = 0; f o r ( y = m a s k s i z e y ; y < = m a s k s i z e y ; y++) f o r ( x = m a s k s i z e x ; x < = m a s k s i z e x ; x++){ i f ( a b s ( e n l a r g e i m g [ j ] [ i ] e n l a r g e i m g [ j+y ] [ i+x ] ) > = t h r e s h o l d ) { seg [ y + mask size y ] [ x + mask size x ] = 0 ; } else { seg [ y + mask size y ] [ x + mask size x ] = 1 ; n b a c t i v e p i x ++; }

118
} / / L o c a l Mean f o r ( y = m a s k s i z e y ; y < = m a s k s i z e y ; y++) f o r ( x = m a s k s i z e x ; x < = m a s k s i z e x ; x++) mu [ j m a s k s i z e y ] [ i m a s k s i z e x ] += ( seg [ y + mask size y ] [ x + mask size x ] enlarge img [ j + y ] [ i + x ] ) ; mu [ j m a s k s i z e y ] [ i m a s k s i z e x ] = mu [ j m a s k s i z e y ] [ i m a s k s i z e x ] / n b a c t i v e p i x ; // Local Variance f o r ( y = m a s k s i z e y ; y < = m a s k s i z e y ; y++) f o r ( x = m a s k s i z e x ; x < = m a s k s i z e x ; x++) s i g m a [ j m a s k s i z e y ] [ i m a s k s i z e x ] += ( seg [ y + mask size y ] [ x + mask size x ] enlarge img [ j + y ] [ i + x ] enlarge img [ j + y ] [ i + x ] ) ; sigma [ j m a s k s i z e y ] [ i m a s k s i z e x ] = ( ( sigma [ j m a s k s i z e y ] [ i m a s k s i z e x ] / n b a c t i v e p i x ) (mu [ j m a s k s i z e y ] [ i m a s k s i z e x ] mu [ j m a s k s i z e y ] [ i m a s k s i z e x ] ) ) ; } } // F i n a l computation f o r ( j = 0 ; j <i m g h e i g h t ; j ++){ f o r ( i = 0 ; i <i m g w i d t h ; i ++){ / / K( x , y ) = MAX( 0 , ( s i g m a ( x , y ) nu ( x , y ) ) ) / s i g m a ( x , y ) K = s i g m a [ j ] [ i ] nu ; i f (K < 0 ) K = 0; else K = K / sigma [ j ] [ i ] ; / / g ( x , y ) = mu( x , y ) + K( x , y ) ( g ( x , y ) mu( x , y ) ) i m g o u t [ j ] [ i ] = ( i n t ) (mu [ j ] [ i ] + (K ( i m g i n [ j ] [ i ] mu [ j ] [ i ] ) ) ) ; } } / / F r e e t h e memory f o r ( j = 0 ; j <i m g h e i g h t + ( 2 m a s k s i z e y ) ; delete [ ] e n l a r g e i m g [ j ] ; f o r ( j = 0 ; j < ((2 m a s k s i z e y ) + 1 ) ; j ++) delete [ ] seg [ j ] ; f o r ( j = 0 ; j <i m g h e i g h t ; j ++){ d e l e t e [ ] mu [ j ] ; delete [ ] sigma [ j ] ; } delete [ ] e n l a r g e i m g ; delete [ ] seg ; d e l e t e [ ] mu ; delete [ ] sigma ; e n l a r g e i m g = NULL ; seg = NULL ; mu = NULL ; sigma = NULL ; return i m g o u t ; } / @ b r i e f G e n e r a t e t h e Hybrid f i l t e r matlab f i l e s / void h y b r i d f i l t e r : : g e n e r a t e m a t l a b f i l e ( s t r i n g p a r a m e t e r f i l e n a m e , string matlab filename , int img src , int img noisy , f l o a t n o i s y q u a l i t y ){ char filename ; float d t , d t s t a r t , dt end ; float img quality = 0; int b t , b t s t a r t , bt end ; int j; int i m g f i l t e r e d ; string tmp filename ; i f s t r e a m ReadTXT ; ofstream WriteMatlab results ; // // // // // // // Parameter file content : j ++)

Image F i l e n a m e Brightness Threshold s t a r t B r i g h t n e s s T h r e s h o l d end Noise estimation s t a r t N o i s e e s t i m a t i o n end

119
// // // // // // // //

Example o f

the content

of

the parameter

file : < Image f i l e n a m e < T h r e s h o l d s t a r t < T h r e s h o l d end < NU s t a r t < NU end

l e n a 2 5 6 . pgm 15 75 10 160

c o u t << Reading P a r a m e t e r s : << e n d l ; / / Open p a r a m e t e r f i l e ReadTXT . open ( p a r a m e t e r f i l e n a m e . c s t r ( ) ) ; / / Save matlab r e s u l t s f i l e f i l e n a m e = new char [ 4 0 ] ; strcat ( filename , matlab filename . c s t r ( ) ) ; s t r c a t ( f i l e n a m e , r e s u l t s .m ) ; W r i t e M a t l a b r e s u l t s . open ( f i l e n a m e ) ; delete [ ] f i l e n a m e ; f i l e n a m e = NULL ; i f ( ! ReadTXT . f a i l ( ) & & ! W r i t e M a t l a b r e s u l t s . f a i l ( ) ) { / / Load t h e s o u r c e image ReadTXT >> t m p f i l e n a m e ; / / Load S e g m e n t a t i o n t h r e s h o l d p a r a m e t e r s ReadTXT >> b t s t a r t >> b t e n d ; c o u t << \ t S e g m e n t a t i o n t h r e s h o l d p a r a m e t e r s : << e n d l ; c o u t << \ t \ t S t a r t : << b t s t a r t << e n d l ; c o u t << \ t \ tEnd : << b t e n d << e n d l ; / / Load NU p a r a m e t e r s ReadTXT >> d t s t a r t >> d t e n d ; c o u t << \ t N o i s e e s t i m a t i o n p a r a m e t e r s : << e n d l ; c o u t << \ t \ t S t a r t : << d t s t a r t << e n d l ; c o u t << \ t \ tEnd : << d t e n d << e n d l ; c o u t << \n ; // my my my I n i t i a l i z e the s s i m i n d e x>s e t s s i m i n d e x>s e t s s i m i n d e x>s e t ssim index object image height ( img height ) ; i m a g e w i d t h ( img width ) ; ssim map ( ) ;

// I n i t i a l i z e the f i l t e r set mask size x (3); set mask size y (3); / / F i l t e r t h e image w i t h d i f f e r e n t Hybrid f i l t e r p a r a m e t e r s W r i t e M a t l a b r e s u l t s << h y b r i d f i l t e r =[ ; f o r ( b t = b t s t a r t ; b t <= b t e n d ; b t = b t + 2 ) { f o r ( d t = d t s t a r t ; d t <= d t e n d ; d t = d t + 5 ) { set threshold ( b t ); set nu ( d t ) ; i m g f i l t e r e d = a p p l y f i l t e r ( img noisy ) ; img quality = ( f l o a t ) ( m y s s i m i n d e x>c o m p u t e s s i m i n d e x ( i m g s r c , img filtered )); i f ( d t != dt end ) W r i t e M a t l a b r e s u l t s << n o i s y q u a l i t y / i m g q u a l i t y << ; else W r i t e M a t l a b r e s u l t s << n o i s y q u a l i t y / i m g q u a l i t y ; / / F r e e t h e memory f o r ( j = 0 ; j <i m g h e i g h t ; j ++) delete [ ] i m g f i l t e r e d [ j ] ; delete [ ] i m g f i l t e r e d ; i m g f i l t e r e d = NULL ; } i f ( b t != bt end ) W r i t e M a t l a b r e s u l t s << , \ n ; } W r i t e M a t l a b r e s u l t s << ] ; ; } ReadTXT . c l o s e ( ) ; WriteMatlab results . close ( ) ; } / / / / Other f u n c t i o n s / / / @ b r i e f Compute t h e Mean o f t h e image / f l o a t h y b r i d f i l t e r : : compute mean ( i n t i m g s r c ) { double r e s u l t m e a n = 0 ;

120
int j,i;

f o r ( j = 0 ; j <i m g h e i g h t ; j ++) f o r ( i = 0 ; i <i m g w i d t h ; i ++) r e s u l t m e a n += i m g s r c [ j ] [ i ] ; result mean = result mean / ( img height img width ) ; return ( f l o a t ) r e s u l t m e a n ; } / @ b r i e f Compute t h e V a r i a n c e o f t h e image / float h y b r i d f i l t e r : : compute variance ( int img src , double r e s u l t v a r i a n c e = 0 ; int j , i ;

f l o a t mean ) {

f o r ( j = 0 ; j <i m g h e i g h t ; j ++) f o r ( i = 0 ; i <i m g w i d t h ; i ++) r e s u l t v a r i a n c e += ( i m g s r c [ j ] [ i ] i m g s r c [ j ] [ i ] ) ; r e s u l t v a r i a n c e = ( r e s u l t v a r i a n c e ( mean mean ) ) / ( i m g h e i g h t i m g w i d t h ) ; return ( f l o a t ) r e s u l t v a r i a n c e ; }

D.2 Code source du ltre SUSAN

D.2.1 Fichier susan lter.h


/ / // Title : SUSAN image f i l t e r // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : susan filter .h / / Author : S e r g e CATUDAL // Created : 05/03/2004 // Last modified : 2 9 / 0 4 / 2 0 0 4 / / // Description : S m a l l e s t U n i v a l u e Segment A s s i m i l a t i n g N u c l e u s ( SUSAN) / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 05/03/2004 : created / / #i f n d e f #d e f i n e SUSAN FILTER HEADER SUSAN FILTER HEADER

/ / VPVE i n c l u s i o n s #include < i m a g e f i l t e r . h> / @ingroup f i l t e r p a c k @ b r i e f T h i s c l a s s i s t h e SUSAN F i l t e r @author S e r g e C a t u d a l @version 1 . 0 @date 0 5 / 0 3 / 2 0 0 4 / c l a s s s u s a n f i l t e r : public i m a g e f i l t e r { public : /// Constructor susan filter (); / / / Copy c o n s t r u c t o r s u s a n f i l t e r ( const s u s a n f i l t e r & ) ; /// Overload the equal ( = ) o p e r a t o r s u s a n f i l t e r & operator =( const s u s a n f i l t e r & ) ; /// Destructor susan filter (); // Access f u n c t i o n s void s e t b t ( i n t b ) { bt = b ; } void s e t d t ( f l o a t d ) { d t = d ; } / / SUSAN f i l t e r f u n c t i o n s int median ( i n t p ) ;

121
int s e t u p b r i g h t n e s s l u t ( i n t t h r e s h , i n t form ) ; int a p p l y f i l t e r ( int img in ) ; void generate matlab file ( string parameter filename , string matlab filename , int img src , int img noisy , float n o i s y q u a l i t y ) ; private : /// Brightness threshold ( Brightness control ) int bt ; /// Distance threshold ( Spatial control ) f l o a t dt ; }; #e n d i f

D.2.2 Fichier susan lter.cc


/ / // Title : SUSAN image f i l t e r // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : s u s a n f i l t e r . cc / / Author : S e r g e CATUDAL // Created : 05/03/2004 // Last modified : 2 9 / 0 4 / 2 0 0 4 / / // Description : S m a l l e s t U n i v a l u e Segment A s s i m i l a t i n g N u c l e u s ( SUSAN) / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 05/03/2004 : created / / #include < s u s a n f i l t e r . h> / / // Default Constructor / @brief / / / s u s a n f i l t e r : : s u s a n f i l t e r ( ) : i m a g e f i l t e r ( VPVE SUSAN FILTER) { bt = 0 ; dt = 0 ; } / / / / Copy C o n s t r u c t o r / @brief / / / s u s a n f i l t e r : : s u s a n f i l t e r ( const s u s a n f i l t e r & s f ) : i m a g e f i l t e r ( s f ) { bt = s f . bt ; dt = s f . dt ; } / / // = Operator Overloading / @brief / / / s u s a n f i l t e r & s u s a n f i l t e r : : operator =( const s u s a n f i l t e r & s f ) { i f ( t h i s != & s f ){ bt = s f . bt ; dt = s f . dt ; } return t h i s ; } / / // Destructor / @brief / / / s u s a n f i l t e r : : s u s a n f i l t e r (){ } / /

122
/ / SUSAN F i l t e r F u n c t i o n s / / / @ b r i e f E v a l u a t e t h e median v a l u e / i n t s u s a n f i l t e r : : median ( i n t p ) { int reg2 0 , reg2 1 , reg2 2 , reg2 3 , reg2 4 , reg2 5 , reg2 6 , reg2 7 ; int reg3 0 , reg3 1 , reg3 2 , reg3 3 ; int reg4 0 , reg4 1 ; int r e s u l t ; // Stage 2 i f (p [0] > p [ 1 ] ) { reg2 0 = p [ 1 ] ; reg2 1 = p [ 0 ] ; } else { reg2 0 = p [ 0 ] ; reg2 1 = p [ 1 ] ; } i f (p [2] > p [ 3 ] ) { reg2 2 = p [ 3 ] ; reg2 3 = p [ 2 ] ; } else { reg2 2 = p [ 2 ] ; reg2 3 = p [ 3 ] ; } i f (p [4] > p [ 5 ] ) { reg2 4 = p [ 5 ] ; reg2 5 = p [ 4 ] ; } else { reg2 4 = p [ 4 ] ; reg2 5 = p [ 5 ] ; } i f (p [6] > p [ 7 ] ) { reg2 6 = p [ 7 ] ; reg2 7 = p [ 6 ] ; } else { reg2 6 = p [ 6 ] ; reg2 7 = p [ 7 ] ; } // Stage 3 i f ( reg2 0 > reg2 2 ) reg3 0 = reg2 0 ; else reg3 0 = reg2 2 ; i f ( reg2 1 > reg2 3 ) reg3 1 = reg2 3 ; else reg3 1 = reg2 1 ; i f ( reg2 4 > reg2 6 ) reg3 2 = reg2 4 ; else reg3 2 = reg2 6 ; i f ( reg2 5 > reg2 7 ) reg3 3 = reg2 7 ; else reg3 3 = reg2 5 ; // Stage 4 i f ( reg3 1 > reg3 3 ) reg4 0 = reg3 1 ; else reg4 0 = reg3 3 ; i f ( reg3 0 > reg3 2 ) reg4 1 = reg3 2 ; else reg4 1 = reg3 0 ; // Stage 5 result = ( reg4 0 + reg4 1 ) / 2 ; / / F r e e t h e memory delete [ ] p ; p = NULL ; return } result ;

123
/ @ b r i e f G e n e r a t e t h e B r i g h t n e s s LookUpT a b l e ( LUT) / i n t s u s a n f i l t e r : : s e t u p b r i g h t n e s s l u t ( i n t t h r e s h , i n t form ) { f l o a t temp ; int k; int b lut ; / / C r e a t e LUT b lut = new i n t [ 5 1 3 ] ; f o r ( k = 256; k < 2 5 7 ; k++){ temp = (( float ) k ) / ( ( float ) thresh ) ; temp = temp temp ; temp = 1 0 0 . 0 exp( temp ) ; b l u t [ 2 5 6 + k ] = ( i n t ) temp ; } return b l u t ; } / @ b r i e f Compute t h e S m a l l e s t U n i v a l u e Segment A s s i m i l a t i n g N u c l e u s ( SUSAN ) / int s u s a n f i l t e r : : a p p l y f i l t e r ( int img in ){ f l o a t temp ; int i m g o u t ; int e n l a r g e i m g ; int a r e a , t o t a l , tmp , b r i g h t n e s s ; int j,i; int y,x; int median pixels ; int centre ; / / C e n t r e p i x e l o f t h e g a u s s i a n mask int b lut ; / / B r i g h t n e s s LUT ( LookUpT a b l e ) int cp ; // Centre P i x e l B r i g h t n e s s int g mask ; / / G a u s s i a n mask / / G a u s s i a n mask s i z e int mask size ; // I n i t i a l i z e img out i m g o u t = new i n t [ i m g h e i g h t ] ; f o r ( j = 0 ; j <i m g h e i g h t ; j ++) i m g o u t [ j ] = new i n t [ i m g w i d t h ] ; / / C r e a t e B r i g h t n e s s LUT b l u t = s e t u p b r i g h t n e s s l u t ( bt , 2 ) ; / / C r e a t e t h e g a u s s i a n mask temp = ( d t d t ) ; m a s k s i z e = ( ( int ) ( 1 . 5 dt ) ) + 1 ; = new i n t [ ( 2 m a s k s i z e ) + 1 ] ; g mask f o r ( j=m a s k s i z e ; j <=m a s k s i z e ; j ++){ g mask [ j+m a s k s i z e ] = new i n t [ ( m a s k s i z e 2 ) + 1 ] ; f o r ( i=m a s k s i z e ; i <=m a s k s i z e ; i ++) g mask [ j+m a s k s i z e ] [ i+m a s k s i z e ] = ( i n t ) ( 1 0 0 . 0 exp ( ( ( f l o a t ) ( ( i i )+( j j ) ) ) / temp ) ) ; } // Enlarge img in e n l a r g e i m g = new i n t [ i m g h e i g h t + ( 2 m a s k s i z e ) ] ; f o r ( j = 0 ; j <i m g w i d t h + ( 2 m a s k s i z e ) ; j ++) e n l a r g e i m g [ j ] = new i n t [ i m g w i d t h + ( 2 m a s k s i z e ) ] ; f o r ( j=m a s k s i z e ; j <( i m g h e i g h t + m a s k s i z e ) ; j ++) / / Copy i m g i n f o r ( i=m a s k s i z e ; i <( i m g w i d t h + m a s k s i z e ) ; i ++) enlarge img [ j ] [ i ] = img in [ j mask size ] [ i mask size ] ; f o r ( j = 0 ; j < m a s k s i z e ; j ++) / / Copy t o p and bottom rows f o r ( i=m a s k s i z e ; i <( i m g w i d t h + m a s k s i z e ) ; i ++){ enlarge img [ j ] [ i ] = enlarge img [ ( ( 2 mask size ) + 1) j ] [ i ] ; e n l a r g e i m g [ j+i m g h e i g h t+m a s k s i z e ] [ i ] = e n l a r g e i m g [ ( i m g h e i g h t+m a s k s i z e 2) j ] [ i ] ; } f o r ( i = 0 ; i < m a s k s i z e ; i ++) / / Copy l e f t and r i g h t columns f o r ( j = 0 ; j <( i m g h e i g h t + ( 2 m a s k s i z e ) ) ; j ++){ enlarge img [ j ] [ i ] = enlarge img [ j ] [ ( ( 2 mask size ) + 1) i ] ; e n l a r g e i m g [ j ] [ i+i m g w i d t h+m a s k s i z e ] = e n l a r g e i m g [ j ] [ ( i m g w i d t h + m a s k s i z e 2) i ] ; } / / F i l t e r t h e image f o r ( j=m a s k s i z e ; j <( i m g h e i g h t + m a s k s i z e ) ; j ++){ f o r ( i=m a s k s i z e ; i <( i m g w i d t h + m a s k s i z e ) ; i ++){ area = 0; total = 0; centre = enlarge img [ j ] [ i ] ; cp = 256 + c e n t r e ; / / Apply t h e g a u s s i a n mask f o r ( y=m a s k s i z e ; y<= m a s k s i z e ; y++){ f o r ( x=m a s k s i z e ; x<= m a s k s i z e ; x++){ b r i g h t n e s s = e n l a r g e i m g [ j+y ] [ i+x ] ; tmp = g mask [ y + m a s k s i z e ] [ x + m a s k s i z e ]

filter

b l u t [ cp b r i g h t n e s s ] ;

124
area total } } tmp = a r e a 1 0 0 0 0 ; i f ( tmp == 0) { / / G e n e r a t e t h e median v e c t o r = new i n t [ 8 ] ; median pixels median pixels [0] = enlarge img median pixels [1] = enlarge img median pixels [2] = enlarge img median pixels [3] = enlarge img median pixels [4] = enlarge img median pixels [5] = enlarge img median pixels [6] = enlarge img median pixels [7] = enlarge img = a r e a + tmp ; = t o t a l + ( tmp b r i g h t n e s s ) ;

[ [ [ [ [ [ [ [

j j j j j j j j

1][ i 1]; 1][ i ] ; 1][ i +1]; ] [ i 1]; ] [ i +1]; +1][ i 1]; +1][ i ] ; +1][ i +1];

/ / Compute t h e median v a l u e i m g o u t [ j m a s k s i z e ] [ i m a s k s i z e ] = median ( m e d i a n p i x e l s ) ; } else { i m g o u t [ j m a s k s i z e ] [ i m a s k s i z e ] = ( ( t o t a l ( c e n t r e 1 0 0 0 0 ) ) / tmp ) ; } } } / / F r e e t h e memory f o r ( j = 0 ; j <i m g w i d t h + ( 2 m a s k s i z e ) ; delete [ ] e n l a r g e i m g [ j ] ; f o r ( j = 0 ; j < ( 2 m a s k s i z e ) + 1 ; j ++) d e l e t e [ ] g mask [ j ] ; delete [ ] b l u t ; delete [ ] e n l a r g e i m g ; d e l e t e [ ] g mask ; b lut = NULL ; e n l a r g e i m g = NULL ; g mask = NULL ; return i m g o u t ; } / @ b r i e f G e n e r a t e t h e SUSAN matlab f i l e s / void s u s a n f i l t e r : : g e n e r a t e m a t l a b f i l e ( s t r i n g p a r a m e t e r f i l e n a m e , s t r i n g m a t l a b f i l e n a m e , int i m g s r c , int img noisy , f l o a t n o i s y q u a l i t y ){ char filename ; float d t , d t s t a r t , dt end ; float img quality ; float ratio ; int b t , b t s t a r t , bt end ; int j; int i m g f i l t e r e d ; string tmp filename ; ssim index my ssim index ; i f s t r e a m ReadTXT ; ofstream WriteMatlab results ; // // // // // // // // // // // // // // // Parameter file content :

j ++)

Image F i l e n a m e Brightness Threshold s t a r t B r i g h t n e s s T h r e s h o l d end Distance Threshold s t a r t D i s t a n c e T h r e s h o l d end Example o f the content of the parameter file :

l e n a 2 5 6 . pgm 5 55 0.6 4.5

/ / Open p a r a m e t e r f i l e ReadTXT . open ( p a r a m e t e r f i l e n a m e . c s t r ( ) ) ; / / Save matlab r e s u l t s f i l e f i l e n a m e = new char [ 4 0 ] ; strcat ( filename , matlab filename . c s t r ( ) ) ; s t r c a t ( f i l e n a m e , r e s u l t s .m ) ; W r i t e M a t l a b r e s u l t s . open ( f i l e n a m e ) ; delete [ ] f i l e n a m e ; f i l e n a m e = NULL ;

125
i f ( ! ReadTXT . f a i l ( ) & & ! W r i t e M a t l a b r e s u l t s . f a i l ( ) ) { / / Load t h e s o u r c e image ReadTXT >> t m p f i l e n a m e ; / / Load B r i g h t n e s s t h r e s h o l d p a r a m e t e r s ReadTXT >> b t s t a r t >> b t e n d ; c o u t << \ t B r i g h t n e s s t h r e s h o l d p a r a m e t e r s ( B r i g h t n e s s c o u t << \ t \ t S t a r t : << b t s t a r t << e n d l ; c o u t << \ t \ tEnd : << b t e n d << e n d l ;

C o n t r o l ) : << e n d l ;

/ / Load D i s t a n c e t h r e s h o l d p a r a m e t e r s ReadTXT >> d t s t a r t >> d t e n d ; c o u t << \ t D i s t a n c e t h r e s h o l d p a r a m e t e r s ( S p a t i a l C o n t r o l ) : << e n d l ; c o u t << \ t \ t S t a r t : << d t s t a r t << e n d l ; c o u t << \ t \ tEnd : << d t e n d << e n d l ; c o u t << \ n ; // my my my my I n i t i a l i z e the ssim index o b j e c t s s i m i n d e x = new s s i m i n d e x ( ) ; s s i m i n d e x>s e t i m a g e h e i g h t ( i m g h e i g h t ) ; s s i m i n d e x>s e t i m a g e w i d t h ( i m g w i d t h ) ; s s i m i n d e x>s e t s s i m m a p ( ) ;

/ / F i l t e r t h e image w i t h d i f f e r e n t SUSAN p a r a m e t e r s W r i t e M a t l a b r e s u l t s << s u s a n f i l t e r =[ ; f o r ( b t = b t s t a r t ; b t < = b t e n d ; b t ++){ f o r ( d t = d t s t a r t ; d t <= d t e n d ; d t = d t + 0 . 1 ) { set bt ( b t ); set dt ( d t ); i m g f i l t e r e d = a p p l y f i l t e r ( img noisy ) ; img quality = ( f l o a t ) ( m y s s i m i n d e x>c o m p u t e s s i m i n d e x ( i m g s r c , i m g f i l t e r e d ) ) ; ratio = noisy quality / img quality ; i f ( d t != dt end ) W r i t e M a t l a b r e s u l t s << r a t i o << ; else W r i t e M a t l a b r e s u l t s << r a t i o ; / / F r e e t h e memory f o r ( j = 0 ; j <i m g h e i g h t ; j ++) delete [ ] i m g f i l t e r e d [ j ] ; delete [ ] i m g f i l t e r e d ; i m g f i l t e r e d = NULL ; } i f ( b t != bt end ) W r i t e M a t l a b r e s u l t s << , \ n ; } W r i t e M a t l a b r e s u l t s << ] ; ; / / F r e e t h e memory delete my ssim index ; } ReadTXT . c l o s e ( ) ; WriteMatlab results . close ( ) ; }

D.3 Code source du ltre adaptatif Wiener

D.3.1 Fichier wiener lter.h


/ / // Title : Model C/C++ du F i l t r e Wiener // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : Cmodel wf . h / / Author : S e r g e CATUDAL // Created : 04/12/2003 // Last modified : 2 9 / 0 4 / 2 0 0 4 / / // Description : Model C/C++ du F i l t r e Wiener d e r i v e r du model SystemC / / / / C o p y r i g h t ( c ) 2 0 0 3 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 04/12/2003 : created / /

126

#i f n d e f #d e f i n e

CMODEL WF HEADER CMODEL WF HEADER

/ / VPVE i n c l u s i o n s #include < i m a g e f i l t e r . h> / @ingroup f i l t e r p a c k @ b r i e f T h i s c l a s s i s t h e Wiener F i l t e r @author S e r g e C a t u d a l @version 1 . 0 @date 0 4 / 1 2 / 2 0 0 3 / c l a s s c m o d e l w f : public i m a g e f i l t e r { public : /// Constructor cmodel wf ( ) ; / / / Copy c o n s t r u c t o r c m o d e l w f ( const c m o d e l w f & ) ; /// Overload the equal ( = ) o p e r a t o r c m o d e l w f & operator =( const c m o d e l w f & ) ; /// Destructor cmodel wf ( ) ; // Access functions

/ / L o c a l Mean and L o c a l V a r i a n c e module f u n c t i o n s float LM div by 9 ( f l o a t ) ; float LM mask 3x3 ( f l o a t , f l o a t , f l o a t , bool ) ; f l o a t LV 3 mult ( f l o a t , f l o a t , f l o a t ) ; float LV div by 9 ( float ) ; float LV mask 3x3 ( f l o a t , bool ) ; float LV mult ( f l o a t ) ; float LV substraction ( float , float ) ; / / Wiener F i l t e r f u n c t i o n s int a p p l y f i l t e r ( int img in ) ; void r e s e t ( void ) ; void generate matlab file ( string parameter filename , string matlab filename , int img src , int img noisy , float n o i s y q u a l i t y ) ; private : / / / L o c a l Mean mask 3 x3 int LM mask 3x3 cycle / / / L o c a l Mean mask 3 x3 int LM mask 3x3 ptr ; / / / L o c a l Mean mask 3 x3 f l o a t LM mask 3x3 var ; / / / L o c a l V a r i a n c e mask int LV mask 3x3 cycle / / / L o c a l V a r i a n c e mask int LV mask 3x3 ptr ; / / / L o c a l V a r i a n c e mask f l o a t LV mask 3x3 var ; }; #e n d i f

cycle counter count ; variable container variable container

pointer

3 x3 c y c l e c o u n t e r count ; 3 x3 v a r i a b l e c o n t a i n e r 3 x3 v a r i a b l e container

pointer

D.3.2 Fichier wiener lter.cc


/ / // Title : Model C/C++ du F i l t r e Wiener // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : Cmodel wf . c c / / Author : S e r g e CATUDAL // Created : 05/12/2003 // Last modified : 2 9 / 0 4 / 2 0 0 4 / / // Description : Model C/C++ du F i l t r e Wiener d e r i v e r du model SystemC / / / / C o p y r i g h t ( c ) 2 0 0 3 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 05/12/2003 : created / / #include < Cmodel wf . h>

127
/ / // Default Constructor / @brief / / / c m o d e l w f : : c m o d e l w f ( ) : i m a g e f i l t e r (VPVE REGULAR WIENER FILTER) { LM mask 3x3 cycle count = 0; LM mask 3x3 ptr = 0; = new f l o a t [ 3 ] ; LM mask 3x3 var LV mask 3x3 cycle count = 0; LV mask 3x3 ptr = 0; LV mask 3x3 var = new f l o a t [ 3 ] ; f o r ( i n t k = 0 ; k < 3 ; k++){ LM mask 3x3 var [ k ] = 0 ; LV mask 3x3 var [ k ] = 0 ; } } / / / / Copy C o n s t r u c t o r / @brief / / / c m o d e l w f : : c m o d e l w f ( const c m o d e l w f & M) : i m a g e f i l t e r (M) { L M m a s k 3 x 3 c y c l e c o u n t = M. L M m a s k 3 x 3 c y c l e c o u n t ; = M. LM mask 3x3 ptr ; LM mask 3x3 ptr LM mask 3x3 var = M. LM mask 3x3 var ; L V m a s k 3 x 3 c y c l e c o u n t = M. L V m a s k 3 x 3 c y c l e c o u n t ; LV mask 3x3 ptr = M. L V m a s k 3 x 3 p t r ; LV mask 3x3 var = M. L V m a s k 3 x 3 v a r ; } / / // = Operator Overloading / @brief / / / c m o d e l w f & c m o d e l w f : : operator =( const c m o d e l w f & M) { i f ( t h i s ! = &M) { L M m a s k 3 x 3 c y c l e c o u n t = M. L M m a s k 3 x 3 c y c l e c o u n t ; LM mask 3x3 ptr = M. LM mask 3x3 ptr ; LM mask 3x3 var = M. LM mask 3x3 var ; L V m a s k 3 x 3 c y c l e c o u n t = M. L V m a s k 3 x 3 c y c l e c o u n t ; LV mask 3x3 ptr = M. L V m a s k 3 x 3 p t r ; LV mask 3x3 var = M. L V m a s k 3 x 3 v a r ; } return t h i s ; } / / // Destructor / @brief / / / cmodel wf : : cmodel wf (){ d e l e t e [ ] LM mask 3x3 var ; delete [ ] LV mask 3x3 var ; LM mask 3x3 var = NULL ; L V m a s k 3 x 3 v a r = NULL ; } / / / / L o c a l Mean and L o c a l V a r i a n c e module F u n c t i o n s / / / @ b r i e f Compute t h e module d i v i s i o n by 9 from t h e L o c a l Mean module / f l o a t cmodel wf : : LM div by 9 ( f l o a t v a l i n ){ float result ; result = val in return } / @ b r i e f Compute t h e module mask 3 x3 from t h e L o c a l Mean module / f l o a t c m o d e l w f : : LM mask 3x3 ( f l o a t v a l i n 0 , f l o a t v a l i n 1 , f l o a t float result ; float temp result ; result ; / 9;

v a l i n 2 , bool n e w l i n e ) {

128
temp result = val in 0 + val in 1 + val in 2 ; i f ( n e w l i n e ){ LM mask 3x3 cycle count = 0; LM mask 3x3 ptr = 0; } LM mask 3x3 var [ LM mask 3x3 ptr ] = t e m p r e s u l t ; LM mask 3x3 ptr++; i f ( LM mask 3x3 ptr == 3) LM mask 3x3 ptr = 0 ; i f ( L M m a s k 3 x 3 c y c l e c o u n t == 2) { r e s u l t = LM mask 3x3 var [ 0 ] + LM mask 3x3 var [ 1 ] + LM mask 3x3 var [ 2 ] ; L M m a s k 3 x 3 c y c l e c o u n t ++; } e l s e i f ( L M m a s k 3 x 3 c y c l e c o u n t == 3) { r e s u l t = LM mask 3x3 var [ 0 ] + LM mask 3x3 var [ 1 ] + LM mask 3x3 var [ 2 ] ; } else { L M m a s k 3 x 3 c y c l e c o u n t ++; } return } / @ b r i e f Compute t h e module m u l t i p l i c a t i o n ( 3 ) from t h e L o c a l V a r i a n c e module / f l o a t c m o d e l w f : : LV 3 mult ( f l o a t v a l i n 0 , f l o a t v a l i n 1 , f l o a t v a l i n 2 ) { f l o a t r e s u l t = new f l o a t [ 3 ] ; float temp result 0 ; float temp result 1 ; float temp result 2 ; temp result 0 = val in 0 val in 0 ; temp result 1 = val in 1 val in 1 ; temp result 2 = val in 2 val in 2 ; result [0] = temp result 0 ; result [1] = temp result 1 ; result [2] = temp result 2 ; return } / @ b r i e f Compute t h e module d i v i s i o n by 9 from t h e L o c a l V a r i a n c e module / f l o a t cmodel wf : : LV div by 9 ( f l o a t v a l i n ){ float result ; result = val in return } / @ b r i e f Compute t h e module mask 3 x3 from t h e L o c a l V a r i a n c e module / f l o a t c m o d e l w f : : LV mask 3x3 ( f l o a t v e c t o r i n , bool n e w l i n e ) { float result ; float temp result ; temp result = vector in [0] + vector in [1] + vector in [ 2 ] ; i f ( n e w l i n e ){ LV mask 3x3 cycle count = 0; LV mask 3x3 ptr = 0; } LV mask 3x3 var [ LV mask 3x3 ptr ] = t e m p r e s u l t ; L V m a s k 3 x 3 p t r ++; i f ( L V m a s k 3 x 3 p t r == 3) LV mask 3x3 ptr = 0 ; i f ( L V m a s k 3 x 3 c y c l e c o u n t == 2) { r e s u l t = LV mask 3x3 var [ 0 ] + LV mask 3x3 var [ 1 ] + LV mask 3x3 var [ 2 ] ; L V m a s k 3 x 3 c y c l e c o u n t ++; } e l s e i f ( L V m a s k 3 x 3 c y c l e c o u n t == 3) { r e s u l t = LV mask 3x3 var [ 0 ] + LV mask 3x3 var [ 1 ] + LV mask 3x3 var [ 2 ] ; } else { L V m a s k 3 x 3 c y c l e c o u n t ++; } / / F r e e t h e memory delete [ ] v e c t o r i n ; v e c t o r i n = NULL ; result ; / 9; result ; result ;

129

return }

result ;

/ @ b r i e f Compute t h e module m u l t i p l i c a t i o n / f l o a t c m o d e l w f : : LV mult ( f l o a t v a l i n ) { float result ; result = val in val in ; return } result ;

from t h e L o c a l V a r i a n c e module

/ @ b r i e f Compute t h e module s u b s t r a c t i o n from t h e L o c a l V a r i a n c e module / f l o a t cmodel wf : : LV substraction ( f l o a t v a l i n 0 , f l o a t v a l i n 1 ){ float result ; result = val in 1 val in 0 ; return } / / / / Wiener F i l t e r F u n c t i o n s / / / @ b r i e f Compute t h e Wiener F i l t e r a l g o r i t h m / int cmodel wf : : a p p l y f i l t e r ( int img in ){ int i,j; int x,y; int val 0 , val 1 , val 2 ; bool new line ; float lm temp result , lv temp result ; int i m g o u t ; float local mean ; float l o c a l v a r i a n c e ; float noise estimation ; float ne reg1 0 , ne reg1 1 , ne reg1 3 ; float ne reg2 0 , ne reg2 1 ; float ne reg3 0 ; // Variable i n i t i a l i z a t i o n x = 0; y = 0; img out = new i n t [ i m g h e i g h t ] ; = new f l o a t [ i m g h e i g h t ] ; local mean l o c a l v a r i a n c e = new f l o a t [ i m g h e i g h t ] ; f o r ( j = 0 ; j < i m g h e i g h t ; j ++){ img out [ j ] = new i n t [ i m g w i d t h ] ; local mean [ j ] = new f l o a t [ i m g w i d t h ] ; l o c a l v a r i a n c e [ j ] = new f l o a t [ i m g w i d t h ] ; } noise estimation = 0; reset (); / / Compute l o c a l mean and l o c a l v a r i a n c e f o r ( j = 0 ; j < i m g h e i g h t ; j ++){ f o r ( i = 1 ; i < ( i m g w i d t h + 1 ) ; i ++){ // Assign values f o r the v e r t i c a l vector i f ( i = = 1 | | i == i m g w i d t h ) { val 0 = 0; val 1 = 0; val 2 = 0; i f ( i == 1) n e w l i n e = true ; } else { i f ( j == 0) { val 0 = 0; val 1 = img in [ j ] [ i ] ; val 2 = img in [ j + 1 ] [ i ] ; } e l s e i f ( j == ( i m g h e i g h t 1 ) ) { val 0 = img in [ j 1 ] [ i ] ; val 1 = img in [ j ] [ i ] ; val 2 = 0; } else { val 0 = img in [ j 1 ] [ i ] ; val 1 = img in [ j ] [ i ] ; val 2 = img in [ j + 1 ] [ i ] ; } new line = false ; } result ;

130

/ / Compute l o c a l m e a n l m t e m p r e s u l t = LM mask 3x3 ( v a l 0 , v a l 1 , v a l 2 , n e w l i n e ) ; i f ( L M m a s k 3 x 3 c y c l e c o u n t == 3) { l o c a l m e a n [ y ] [ x ] = LM div by 9 ( l m t e m p r e s u l t ) ; } / / Compute l o c a l v a r i a n c e l v t e m p r e s u l t = LV mask 3x3 ( LV 3 mult ( v a l 0 , v a l 1 , v a l 2 ) , n e w l i n e ) ; i f ( L V m a s k 3 x 3 c y c l e c o u n t == 3) { l o c a l v a r i a n c e [ y ] [ x ] = L V s u b s t r a c t i o n ( LV mult ( l o c a l m e a n [ y ] [ x ] ) , LV div by 9 ( l v t e m p r e s u l t ) ) ; noise estimation = noise estimation + local variance [ y ] [ x ] ; } / / update t a b l e p o i n t e r i f ( L V m a s k 3 x 3 c y c l e c o u n t == 3) { x++; i f ( x == i m g w i d t h ) { x = 0; y++; } } } } / / Compute n o i s e e s t i m a t i o n n o i s e e s t i m a t i o n = n o i s e e s t i m a t i o n / ( img height img width ) ; / / F i l t e r t h e image f o r ( j = 0 ; j < i m g h e i g h t ; j ++){ f o r ( i = 0 ; i < i m g w i d t h ; i ++){ // Stage 2 if ( local variance [ j ] [ i ] < noise estimation ) ne reg1 0 = noise estimation ; else ne reg1 0 = local variance [ j ] [ i ] ; ne reg1 1 = local variance [ j ] [ i ] noise estimation ; ne reg1 3 = img in [ j ] [ i ] local mean [ j ] [ i ] ; // Stage 3 ne reg2 0 = ne reg1 3 / ne reg1 0 ; i f ( ne reg1 1 < 0) ne reg2 1 = 0; else ne reg2 1 = ne reg1 1 ; // Stage 4 ne reg3 0 = ne reg2 0 ne reg2 1 ; // Stage 5 img out [ j ] [ i ] = ( int ) ( n e r e g 3 0 + local mean [ j ] [ i ] ) ; } } / / F r e e t h e memory f o r ( j = 0 ; j <i m g h e i g h t ; j ++){ delete [ ] local mean [ j ] ; delete [ ] l o c a l v a r i a n c e [ j ] ; } delete [ ] local mean ; delete [ ] l o c a l v a r i a n c e ; local mean = NULL ; l o c a l v a r i a n c e = NULL ; return i m g o u t ; } / @ b r i e f R e s e t t h e C/C++ Wiener / void c m o d e l w f : : r e s e t ( void ) { LM mask 3x3 cycle count = 0; LM mask 3x3 ptr = 0; LV mask 3x3 cycle count = 0; LV mask 3x3 ptr = 0; f o r ( i n t k = 0 ; k < 3 ; k++){ LM mask 3x3 var [ k ] = 0 ; LV mask 3x3 var [ k ] = 0 ; } }

Filter

model

/ @ b r i e f G e n e r a t e t h e r e g u l a r Wiener f i l t e r matlab f i l e s / void c m o d e l w f : : g e n e r a t e m a t l a b f i l e ( s t r i n g p a r a m e t e r f i l e n a m e , s t r i n g

matlab filename ,

131
int i m g s r c , int img noisy , f l o a t n o i s y q u a l i t y ){ c o u t << \ t \ t F u n c t i o n n o t i m p l e m e n t e d R e g u l a r Wiener F i l t e r << e n d l ; c o u t << \ n ; }

132 ANNEXE E

FICHIERS DE SIMULATIONS

E.1 Code source pour simuler les ltres num eriques

E.1.1 Fichier Ximage.c


/ / // Title : Modele C/C++ du F i l t r e Numerique // Project : Video P r o c e s s i n g Module (VPM) / / // File : numerical filter . c / / Author : S e r g e CATUDAL // Created : 11/12/2003 // Last modified : 1 4 / 1 2 / 2 0 0 3 / / // Description : / / / / C o p y r i g h t ( c ) 2 0 0 3 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 11/12/2003 : created / / // Architecture // Constant optimization definition

definitions

/ / C/C++ i n c l u s i o n s #include < s t d i o . h> #include < s t d l i b . h> #include < i o s t r e a m . h> #include < f s t r e a m . h> #include < math . h> / / SynapC i n c l u s i o n s #include < g F i x . h> #include < X p u b l i c . h> // Global e x t e r n a l v a r i a b l e extern i n t LAST CHECK ; extern i n t SARGE FLAG0 ; // Global variable declaration

declaration

// Numerical F i l t e r Functions i n t c o m p u t e n f ( i n t img , i n t h e i g h t , i n t w i d t h ) ; void p u t i m a g e ( i n t img num , i n t i m g s r c , i n t i m g f i l t e r e d , f l o a t i m g q u a l i t y , int img height , int img width ) ; void XSmain ( ) { int i m g s r c ; int i m g n o i s y ; int i m g f i l t e r e d ; int img height , img width ; int img num = 0 ; int row , c o l ; int the int ; float img quality ; float t he f l o a t ; float the height , the width ; while ( ( g e t i n p u t (& i m g q u a l i t y ) = = 1 ) & & ( g e t i n p u t (& t h e h e i g h t ) == 1) && ( g e t i n p u t (& t h e w i d t h ) = = 1 ) ) { / / Get image s i z e

133
img height = ( int ) t h e h e i g h t ; = ( int ) the width ; img width / / I n i t i a l i z e t h e o r i g i n a l and n o i s y image img src = new i n t [ i m g h e i g h t ] ; i m g n o i s y = new i n t [ i m g h e i g h t ] ; f o r ( row = 0 ; row<i m g h e i g h t ; row++){ = new i n t [ i m g w i d t h ] ; i m g s r c [ row ] i m g n o i s y [ row ] = new i n t [ i m g w i d t h ] ; } / / Get t h e o r i g i n a l image f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ i f ( g e t i n p u t (& t h e f l o a t ) = = 1 ) i m g s r c [ row ] [ c o l ] = ( i n t ) t h e f l o a t ; else f p r i n t f ( s t d e r r , O r i g i n a l image i s wrong } }

s i z e . \ n ) ;

/ / Get t h e n o i s y image f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ i f ( g e t i n p u t (& t h e f l o a t ) = = 1 ) i m g n o i s y [ row ] [ c o l ] = ( i n t ) t h e f l o a t ; else f p r i n t f ( s t d e r r , N o i s y image i s wrong s i z e . \ n ) ; } } / / E x e c u t e t h e image f i l t e r i m g f i l t e r e d = compute nf ( img noisy , img height , img width ) ; / / Save t h e r e s u l t p u t i m a g e ( img num , i m g s r c , i m g f i l t e r e d , i m g q u a l i t y , i m g h e i g h t , i m g w i d t h ) ; img num++; / / F r e e t h e memory f o r ( row = 0 ; row<i m g h e i g h t ; row++){ d e l e t e [ ] i m g s r c [ row ] ; d e l e t e [ ] i m g n o i s y [ row ] ; d e l e t e [ ] i m g f i l t e r e d [ row ] ; } delete [ ] i m g s r c ; delete [ ] img noisy ; delete [ ] i m g f i l t e r e d ; img src = NULL ; = NULL ; img noisy i m g f i l t e r e d = NULL ; / / WARNING // Encountered a n e g a t i v e i f (SARGE FLAG0 == 1) break ; } } / / // Numerical F i l t e r Functions / / / / Compute t h e N u m e r i c a l F i l t e r a l g o r i t h m i n t c o m p u t e n f ( i n t img , i n t h e i g h t , i n t w i d t h ) { // Numerical return } / / Save t h e d a t a f o r t h e X e r r o r a l g o r i t h m void p u t i m a g e ( i n t img num , i n t i m g s r c , i n t i m g f i l t e r e d , f l o a t i m g q u a l i t y , int img height , int img width ){ int row , c o l ; int itr ; char ctmp = new char [ 1 0 ] ; char f i l e n a m e = new char [ 3 0 ] ; char f i l e n a m e e r r = new char [ 3 0 ] ; char h e a d e r t m p = new char [ 2 0 ] ; o f s t r e a m WriteBIN ; o f s t r e a m WriteTXT ; / / Save t h e image q u a l i t y putoutput ( i m g q u a l i t y ) ; / / Save t h e image size Filter Algorithm code here

pixel

in

the

fixed

filter

result

img filtered ;

134
putoutput ( ( f l o a t ) img height ) ; putoutput ( ( f l o a t ) img width ) ; i f (LAST CHECK == 1) { / / C r e a t e t h e e r r o r f i l e n a m e ( when t h e program e n c o u n t e r a n e g a t i v e strcat ( filename err , neg pixel report img ); s p r i n t f ( ctmp , %d , img num ) ; s t r c a t ( f i l e n a m e e r r , ctmp ) ; strcat ( filename err , . log ) ; WriteTXT . open ( f i l e n a m e e r r ) ; / / C r e a t e raw PGM image f i l e h e a d e r s t r c a t ( h e a d e r t m p , P5 \ n ) ; s p r i n t f ( ctmp , %d , i m g h e i g h t ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( header tmp , ) ; s p r i n t f ( ctmp , %d , i m g w i d t h ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( h e a d e r t m p , \ n255 \ n ) ; // Create filename strcat ( filename , i m g f i l t e r f i x e d ) ; s p r i n t f ( ctmp , %d , img num ) ; s t r c a t ( f i l e n a m e , ctmp ) ; s t r c a t ( f i l e n a m e , . pgm ) ; / / Write raw PGM image f i l e WriteBIN . open ( f i l e n a m e , i o s : : b i n a r y ) ; WriteBIN . s e e k p ( 0 , i o s : : beg ) ; / / Write h e a d e r f o r ( i t r = 0 ; i t r < s t r l e n ( h e a d e r t m p ) ; i t r ++) WriteBIN . w r i t e ( ( char ) & h e a d e r t m p [ i t r ] , s i z e o f ( char ) ) ; } / / Save t h e o r i g i n a l and t h e f i l t e r e d image ( i n t e r l a c e d p i x e l ) f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ p u t o u t p u t ( ( f l o a t ) i m g s r c [ row ] [ c o l ] ) ; p u t o u t p u t ( ( f l o a t ) i m g f i l t e r e d [ row ] [ c o l ] ) ; / / Write e a c h p i x e l s i n t o t h e raw PGM f i l e i f (LAST CHECK == 1) { WriteBIN . w r i t e ( ( char ) & ( unsigned char ) i m g f i l t e r e d [ row ] [ c o l ] , s i z e o f ( unsigned char ) ) ; i f ( i m g f i l t e r e d [ row ] [ c o l ] < 0 ) WriteTXT << N e g a t i v e P i x e l [ << row << ] [ << c o l << ] = << i m g f i l t e r e d [ row ] [ c o l ] << e n d l ; } } } i f (LAST CHECK == 1) { WriteBIN . c l o s e ( ) ; WriteTXT . c l o s e ( ) ; } / / F r e e t h e memory d e l e t e [ ] ctmp ; delete [ ] f i l e n a m e ; delete [ ] f i l e n a m e e r r ; delete [ ] header tmp ; ctmp = NULL ; filename = NULL ; f i l e n a m e e r r = NULL ; header tmp = NULL ; }

pixel )

E.1.2 Fichier Ximage error.c


/ / // Title : S t r u c t u r a l S I M i l a r i t y I n d e x ( SSIM I n d e x ) // Project : Video P r o c e s s i n g Module / / // File : Ximage error . c / / Author : Serge Catudal // Created : 12/12/2003 // Last modified : 1 2 / 1 2 / 2 0 0 3 / / // Description : O b j e c t i v e Image Q u a l i t y M e t r i c / / / / C o p y r i g h t ( c ) 2 0 0 3 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 12/12/2003 : created

135
/ / / / C/C++ i n c l u s i o n s #include < s t d i o . h> #include < s t d l i b . h> / / SynapC i n c l u s i o n s #include < X p u b l i c . h> // S i z e of the c i r c u l a r #d e f i n e s i z e w i n d o w 1 1 symmetric g a u s s i a n weighting function

/ / C o n s t a n t s i n t h e SSIM i n d e x f o r m u l a #d e f i n e K1 0 . 0 1 #d e f i n e K2 0 . 0 3 #d e f i n e L 255 // Global e x t e r n a l extern i n t SARGE extern f l o a t SARGE extern f l o a t SARGE variable declaration FLAG0 ; // Negative p i x e l detector (1 = negative FLAG1 ; / / IRATIO o b j e c t i v e FLAG2 ; / / MAX objective

pixel )

/ / C i r c u l a r symmetric g a u s s i a n w e i g h t i n g f u n c t i o n const double window [ s i z e w i n d o w ] [ s i z e w i n d o w ] = { {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0003,0.0020,0.0096,0.0291,0.0567,0.0708,0.0567,0.0291,0.0096,0.0020,0.0003}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000} }; void X e r r o r ( ) { bool f i r s t t i m e = true ; double C1 , C2 ; double d e n o m i n a t o r 1 , d e n o m i n a t o r 2 ; double n u m e r a t o r 1 , n u m e r a t o r 2 ; int border ; int i,j; int m, n ; int c u r r e n t t h r e s h o l d , max threshold ; int i m g 1 i m g 2 , i m g 1 s q , i m g 2 s q ; double mu1 mu2 , mu1 , mu2 ; double mu1 sq , mu2 sq ; double s i g m a 1 2 , s i g m a 1 s q , s i g m a 2 s q ; double r e s u l t = 0 . 0 ; double ssim map ; int o r i g i n a l , d i s t o r t e d ; int h e i g h t , width ; float filtered floating ; float f l o a t i n g , f i x e d , q u a l i t y , tmp ; float the height , the width ; float ratio , smallest ratio ; // Variable i n i t i a l i z a t i o n border = (( size window 1 ) / 2 ) ; smallest ratio = 1.0; // Constants i n i t i a l i a z a t i o n C1 = ( K1 L ) ( K1 L ) ; C2 = ( K2 L ) ( K2 L ) ; / / MAX t h r e s h o l d i n i t i a l i z a t i o n max threshold = 0; while ( ( g e t o u t p u t (& f l o a t i n g ,& q u a l i t y ) = = 1 ) & & ( g e t o u t p u t (& f l o a t i n g ,& t h e h e i g h t ) = = 1 ) && ( g e t o u t p u t (& f l o a t i n g ,& t h e w i d t h ) = = 1 ) ) { / / WARNING // Encountered a n e g a t i v e p i x e l i n the f i x e d f i l t e r r e s u l t i f (SARGE FLAG0 == 1) break ; / / Get image c h a r a c t e r i s t i c s height = ( int ) t h e h e i g h t ; width = ( int ) the width ; // I n i t i a l i z e result = 0.0; result

// Calculate the square f o r the original = new i n t [ h e i g h t ] ;

o r i g i n a l and d i s t o r t e d

image

136
d i s t o r t e d = new i n t [ h e i g h t ] ; i m g 1 i m g 2 = new i n t [ h e i g h t ] ; img1 sq = new i n t [ h e i g h t ] ; img2 sq = new i n t [ h e i g h t ] ; f o r ( j = 0 ; j < h e i g h t ; j ++){ original [ j ] = new i n t [ w i d t h ] ; d i s t o r t e d [ j ] = new i n t [ w i d t h ] ; i m g 1 i m g 2 [ j ] = new i n t [ w i d t h ] ; img1 sq [ j ] = new i n t [ w i d t h ] ; = new i n t [ w i d t h ] ; img2 sq [ j ] f o r ( i = 0 ; i < w i d t h ; i ++){ i f ( g e t o u t p u t (&tmp,& f l o a t i n g ) ! = 1 | | g e t o u t p u t (& f i l t e r e d f l o a t i n g ,& f i x e d ) ! = 1 ) { f p r i n t f ( s t d e r r , \ n \ t E r r o r \ n \ n \ t \ tThe s i z e o f t h e image i s i n c o r r e c t \ n ) ; exit (1); } original [ j ][ i ] = ( int ) f l o a t i n g ; d i s t o r t e d [ j ] [ i ] = ( int ) f i x e d ; img1 img2 [ j ] [ i ] = o r i g i n a l [ j ] [ i ] d i s t o r t e d [ j ] [ i ] ; img1 sq [ j ] [ i ] = original [ j ][ i ] original [ j ][ i ]; img2 sq [ j ] [ i ] = distorted [ j ] [ i ] distorted [ j ] [ i ] ; / / C a l c u l a t e MAX v a l u e c u r r e n t t h r e s h o l d = abs ( ( ( int ) f i l t e r e d f l o a t i n g ) d i s t o r t e d [ j ] [ i ] ) ; i f ( c u r r e n t t h r e s h o l d > max threshold ) max threshold = c u r r e n t t h r e s h o l d ; } } / / Apply t h e 2D F i l t e r on t h e mean i n t e n s i t y and t h e v a r i a n c e mu1 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu2 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; sigma12 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu1 mu2 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu1 sq mu2 sq = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; f o r ( j = ( 0 + b o r d e r ) ; j < ( h e i g h t b o r d e r ) ; j ++){ mu1 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu1 mu2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu1 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; f o r ( i = ( 0 + b o r d e r ) ; i < ( w i d t h b o r d e r ) ; i ++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = 0; mu2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; / / Apply t h e c i r c u l a r s y m m e t r i c g a u s s i a n w e i g h t i n g f u n c t i o n on e a c h f o r ( n = ( 0 b o r d e r ) ; n < ( s i z e w i n d o w b o r d e r ) ; n++){ f o r (m = ( 0 b o r d e r ) ; m < ( s i z e w i n d o w b o r d e r ) ; m++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( o r i g i n a l [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; mu2 [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( d i s t o r t e d [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 1 i m g 2 [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 1 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 2 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; } }

pixel

/ / SSIM ( x , y ) = [ l ( x , y ) ] [ c ( x , y ) ] [ s ( x , y ) ] // // where // // l ( x , y ) i s the luminance comparison // l ( x , y ) = ( 2 mu x mu y + C1 ) / ( mu x 2 + mu y 2 + C1 ) // // c ( x , y ) i s the c o n t r a s t comparison // c ( x , y ) = ( 2 s i g m a x s i g m a y + C2 ) / ( s i g m a x 2 + s i g m a y 2 + C2 ) // // s ( x , y ) i s the s t r u c t u r e comparison // s ( x , y ) = ( s i g m a x y + C3 ) / ( s i g m a x s i g m a y + C3 ) //

137
/ / SSIM ( x , y ) = [ ( 2 mu x mu y + C1 ) ( 2 s i g m a x s i g m a y + C2 ) ] / // [ ( mu x 2 + mu y 2 + C1 ) ( s i g m a x 2 + s i g m a y 2 + C2 ) ] // mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; mu1 sq [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu1 [ j b o r d e r ] [ i b o r d e r ] ; mu2 sq [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) ; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] mu1 sq [ j b o r d e r ] [ i b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] mu2 sq [ j b o r d e r ] [ i b o r d e r ] ) ; n u m e r a t o r 1 = ( ( 2 mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) + C1 ) ; n u m e r a t o r 2 = ( ( 2 s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] ) + C2 ) ; d e n o m i n a t o r 1 = ( mu1 sq [ j b o r d e r ] [ i b o r d e r ] + mu2 sq [ j b o r d e r ] [ i b o r d e r ] + C1 ) ; d e n o m i n a t o r 2 = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + C2 ) ; ssim map = ( n u m e r a t o r 1 n u m e r a t o r 2 ) / ( d e n o m i n a t o r 1 d e n o m i n a t o r 2 ) ; r e s u l t = r e s u l t + ( f l o a t ) ssim map ; } } / / A mean SSIM i n d e x ( MSSIM ) i s u s e d t o e v a l u a t e t h e o v e r a l l image q u a l i t y // / / MSSIM(X , Y) = ( 1 /M)SUM( SSIM ( x , y ) ) // r e s u l t = r e s u l t / ( ( ( h e i g h t s i z e w i n d o w ) + 1 ) ( ( width s i z e w i n d o w ) + 1 ) ) ; // Calculate the r a t i o ratio = (( float ) result ) / quality ; i f ( f i r s t t i m e ){ smallest ratio = ratio ; first time = false ; } else { if ( ratio < smallest ratio ) smallest ratio = ratio ; } / / F r e e t h e memory f o r ( j = 0 ; j < h e i g h t ; j ++){ delete [ ] o r i g i n a l [ j ] ; delete [ ] d i s t o r t e d [ j ] ; delete [ ] img1 img2 [ j ] ; delete [ ] img1 sq [ j ] ; delete [ ] img2 sq [ j ] ; i f ( ( j > (0 + border 1)) && ( j < ( height border ) ) ) { d e l e t e [ ] mu1 mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 [ j b o r d e r ] ; d e l e t e [ ] mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 sq [ j b o r d e r ] ; d e l e t e [ ] mu2 sq [ j b o r d e r ] ; d e l e t e [ ] s i g m a 1 2 [ j b o r d e r ] ; d e l e t e [ ] s i g m a 1 s q [ j b o r d e r ] ; d e l e t e [ ] s i g m a 2 s q [ j b o r d e r ] ; } } delete [ ] img1 img2 ; delete [ ] img1 sq ; delete [ ] img2 sq ; d e l e t e [ ] mu1 mu2 ; d e l e t e [ ] mu1 ; d e l e t e [ ] mu2 ; d e l e t e [ ] mu1 sq ; d e l e t e [ ] mu2 sq ; delete [ ] sigma12 ; delete [ ] sigma1 sq ; delete [ ] sigma2 sq ; delete [ ] o r i g i n a l ; delete [ ] d i s t o r t e d ; i m g 1 i m g 2 = NULL ; img1 sq = NULL ; = NULL ; img2 sq mu1 mu2 = NULL ; mu1 = NULL ; mu2 = NULL ; mu1 sq = NULL ; mu2 sq = NULL ; sigma12 = NULL ; s i g m a 1 s q = NULL ; s i g m a 2 s q = NULL ; original = NULL ; d i s t o r t e d = NULL ; / / WARNING / / One o f t h e o b j e c t i v e s i s n o t met , jump t o t h e n e x t // o p t i m i z a t i o n to save s i m u l a t i o n time i f ( ( ( 1 s m a l l e s t r a t i o ) > SARGE FLAG1 ) | | ( m a x t h r e s h o l d > SARGE FLAG2 ) )

138
break ; } / / WARNING // Encountered a n e g a t i v e i f (SARGE FLAG0 == 1) { smallest ratio = 0; = 0; SARGE FLAG0 }

pixel

in

the

fixed

filter

result

p u t e r r o r ( IRATIO ,1 s m a l l e s t r a t i o ) ; p u t e r r o r ( MAX , m a x t h r e s h o l d ) ; }

E.2 Code source pour simuler les ltres num eriques avec param` etres

E.2.1 Fichier Xparam.c


/ / // Title : N u m e r i c a l image f i l t e r w i t h p a r a m e t e r s // Project : Video P r o c e s s i n g V a l i d a t i o n Environment / / // File : Xparam . c / / Author : S e r g e CATUDAL // Created : 18/05/2004 // Last modified : 0 2 / 0 6 / 2 0 0 4 / / // Description : / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 18/05/2004 : created / / / / Parameter o p t i m i z a t i o n // Architecture // Constant definition definition

optimization

definitions

/ / C/C++ i n c l u s i o n s #include < s t d i o . h> #include < s t d l i b . h> #include < i o s t r e a m . h> #include < f s t r e a m . h> #include < math . h> / / SynapC i n c l u s i o n s #include < g F i x . h> #include < X p u b l i c . h> // Global e x t e r n a l v a r i a b l e extern i n t LAST CHECK ; declaration

/ / Hybrid F i l t e r f u n c t i o n int compute param nf ( int img in ,

int

img height ,

int img width ) ;

/ / SynapC f u n c t i o n void p u t i m a g e ( i n t img num , i n t i m g s r c , i n t i m g f i l t e r e d , f l o a t n o i s y q u a l i t y , int img height , int img width ) ; / / SynapC main f u n c t i o n void XSmain ( ) { int i m g s r c ; int i m g n o i s y ; int i m g f i l t e r e d ; int img height , img width ; int img num = 0 ; int row , c o l ; int the int ; float t he f l o a t ; float the height , the width ; float the noisy quality ; while ( ( g e t i n p u t (& t h e n o i s y q u a l i t y ) = = 1 ) & & ( g e t i n p u t (& t h e h e i g h t ) == 1) &&

139
( g e t i n p u t (& t h e w i d t h ) = = 1 ) ) { / / Get image s i z e img height = ( int ) t h e h e i g h t ; img width = ( int ) the width ; / / I n i t i a l i z e t h e o r i g i n a l and n o i s y image img src = new i n t [ i m g h e i g h t ] ; i m g n o i s y = new i n t [ i m g h e i g h t ] ; f o r ( row = 0 ; row<i m g h e i g h t ; row++){ = new i n t [ i m g w i d t h ] ; i m g s r c [ row ] i m g n o i s y [ row ] = new i n t [ i m g w i d t h ] ; } / / Get t h e o r i g i n a l image f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ i f ( g e t i n p u t (& t h e f l o a t ) = = 1 ) i m g s r c [ row ] [ c o l ] = ( i n t ) t h e f l o a t ; else f p r i n t f ( s t d e r r , O r i g i n a l image i s wrong } }

s i z e . \ n ) ;

/ / Get t h e n o i s y image f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ i f ( g e t i n p u t (& t h e f l o a t ) = = 1 ) i m g n o i s y [ row ] [ c o l ] = ( i n t ) t h e f l o a t ; else f p r i n t f ( s t d e r r , N o i s y image i s wrong s i z e . \ n ) ; } } / / E x e c u t e t h e image f i l t e r i m g f i l t e r e d = compute param nf ( i m g n o i s y , i m g h e i g h t , img width ) ; / / Save t h e r e s u l t p u t i m a g e ( img num , i m g s r c , i m g f i l t e r e d , t h e n o i s y q u a l i t y , i m g h e i g h t , i m g w i d t h ) ; img num++; / / F r e e t h e memory f o r ( row = 0 ; row<i m g h e i g h t ; row++){ d e l e t e [ ] i m g s r c [ row ] ; d e l e t e [ ] i m g n o i s y [ row ] ; d e l e t e [ ] i m g f i l t e r e d [ row ] ; } delete [ ] i m g s r c ; delete [ ] img noisy ; delete [ ] i m g f i l t e r e d ; img src = NULL ; = NULL ; img noisy i m g f i l t e r e d = NULL ; } } / / // Numerical F i l t e r with Parameters Functions / / / / Comput t h e Hybrid f i l t e r int compute param nf ( int img in , int i m g h e i g h t , int img width ){ // Numerical } / / / / SynapC F u n c t i o n / / / / Save t h e d a t a f o r t h e X e r r o r a l g o r i t h m void p u t i m a g e ( i n t img num , i n t i m g s r c , i n t i m g f i l t e r e d , f l o a t n o i s y q u a l i t y , int img height , int img width ){ int row , c o l ; int itr ; char ctmp = new char [ 1 0 ] ; char f i l e n a m e = new char [ 3 0 ] ; char h e a d e r t m p = new char [ 2 0 ] ; o f s t r e a m WriteBIN ; / / Save t h e n o i s y q u a l i t y putoutput ( n o i s y q u a l i t y ) ; / / Save t h e image s i z e putoutput ( ( f l o a t ) img height ) ; putoutput ( ( f l o a t ) img width ) ; Filter Algorithm with parameters code here

return i m g o u t ;

140
i f (LAST CHECK == 1) { / / C r e a t e raw PGM image f i l e h e a d e r s t r c a t ( h e a d e r t m p , P5 \ n ) ; s p r i n t f ( ctmp , %d , i m g h e i g h t ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( header tmp , ) ; s p r i n t f ( ctmp , %d , i m g w i d t h ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( h e a d e r t m p , \ n255 \ n ) ; // Create filename strcat ( filename , i m g f i l t e r f i x e d ) ; s p r i n t f ( ctmp , %d , img num ) ; s t r c a t ( f i l e n a m e , ctmp ) ; s t r c a t ( f i l e n a m e , . pgm ) ; / / Write raw PGM image f i l e WriteBIN . open ( f i l e n a m e , i o s : : b i n a r y ) ; WriteBIN . s e e k p ( 0 , i o s : : beg ) ; / / Write h e a d e r f o r ( i t r = 0 ; i t r < s t r l e n ( h e a d e r t m p ) ; i t r ++) WriteBIN . w r i t e ( ( char ) & h e a d e r t m p [ i t r ] , s i z e o f ( char ) ) ; } / / Save t h e o r i g i n a l and t h e f i l t e r e d image ( i n t e r l a c e d p i x e l ) f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ p u t o u t p u t ( ( f l o a t ) i m g s r c [ row ] [ c o l ] ) ; p u t o u t p u t ( ( f l o a t ) i m g f i l t e r e d [ row ] [ c o l ] ) ; / / Write e a c h p i x e l s i n t o t h e raw PGM f i l e i f (LAST CHECK == 1) WriteBIN . w r i t e ( ( char ) & ( unsigned char ) i m g f i l t e r e d [ row ] [ c o l ] , s i z e o f ( unsigned char ) ) ; } } i f (LAST CHECK == 1) WriteBIN . c l o s e ( ) ; / / F r e e t h e memory d e l e t e [ ] ctmp ; delete [ ] f i l e n a m e ; delete [ ] header tmp ; ctmp = NULL ; filename = NULL ; h e a d e r t m p = NULL ; }

E.2.2 Fichier Xparam error.c


/ / // Title : S t r u c t u r a l S I M i l a r i t y I n d e x ( SSIM I n d e x ) // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t (VPVE) / / // File : Xparam error . c / / Author : Serge Catudal // Created : 18/05/2004 // Last modified : 2 6 / 0 5 / 2 0 0 4 / / // Description : O b j e c t i v e Image Q u a l i t y M e t r i c / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 18/05/2004 : created / / / / C/C++ i n c l u s i o n s #include < s t d i o . h> #include < s t d l i b . h> / / SynapC i n c l u s i o n s #include < X p u b l i c . h> // Size #d e f i n e o f image d a t a b a s e 5 size img db symmetric g a u s s i a n weighting function

// S i z e of the c i r c u l a r #d e f i n e s i z e w i n d o w 1 1 // Constants in

t h e SSIM i n d e x f o r m u l a

141
#d e f i n e K1 0 . 0 1 #d e f i n e K2 0 . 0 3 #d e f i n e L 255 // Global i n t e r n a l v a r i a b l e d e c l a r a t i o n float floating MSSIM array [ size img db ] ; // Global e x t e r n a l v a r i a b l e d e c l a r a t i o n extern i n t PAR OPT ; / / 1 = Parameter e s t i m a t i o n , 0 = Parameter e s t i m a t i o n + operands // Negative p i x e l detector (1 = negative p i x e l ) extern i n t SARGE FLAG0 ; / / C i r c u l a r symmetric g a u s s i a n w e i g h t i n g f u n c t i o n const double window [ s i z e w i n d o w ] [ s i z e w i n d o w ] = { {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0003,0.0020,0.0096,0.0291,0.0567,0.0708,0.0567,0.0291,0.0096,0.0020,0.0003}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000} }; / / SynapC e r r o r f u n c t i o n void X e r r o r ( ) { int border ; double C1 , C2 ; double d e n o m i n a t o r 1 , d e n o m i n a t o r 2 ; double l u m i n a n c e , m e a n l u m i n a n c e ; double n u m e r a t o r 1 , n u m e r a t o r 2 ; bool f i r s t t i m e = true ; int i,j; int m, n ; int c u r r e n t t h r e s h o l d , max threshold ; int i m g 1 i m g 2 , i m g 1 s q , i m g 2 s q ; double mu1 mu2 , mu1 , mu2 ; double mu1 sq , mu2 sq ; double s i g m a 1 2 , s i g m a 1 s q , s i g m a 2 s q ; double r e s u l t = 0 . 0 ; double ssim map ; int o r i g i n a l , d i s t o r t e d ; int h e i g h t , width ; float filtered floating ; float f l o a t i n g , f i x e d , q u a l i t y , tmp ; float the height , the width ; float the noisy quality ; float ratio , s m a l l e s t r a t i o , sum ratio , worst ratio ; float worst luminance ; int img ptr ; // Variable i n i t i a l i z a t i o n border = (( size window 1 ) / 2 ) ; img ptr = 0; = 0.0; mean luminance smallest ratio = 1.0; sum ratio = 0.0; worst luminance = 1 . 0 ; // Constants i n i t i a l i a z a t i o n C1 = ( K1 L ) ( K1 L ) ; C2 = ( K2 L ) ( K2 L ) ; / / MAX t h r e s h o l d i n i t i a l i z a t i o n max threshold = 0; while ( ( g e t o u t p u t (& f l o a t i n g ,& t h e n o i s y q u a l i t y ) == 1) && ( g e t o u t p u t (& f l o a t i n g ,& t h e h e i g h t ) = = 1 ) & & ( g e t o u t p u t (& f l o a t i n g ,& t h e w i d t h ) = = 1 ) ) { / / WARNING // Encountered a n e g a t i v e p i x e l i n the f i x e d f i l t e r r e s u l t i f (SARGE FLAG0 == 1) break ; / / Get image c h a r a c t e r i s t i c s height = ( int ) t h e h e i g h t ; width = ( int ) the width ; / / I n i t i a l i z e r e s u l t and mean l u m i n a n c e result = 0.0; mean luminance = 0 . 0 ; // Calculate the square f o r the original = new i n t [ h e i g h t ] ; d i s t o r t e d = new i n t [ h e i g h t ] ; o r i g i n a l and d i s t o r t e d image

142
i m g 1 i m g 2 = new i n t [ h e i g h t ] ; = new i n t [ h e i g h t ] ; img1 sq img2 sq = new i n t [ h e i g h t ] ; f o r ( j = 0 ; j < h e i g h t ; j ++){ original [ j ] = new i n t [ w i d t h ] ; d i s t o r t e d [ j ] = new i n t [ w i d t h ] ; i m g 1 i m g 2 [ j ] = new i n t [ w i d t h ] ; = new i n t [ w i d t h ] ; img1 sq [ j ] img2 sq [ j ] = new i n t [ w i d t h ] ; f o r ( i = 0 ; i < w i d t h ; i ++){ i f ( g e t o u t p u t (&tmp,& f l o a t i n g ) ! = 1 | | g e t o u t p u t (& f i l t e r e d f l o a t i n g ,& f i x e d ) ! = 1 ) { f p r i n t f ( s t d e r r , \ n \ t E r r o r \ n \ n \ t \ tThe s i z e o f t h e image i s i n c o r r e c t \ n ) ; exit (1); } original [ j ][ i ] = ( int ) f l o a t i n g ; d i s t o r t e d [ j ] [ i ] = ( int ) f i x e d ; img1 img2 [ j ] [ i ] = o r i g i n a l [ j ] [ i ] d i s t o r t e d [ j ] [ i ] ; = original [ j ][ i ] original [ j ][ i ]; img1 sq [ j ] [ i ] img2 sq [ j ] [ i ] = distorted [ j ] [ i ] distorted [ j ] [ i ] ; i f (PAR OPT == 0) { / / C a l c u l a t e MAX v a l u e c u r r e n t t h r e s h o l d = abs ( ( ( int ) f i l t e r e d f l o a t i n g ) d i s t o r t e d [ j ] [ i ] ) ; i f ( c u r r e n t t h r e s h o l d > max threshold ) max threshold = c u r r e n t t h r e s h o l d ; } } } / / Apply t h e 2D F i l t e r on t h e mean i n t e n s i t y and t h e v a r i a n c e mu1 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu2 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; sigma12 = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu1 mu2 mu1 sq = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; mu2 sq f o r ( j = ( 0 + b o r d e r ) ; j < ( h e i g h t b o r d e r ) ; j ++){ mu1 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu1 mu2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu1 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; f o r ( i = ( 0 + b o r d e r ) ; i < ( w i d t h b o r d e r ) ; i ++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = 0; mu2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; / / Apply t h e c i r c u l a r s y m m e t r i c g a u s s i a n w e i g h t i n g f u n c t i o n on e a c h f o r ( n = ( 0 b o r d e r ) ; n < ( s i z e w i n d o w b o r d e r ) ; n++){ f o r (m = ( 0 b o r d e r ) ; m < ( s i z e w i n d o w b o r d e r ) ; m++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( o r i g i n a l [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; mu2 [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( d i s t o r t e d [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 1 i m g 2 [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 1 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; ( ( double ) ( i m g 2 s q [ j+n ] [ i+ } }

pixel

/ / SSIM ( x , y ) = [ l ( x , y ) ] [ c ( x , y ) ] [ s ( x , y ) ] // // where // // l ( x , y ) i s the luminance comparison // l ( x , y ) = ( 2 mu x mu y + C1 ) / ( mu x 2 + mu y 2 + C1 ) // // c ( x , y ) i s the c o n t r a s t comparison // c ( x , y ) = ( 2 s i g m a x s i g m a y + C2 ) / ( s i g m a x 2 + s i g m a y 2 + C2 ) // // s ( x , y ) i s the s t r u c t u r e comparison // s ( x , y ) = ( s i g m a x y + C3 ) / ( s i g m a x s i g m a y + C3 )

143
// / / SSIM ( x , y ) = [ ( 2 mu x mu y + C1 ) ( 2 s i g m a x s i g m a y + C2 ) ] / // [ ( mu x 2 + mu y 2 + C1 ) ( s i g m a x 2 + s i g m a y 2 + C2 ) ] // mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; mu1 sq [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu1 [ j b o r d e r ] [ i b o r d e r ] ; mu2 sq [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) ; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] mu1 sq [ j b o r d e r ] [ i b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] mu2 sq [ j b o r d e r ] [ i b o r d e r ] ) ; n u m e r a t o r 1 = ( ( 2 mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) + C1 ) ; n u m e r a t o r 2 = ( ( 2 s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] ) + C2 ) ; d e n o m i n a t o r 1 = ( mu1 sq [ j b o r d e r ] [ i b o r d e r ] + mu2 sq [ j b o r d e r ] [ i b o r d e r ] + C1 ) ; d e n o m i n a t o r 2 = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + C2 ) ; ssim map = ( n u m e r a t o r 1 n u m e r a t o r 2 ) / ( d e n o m i n a t o r 1 d e n o m i n a t o r 2 ) ; r e s u l t = r e s u l t + ( f l o a t ) ssim map ; / / C a l c u l a t e t h e Luminance i f (PAR OPT == 0) { luminance = numerator1 / denominator1 ; mean luminance = mean luminance + luminance ; } } } / / A mean SSIM i n d e x ( MSSIM ) i s u s e d t o e v a l u a t e t h e o v e r a l l image q u a l i t y // / / MSSIM(X , Y) = ( 1 /M)SUM( SSIM ( x , y ) ) // r e s u l t = r e s u l t / ( ( ( h e i g h t s i z e w i n d o w ) + 1 ) ( ( width s i z e w i n d o w ) + 1 ) ) ; i f (PAR OPT == 0) { // Calculate the r a t i o r a t i o = (( float ) r e s u l t ) / floating MSSIM array [ img ptr ] ; i m g p t r ++; / / C a l c u l a t e t h e Mean Luminance mean luminance = mean luminance / ( ( ( h e i g h t s i z e w i n d o w ) + 1 ) ( ( width s i z e w i n d o w ) + 1 ) ) ; / / Find t h e s m a l l e s t r a t i o and w o r s t mean l u m i n a n c e i f ( f i r s t t i m e ){ smallest ratio = ratio ; w o r s t l u m i n a n c e = ( f l o a t ) mean luminance ; first time = false ; } else { if ( ratio < smallest ratio ) smallest ratio = ratio ; i f ( mean luminance < w o r s t l u m i n a n c e ) w o r s t l u m i n a n c e = ( f l o a t ) mean luminance ; } } else { / / C a l c u l a t e t h e sum o f a l l RATIO ratio = ( the noisy quality / result ); s u m r a t i o += r a t i o ; / / Save f l o a t i n g s i m u l a t i o n r e s u l t floating MSSIM array [ img ptr ] = ( ( float ) r e s u l t ) ; i m g p t r ++; / / Find t h e w o r s t r a t i o ( b i g g e s t ) i f ( f i r s t t i m e ){ worst ratio = ratio ; = false ; first time } else { if ( ratio > worst ratio ) worst ratio = ratio ; } } / / F r e e t h e memory f o r ( j = 0 ; j < h e i g h t ; j ++){ delete [ ] o r i g i n a l [ j ] ; delete [ ] d i s t o r t e d [ j ] ; delete [ ] img1 img2 [ j ] ; delete [ ] img1 sq [ j ] ; delete [ ] img2 sq [ j ] ; i f ( ( j > (0 + border 1)) && ( j < ( height border ) ) ) { d e l e t e [ ] mu1 mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 [ j b o r d e r ] ; d e l e t e [ ] mu2 [ j b o r d e r ] ;

144
delete delete delete delete delete [] [] [] [] [] mu1 sq [ j b o r d e r ] ; mu2 sq [ j b o r d e r ] ; s i g m a 1 2 [ j b o r d e r ] ; s i g m a 1 s q [ j b o r d e r ] ; s i g m a 2 s q [ j b o r d e r ] ;

} } delete [ ] img1 img2 ; delete [ ] img1 sq ; delete [ ] img2 sq ; d e l e t e [ ] mu1 mu2 ; d e l e t e [ ] mu1 ; d e l e t e [ ] mu2 ; d e l e t e [ ] mu1 sq ; d e l e t e [ ] mu2 sq ; delete [ ] sigma12 ; delete [ ] sigma1 sq ; delete [ ] sigma2 sq ; delete [ ] o r i g i n a l ; delete [ ] d i s t o r t e d ; i m g 1 i m g 2 = NULL ; = NULL ; img1 sq img2 sq = NULL ; = NULL ; mu1 mu2 mu1 = NULL ; mu2 = NULL ; mu1 sq = NULL ; = NULL ; mu2 sq sigma12 = NULL ; s i g m a 1 s q = NULL ; s i g m a 2 s q = NULL ; original = NULL ; d i s t o r t e d = NULL ; } / / WARNING // Encountered a n e g a t i v e i f (SARGE FLAG0 == 1) { smallest ratio = 0.0; SARGE FLAG0 = 0; }

pixel

in

the

fixed

filter

result

i f (PAR OPT == 0) { p u t e r r o r ( IRATIO , 1 s m a l l e s t r a t i o ) ; p u t e r r o r ( MAX PT , m a x t h r e s h o l d ) ; p u t e r r o r ( ILUMA , 1 w o r s t l u m i n a n c e ) ; } else { p u t e r r o r ( IRATIO , ( s u m r a t i o / i m g p t r ) ) ; p u t e r r o r ( MAX PT , w o r s t r a t i o ) ; p u t e r r o r ( ILUMA , 1 ) ; } }

E.3 Code source pour simuler les s equences vid eo

E.3.1 Fichier Xvideo.c


/ / // Title : Modele C/C++ de l a l g o r i t h m c o n e t a n t une s e q u e n c e v i d e o // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : Xvideo . c / / Author : S e r g e CATUDAL // Created : 04/01/2005 // Last modified : 1 0 / 0 1 / 2 0 0 5 / / // Description : / / / / C o p y r i g h t ( c ) 2 0 0 5 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 04/01/2005 : created / / / / Parameter o p t i m i z a t i o n definition

145
// Architecture // Constant optimization definition

definitions

/ / C/C++ i n c l u s i o n s #include < s t d i o . h> #include < s t d l i b . h> #include < i o s t r e a m . h> #include < f s t r e a m . h> #include < math . h> / / SynapC i n c l u s i o n s #include < g F i x . h> #include < X p u b l i c . h> // Global e x t e r n a l v a r i a b l e extern i n t LAST CHECK ; declaration

/ / Video f u n c t i o n int compute video ( int img in , int

img height , int img width , int

cur field );

/ / SynapC f u n c t i o n void p u t i m a g e ( i n t img num , i n t i m g s r c , i n t i m g d e i n t e r l a c e d , int img height , int img width ) ; / / SynapC main f u n c t i o n void XSmain ( ) { int cur field ; int first field ; int nb field ; int i m g s e q ; int i m g s r c ; int i m g d e i n t e r l a c e d ; int img height , img width ; int img num = 0 ; int row , c o l ; int the int ; float t he f l o a t ; float the height , the width , t h e n b f i e l d , t h e f i r s t f i e l d ; while ( ( g e t i n p u t (& t h e h e i g h t ) = = 1 ) & & ( g e t i n p u t (& t h e w i d t h ) == 1) && ( g e t i n p u t (& t h e n b f i e l d ) = = 1 ) & & ( g e t i n p u t (& t h e f i r s t f i e l d ) = = 1 ) ) { / / Get image s i z e img height = ( int ) t h e h e i g h t ; img width = ( int ) the width ; / / Get s e q u e n c e number o f f i e l d ( s ) and nb field = ( int ) t h e n b f i e l d ; f i r s t f i e l d = ( int ) t h e f i r s t f i e l d ; first field

/ / I n i t i a l i z e and g e t t h e o r i g i n a l f r a m e i m g s r c = new i n t [ i m g h e i g h t ] ; f o r ( row = 0 ; row<i m g h e i g h t ; row++){ i m g s r c [ row ] = new i n t [ i m g w i d t h ] ; f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ i f ( g e t i n p u t (& t h e f l o a t ) = = 1 ) i m g s r c [ row ] [ c o l ] = ( i n t ) t h e f l o a t ; else f p r i n t f ( s t d e r r , O r i g i n a l f r a m e i s wrong } }

s i z e . \ n ) ;

/ / I n i t i a l i z e and g e t t h e image s e q u e n c e img height = img height / 2 ; img seq = new i n t [ n b f i e l d ] ; f o r ( c u r f i e l d = 0 ; c u r f i e l d < n b f i e l d ; c u r f i e l d ++){ i m g s e q [ c u r f i e l d ] = new i n t [ i m g h e i g h t ] ; f o r ( row = 0 ; row< i m g h e i g h t ; row++){ i m g s e q [ c u r f i e l d ] [ row ] = new i n t [ i m g w i d t h ] ; f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ i f ( g e t i n p u t (& t h e f l o a t ) = = 1 ) i m g s e q [ c u r f i e l d ] [ row ] [ c o l ] = ( i n t ) t h e f l o a t ; else f p r i n t f ( s t d e r r , Image s e q u e n c e i s wrong s i z e . \ n ) ; } } } / / E x e c u t e t h e image d e i n t e r l a c e r i m g d e i n t e r l a c e d = c o m p u t e m o t i o n d e i n t e r l a c e r ( img seq , img height , img width , f i r s t f i e l d ) ; / / Save t h e r e s u l t img height = img height 2 ; p u t i m a g e ( img num , i m g s r c , i m g d e i n t e r l a c e d , i m g h e i g h t , i m g w i d t h ) ; img num++;

146
/ / F r e e t h e memory f o r ( row = 0 ; row<i m g h e i g h t ; row++){ d e l e t e [ ] i m g s r c [ row ] ; d e l e t e [ ] i m g d e i n t e r l a c e d [ row ] ; } img height = img height / 2 ; f o r ( c u r f i e l d = 0 ; c u r f i e l d < n b f i e l d ; c u r f i e l d ++){ f o r ( row = 0 ; row< i m g h e i g h t ; row++) d e l e t e [ ] i m g s e q [ c u r f i e l d ] [ row ] ; delete [ ] img seq [ c u r f i e l d ] ; } delete [ ] i m g s r c ; delete [ ] i m g d e i n t e r l a c e d ; delete [ ] img seq ; img src = NULL ; i m g d e i n t e r l a c e d = NULL ; img seq = NULL ; } } / / / / Video A l g o r i t h m F u n c t i o n s / / / / Compute t h e Video A l g o r i t h m int compute video ( int img in , int img height , int img width , int c u r f i e l d ){ / / Video A l g o r i t h m c o d e h e r e return i m g o u t ; } / / / / SynapC F u n c t i o n / / / / Save t h e d a t a f o r t h e X e r r o r a l g o r i t h m void p u t i m a g e ( i n t img num , i n t i m g s r c , i n t i m g d e i n t e r l a c e d , int img height , int img width ){ int row , c o l ; int itr ; char ctmp = new char [ 1 0 ] ; char f i l e n a m e = new char [ 3 0 ] ; = new char [ 2 0 ] ; char h e a d e r t m p o f s t r e a m WriteBIN ; / / Save t h e image s i z e putoutput ( ( f l o a t ) img height ) ; putoutput ( ( f l o a t ) img width ) ; i f (LAST CHECK == 1) { / / C r e a t e raw PGM image f i l e h e a d e r s t r c a t ( h e a d e r t m p , P5 \ n ) ; s p r i n t f ( ctmp , %d , i m g w i d t h ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( header tmp , ) ; s p r i n t f ( ctmp , %d , i m g h e i g h t ) ; s t r c a t ( h e a d e r t m p , ctmp ) ; s t r c a t ( h e a d e r t m p , \ n255 \ n ) ; // Create filename strcat ( filename , img deint fixed ) ; s p r i n t f ( ctmp , %d , img num ) ; s t r c a t ( f i l e n a m e , ctmp ) ; s t r c a t ( f i l e n a m e , . pgm ) ; / / Write raw PGM image f i l e WriteBIN . open ( f i l e n a m e , i o s : : b i n a r y ) ; WriteBIN . s e e k p ( 0 , i o s : : beg ) ; / / Write h e a d e r f o r ( i t r = 0 ; i t r < s t r l e n ( h e a d e r t m p ) ; i t r ++) WriteBIN . w r i t e ( ( char ) & h e a d e r t m p [ i t r ] , s i z e o f ( char ) ) ; } / / Save t h e o r i g i n a l and t h e f i l t e r e d image ( i n t e r l a c e d p i x e l ) f o r ( row = 0 ; row<i m g h e i g h t ; row++){ f o r ( c o l = 0 ; c o l <i m g w i d t h ; c o l ++){ p u t o u t p u t ( ( f l o a t ) i m g s r c [ row ] [ c o l ] ) ; p u t o u t p u t ( ( f l o a t ) i m g d e i n t e r l a c e d [ row ] [ c o l ] ) ; / / Write e a c h p i x e l s i n t o t h e raw PGM f i l e i f (LAST CHECK == 1) WriteBIN . w r i t e ( ( char ) & ( unsigned char ) i m g d e i n t e r l a c e d [ row ] [ c o l ] , s i z e o f ( unsigned char ) ) ; } } i f (LAST CHECK == 1) WriteBIN . c l o s e ( ) ;

147

/ / F r e e t h e memory d e l e t e [ ] ctmp ; delete [ ] f i l e n a m e ; delete [ ] header tmp ; ctmp = NULL ; filename = NULL ; h e a d e r t m p = NULL ; }

E.3.2 Fichier Xvideo error.c


/ / // Title : S t r u c t u r a l S I M i l a r i t y I n d e x ( SSIM I n d e x ) // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t (VPVE) / / // File : Xvideo error . c / / Author : Serge Catudal // Created : 04/01/2005 // Last modified : 0 4 / 0 1 / 2 0 0 5 / / // Description : O b j e c t i v e Image Q u a l i t y M e t r i c / / / / C o p y r i g h t ( c ) 2 0 0 5 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 04/01/2005 : created / / / / C/C++ i n c l u s i o n s #include < s t d i o . h> #include < s t d l i b . h> / / SynapC i n c l u s i o n s #include < X p u b l i c . h> // Size #d e f i n e o f image d a t a b a s e 5 size img db symmetric g a u s s i a n weighting function

// S i z e of the c i r c u l a r #d e f i n e s i z e w i n d o w 1 1

/ / C o n s t a n t s i n t h e SSIM i n d e x f o r m u l a #d e f i n e K1 0 . 0 1 #d e f i n e K2 0 . 0 3 #d e f i n e L 255 // Global i n t e r n a l v a r i a b l e d e c l a r a t i o n float floating MSSIM array [ size img db ] ; // Global e x t e r n a l v a r i a b l e d e c l a r a t i o n extern i n t PAR OPT ; / / 1 = P a r a m e t e r e s t i m a t i o n , 0 = Param e s t i m a t i o n + o p s o p t i m i z a t i o n extern i n t SARGE FLAG0 ; // Negative p i x e l detector (1 = negative p i x e l ) / / C i r c u l a r symmetric g a u s s i a n w e i g h t i n g f u n c t i o n const double window [ s i z e w i n d o w ] [ s i z e w i n d o w ] = { {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0003,0.0020,0.0096,0.0291,0.0567,0.0708,0.0567,0.0291,0.0096,0.0020,0.0003}, {0.0002,0.0016,0.0077,0.0233,0.0454,0.0567,0.0454,0.0233,0.0077,0.0016,0.0002}, {0.0001,0.0008,0.0039,0.0120,0.0233,0.0291,0.0233,0.0120,0.0039,0.0008,0.0001}, {0.0000,0.0003,0.0013,0.0039,0.0077,0.0096,0.0077,0.0039,0.0013,0.0003,0.0000}, {0.0000,0.0001,0.0003,0.0008,0.0016,0.0020,0.0016,0.0008,0.0003,0.0001,0.0000}, {0.0000,0.0000,0.0000,0.0001,0.0002,0.0003,0.0002,0.0001,0.0000,0.0000,0.0000} }; / / SynapC e r r o r f u n c t i o n void X e r r o r ( ) { int border ; double C1 , C2 ; double d e n o m i n a t o r 1 , d e n o m i n a t o r 2 ; double l u m i n a n c e , m e a n l u m i n a n c e ; double n u m e r a t o r 1 , n u m e r a t o r 2 ; bool f i r s t t i m e = true ; int i,j; int m, n ; int c u r r e n t t h r e s h o l d , max threshold ; int i m g 1 i m g 2 , i m g 1 s q , i m g 2 s q ;

148
double double double double double int int float float float float float int mu1 mu2 , mu1 , mu2 ; mu1 sq , mu2 sq ; sigma12 , sigma1 sq , sigma2 sq ; result = 0.0; ssim map ; o r i g i n a l , d i s t o r t e d ; h e i g h t , width ; filtered floating ; f l o a t i n g , f i x e d , q u a l i t y , tmp ; the height , the width ; the noisy quality ; r a t i o , s m a l l e s t r a t i o , sum quality , img ptr ;

worst quality ;

// Variable i n i t i a l i z a t i o n border = (( size window 1 ) / 2 ) ; img ptr = 0; mean luminance = 0 . 0 ; smallest ratio = 1.0; sum quality = 0.0; worst quality = 1.0; // Constants i n i t i a l i a z a t i o n C1 = ( K1 L ) ( K1 L ) ; C2 = ( K2 L ) ( K2 L ) ; / / MAX t h r e s h o l d i n i t i a l i z a t i o n max threshold = 0; while ( ( g e t o u t p u t (& f l o a t i n g ,& t h e h e i g h t ) = = 1 ) & & ( g e t o u t p u t (& f l o a t i n g ,& t h e w i d t h ) = = 1 ) ) { / / WARNING // Encountered a n e g a t i v e p i x e l i n the f i x e d f i l t e r r e s u l t i f (SARGE FLAG0 == 1) break ; / / f i r s t t i m e v a r i a b l e r e i n i t i a l i z a t i o n i f (PAR OPT == 0 && ! f i r s t t i m e ) f i r s t t i m e = true ; / / Get image c h a r a c t e r i s t i c s height = ( int ) t h e h e i g h t ; width = ( int ) the width ; // I n i t i a l i z e result = 0.0; result

/ / C a l c u l a t e t h e s q u a r e f o r t h e o r i g i n a l and d i s t o r t e d image original = new i n t [ h e i g h t ] ; d i s t o r t e d = new i n t [ h e i g h t ] ; i m g 1 i m g 2 = new i n t [ h e i g h t ] ; = new i n t [ h e i g h t ] ; img1 sq img2 sq = new i n t [ h e i g h t ] ; f o r ( j = 0 ; j < h e i g h t ; j ++){ original [ j ] = new i n t [ w i d t h ] ; d i s t o r t e d [ j ] = new i n t [ w i d t h ] ; i m g 1 i m g 2 [ j ] = new i n t [ w i d t h ] ; = new i n t [ w i d t h ] ; img1 sq [ j ] img2 sq [ j ] = new i n t [ w i d t h ] ; f o r ( i = 0 ; i < w i d t h ; i ++){ i f ( g e t o u t p u t (&tmp,& f l o a t i n g ) ! = 1 | | g e t o u t p u t (& f i l t e r e d f l o a t i n g ,& f i x e d ) ! = 1 ) { f p r i n t f ( s t d e r r , \ n \ t E r r o r \ n \ n \ t \ tThe s i z e o f t h e image i s i n c o r r e c t \ n ) ; exit (1); } original [ j ][ i ] = ( int ) f l o a t i n g ; d i s t o r t e d [ j ] [ i ] = ( int ) f i x e d ; img1 img2 [ j ] [ i ] = o r i g i n a l [ j ] [ i ] d i s t o r t e d [ j ] [ i ] ; img1 sq [ j ] [ i ] = original [ j ][ i ] original [ j ][ i ]; img2 sq [ j ] [ i ] = distorted [ j ] [ i ] distorted [ j ] [ i ] ; i f (PAR OPT == 0) { / / C a l c u l a t e MAX v a l u e c u r r e n t t h r e s h o l d = abs ( ( ( int ) f i l t e r e d f l o a t i n g ) d i s t o r t e d [ j ] [ i ] ) ; i f ( c u r r e n t t h r e s h o l d > max threshold ) max threshold = c u r r e n t t h r e s h o l d ; } } } / / Apply t h e 2D mu1 = new mu2 = new sigma12 = new s i g m a 1 s q = new s i g m a 2 s q = new mu1 mu2 = new mu1 sq = new F i l t e r on t h e mean i n t e n s i t y and double [ ( h e i g h t s i z e w i n d o w ) + double [ ( h e i g h t s i z e w i n d o w ) + double [ ( h e i g h t s i z e w i n d o w ) + double [ ( h e i g h t s i z e w i n d o w ) + double [ ( h e i g h t s i z e w i n d o w ) + double [ ( h e i g h t s i z e w i n d o w ) + double [ ( h e i g h t s i z e w i n d o w ) + the 1]; 1]; 1]; 1]; 1]; 1]; 1]; variance

149
mu2 sq = new double [ ( h e i g h t s i z e w i n d o w ) + 1 ] ; f o r ( j = ( 0 + b o r d e r ) ; j < ( h e i g h t b o r d e r ) ; j ++){ mu1 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 2 [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 1 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; s i g m a 2 s q [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu1 mu2 [ j b o r d e r ] mu1 sq [ j b o r d e r ] = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; = new double [ ( w i d t h s i z e w i n d o w ) + 1 ] ; mu2 sq [ j b o r d e r ] f o r ( i = ( 0 + b o r d e r ) ; i < ( w i d t h b o r d e r ) ; i ++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = 0; mu2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = 0; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = 0 ; / / Apply t h e c i r c u l a r s y m m e t r i c g a u s s i a n w e i g h t i n g f u n c t i o n on e a c h f o r ( n = ( 0 b o r d e r ) ; n < ( s i z e w i n d o w b o r d e r ) ; n++){ f o r (m = ( 0 b o r d e r ) ; m < ( s i z e w i n d o w b o r d e r ) ; m++){ mu1 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( o r i g i n a l [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; mu2 [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( d i s t o r t e d [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] + m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; ( ( double ) ( i m g 1 i m g 2 [ j+n ] [ i+ s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 1 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + ( ( double ) ( i m g 2 s q [ j+n ] [ i+ m] ) window [ n+b o r d e r ] [ m +b o r d e r ] ) ; } }

pixel

/ / SSIM ( x , y ) = [ l ( x , y ) ] [ c ( x , y ) ] [ s ( x , y ) ] // // where // // l ( x , y ) i s the luminance comparison // l ( x , y ) = ( 2 mu x mu y + C1 ) / ( mu x 2 + mu y 2 + C1 ) // // c ( x , y ) i s the c o n t r a s t comparison // c ( x , y ) = ( 2 s i g m a x s i g m a y + C2 ) / ( s i g m a x 2 + s i g m a y 2 + C2 ) // // s ( x , y ) i s the s t r u c t u r e comparison // s ( x , y ) = ( s i g m a x y + C3 ) / ( s i g m a x s i g m a y + C3 ) // / / SSIM ( x , y ) = [ ( 2 mu x mu y + C1 ) ( 2 s i g m a x s i g m a y + C2 ) ] / // [ ( mu x 2 + mu y 2 + C1 ) ( s i g m a x 2 + s i g m a y 2 + C2 ) ] // mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; mu1 sq [ j b o r d e r ] [ i b o r d e r ] = mu1 [ j b o r d e r ] [ i b o r d e r ] mu1 [ j b o r d e r ] [ i b o r d e r ] ; mu2 sq [ j b o r d e r ] [ i b o r d e r ] = mu2 [ j b o r d e r ] [ i b o r d e r ] mu2 [ j b o r d e r ] [ i b o r d e r ] ; s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) ; s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] mu1 sq [ j b o r d e r ] [ i b o r d e r ] ) ; s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] = ( s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] mu2 sq [ j b o r d e r ] [ i b o r d e r ] ) ; n u m e r a t o r 1 = ( ( 2 mu1 mu2 [ j b o r d e r ] [ i b o r d e r ] ) + C1 ) ; n u m e r a t o r 2 = ( ( 2 s i g m a 1 2 [ j b o r d e r ] [ i b o r d e r ] ) + C2 ) ; d e n o m i n a t o r 1 = ( mu1 sq [ j b o r d e r ] [ i b o r d e r ] + mu2 sq [ j b o r d e r ] [ i b o r d e r ] + C1 ) ; d e n o m i n a t o r 2 = ( s i g m a 1 s q [ j b o r d e r ] [ i b o r d e r ] + s i g m a 2 s q [ j b o r d e r ] [ i b o r d e r ] + C2 ) ; ssim map = ( n u m e r a t o r 1 n u m e r a t o r 2 ) / ( d e n o m i n a t o r 1 d e n o m i n a t o r 2 ) ; r e s u l t = r e s u l t + ( f l o a t ) ssim map ; / / C a l c u l a t e t h e Luminance i f (PAR OPT == 0) { luminance = numerator1 / denominator1 ; mean luminance = mean luminance + luminance ; } } } / / A mean SSIM i n d e x ( MSSIM ) i s u s e d t o e v a l u a t e t h e o v e r a l l image q u a l i t y // / / MSSIM(X , Y) = ( 1 /M)SUM( SSIM ( x , y ) ) // r e s u l t = r e s u l t / ( ( ( h e i g h t s i z e w i n d o w ) + 1 ) ( ( width s i z e w i n d o w ) + 1 ) ) ; i f (PAR OPT = = 0 ) { / / Operand + P a r a m e t e r O p t i m i z a t i o n // Calculate the r a t i o r a t i o = (( float ) r e s u l t ) / floating MSSIM array [ img ptr ] ;

150
i m g p t r ++; i f ( f i r s t t i m e ){ smallest ratio = ratio ; first time = false ; } else { if ( ratio < smallest ratio ) smallest ratio = ratio ; } / / C a l c u l a t e t h e Mean Luminance mean luminance = mean luminance / ( ( ( h e i g h t s i z e w i n d o w ) + 1 ) ( ( width s i z e w i n d o w ) + 1 ) ) ; } else { / / Parameter Optimization / / C a l c u l a t e t h e sum o f a l l image q u a l i t y s u m q u a l i t y += r e s u l t ; / / Save f l o a t i n g s i m u l a t i o n r e s u l t floating MSSIM array [ img ptr ] = ( ( float ) r e s u l t ) ; i m g p t r ++; / / Find t h e w o r s t image q u a l i t y i f ( f i r s t t i m e ){ worst quality = result ; = false ; first time } else { if ( result < worst quality ) worst quality = result ; } } / / F r e e t h e memory f o r ( j = 0 ; j < h e i g h t ; j ++){ delete [ ] o r i g i n a l [ j ] ; delete [ ] d i s t o r t e d [ j ] ; delete [ ] img1 img2 [ j ] ; delete [ ] img1 sq [ j ] ; delete [ ] img2 sq [ j ] ; i f ( ( j > (0 + border 1)) && ( j < ( height border ) ) ) { d e l e t e [ ] mu1 mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 [ j b o r d e r ] ; d e l e t e [ ] mu2 [ j b o r d e r ] ; d e l e t e [ ] mu1 sq [ j b o r d e r ] ; d e l e t e [ ] mu2 sq [ j b o r d e r ] ; d e l e t e [ ] s i g m a 1 2 [ j b o r d e r ] ; d e l e t e [ ] s i g m a 1 s q [ j b o r d e r ] ; d e l e t e [ ] s i g m a 2 s q [ j b o r d e r ] ; } } delete [ ] img1 img2 ; delete [ ] img1 sq ; delete [ ] img2 sq ; d e l e t e [ ] mu1 mu2 ; d e l e t e [ ] mu1 ; d e l e t e [ ] mu2 ; d e l e t e [ ] mu1 sq ; d e l e t e [ ] mu2 sq ; delete [ ] sigma12 ; delete [ ] sigma1 sq ; delete [ ] sigma2 sq ; delete [ ] o r i g i n a l ; delete [ ] d i s t o r t e d ; i m g 1 i m g 2 = NULL ; img1 sq = NULL ; img2 sq = NULL ; mu1 mu2 = NULL ; mu1 = NULL ; mu2 = NULL ; mu1 sq = NULL ; = NULL ; mu2 sq sigma12 = NULL ; s i g m a 1 s q = NULL ; s i g m a 2 s q = NULL ; original = NULL ; d i s t o r t e d = NULL ; } / / WARNING // Encountered a n e g a t i v e i f (SARGE FLAG0 == 1) { smallest ratio = 0.0; SARGE FLAG0 = 0; } pixel in the fixed filter result

i f (PAR OPT == 0) { p u t e r r o r ( IRATIO , 1 s m a l l e s t r a t i o ) ; p u t e r r o r ( MAX PT , m a x t h r e s h o l d ) ;

151
p u t e r r o r ( ILUMA , 1 m e a n l u m i n a n c e ) ; } else { p u t e r r o r ( IRATIO , 1 ( s u m q u a l i t y / i m g p t r ) ) ; p u t e r r o r ( MAX PT , 1 w o r s t q u a l i t y ) ; p u t e r r o r ( ILUMA , 1 ) ; } }

152 ANNEXE F

ALGORITHME DE DE-ENTRELACEMENT

F.1 Code source de lalgorithme de d e-entrelacement adapatatif au mouvement

F.1.1 Fichier motion.h


/ / // Title : Motion A d a p t i v e De i n t e r l a c i n g // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : motion adaptive . h / / Author : S e r g e CATUDAL // Created : 30/11/2004 // Last modified : 3 0 / 1 1 / 2 0 0 4 / / // Description : Motion A d a p t i v e a l g o r i t h m t o d e i n t e r l a c e image / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 30/11/2004 : created / / #i f n d e f #d e f i n e MOTION ADAPTIVE HEADER MOTION ADAPTIVE HEADER

/ / VPVE i n c l u s i o n s #include < i m a g e d e i n t e r l a c e r . h> / /

@ingroup d e i n t p a c k @ b r i e f T h i s c l a s s i s t h e Motion A d a p t i v e De i n t e r l a c e r @author S e r g e C a t u d a l @version 1 . 0 @date 3 0 / 1 1 / 2 0 0 4

c l a s s m o t i o n a d a p t i v e : public i m a g e d e i n t e r l a c e r { public : /// Constructor motion adaptive ( ) ; / / / Copy C o n s t r u c t o r m o t i o n a d a p t i v e ( const m o t i o n a d a p t i v e & ) ; /// Overload the equal ( = ) o p e r a t o r m o t i o n a d a p t i v e & operator =( const m o t i o n a d a p t i v e & ) ; /// Destructor motion adaptive ( ) ; // Access f u n c t i o n s void s e t T m o v ( i n t tm ) void s e t T b a k ( i n t t b ) void s e t T m r ( i n t tmr ) void s e t T b r ( i n t t b r ) void s e t T d ( i n t t d ) void s e t T v ( i n t t v )

{T {T {T {T {T {T

mov bak mr br d v

= = = = = =

tm ; } tb ; } tmr ; } tbr ;} td ; } tv ; }

/ / Image d e i n t e r l a c e r f u n c t i o n s int a p p l y d e i n t e r l a c e r ( int img in , v p v e f i e l d t y p e c u r f i e l d ) ; int a p p l y i n t e r f i e l d ( int img in , int p t r j , int i , v p v e f i e l d t y p e c u r f i e l d ) ; int a p p l y i n t r a f i e l d ( int img in , int p t r j , int i , int j , int frame height , v p v e f i e l d t y p e c u r f i e l d ) ; void generate matlab file ( string parameter filename , string matlab filename , int img src , int s e q i n ) ;

153
private : / / / MSSIM i n d e x ssim index my ssim index ; / / / T h r e s h o l d f o r moving a r e a int T mov ; / / / T h r e s h o l d f o r boundary and b a c k g r o u n d a r e a int T bak ; / / / T h r e s h o l d f o r moving r e g i o n (AMPDF de i n t e r l a c e r ) int T mr ; / / / T h r e s h o l d f o r boundary and b a c k g r o u n d r e g i o n (AMPDF de i n t e r l a c e r ) int T br ; / / / D i s t a n c e T h r e s h o l d ( e n h a n c e d ELA) int T d; / / / V e r t i c a l T h r e s h o l d ( e n h a n c e d ELA) int T v; }; #e n d i f

F.1.2 Fichier motion.cc


/ / // Title : Motion A d a p t i v e De i n t e r l a c i n g // Project : Video P r o c e s s i n g V a l i d a t i o n E n v i r r o n m e n t / / // File : motion adaptive . cc / / Author : S e r g e CATUDAL // Created : 30/11/2004 // Last modified : 3 0 / 1 1 / 2 0 0 4 / / // Description : Motion A d a p t i v e a l g o r i t h m t o d e i n t e r l a c e image / / / / C o p y r i g h t ( c ) 2 0 0 4 by S e r g e C a t u d a l . T h i s model i s t h e c o n f i d e n t i a l and / / p r o p r i e t a r y p r o p e r t y o f S e r g e C a t u d a l and t h e p o s s e s s i o n o r u s e o f t h i s / / f i l e r e q u i r e s a w r i t t e n l i c e n s e from S e r g e C a t u d a l . / / // Modification history : // 30/11/2004 : created / / #include < m o t i o n a d a p t i v e . h> / / // Default Constructor / @brief / / / m o t i o n a d a p t i v e : : m o t i o n a d a p t i v e ( ) : i m a g e d e i n t e r l a c e r (VPVE MOTION ADAPTIVE DEINTERLACER) { m y s s i m i n d e x = new s s i m i n d e x ( ) ; = 31; // 50 T mov T bak = T mov 2 4 ; / / 3 0 T mr = 55; // 60 T br = 85; // 80 T d = 50; // 50 = 102; // 90 T v } / / / / Copy C o n s t r u c t o r / @brief / / / m o t i o n a d a p t i v e : : m o t i o n a d a p t i v e ( const m o t i o n a d a p t i v e &my mad ) : i m a g e d e i n t e r l a c e r ( my mad ) { m y s s i m i n d e x = my mad . m y s s i m i n d e x ; T mov = my mad . T mov ; T bak = my mad . T bak ; T mr = my mad . T mr ; T br = my mad . T br ; T d = my mad . T d ; T v = my mad . T v ; } / / // = Operator Overloading / @brief / / / m o t i o n a d a p t i v e & m o t i o n a d a p t i v e : : operator =( const m o t i o n a d a p t i v e &my mad ) { i f ( t h i s ! = & my mad ) { m y s s i m i n d e x = my mad . m y s s i m i n d e x ;

154
T T T T T T } / / // Destructor / @brief / / / motion adaptive : : motion adaptive (){ delete my ssim index ; } / / / / Motion A d a p t i v e De i n t e r l a c e r F u n c t i o n s / / / @ b r i e f Apply t h e Motion A d a p t i v e de i n t e r l a c e r / int motion adaptive : : a p p l y d e i n t e r l a c e r ( int img in , v p v e f i e l d t y p e c u r f i e l d ){ float alpha ; float Z; int BD [ 3 ] ; int frame height = img height 2 ; int i,j; int i m g o u t ; int itr ; int MBD M [ 3 ] ; int MBD t [ 3 ] ; int ptr j ; int ptr max ; int ptr med ; int tmp val ; int Z ampdf , Z m e l a ; / / / / | ( k 2) t h f i e l d | ( k 1) t h f i e l d | ( k ) t h f i e l d | ( k+1) t h f i e l d | / / // | img in [ 0 ] | img in [ 1 ] | img in [ 2 ] | img in [ 3 ] | / / // p t r j i n i t i a l i z a t i o n switch ( c u r f i e l d ) { case VPVE EVEN FIELD : ptr j = 0; break ; case VPVE ODD FIELD : p t r j = 1; break ; } // img out i n i t i a l i z a t i o n i m g o u t = new i n t [ f r a m e h e i g h t ] ; f o r ( j = 0 ; j < f r a m e h e i g h t ; j ++){ i m g o u t [ j ] = new i n t [ i m g w i d t h ] ; switch ( c u r f i e l d ) { case VPVE EVEN FIELD : i f ( j %2 == 0) { f o r ( i = 0 ; i <i m g w i d t h ; i ++) img out [ j ] [ i ] = img in [ 2 ] [ p t r j ] [ i ] ; } else { / / I n i t i a l i s a t i o n de MBD t MBD t [ 0 ] = 0 ; MBD t [ 1 ] = 0 ; MBD t [ 2 ] = 0 ; f o r ( i = 0 ; i <i m g w i d t h ; / / ( k 2) t h ( k 1) t h // // | a 0 | | c 1 | // // | b 0 | // // i i // / / EVEN ODD / / Motion D e t e c t i o n i ++){ ( k ) th ( k+1) t h | a 2 | | c 3 | | b 2 | i i EVEN ODD mov bak mr br d v = = = = = = my my my my my my mad . T mad . T mad . T mad . T mad . T mad . T mov ; bak ; mr ; br ; d; v;

} return t h i s ;

field ptr j ptr j + 1

155
/ / ( BD a , BD b , BD c ) BD[ 0 ] = a b s ( i m g i n [ 0 ] [ p t r j ] [ i ] i m g i n [ 2 ] [ p t r j ] [ i ] ) ; i f (( p t r j + 1) < img height ) BD[ 1 ] = a b s ( i m g i n [ 0 ] [ p t r j + 1 ] [ i ] i m g i n [ 2 ] [ p t r j + 1 ] [ i ] ) ; else BD [ 1 ] = 0 ; BD[ 2 ] = a b s ( i m g i n [ 1 ] [ p t r j ] [ i ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; / / Maximum B r i g h t n e s s D i f f e r e n c e / / Max( BD a , BD b , BD c ) f o r ( i t r = 0 ; i t r < 2 ; i t r ++){ f o r ( ptr max = 0 ; ptr max < 2 ; ptr max++){ i f (BD[ ptr max + 1 ] < BD[ ptr max ] ) { = BD[ ptr max ] ; tmp val BD[ ptr max ] = BD[ ptr max + 1 ] ; BD[ ptr max + 1 ] = t m p v a l ; } } } MBD t [ 0 ] = BD [ 2 ] ; // 3 t a p Median F i l t e r ( MBD t , MBD t 1 , MBD t 2) MBD M[ 0 ] = MBD t [ 0 ] ; MBD M[ 1 ] = MBD t [ 1 ] ; MBD M[ 2 ] = MBD t [ 2 ] ; f o r ( i t r = 0 ; i t r < 2 ; i t r ++){ f o r ( p t r m e d = 0 ; p t r m e d < 2 ; p t r m e d++){ i f (MBD M[ p t r m e d + 1 ] < MBD M[ p t r m e d ] ) { tmp val = MBD M[ p t r m e d ] ; = MBD M[ p t r m e d + 1 ] ; MBD M[ p t r m e d ] MBD M[ p t r m e d + 1 ] = t m p v a l ; } } } / / Save MBD t MBD t [ 2 ] = MBD t [ 1 ] ; MBD t [ 1 ] = MBD t [ 0 ] ; // Threshold Decision i f (MBD M[ 1 ] > T mov ) { / / Moving R e g i o n alpha = 1; } else { i f (MBD M[ 1 ] > T bak ) { / / Boundary Area a l p h a = ( (MBD M[ 1 ] T bak ) / ( T mov T bak ) ) ; i f ( alpha > 1) c o u t << a l p h a = << a l p h a << e n d l ; } else { / / Background Area alpha = 0; } } // Soft Z ampdf Z mela Z Switch = a p p l y i n t e r f i e l d ( img in , p t r j , i , c u r f i e l d ) ; = a p p l y i n t r a f i e l d ( img in , p t r j , i , j , frame height , = ( ( 1 a l p h a ) Z ampdf ) + ( a l p h a Z m e l a ) ;

cur field );

img out [ j ] [ i ] = ( int )Z ; } // increase p t r j p t r j ++; } // c o u t << ok ; break ; case VPVE ODD FIELD : break ; default : break ; } } return i m g o u t ; } / @ b r i e f Apply t h e AMPDF d e i n t e r l a c e r / int motion adaptive : : a p p l y i n t e r f i e l d ( int img in , int p t r j , int i , v p v e f i e l d t y p e c u r f i e l d ){ i n t AD, min AD ; int i t r ; i n t median [ 3 ] ; int ptr med ;

156
int int int int tmp val ; Z ampdf ; Z cand1 , p o s x Z c a n d 1 , p o s y Z c a n d 1 ; Z cand2 , p o s x Z c a n d 2 , p o s y Z c a n d 2 ;

/ / / / | ( k 1) t h f i e l d | ( k ) t h f i e l d | ( k+1) t h f i e l d | / / | img in [ 2 ] | img in [ 3 ] | // | img in [ 1 ] / / switch ( c u r f i e l d ) { case VPVE EVEN FIELD : { / / Step 1 > Coarse S e a r c h / / F i e l d ( k 1) t h // // | | | 1 | | | // // | 2 | | 3 | | 4 | // // | | | 5 | | | // // i 2 i i +2

p t r j 1 ptr j p t r j +1

/ / AD ( A b s o l u t e D i f f e r e n c e ) f o r 5 p o t e n t i a l p i x e l s i f ( ( p t r j 1) < 0){ = 255; min AD } else { Z cand1 = img in [ 1 ] [ p t r j 1][ i ] ; min AD = abs ( img in [ 1 ] [ p t r j 1][ i ] img in [ 3 ] [ p t r j ] [ i ] ) ; pos x Z cand1 = i ; p o s y Z c a n d 1 = p t r j 1; } i f ( ( i 2) < 0) AD = 2 5 5 ; else AD = a b s ( i m g i n [ 1 ] [ p t r j ] [ i 2] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { Z cand1 = img in [ 1 ] [ p t r j ] [ i 2]; = AD; min AD p o s x Z c a n d 1 = i 2; pos y Z cand1 = p t r j ; } AD = a b s ( i m g i n [ 1 ] [ p t r j ] [ i ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { = img in [ 1 ] [ p t r j ] [ i ] ; Z cand1 min AD = AD; pos x Z cand1 = i ; pos y Z cand1 = p t r j ; } i f ( ( i +2) > ( img width 1 ) ) AD = 2 5 5 ; else AD = a b s ( i m g i n [ 1 ] [ p t r j ] [ i + 2 ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { Z cand1 = img in [ 1 ] [ p t r j ] [ i +2]; min AD = AD; p o s x Z c a n d 1 = i +2; pos y Z cand1 = p t r j ; } i f ( ( p t r j +1) > ( i m g h e i g h t 1 ) ) AD = 2 5 5 ; else AD = a b s ( i m g i n [ 1 ] [ p t r j + 1 ] [ i ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { = img in [ 1 ] [ p t r j +1][ i ] ; Z cand1 min AD = AD; pos x Z cand1 = i ; p o s y Z c a n d 1 = p t r j +1; } / / | Z r e f Z c a n d 1 | < T mr i f ( min AD < T mr ) { // 3 t a p Median F i l t e r ( Z r e f , Z c a n d 1 , Z k 1) median [ 0 ] = i m g i n [ 3 ] [ p t r j ] [ i ] ; median [ 1 ] = Z c a n d 1 ; median [ 2 ] = i m g i n [ 1 ] [ p t r j ] [ i ] ; f o r ( i t r = 0 ; i t r < 2 ; i t r ++){ f o r ( p t r m e d = 0 ; p t r m e d < 2 ; p t r m e d++){ i f ( median [ p t r m e d + 1 ] < median [ p t r m e d ] ) { tmp val = median [ p t r m e d ] ;

157
median [ p t r m e d ] = median [ p t r m e d + 1 ] ; median [ p t r m e d + 1 ] = t m p v a l ; } } } Z ampdf = median [ 1 ] ; } else { / / Step 2 > F i n e S e a r c h 1 / / F i e l d ( k ) th // // | 1 | | 3 | y // ( Z cand1 ) // | 2 | | 4 | y+1 // / / x 1 x+1 // ( Z cand1 ) / / AD ( A b s o l u t e D i f f e r e n c e ) f o r 4 p o t e n t i a l p i x e l s i f ( ( p o s x Z c a n d 1 1) < 0){ min AD = 2 5 5 ; } else { = img in [ 2 ] [ pos y Z cand1 ] [ pos x Z cand1 1]; Z cand2 = a b s ( i m g i n [ 2 ] [ p o s y Z c a n d 1 ] [ p o s x Z c a n d 1 1] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; min AD p o s x Z c a n d 2 = p o s x Z c a n d 1 1; pos y Z cand2 = pos y Z cand1 ; i f ( ( p o s y Z c a n d 1 +1) < i m g h e i g h t ) { AD = a b s ( i m g i n [ 2 ] [ p o s y Z c a n d 1 + 1 ] [ p o s x Z c a n d 1 1] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { = img in [ 2 ] [ pos y Z cand1 +1][ pos x Z cand1 1]; Z cand2 min AD = AD; p o s y Z c a n d 2 = p o s y Z c a n d 1 +1; } } } i f ( ( p o s x Z c a n d 1 +1) < i m g w i d t h ) { AD = a b s ( i m g i n [ 2 ] [ p o s y Z c a n d 1 ] [ p o s x Z c a n d 1 + 1 ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { Z cand2 = img in [ 2 ] [ pos y Z cand1 ] [ pos x Z cand1 +1]; min AD = AD; p o s x Z c a n d 2 = p o s x Z c a n d 1 +1; pos y Z cand2 = pos y Z cand1 ; } i f ( ( p o s y Z c a n d 1 +1) < i m g h e i g h t ) { AD = a b s ( i m g i n [ 2 ] [ p o s y Z c a n d 1 + 1 ] [ p o s x Z c a n d 1 + 1 ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < Z c a n d 2 ) { Z cand2 = img in [ 2 ] [ pos y Z cand1 +1][ pos x Z cand1 +1]; = AD; min AD p o s x Z c a n d 2 = p o s x Z c a n d 1 +1; p o s y Z c a n d 2 = p o s y Z c a n d 1 +1; } } } / / | Z r e f Z c a n d 1 | < T mr i f ( min AD < T br ) { Z ampdf = Z c a n d 2 ; } else { / / Step 3 > F i n e S e a r c h 2 // c e r r << S t e p 3 > F i n e S e a r c h 2 << e n d l ; / / F i e l d ( k ) th // // | | | | y 1 // ( Z cand2 ) // | 1 | | 2 | y // / / x 1 x +1 // ( Z cand2 ) F i e l d ( k 1) t h | | 3 | | y1 ( Z cand2 ) | | 4 | | y x ( Z cand2 )

i f ( ( p o s x Z c a n d 2 1) < 0){ min AD = 2 5 5 ; } else { min AD = a b s ( i m g i n [ 2 ] [ p o s y Z c a n d 2 ] [ p o s x Z c a n d 2 1] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; Z ampdf = i m g i n [ 2 ] [ p o s y Z c a n d 2 ] [ p o s x Z c a n d 2 1 ] ; } i f ( ( p o s x Z c a n d 2 +1) < i m g w i d t h ) { AD = a b s ( i m g i n [ 2 ] [ p o s y Z c a n d 2 ] [ p o s x Z c a n d 2 + 1 ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { min AD = AD; Z ampdf = i m g i n [ 2 ] [ p o s y Z c a n d 2 ] [ p o s x Z c a n d 2 + 1 ] ; } }

158
i f ( ( p o s y Z c a n d 2 1) > = 0) { AD = a b s ( i m g i n [ 1 ] [ p o s y Z c a n d 2 1 ] [ p o s x Z c a n d 2 ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) { min AD = AD; Z ampdf = i m g i n [ 1 ] [ p o s y Z c a n d 2 1 ] [ p o s x Z c a n d 2 ] ; } } AD = a b s ( i m g i n [ 1 ] [ p o s y Z c a n d 2 ] [ p o s x Z c a n d 2 ] i m g i n [ 3 ] [ p t r j ] [ i ] ) ; i f (AD < min AD ) Z ampdf = i m g i n [ 1 ] [ p o s y Z c a n d 2 ] [ p o s x Z c a n d 2 ] ; } } } break ; case VPVE ODD FIELD : Z ampdf = 0 ; break ; default : break ; } return Z ampdf ; } / @ b r i e f Apply t h e e n h a n c e d ELA d e i n t e r l a c e r / int motion adaptive : : a p p l y i n t r a f i e l d ( int img in , int p t r j , int i , int j , int frame height , v p v e f i e l d t y p e bool dominant = f a l s e ; float interpolated val ; int D d1 , D d2 ; int dir dif [5]; int itr ; int line buf up [ 5 ] ; int line buf down [ 5 ] ; int median [ 3 ] ; int n; int p t r u p , ptr down ; int ptr med ; int smallest , smallest 1 , smallest 2 ; int tmp val ; int Z mela ; // / / | ( k ) th f i e l d | // // | img in [ 2 ] | // switch ( c u r f i e l d ) { case VPVE EVEN FIELD : { / / Two n e i g h b o r i n g s c a n l i n e s / / G e n e r a t e t h e two s c a n l i n e s i f ( j == f r a m e h e i g h t 1 ) { / / Buttom s c a n l i n e f o r ( n= 2; n < =2; n++) line buf down [ n+2] = 0; / / Top s c a n l i n e i f ( i == 0) { line buf up [0] = 0; line buf up [1] = 0; f o r ( n = 0 ; n < =2; n++) l i n e b u f u p [ n+2] = i m g i n [ 2 ] [ } e l s e i f ( i == 1) { line buf up [0] = 0; f o r ( n= 1; n < =2; n++) l i n e b u f u p [ n+2] = i m g i n [ 2 ] [ } e l s e i f ( i == i m g w i d t h 2 ) { f o r ( n= 2; n < =1; n++) l i n e b u f u p [ n+2] = i m g i n [ 2 ] [ line buf up [4] = 0; } e l s e i f ( i == i m g w i d t h 1 ) { f o r ( n= 2; n < =0; n++) l i n e b u f u p [ n+2] = i m g i n [ 2 ] [ line buf up [3] = 0; line buf up [4] = 0; } else { f o r ( n= 2; n < =2; n++) l i n e b u f u p [ n+2] = i m g i n [ 2 ] [ } } else { i f ( i == 0) { = 0; line buf up [ 0 ] line buf down [ 0 ] = 0 ;

c u r f i e l d ){

p t r j ] [ i+n ] ;

p t r j ] [ i+n ] ; p t r j ] [ i+n ] ;

p t r j ] [ i+n ] ;

p t r j ] [ i+n ] ;

159
line buf up [ 1 ] = 0; line buf down [ 1 ] = 0 ; f o r ( n = 0 ; n < =2; n++){ l i n e b u f u p [ n+2] = l i n e b u f d o w n [ n+2] = } e l s e i f ( i == 1) { = 0; line buf up [ 0 ] line buf down [ 0 ] = 0 ; f o r ( n= 1; n < =2; n++){ l i n e b u f u p [ n+2] = l i n e b u f d o w n [ n+2] = } e l s e i f ( i == i m g w i d t h f o r ( n= 2; n < =1; n++){ = l i n e b u f u p [ n+2] l i n e b u f d o w n [ n+2] = } = 0; line buf up [ 4 ] line buf down [ 4 ] = 0 ; e l s e i f ( i == i m g w i d t h f o r ( n= 2; n < =0; n++){ = l i n e b u f u p [ n+2] l i n e b u f d o w n [ n+2] = } line buf up [ 3 ] = 0; line buf down [ 3 ] = 0 ; = 0; line buf up [ 4 ] line buf down [ 4 ] = 0 ; else { f o r ( n= 2; n < =2; n++){ l i n e b u f u p [ n+2] = l i n e b u f d o w n [ n+2] = }

i m g i n [ 2 ] [ p t r j ] [ i+n ] ; i m g i n [ 2 ] [ p t r j + 1 ] [ i+n ] ;

i m g i n [ 2 ] [ p t r j ] [ i+n ] ; i m g i n [ 2 ] [ p t r j + 1 ] [ i+n ] ; 2){ i m g i n [ 2 ] [ p t r j ] [ i+n ] ; i m g i n [ 2 ] [ p t r j + 1 ] [ i+n ] ;

1){ i m g i n [ 2 ] [ p t r j ] [ i+n ] ; i m g i n [ 2 ] [ p t r j + 1 ] [ i+n ] ;

i m g i n [ 2 ] [ p t r j ] [ i+n ] ; i m g i n [ 2 ] [ p t r j + 1 ] [ i+n ] ;

} } // Directional c o ro la ti on c a l c u l a t i o n ( a , b , c , d , e ) // 5 directional differences // a b c d e // d i r d i f [ 0 ] d i r d i f [ 1 ] d i r d i f [ 2 ] d i r d i f [ 3 ] d i r d i f [ 4 ] d i r d i f [ 0 ] = abs ( l i n e b u f u p [ 0 ] l i n e b u f d o w n [ 4 ] ) ; d i r d i f [ 1 ] = abs ( l i n e b u f u p [ 1 ] l i n e b u f d o w n [ 3 ] ) ; d i r d i f [ 2 ] = abs ( l i n e b u f u p [ 2 ] l i n e b u f d o w n [ 2 ] ) ; d i r d i f [ 3 ] = abs ( l i n e b u f u p [ 3 ] l i n e b u f d o w n [ 1 ] ) ; d i r d i f [ 4 ] = abs ( l i n e b u f u p [ 4 ] l i n e b u f d o w n [ 0 ] ) ; i f ( d i r d i f [ 2 ] < T v ) { / / Smooth r e g i o n = 2; ptr up ptr down = 2 ; dominant = f a l s e ; } else { / / Edge r e g i o n / / Min ( a , b , c , d , e ) // Smallest d i f f e r e n c e step 1 if ( dir dif [0] < dir dif [1]) smallest 1 = 0; else smallest 1 = 1; if ( dir dif [3] < dir dif [4]) smallest 2 = 3; else smallest 2 = 4; // Smallest d i f f e r e n c e step 2 if ( dir dif [ smallest 1 ] < dir dif [ smallest 2 ]){ // Smallest d i f f e r e n c e step 3 if ( dir dif [ smallest 1 ] < dir dif [2]) smallest = smallest 1 ; else smallest = 2; } else { // Smallest d i f f e r e n c e step 3 if ( dir dif [ smallest 2 ] < dir dif [2]) smallest = smallest 2 ; else smallest = 2; } // I r r e g u l a r ? switch ( s m a l l e s t ) { case 0 : / / min = a D d1 = a b s ( d i r d i f [ 0 ] d i r d i f [ 3 ] ) ; D d2 = a b s ( d i r d i f [ 0 ] d i r d i f [ 4 ] ) ; ptr up = 0; ptr down = 4 ; i f ( D d1 > T d && D d2 > T d ) { / / Dominant d i r e c t i o n a l dominant = true ;

edge

160
} else { / / Nondominant d i r e c t i o n a l e d g e dominant = f a l s e ; } break ; case 1 : / / min = b D d1 = a b s ( d i r d i f [ 1 ] d i r d i f [ 3 ] ) ; D d2 = a b s ( d i r d i f [ 1 ] d i r d i f [ 4 ] ) ; = 1; ptr up ptr down = 3 ; i f ( D d1 > T d && D d2 > T d ) { / / Dominant d i r e c t i o n a l e d g e dominant = true ; } else { / / Nondominant d i r e c t i o n a l e d g e dominant = f a l s e ; } break ; case 2 : / / min = c = 2; ptr up ptr down = 2 ; dominant = f a l s e ; break ; case 3 : / / min = d D d1 = a b s ( d i r d i f [ 3 ] d i r d i f [ 0 ] ) ; D d2 = a b s ( d i r d i f [ 3 ] d i r d i f [ 1 ] ) ; = 3; ptr up ptr down = 1 ; i f ( D d1 > T d && D d2 > T d ) { / / Dominant d i r e c t i o n a l e d g e dominant = true ; } else { / / Nondominant d i r e c t i o n a l e d g e dominant = f a l s e ; } break ; case 4 : / / min = e D d1 = a b s ( d i r d i f [ 4 ] d i r d i f [ 0 ] ) ; D d2 = a b s ( d i r d i f [ 4 ] d i r d i f [ 1 ] ) ; ptr up = 4; ptr down = 0 ; i f ( D d1 > T d && D d2 > T d ) { / / Dominant d i r e c t i o n a l e d g e dominant = true ; } else { / / Nondominant d i r e c t i o n a l e d g e dominant = f a l s e ; } break ; default : break ; } } / / I n t e r p o l a t e d Value i n t e r p o l a t e d v a l = ( ( f l o a t ) ( l i n e b u f u p [ p t r u p ] + l i n e b u f d o w n [ ptr down ] ) ) / 2 ; i f ( dominant ) { / / Median f i l t e r / / y = Median [ x ( k 1,n ) , x ( k +1, n ) , ELA ] median [ 0 ] = l i n e b u f u p [ 2 ] ; median [ 1 ] = l i n e b u f d o w n [ 2 ] ; median [ 2 ] = ( i n t ) i n t e r p o l a t e d v a l ; f o r ( i t r = 0 ; i t r < 2 ; i t r ++){ f o r ( p t r m e d = 0 ; p t r m e d < 2 ; p t r m e d++){ i f ( median [ p t r m e d + 1 ] < median [ p t r m e d ] ) { tmp val = median [ p t r m e d ] ; median [ p t r m e d ] = median [ p t r m e d + 1 ] ; median [ p t r m e d + 1 ] = t m p v a l ; } } } Z m e l a = median [ 1 ] ; } else { Z mela = ( int ) i n t e r p o l a t e d v a l ; } } break ; case VPVE ODD FIELD : Z mela = 0 ; break ; default : break ; } return Z m e l a ; } / @ b r i e f G e n e r a t e t h e Motion A d a p t i v e de i n t e r l a c e r matlab f i l e s / void m o t i o n a d a p t i v e : : g e n e r a t e m a t l a b f i l e ( s t r i n g p a r a m e t e r f i l e n a m e , s t r i n g int i m g s r c , int s e q i n ){

matlab filename ,

161
char filename ; float img quality = 0; int mov t , m o v s t a r t , mov end ; int bak t , b a k s t a r t , bak end ; int j; int i m g d e i n t e r l a c e d ; int nb fields ; string first field type ; string tampon ; string tmp filename ; vpve field type cur field ; i f s t r e a m ReadTXT ; ofstream WriteMatlab results ; // // // // // // // // // // // // // // // // // // // Parameter file content :

Image F i l e n a m e Nb f i e l d p e r s e q u e n c e F i r s t f i e l d t y p e ( e v e n o r odd ) Moving R e g i o n T h r e s h o l d s t a r t Moving R e g i o n T h r e s h o l d end Boundary and Background R e g i o n T h r e s h o l d s t a r t Boundary and Background R e g i o n T h r e s h o l d end Example o f the content of the parameter < < < < < < < file :

f o o t b a l l 0 9 . pgm 4 even 0 120 0 100

Image f i l e n a m e Nb f i e l d s p e r s e q u e n c e F i r s t f i e l d type Moving Area T h r e s h o l d s t a r t Moving Area T h r e s h o l d end Boundary and Background Area T h r e s h o l d s t a r t Boundary and Background Area T h r e s h o l d end

c o u t << Reading P a r a m e t e r s : << e n d l ; / / Open p a r a m e t e r f i l e ReadTXT . open ( p a r a m e t e r f i l e n a m e . c s t r ( ) ) ; / / Save matlab r e s u l t s f i l e f i l e n a m e = new char [ 4 0 ] ; strcat ( filename , matlab filename . c s t r ( ) ) ; s t r c a t ( f i l e n a m e , r e s u l t s .m ) ; W r i t e M a t l a b r e s u l t s . open ( f i l e n a m e ) ; delete [ ] f i l e n a m e ; f i l e n a m e = NULL ; i f ( ! ReadTXT . f a i l ( ) & & ! W r i t e M a t l a b r e s u l t s . f a i l ( ) ) { / / Load t h e s o u r c e image ReadTXT >> t m p f i l e n a m e >> tampon ; / / Load image s e q u e n c e i n f o r m a t i o n s ReadTXT >> n b f i e l d s >> f i r s t f i e l d t y p e ; c o u t << \ t I m a g e s e q u e n c e i n f o r m a t i o n s : << e n d l ; c o u t << \ t \ tNb f i e l d s p e r s e q u e n c e : << n b f i e l d s << e n d l ; << f i r s t f i e l d t y p e << e n d l ; c o u t << \ t \ t F i r s t f i e l d t y p e : i f ( f i r s t f i e l d t y p e == e v e n ) c u r f i e l d = VPVE EVEN FIELD ; else c u r f i e l d = VPVE ODD FIELD ; / / Load D i s t a n c e t h r e s h o l d p a r a m e t e r s ReadTXT >> m o v s t a r t >> mov end ; c o u t << \ tMoving Area t h r e s h o l d p a r a m e t e r s : << e n d l ; c o u t << \ t \ t S t a r t : << m o v s t a r t << e n d l ; c o u t << \ t \ tEnd : << mov end << e n d l ; / / Load V e r t i c a l t h r e s h o l d p a r a m e t e r s ReadTXT >> b a k s t a r t >> b a k e n d ; c o u t << \ tBoundary and Background Area t h r e s h o l d p a r a m e t e r s : << e n d l ; c o u t << \ t \ t S t a r t : << b a k s t a r t << e n d l ; c o u t << \ t \ tEnd : << b a k e n d << e n d l ; c o u t << \ n ; // my my my I n i t i a l i z e the s s i m i n d e x>s e t s s i m i n d e x>s e t s s i m i n d e x>s e t ssim index object image height ( img height ) ; i m a g e w i d t h ( img width ) ; ssim map ( ) ; filter parameters

/ / F i l t e r t h e image w i t h d i f f e r e n t Hybrid / / Motion D e t e c t o r W r i t e M a t l a b r e s u l t s << motion md =[ ; / / I n t r a F i e l d : M o d i f i e d ELA / / W r i t e M a t l a b r e s u l t s << m o t i o n e l a =[ ; / / I n t e r F i e l d : AMPDF

162
/ / W r i t e M a t l a b r e s u l t s << motion ampdf =[ ; f o r ( mov t = m o v s t a r t ; mov t < = mov end ; mov t = mov t + 2 ) { f o r ( b a k t = b a k s t a r t ; b a k t <= b a k e n d ; b a k t = b a k t + 2 ) { / / Motion D e t e c t o r s e t T m o v ( mov t ) ; i f ( ( mov t b a k t ) < 2 ) set T bak ( 2 ) ; else s e t T b a k ( ( mov t b a k t ) ) ; / / I n t r a F i e l d : M o d i f i e d ELA / / s e t T d ( mov t ) ; // set T v ( bak t ) ; / / I n t e r F i e l d : AMPDF / / s e t T m r ( mov t ) ; // set T br ( bak t ) ; = img height / 2 ; img height img deinterlaced = apply deinterlacer ( seq in , c ur f ie ld ); i m g q u a l i t y = ( f l o a t ) ( m y s s i m i n d e x>c o m p u t e s s i m i n d e x ( i m g s r c , i m g d e i n t e r l a c e d ) ) ; i f ( bak t ! = bak end ) W r i t e M a t l a b r e s u l t s << i m g q u a l i t y << ; else W r i t e M a t l a b r e s u l t s << i m g q u a l i t y ; / / F r e e t h e memory img height = img height 2 ; f o r ( j = 0 ; j <i m g h e i g h t ; j ++) delete [ ] i m g d e i n t e r l a c e d [ j ] ; delete [ ] i m g d e i n t e r l a c e d ; i m g d e i n t e r l a c e d = NULL ; } i f ( mov t ! = mov end ) W r i t e M a t l a b r e s u l t s << , \ n ; } W r i t e M a t l a b r e s u l t s << ] ; ; } ReadTXT . c l o s e ( ) ; WriteMatlab results . close ( ) ; }

Vous aimerez peut-être aussi