asu.seismo.signals.oned
Class blursetCumFG

java.lang.Object
  extended by asu.seismo.signals.oned.blursetCumFG

public class blursetCumFG
extends java.lang.Object

This class contains everything needed for the deconvolution

i)the real (unblurred) signal (if known, otherwise only the length is needed)
ii)the real psf that blurs the signal
iii)the parameters (\lambda_f, \lambda_h and the norms to be used to regularize)
iv)the estimation of the real signal f_hat
v)the estimation of the real psf h_hat

This class also provides a cost function to be minimized to deconvolve the signal and a costfunction for the psf.

These costfunctions can be minimized by any minimization algoruthm.

Sample program to deblur a signal

Suppose we want to deblur a signal stored in the ASCII file "g.ascii" as a column vector g. We assume that g is result of the convolution of a vector f with the point spread function h and that h is a Gauss-bell shaped function with \sigma=0.08.
g=f*h+noise

import signals.*;     // needed for the exceptions
import signals.oned.*;  // 1d signals
import signals.min1d.*; // minimization routine
public class example1 {
        public static void main(String[] args)
                throws java.io.IOException,    // loading the vector could fail
                       invalid_data_exception, // should not happen, but must be dealt with
                       size_mismatch_exception { // same thing here

                doubleSignal1dfft g=new doubleSignal1dfft(doubleSignal1d.loadASCII("g.ascii")); // load g

                // create psf with a size of 256 points.
                psf1d h=psf1d.gauss(1024,.08);
                // a suitable delta function
                psf1d d=psf1d.delta(1024);
                // initial guess. Note in this case the size of f_hat_0 is
                // larger the the size of g. The full convolution with
                // the delta function pads the original signal with zeros.
                // The PSF has to be converted into a representation with FFT data.
                doubleSignal1dfft f_hat_0=doubleSignal1dfft.conv(g,new doubleSignal1dfft(d),'f');
                // Now we have all we need to deblur g.

                // Note that f_hat_0 is passed as the true signal since the true
                // signal is unknown.
                blurset b=new blurset(g,f_hat_0,h);
                // set regularization parameter. Use TV-Norm.
                b.setLambdaf(.1); b.setNormf(1);
                // set initial guess for the signal.
                b.getF_hat().assign(f_hat_0);
                // use h as point spread function
                b.getH_hat().assign(h);
                // Create a minimazation object using the matrix free BFGS version. b.getJf() is the
                // cost function, b.getF_hat() is the initial guess of f_hat. Minimum is reached if
                // the gradient decreases by a factor of 1000 form the initial gradient
                fminbfgsmf1d min=new fminbfgsmf1d(b.getJf(),b.getF_hat(),1e-3);
                // iterate until min is reached.
                while(!min.isMin())min.step();
                // save result as f_hat.ascii
                b.getF_hat().saveASCII("f_hat.ascii");
        }
}
    


Nested Class Summary
 class blursetCumFG.objectiveh
          This class represents the function
||f_hat*h_hat-g||_2^2 + \lambda_h * ||h_hat||_{normh}.
 
Field Summary
protected  doubleSignal1dfft f
          the real and blurred signal and the psf.
protected  doubleSignal1dfft grad_temp_h
          the real and blurred signal and the psf.
protected  doubleSignal1dfft h
          the real and blurred signal and the psf.
protected  doubleSignal1dfft h_hat
          the real and blurred signal and the psf.
protected  doubleSignal1dfft Res
          the real and blurred signal and the psf.
 
Constructor Summary
blursetCumFG(doubleSignal1d blured, doubleSignal1d real, doubleSignal1d psf, int n)
          constructor with all the needed signals.
 
Method Summary
 void addPair(doubleSignal1d G, doubleSignal1d F, double Weight)
           
 double fitToData_h()
           
 double fitToData_h(boolean returngrad, doubleSignal1d grad)
          fit to data functional with gradient wrt h.
 doubleSignal1dfft[] getG_hat()
          return g_hat. f_hat * h_hat.
 doubleSignal1dfft getH_hat()
          return h_hat.
 blursetCumFG.objectiveh getJh()
          return the debluring objective function wrt h.
 double getLambdaf()
          return \lambda_f
 double getLambdah()
          return \lambda_h
 int getNormf()
          return the norm used for the regularization wrt f.
 int getNormh()
          return the norm used for the regularization wrt h.
 double getWeight(int i)
           
 void normWeights(double nf)
          normalize weights to the normalization factor nf
 void setBeta(double Beta)
           
 void setLambdah(double v)
           
 void setNormh(int n)
          the norm used for the regularization wrt h.
 void setWeight(int i, double w)
          set the weight for the i-th signal
 double sumWeights()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

f

protected doubleSignal1dfft f
the real and blurred signal and the psf.


h

protected doubleSignal1dfft h
the real and blurred signal and the psf.


h_hat

protected doubleSignal1dfft h_hat
the real and blurred signal and the psf.


grad_temp_h

protected doubleSignal1dfft grad_temp_h
the real and blurred signal and the psf.


Res

protected doubleSignal1dfft Res
the real and blurred signal and the psf.

Constructor Detail

blursetCumFG

public blursetCumFG(doubleSignal1d blured,
                    doubleSignal1d real,
                    doubleSignal1d psf,
                    int n)
             throws invalid_data_exception,
                    size_mismatch_exception
constructor with all the needed signals.
blurredthe blurred signal
realthe real signal. The only thing needed is the length of this signal.
psfthe point spread function. Again only the length is needed.

Throws:
invalid_data_exception
size_mismatch_exception
Method Detail

addPair

public void addPair(doubleSignal1d G,
                    doubleSignal1d F,
                    double Weight)
             throws invalid_data_exception
Throws:
invalid_data_exception

getWeight

public double getWeight(int i)

normWeights

public void normWeights(double nf)
normalize weights to the normalization factor nf


sumWeights

public double sumWeights()

setBeta

public void setBeta(double Beta)

setLambdah

public void setLambdah(double v)

setNormh

public void setNormh(int n)
the norm used for the regularization wrt h.
1 is the Total variation norm.
2 is the Tikhonov norm.


setWeight

public void setWeight(int i,
                      double w)
set the weight for the i-th signal


getH_hat

public doubleSignal1dfft getH_hat()
return h_hat. Use getH_hat().assign(...) to assign a new value for h_hat.


getG_hat

public doubleSignal1dfft[] getG_hat()
return g_hat. f_hat * h_hat.


getLambdaf

public double getLambdaf()
return \lambda_f


getLambdah

public double getLambdah()
return \lambda_h


getNormf

public int getNormf()
return the norm used for the regularization wrt f. See setFormf() for details.


getNormh

public int getNormh()
return the norm used for the regularization wrt h. See setNormh() for details.


getJh

public blursetCumFG.objectiveh getJh()
return the debluring objective function wrt h.
The function returned represents the function
||f_hat*h_hat-g||_2^2 + \lambda_h * ||h_hat||_{normh}.
The class is also able to return the gradient of the functional. The more "deblured" the signal is the smaller is the value of this function, so that finding the psf h_hat that minimizes this functional will yield the the psf between g and f_hat.
Note that the parameter \lambda_h represents a trade off between the smoothness of the best fitting h_hat and the fit to data of the forward projection g_hat to the given data (g_hat=f_hat*h_hat).


fitToData_h

public double fitToData_h(boolean returngrad,
                          doubleSignal1d grad)
                   throws invalid_data_exception,
                          size_mismatch_exception
fit to data functional with gradient wrt h. i.e. ||f_hat*h_hat-g||_2^2.

Throws:
invalid_data_exception
size_mismatch_exception

fitToData_h

public double fitToData_h()
                   throws invalid_data_exception,
                          size_mismatch_exception
Throws:
invalid_data_exception
size_mismatch_exception