1 2 package JSci.maths.wavelet.daubechies2; 3 4 import JSci.maths.wavelet.*; 5 import JSci.maths.*; 6 7 13 public final class Daubechies2 extends Multiresolution implements Filter, NumericalConstants { 14 protected final static int filtretype=2; 15 protected final static int minlength=4; 16 17 30 public int getFilterType () { 31 return(filtretype); 32 } 33 34 public MultiscaleFunction primaryScaling(int n0, int k) { 35 return(new Scaling2(n0,k)); 36 } 37 38 public MultiscaleFunction dualScaling(int n0, int k) { 39 return(new Scaling2(n0,k)); 40 } 41 public MultiscaleFunction primaryWavelet(int n0, int k) { 42 return(new Wavelet2(n0,k)); 43 } 44 public MultiscaleFunction dualWavelet(int n0, int k) { 45 return(new Wavelet2(n0,k)); 46 } 47 48 49 50 final static double[] vgtemp={0.482962913145,0.836516303738,0.224143868042,-0.129409522551}; 51 final static double[] v0temp={0.848528137424,-0.529150262213}; 52 final static double[] v1temp={0.132287565553, 0.212132034356, 0.838525491562,- 0.484122918276}; 53 54 final static double[] vd0temp={ 55 0.848528137424, 56 0.529150262213}; 57 58 final static double[] vd1temp={ 59 -0.132287565553, 60 0.212132034356, 61 0.838525491562, 62 0.484122918276}; 63 64 final static double[] vg=ArrayMath.scalarMultiply(SQRT2,vgtemp); 65 final static double[] vd0=ArrayMath.scalarMultiply(SQRT2,ArrayMath.invert(vd0temp)); 66 final static double[] vd1=ArrayMath.scalarMultiply(SQRT2,ArrayMath.invert(vd1temp)); 67 final static double[] v0=ArrayMath.scalarMultiply(SQRT2,v0temp); 68 final static double[] v1=ArrayMath.scalarMultiply(SQRT2,v1temp); 69 70 71 75 final static double[] phvg=WaveletMath.lowToHigh(vgtemp); 76 final static double[] phv0={-0.512347538298, -0.821583836258, 0.216506350947, -0.125}; 77 78 final static double[] phvd0temp={ 79 0.512347538298, 80 -0.821583836258, 81 0.216506350946, 82 0.125}; 83 final static double[] phvd0=ArrayMath.invert(phvd0temp); 84 85 95 public int previousDimension (int k) { 96 return(Cascades.previousDimension(filtretype,k)); 97 } 98 99 100 public Daubechies2 () {} 101 102 109 public double[] lowpass (double[] v, double[] param) { 110 return(lowpass(v)); 111 } 112 113 122 public double[] highpass (double[] v, double[] param) { 123 return(highpass(v)); 124 } 125 126 133 public double[] lowpass (double[] gete) { 134 if(gete.length<minlength) { 135 throw new IllegalScalingException("The array is not long enough: "+gete.length+" < "+minlength); 136 } 137 double[] sortie=new double[2*gete.length-2]; 138 int dl0=gete.length-1; 139 for(int k=2;k<=dl0-2;k++) { 140 for(int L=-2;L<2;L++){ 141 sortie[2*k+L]+=vg[L+2]*gete[k]; 142 } 143 } 144 sortie=ArrayMath.add(sortie,gete[0],v0,0); 145 sortie=ArrayMath.add(sortie,gete[1],v1,0); 146 int p0=sortie.length-vd0.length; 147 int p1=sortie.length-vd1.length; 148 sortie=ArrayMath.add(sortie,gete[dl0],vd0,p0); 149 sortie=ArrayMath.add(sortie,gete[dl0-1],vd1,p1); 150 return(sortie); 151 } 152 153 162 public double[] highpass(double[] gete) { 163 double[] sortie=new double[2*gete.length+2]; 164 int dl0=gete.length-1; 165 for(int k=1;k<=dl0-1;k++) { 166 for(int L=-2;L<2;L++){ 167 sortie[2*k+L + 2 ]+=phvg[L+2]*gete[k]; 168 } 169 } 170 sortie=ArrayMath.add(sortie,gete[0],phv0,0); 171 int p0=sortie.length-phvd0.length; 172 sortie=ArrayMath.add(sortie,gete[dl0],phvd0,p0); 173 return(sortie); 174 } 175 176 177 public double[] evalScaling (int n0, int k, int j1) { 178 return(Cascades.evalScaling(this,n0,j1,k)); 179 } 180 181 public double[] evalWavelet (int n0, int k, int j1) { 182 return(Cascades.evalWavelet(this,filtretype,n0,j1,k)); 183 } 185 186 } 187
| Popular Tags
|