Digital Signal Processing Reference
In-Depth Information
int C = ip.getPixel(u,v+1);
16.4 Java-Implementierung
10
int D = ip.getPixel(u+1,v+1);
11
double E = A + a*(B-A);
12
double F = C + a*(D-C);
13
double G = E + b*(F-E);
14
return G;
15
}
16
17 }
Die bilineare Interpolation ist ubrigens auch in der ImageJ-Klasse
ImageProcessor in Form der Methode
double getInterpolatedPixel (double x, double y)
bereits verfugbar.
BicubicInterpolator (Klasse)
Diese Klasse implementiert die bikubische Interpolation nach Gl. 16.61
bzw. Alg. 16.2. Der Steuerfaktor a hat normalerweise den Wert
1, kann
aber mithilfe der zweiten Konstruktor-Methode (Zeile 6) initialisiert wer-
den. Die eindimensionale kubische Interpolation (Gl. 16.48) ist durch die
Methode double cubic (double r) realisiert:
1 public class BicubicInterpolator extends PixelInterpolator {
2
double a = -1;
3
4
BicubicInterpolator() {}
5
6
BicubicInterpolator(double a) {
this.a = a;
7
}
8
9
10
double getInterpolatedPixel(Pnt2d pnt) {
double x = pnt.x;
11
double y = pnt.y;
12
// use floor to handle negative coordinates:
13
int x0 = (int) Math.floor(x);
14
int y0 = (int) Math.floor(y);
15
16
17
double q = 0;
for (int j = 0; j < 4; j++) {
18
int v = y0 - 1 + j;
19
double p = 0;
20
for (int i = 0; i < 4; i++) {
21
intu=x0-1+i;
22
p = p + ip.getPixel(u,v) * cubic(x - u);
23
}
24
q = q + p * cubic(y - v);
25
}
26
return q;
27
Search WWH ::




Custom Search