1 package JSci.maths.wavelet.cdf3_5; 2 3 import JSci.maths.wavelet.*; 4 import JSci.maths.*; 5 6 7 14 public final class CDF3_5 extends Multiresolution implements Filter { 15 protected final static int filtretype=2; 16 protected final static int minlength=12; 17 30 public int getFilterType () { 31 return(filtretype); 32 } 33 34 public MultiscaleFunction primaryScaling(int n0, int k) { 35 return(MultiSpline3_5.scaling(n0,k)); 36 } 37 38 public MultiscaleFunction dualScaling(int n0, int k) { 39 return(new DualScaling3_5(n0,k)); 40 } 41 public MultiscaleFunction primaryWavelet(int n0, int k) { 42 return(MultiSpline3_5.wavelet(n0,k)); 43 } 44 public MultiscaleFunction dualWavelet(int n0, int k) { 45 return(new DualWavelet3_5(n0,k)); 46 } 47 50 final static double[] v0={8703/5120d, 14851/5120d, -7497/2560d, -4137/2560d, 4703/2560d, 5799/2560d, -3315/1024d, 1105/1024d}; 51 final static double[] v1={-983/5120d, 2949/5120d, 4977/2560d, 1617/2560d, -2423/2560d, -2559/2560d, 1515/1024d, -505/1024d}; 52 final static double[] v2={2897/51200d, -8691/51200d, -3863/25600d, 23177/25600d, 116611/76800d, 22521/25600d, -3153/2048d, 2833/6144d, 15/256d, -5/256d}; 53 final static double[] v3={-789/51200d, 2367/51200d, 531/25600d, -4749/25600d, -869/25600d, 16323/25600d, 4429/2048d, -751/2048d, -97/256d, 19/256d, 15/256d, -5/256d}; 54 final static double[] v4={7/3200d, -21/3200d, -3/1600d, 37/1600d, -3/1600d, -99/1600d, -55/128d, 189/128d, 175/128d, -13/128d, -97/256d, 19/256d, 15/256d, -5/256d}; 55 final static double[] v5={0d, 0d, 0d, 0d, 0d, 0d, 17/128d, -51/128d, -13/128d, 175/128d, 175/128d, -13/128d, -97/256d, 19/256d, 15/256d, -5/256d}; 56 final static double[] vg={-5/256d, 15/256d, 19/256d, -97/256d, -13/128d, 175/128d, 175/128d, -13/128d, -97/256d, 19/256d, 15/256d, -5/256d}; 57 final static double[] vd0=ArrayMath.invert(v0); 58 final static double[] vd1=ArrayMath.invert(v1); 59 final static double[] vd2=ArrayMath.invert(v2); 60 final static double[] vd3=ArrayMath.invert(v3); 61 final static double[] vd4=ArrayMath.invert(v4); 62 final static double[] vd5=ArrayMath.invert(v5); 63 64 65 67 final static double[] phvg={-1/2d, 3/2d, -3/2d, 1/2d}; 68 69 79 public int previousDimension (int k) { 80 return(Cascades.previousDimension(filtretype,k)); 81 } 82 83 84 public CDF3_5 () {} 85 86 93 public double[] lowpass (double[] v, double[] param) { 94 return(lowpass(v)); 95 } 96 97 106 public double[] highpass (double[] v, double[] param) { 107 return(highpass(v)); 108 } 109 110 117 public double[] lowpass (double[] gete) { 118 if(gete.length<12) { 119 throw new IllegalScalingException("The array is not long enough : "+gete.length+" < 12"); 120 } 121 double[] sortie=new double[2*gete.length-2]; 122 int dl0=gete.length-1; 123 for(int k=6;k<=dl0-6;k++) { 124 for(int L=-6;L<=5;L++){ 125 sortie[2*k+L]+=vg[L+6]*gete[k]; 126 } 127 } 128 sortie=ArrayMath.add(sortie,gete[0],v0,0); 129 sortie=ArrayMath.add(sortie,gete[1],v1,0); 130 sortie=ArrayMath.add(sortie,gete[2],v2,0); 131 sortie=ArrayMath.add(sortie,gete[3],v3,0); 132 sortie=ArrayMath.add(sortie,gete[4],v4,0); 133 sortie=ArrayMath.add(sortie,gete[5],v5,0); 134 135 int p0=sortie.length-vd0.length; 136 int p1=sortie.length-vd1.length; 137 int p2=sortie.length-vd2.length; 138 int p3=sortie.length-vd3.length; 139 int p4=sortie.length-vd4.length; 140 int p5=sortie.length-vd5.length; 141 142 sortie=ArrayMath.add(sortie,gete[dl0],vd0,p0); 143 sortie=ArrayMath.add(sortie,gete[dl0-1],vd1,p1); 144 sortie=ArrayMath.add(sortie,gete[dl0-2],vd2,p2); 145 sortie=ArrayMath.add(sortie,gete[dl0-3],vd3,p3); 146 sortie=ArrayMath.add(sortie,gete[dl0-4],vd4,p4); 147 sortie=ArrayMath.add(sortie,gete[dl0-5],vd5,p5); 148 149 return(sortie); 150 } 151 152 161 public double[] highpass(double[] v) { 162 if(v.length<4) { 163 throw new IllegalScalingException("The array is not long enough : "+v.length+" < 4"); 164 } 165 double[] ans=new double[2*v.length+2]; 166 for(int k=0;k<v.length;k++) { 167 ans[2*k]+=v[k]*phvg[0]; 168 ans[2*k+1]+=v[k]*phvg[1]; 169 ans[2*k+2]+=v[k]*phvg[2]; 170 ans[2*k+3]+=v[k]*phvg[3]; 171 } 172 return(ans); 173 } 174 175 177 public double[] evalScaling (int n0, int k, int j1) { 178 return(Cascades.evalScaling(this,n0,j1,k)); 179 } 180 181 183 public double[] evalWavelet (int n0, int k, int j1) { 184 return(Cascades.evalWaveletQuadratic(this,n0,j1,k)); 185 } 186 187 } 188 | Popular Tags |