All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JSci.maths.wavelet.daubechies2.FastDaubechies2 Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci.maths.wavelet.daubechies2;

import JSci.maths.wavelet.FWT;

/************************
* This is a very fast implementation of the
* Fast Wavelet Transform. It uses in-place computations
* for less memory usage. Data length should be
* a power of 2 a be at least of length 4.
* Handles boundaries by assuming periodicity.
* Ideal for image processing or processing large
* amount of data. Uses floats for more performance.
* Safety is minimal, so be careful!
* @author Daniel Lemire
*************************/
public final class FastDaubechies2 extends FWT  {
  static final private float root3 =  (float)(Math.sqrt(3.0));
  static final private float normalizer = (float)(Math.pow(2d,-.5d));
  static final float[] scale = {(1f+(root3))*normalizer/4f,(3f+(root3))*normalizer/4f,(3f+(-1*(root3)))*normalizer/4f,(1f+(-1*(root3)))*normalizer/4f};
  static final float[] wavelet = {-(1f+(-1*(root3)))*normalizer/4f,(3f+(-1*(root3)))*normalizer/4f,-(3f+(root3))*normalizer/4f,(1f+(root3))*normalizer/4f};


  public FastDaubechies2() {
  }

  public static void transform (float[] v,int last) {
    float[] ans=new float[last];
    final int half=last/2;
    try {
      for(int k=0;/*k4;last/=2) {
      transform(v,last);
    }
    if(last!=4)
      System.err.println("Careful! this should be a power of 2 : "+v.length);
  }

  public void invTransform(float[] v) {
    int last;
    for (last=4;2*last<=v.length;last*=2) {
      invTransform(v,last);
    }
    if(last!=v.length)
      System.err.println("Careful! this should be a power of 2 : "+v.length);

  }

  public static void invTransform (float[] v, int last) {
    int ResultingLength=2*last;
    float[] ans=new float[ResultingLength];
    try {
      for(int k=0;/*k




© 2015 - 2024 Weber Informatics LLC | Privacy Policy