asu.seismo.signals.oned
Class blurset

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

public class blurset
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 cost function for the psf.

These cost functions can be minimized by any minimization algorithm.

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 to 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 minimization 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 blurset.objectivef
          This class represents the function
||f_hat*h_hat-g||_2^2 + \lambda_f * ||f_hat||_{normf}.
 class blurset.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 g
          the real and blurred signal and the psf.
protected  doubleSignal1dfft h
          the real and blurred signal and the psf.
 
Constructor Summary
blurset(doubleSignal1d blured, doubleSignal1d real, doubleSignal1d psf)
          constructor with all the needed signals.
 
Method Summary
static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, char mode, double lambda, int norm)
          As deconvf(doubleSignal1d g,psf1d h,char mode,double lambda,int regNorm,double eps,int verbose,double Beta) with
eps1e-6 verbose0 (i.e.
static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, char mode, double lambda, int regNorm, double eps, int verbose, double Beta)
          deconvolve g given h.
static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, double lambda)
          As deconvf(doubleSignal1d g,psf1d h,char mode,double lambda,int regNorm,double eps,int verbose,double Beta) with
mode'f' regNorm1 (i.e.
static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, double lambda, int norm)
          As deconvf(doubleSignal1d g,psf1d h,char mode,double lambda,int regNorm,double eps,int verbose,double Beta) with
mode'f' eps1e-6 verbose0 (i.e.
static psf1d deconvh(doubleSignal1d g, doubleSignal1d f, double lambda)
           
static psf1d deconvh(doubleSignal1d g, doubleSignal1d f, double lambda, int regNorm)
           
static psf1d deconvh(doubleSignal1d g, doubleSignal1d f, double lambda, int regNorm, double eps, int verbose)
           
 double fitToData_f()
           
 double fitToData_f(boolean returngrad, doubleSignal1d grad)
          fit to data functional with gradient wrt f. i.e.
 double fitToData_h()
           
 double fitToData_h(boolean returngrad, doubleSignal1d grad)
          fit to data functional with gradient wrt h.
 doubleSignal1dfft get_blured()
          return blurred function.
 doubleSignal1dfft get_psf()
          return point spread function.
 doubleSignal1dfft get_real()
          return the "real" function.
 double getBeta()
           
 doubleSignal1dfft getF_hat()
          return f_hat.
 doubleSignal1dfft getG_hat()
          return g_hat, that is g_hat=f_hat * h_hat.
 doubleSignal1dfft getH_hat()
          return h_hat.
 blurset.objectivef getJf()
          return the debluring objective function wrt f.
 blurset.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.
 void setBeta(double Beta)
          set beta, used to make the TV norm diffb.
 void setLambdaf(double v)
          regularization parameter \lambda_f.
 void setLambdah(double v)
          regularization parameter \lambda_h.
 void setNormf(int n)
          the norm used for the regularization wrt f.
 void setNormh(int n)
          the norm used for the regularization wrt h.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g

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


f

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


h

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

Constructor Detail

blurset

public blurset(doubleSignal1d blured,
               doubleSignal1d real,
               doubleSignal1d psf)
        throws invalid_data_exception,
               size_mismatch_exception
constructor with all the needed signals.
blurredThe blurred signal
realThe real signal. Only the length is needed.
psfThe point spread function, again only the length is needed.

Throws:
invalid_data_exception
size_mismatch_exception
Method Detail

setBeta

public void setBeta(double Beta)
set beta, used to make the TV norm diffb. The smaller beta the sharper the edges and the slower the convergence.


getBeta

public double getBeta()

setLambdaf

public void setLambdaf(double v)
regularization parameter \lambda_f. The cost function return by GetJf() will have the form: ||f_hat*h_hat-g||_2^2+\lambda_f*||f_hat||_{Normf}


setLambdah

public void setLambdah(double v)
regularization parameter \lambda_h. The cost function return by GetJh() will have the form: ||f_hat*h_hat-g||_2^2+\lambda_h*||h_hat||_{Normh}


setNormf

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


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.


getF_hat

public doubleSignal1dfft getF_hat()
return f_hat. Use getF_hat().assign(...) to assign a new value for f_hat.


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, that is g_hat=f_hat * h_hat.


get_real

public doubleSignal1dfft get_real()
return the "real" function. This function returns the real function passed to the constructor


get_blured

public doubleSignal1dfft get_blured()
return blurred function. This function returns the blurred function passed to the constructor.


get_psf

public doubleSignal1dfft get_psf()
return point spread function. This function returns the point spread function passed to the constructor.


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.


getJf

public blurset.objectivef getJf()
return the debluring objective function wrt f.
The function returned represents the function
||f_hat*h_hat-g||_2^2 + \lambda_f * ||f_hat||_{normf}.
The class is also able to return the gradient of the functional. The more "deblured" the signal the smaller the value of this function. Finding the signal f_hat that minimizes this functional will yield the deblurred signal.
The parameter \lambda_f represents a trade off between the smoothness of the best fitting f_hat and the fit to data of the forward projection g_hat to the given data (i.e. g_hat=f_hat*h_hat).


getJh

public blurset.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 the smaller the value of this function. Finding the psf h_hat that minimizes this functional will yield the the best fitting psf between g and f_hat.
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 (i.e. g_hat=f_hat*h_hat).


fitToData_f

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

Throws:
invalid_data_exception
size_mismatch_exception

fitToData_f

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

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

deconvf

public static doubleSignal1d deconvf(doubleSignal1d g,
                                     psf1d h,
                                     double lambda)
                              throws invalid_data_exception,
                                     size_mismatch_exception,
                                     min_failed_exception
As deconvf(doubleSignal1d g,psf1d h,char mode,double lambda,int regNorm,double eps,int verbose,double Beta) with
mode
'f'
regNorm1 (i.e. TV)
eps1e-6
verbose0 (i.e. No debug output
Betastd_beta (standard \beta)

Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception

deconvf

public static doubleSignal1d deconvf(doubleSignal1d g,
                                     psf1d h,
                                     double lambda,
                                     int norm)
                              throws invalid_data_exception,
                                     size_mismatch_exception,
                                     min_failed_exception
As deconvf(doubleSignal1d g,psf1d h,char mode,double lambda,int regNorm,double eps,int verbose,double Beta) with
mode
'f'
eps1e-6
verbose0 (i.e. No debug output
Betastd_beta (standard \beta defined in doubleSignal1d.java)

Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception

deconvf

public static doubleSignal1d deconvf(doubleSignal1d g,
                                     psf1d h,
                                     char mode,
                                     double lambda,
                                     int norm)
                              throws invalid_data_exception,
                                     size_mismatch_exception,
                                     min_failed_exception
As deconvf(doubleSignal1d g,psf1d h,char mode,double lambda,int regNorm,double eps,int verbose,double Beta) with
eps1e-6
verbose0 (i.e. No debug output
Betastd_beta (standard \beta defined in doubleSignal1d.java)

Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception

deconvf

public static doubleSignal1d deconvf(doubleSignal1d g,
                                     psf1d h,
                                     char mode,
                                     double lambda,
                                     int regNorm,
                                     double eps,
                                     int verbose,
                                     double Beta)
                              throws invalid_data_exception,
                                     size_mismatch_exception,
                                     min_failed_exception
deconvolve g given h. No initialization is needed. The origial data, i.e. g is used as an initial guess. mode ... convolution mode in g=f*h 'f' for full or 'v' for valid. lambda>0 ... regularization parameter regNorm ... norm to be used on der. 1 or 2 eps>0 ... stopping parameter of the minimization verbose ... debugging output Beta>0 ... parameter to make the TV diffb

Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception

deconvh

public static psf1d deconvh(doubleSignal1d g,
                            doubleSignal1d f,
                            double lambda)
                     throws invalid_data_exception,
                            size_mismatch_exception,
                            min_failed_exception
Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception

deconvh

public static psf1d deconvh(doubleSignal1d g,
                            doubleSignal1d f,
                            double lambda,
                            int regNorm)
                     throws invalid_data_exception,
                            size_mismatch_exception,
                            min_failed_exception
Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception

deconvh

public static psf1d deconvh(doubleSignal1d g,
                            doubleSignal1d f,
                            double lambda,
                            int regNorm,
                            double eps,
                            int verbose)
                     throws invalid_data_exception,
                            size_mismatch_exception,
                            min_failed_exception
Throws:
invalid_data_exception
size_mismatch_exception
min_failed_exception