1 package JSci.maths.wavelet.haar; 2 3 import JSci.maths.*; 4 import JSci.maths.wavelet.splines.*; 5 import JSci.maths.wavelet.*; 6 7 11 public final class MultiSplineHaar extends Multiresolution implements Filter, NumericalConstants { 12 protected final static int filtretype=0; 13 public MultiSplineHaar() {} 14 15 28 public int getFilterType () { 29 return(filtretype); 30 } 31 public MultiscaleFunction primaryScaling(int n0, int k) { 32 return(scaling(n0,k)); 33 } 34 35 public MultiscaleFunction dualScaling(int n0, int k) { 36 return(scaling(n0,k)); 37 } 38 public MultiscaleFunction primaryWavelet(int n0, int k) { 39 return(wavelet(n0,k)); 40 } 41 public MultiscaleFunction dualWavelet(int n0, int k) { 42 return(wavelet(n0,k)); 43 } 44 static final double[] vg={1d,1d}; 45 static final double[] vog={1.0/SQRT2,-1.0/SQRT2}; 46 56 public int previousDimension(int k) { 57 int i=(int) Math.round(k/2d); 58 if(2*i==k) { 59 return(i); 60 } else { 61 throw new IllegalScalingException("Odd number of values into an even Filter. Please change the number of values."); 62 } 63 } 64 65 67 public double[] lowpass (double[] v, double[] param) { 68 return(lowpass(v)); 69 } 70 71 80 public double[] highpass (double[] v, double[] param) { 81 return(highpass(v)); 82 } 83 84 87 public double[] lowpass(double[] gete) { 88 if(gete.length<1) { 89 throw new IllegalArgumentException ("The array is not long enough : "+gete.length+" < 1"); 90 } 91 double[] sortie=new double[2*gete.length]; 92 for(int k=0;k<gete.length;k++) { 93 sortie[2*k]+=gete[k]*vg[0]; 94 sortie[2*k+1]+=gete[k]*vg[1]; 95 } 96 return(sortie); 97 } 98 107 public double[] highpass(double[] gete) { 108 if(gete.length<1) { 109 throw new IllegalArgumentException ("The array is not long enough : "+gete.length+" < 1"); 110 } 111 double[] sortie=new double[2*gete.length]; 112 for(int k=0;k<gete.length;k++) { 113 sortie[2*k]+=gete[k]*vog[0]; 114 sortie[2*k+1]+=gete[k]*vog[1]; 115 } 116 return(sortie); 117 } 118 119 120 122 public static PiecewiseConstant scaling(int n0, int k) { 123 if((k<0)||(n0<0)||(k>=n0)) { 124 throw new IllegalArgumentException ("Incorrect parameters : "+n0+", "+k); 125 } 126 double[] v=new double[n0]; 127 v[k]=1; 128 return(new PiecewiseConstant(v)); 129 } 130 131 133 public static PiecewiseConstant wavelet(int n0, int k) { 134 if((k<0)||(n0<0)||(k>=n0)) { 135 throw new IllegalArgumentException ("Incorrect parameters : "+n0+", "+k); 136 } 137 double[] v=new double[2*n0]; 138 v[2*k]=vog[0]; 139 v[2*k+1]=vog[1]; 140 return(new PiecewiseConstant(v)); 141 } 142 } 143 | Popular Tags |