Digital Signal Processing Reference
In-Depth Information
AffineMapping (Klasse)
16 Geometrische
Bildoperationen
AffineMapping erweitert die Klasse LinearMapping durch zwei zusatz-
liche Funktionen: erstens durch eine spezielle Konstruktor-Methode, in
der die Elemente a 31 ,a 32 ,a 33 der Abbildungsmatrix - wie fur a ne Ab-
bildungen erforderlich (s. Gl. 16.12) - auf die Werte 0 , 0 , 1 initialisiert
werden; zweitens die Methode makeMapping() , mit der die a ne Ab-
bildung (Vorwartstransformation T )fur beliebige Paare von Dreiecken
berechnet wird (Gl. 16.14):
1 public class AffineMapping extends LinearMapping {
2
3
AffineMapping (
double a11, double a12, double a13,
4
double a21, double a22, double a23,
5
boolean inv) {
6
super(a11,a12,a13,a21,a22,a23,0,0,1,inv);
7
}
8
9
10
// create the a ne transform between
// arbitrary triangles ( A1..A3 ) and ( B1..B3 )
11
static AffineMapping makeMapping (
12
Pnt2d A1, Pnt2d A2, Pnt2d A3,
13
Pnt2d B1, Pnt2d B2, Pnt2d B3) {
14
15
16
double ax1 = A1.x, ax2 = A2.x, ax3 = A3.x;
double ay1 = A1.y, ay2 = A2.y, ay3 = A3.y;
17
double bx1 = B1.x, bx2 = B2.x, bx3 = B3.x;
18
double by1 = B1.y, by2 = B2.y, by3 = B3.y;
19
20
21
double S = ax1*(ay3-ay2) + ax2*(ay1-ay3) + ax3*(ay2-ay1);
double a11 =
22
(ay1*(bx2-bx3)+ay2*(bx3-bx1)+ay3*(bx1-bx2)) / S;
23
double a12 =
24
(ax1*(bx3-bx2)+ax2*(bx1-bx3)+ax3*(bx2-bx1)) / S;
25
double a21 =
26
(ay1*(by2-by3)+ay2*(by3-by1)+ay3*(by1-by2)) / S;
27
double a22 =
28
(ax1*(by3-by2)+ax2*(by1-by3)+ax3*(by2-by1)) / S;
29
double a13 =
30
(ax1*(ay3*bx2-ay2*bx3) + ax2*(ay1*bx3-ay3*bx1)
31
+ ax3*(ay2*bx1-ay1*bx2)) / S;
32
double a23 =
33
(ax1*(ay3*by2-ay2*by3) + ax2*(ay1*by3-ay3*by1)
34
+ ax3*(ay2*by1-ay1*by2)) / S;
35
36
37
return new AffineMapping(a11,a12,a13,a21,a22,a23,false);
}
38
Search WWH ::




Custom Search