Formation et Analyse d'images James L. Crowley ENSIMAG - Option IRV Premier Semestre 2010/2011 Séance 1 27 sept 2010 Coordonnées Homogènes Plan de la Séance : Coordonnées Homogènes en Notation Tensorielle...2 Vecteur et Matrice en Notation Tensorielle...2 L'équation d'une droite... Le produit Croisé...4 Intersection de deux droites...6 Transformations en Coordonnées Homogènes...7 Transformations d'images...7 Interpolation Linéaire...9 Interpolation Bi-lineaire...10 Translation...11 Rotation...11 Translation et Rotation...11 Transformations d'échelle, rotation et translation...12
Coordonnées Homogènes en Notation Tensorielle Les coordonnées homogènes repose sur une notation dans laquelle les vecteurs en N dimensions sont représentées par un vecteur en N+1 dimensions. Les coordonnées homogènes sont un outil de base en vision, en robotique et en synthèse d'images. Exemple : un point Soit un plan Euclidienne en R 2 composé de points, En notation classique, un point est un vecteur : P x y En notation homogène, un point est un vecteur x P y 1 x On note que a, b : a y 1 x b y 1 démonstration x a y 1 ax ay a ax/a x ay/a a/1 y 1 Vecteur et Matrice en Notation Tensorielle En notation tensorielle, la signe " " est remplacé par un indice en super-scripte ou sous-scripte. Une super-scripte signifie un vecteur colonne. Par exemple, le point est indiqué par un vecteur p i P i p1 p 2 p une sous-scripte indique un vecteur ligne Par exemple, la droite est indiquée par le vecteur l i : L i (l 1, l 2, l ) Une matrice est une ligne de vecteurs (ou une vecteurs de lignes). M i j m1 1 m1 2 m1 m2 1 m2 2 m2 m 1 m 2 m Le produit d'un vecteur avec une indice en super scripte et une vecteur avec le même indice en sous-scripte signifie une produit scalaire. Ceci est fait par une sommation implicite des indices. (La Convention de Sommation d'einstein).
Donc, le produit indique une annulation des souscriptes et superscriptes. L i P i l 1 p 1 + l 2 p 2 + l p Cette sommation et commutative L i P i P i L i Pour la produit d'une matrice et une vecteur, ceci donne une nouvelle vecteur. P j M i j P i Ceci représent une tranformation du repère "i" vers le repère "j". L'équation d'une droite Dans un plan Euclidienne en R 2, en notation "classique", une droite est définie par une équation a x + b y + x 0. On peut exprimer cette équation comme la produit de deux vecteurs : L P 0 ou L (a b c ) et x P y 1 En notation tensorielle, cette equation est exprimé : L i P i 0 avec i1, 2,. La sommation des indices est implicites.
Le produit Croisé Une droite est définie par deux points. Un point est défini par le croisement de deux droites. Il y a une dualité parfaite entre les points et les droites. En notation classique, ax + by + c 0 le manière de déterminer la droite pour deux points est : où a (y 1 y 2 ) b (x 2 x 1 ) c (a x 1 + b y 1 ) x 1 ( y 1 y 2 ) y 1 (x 2 x 1 ) x 1 y 1 + x 1 y 2 y 1 x 2 + y 1 x 1 x 1 y 2 y 1 x 2 La droite est x (y 2 y 1 ) + y (x 1 x 2 ) x 1 y 2 + y 1 x 2 0 Ceci peut être calculé par la déterminante, avec les variables libres dans le premier colonne : x y 1 x 1 y 1 1 x 2 y 2 1 x (y 1 y 2 ) + y (x 2 x 1 ) + x 1 y 2 y 1 x 2 0 Il s'agit d'une méthode générale de déterminer les paramètres d une équation linéaire à partir des contraintes. Ca marche aussi pour trouver la point d'intersection de deux lignes. On peut, également, écrire la déterminante comme un produit croisé. a L T b c P 1 x P 2 0 1 y 1 x 2 1 0 x 1 y 2 y 1 x 1 0 y 1 y 2 x 2 x 1 x 1 y 2 x 2 y En notation tensorielle, le déterminant et fait par l opérateur tensorielle E ijk et E ijk. Cette opérateur signifie une evaluation des indices pour une déterminant. Exemple : La droite L i est définit par les points P j et Q k : Pour L i E ijk P j Q k P j p1 p 2 p 1 /p p p 2 /p 1 et Q j q1 q 2 q q 1 /q q 2 /q 1 i 1, ijk-ikj 12-12 : l 1 p 2 q p q 2 i 2, ijk-ikj 21-21 : l 2 p q 1 p 1 q i, ijk-ikj 12-21 : l p 1 q 2 p 2 q 1
et si p 1 et q 1 alors nous retrouvons notre forme : P j p1 p 2 et Q j q1 q 2 i 1, ijk-ikj 12-12 : l 1 p 2 q p q 2 p 2 q 2 i 2, ijk-ikj 21-21 : l 2 p q 1 p 1 q p 1 q 1 i, ijk-ikj 12-21 : l p 1 q 2 p 2 q 1
Intersection de deux droites Pour le calcul d'un point d'intersection de deux droites. soit deux droites : L: ax + by + c 0 et M : dx + ey + f 0. En notation classique : Soit L (a b c ) et M (d e f ) Le point d'intersection est x bf ce ae bd y cd af ae bd Pour le demontrer : bf ce P L x M 0 c b d bf ce ae db c 0 a b a 0 e f cd af cd af ae db ae db Le operateur "x" est équivalent à une déterminant. Un point est l'intérsection d'une infini de droites. Soit deux droits Soit deux droites (a, b, c) et (d, e, f). soit une droit "libre" avec coéfficient u, v, w : u x + v y +w 0. On peut trouver les coordonées du point grace au déterminant. u v w a b c d e f 0 u(bf-ce) + v(cd-af) + w(ae-bd) 0 ou bien u bf ce ae bd + v cd af ae bd + w 0 u x + v y + w donc x bf ce ae bd et y cd af ae bd et 11. En notation Tensorielle, nous avons l opérateur tensorielle E ijk On a P i E ijk L i M j Pour L j l1 l 2 l et M k m 1 m 2 m i 1, ijk-ikj 12-12 : p 1 l 2 m l m 2 i 2, ijk-ikj 21-21 : p 2 l m 1 l 1 m i, ijk-ikj 12-21 : p l 1 m 2 l 2 m 1
Transformations en Coordonnées Homogènes. Les coordonnés homogènes fournissent une notation uniforme pour les transformations. Par exemple, les transformations dans un plan sont décrites par une matrice homogène x. Transformations d'images M Image Source Pour chaque pixel de l'image de destination (x d, y d ), on calcule une position (x s, y s ) dans l'image de la source. P s M d s P d Image Destination p1 ou p 2 m1 1 m1 2 m1 m2 1 m2 2 m2 m 1 m 2 m p x d y d x s p 1 p y s p 2 p ou x s y s p 1 /p p 2 /p 1 Ensuite la nouvelle valeur de pixel destination, P 2, est calculé en fonction du voisinage de la position source. MAIS, P s x s y s n'est pas des entier! Quelle valeur faut-il prendre pour les pixels? Pour chaque pixel du destination, (x d, y d ) on calcul le position du source, (x s, y s ).
Ensuite, on détermine une valeur par interpolation avec les pixels voisins. Il existe plusieurs fonctions d'interpolation. Ordre zéro : Ordre unité : Ordre trois : Plus proche voisin. intérpolation linéaire et "bi-linéaire" Spline cubic. Interpolation d'ordre zéro Pour les images Binaire, on peut fair que l'ordre zéro. La valeur de p(i 2, j 2 ) déterminer par arrondis de p(i 1, j 1 ). Surface de Décision
Interpolation Linéaire Interpolation Linéaire en 1-D. soit i o x i o +1 p(i) i 0 x i 0 +1 i A partir de l'origine : p(x) p(0) + m x x A partire de deux points i o et i 0 +1 : pente : m x P x p(i+1) p(i) p(x) (x i o ) m x + p(i o ) Interpolation Linéaire en 2D p(i o,j o +1) p(x,y) y p(i o,j o ) p(i o +1,j o ) (i o, j o ) x m x m y P x P y p(i o +1, j o ) p(i o, j o ) p(i o, j o +1) p(i o, j o ) donc p(x, y) m x. (x io ) + m y. (y jo ) + p(i o, j o )
Interpolation Bi-lineaire p(i o,j o +1) p(x,y) y p(i o +1,j o +1) p(i o,j o ) p(i o +1,j o ) (i o, j o ) Forme Bilinéaire : Hyperbolic Paraboloïde x p(x, y) a x + b y + c x y + d. Une interpolation linéaire en "y" de deux interpolations linaire en "x". Dérivation : p(x, 0) p(0, 0) + x. (p(1, 0) p(0, 0)) p(x, 1) p(0, 1) + x. (p(1, 1) p(0, 1)) p(x, y) p(x, 0) + y. (p(x, 1) p(x, 0)) p(0, 0) + x. (p(1, 0) p(0, 0)) + y. (p(0, 1) + x. (p(1, 1) p(0, 1))) y. (p(0, 0) + x. (p(1, 0) p(0, 0))) p(0, 0) + x. (p(1, 0) p(0, 0)) + y. (p(0, 1) p(0, 0)) + x. y. (p(1, 1) p(0, 1) p(1, 0) + p(0, 0)) Pour le point i o, j o, remplace : 0 i o, 1 i o, x (x i o ), y (y i o ) a m x P x p(i o +1, j o ) p(i o, j o ) b m y P y p(i o, j o +1) p(i o, j o ) c m xy p(i o +1, j o ) + p(i o, j o +1) p(i o, j o ) p(i o +1, j o +1) d p(i o, j o ) p(x, y) a. (x io ) + b. (y jo ) + c. (x-io ). (y j o ) + p(i o, j o )
Translation x 2 x 1 + t x, y 2 y 1 + t y x 2 y 2 0 0 t x x 1 0 0 t y y 1 0 0 En notation tensorielle : P B T A B P A pour A, B 1, 2,. Donc T A B est une transformation du repère A vers le repère B. Les indices permet de noter les repères. Rotation (Repère main droite, rotation sens trigonométrique) x 2 Cos(θ) x 1 + Sin(θ) y 1, y 2 Sin(θ) x 1 Cos(θ)y 1 x 2 Cos(θ) Sin(θ) 0 x 1 y 2 Sin(θ) Cos(θ) 0 y 1 0 0 1 Quand le repère tourne dans le sanse "θ", le vecteur est tourner dans le sense θ Translation et Rotation x 2 Cos(θ) x 1 + Sin(θ) y 1 + t x x 2 Sin(θ) x 1 Cos(θ) y 1 + t y x 2 Cos(θ) Sin(θ) t x x 1 y 2 Sin(θ) Cos(θ) t y y 1 0 0 En tensorielle, P B R A B P A
Transformations d'échelle, rotation et translation Une transformation de similitude d'une image est définie par une rotation, une translation, et un changement de taille des axes. Soit un changement d'échelle s x et s y des axes x 1 et y 1 (repère source) suivi d'une rotation d'angle θ dans le plan de l'image source, suivi d'une translation t x, t y s'exprimes dans le repère de la destination. Ces paramètres donne une transformation (s x, s y, θ, t x, t y ) de 1) Un changement d'échelle des axes, puis 2) Une rotation des axes, puis ) Une translation. x 2 y 2 s x Cos(θ) s y Sin(θ) t x x 1 s x Sin(θ) s y Cos(θ) t y y 1 0 0 ou bien x 2 s x Cos(θ) x 1 + s y Sin(θ)y 1 + t x, y 2 s y Sin(θ) x 1 s x Cos(θ)y 1 + t y