|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectasu.seismo.signals.oned.blurset
public class blurset
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.
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 |
---|
protected doubleSignal1dfft g
protected doubleSignal1dfft f
protected doubleSignal1dfft h
Constructor Detail |
---|
public blurset(doubleSignal1d blured, doubleSignal1d real, doubleSignal1d psf) throws invalid_data_exception, size_mismatch_exception
blurred | The blurred signal |
real | The real signal. Only the length is needed. |
psf | The point spread function, again only the length is needed. |
invalid_data_exception
size_mismatch_exception
Method Detail |
---|
public void setBeta(double Beta)
public double getBeta()
public void setLambdaf(double v)
public void setLambdah(double v)
public void setNormf(int n)
public void setNormh(int n)
public doubleSignal1dfft getF_hat()
public doubleSignal1dfft getH_hat()
public doubleSignal1dfft getG_hat()
public doubleSignal1dfft get_real()
public doubleSignal1dfft get_blured()
public doubleSignal1dfft get_psf()
public double getLambdaf()
public double getLambdah()
public int getNormf()
public int getNormh()
public blurset.objectivef getJf()
public blurset.objectiveh getJh()
public double fitToData_f(boolean returngrad, doubleSignal1d grad) throws invalid_data_exception, size_mismatch_exception
invalid_data_exception
size_mismatch_exception
public double fitToData_f() throws invalid_data_exception, size_mismatch_exception
invalid_data_exception
size_mismatch_exception
public double fitToData_h(boolean returngrad, doubleSignal1d grad) throws invalid_data_exception, size_mismatch_exception
invalid_data_exception
size_mismatch_exception
public double fitToData_h() throws invalid_data_exception, size_mismatch_exception
invalid_data_exception
size_mismatch_exception
public static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, double lambda) throws invalid_data_exception, size_mismatch_exception, min_failed_exception
moderegNorm | 1 (i.e. TV)
| eps | 1e-6
| verbose | 0 (i.e. No debug output
| Beta | std_beta (standard \beta)
| |
invalid_data_exception
size_mismatch_exception
min_failed_exception
public static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, double lambda, int norm) throws invalid_data_exception, size_mismatch_exception, min_failed_exception
modeeps | 1e-6
| verbose | 0 (i.e. No debug output
| Beta | std_beta (standard \beta defined in doubleSignal1d.java)
| |
invalid_data_exception
size_mismatch_exception
min_failed_exception
public static doubleSignal1d deconvf(doubleSignal1d g, psf1d h, char mode, double lambda, int norm) throws invalid_data_exception, size_mismatch_exception, min_failed_exception
eps | 1e-6 |
verbose | 0 (i.e. No debug output |
Beta | std_beta (standard \beta defined in doubleSignal1d.java) |
invalid_data_exception
size_mismatch_exception
min_failed_exception
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
invalid_data_exception
size_mismatch_exception
min_failed_exception
public static psf1d deconvh(doubleSignal1d g, doubleSignal1d f, double lambda) throws invalid_data_exception, size_mismatch_exception, min_failed_exception
invalid_data_exception
size_mismatch_exception
min_failed_exception
public static psf1d deconvh(doubleSignal1d g, doubleSignal1d f, double lambda, int regNorm) throws invalid_data_exception, size_mismatch_exception, min_failed_exception
invalid_data_exception
size_mismatch_exception
min_failed_exception
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
invalid_data_exception
size_mismatch_exception
min_failed_exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |