|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectasu.seismo.signals.oned.blursetCumFG
public class blursetCumFG
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.
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 |
---|
protected doubleSignal1dfft f
protected doubleSignal1dfft h
protected doubleSignal1dfft h_hat
protected doubleSignal1dfft grad_temp_h
protected doubleSignal1dfft Res
Constructor Detail |
---|
public blursetCumFG(doubleSignal1d blured, doubleSignal1d real, doubleSignal1d psf, int n) throws invalid_data_exception, size_mismatch_exception
blurred | the blurred signal |
real | the real signal. The only thing needed is the length of this signal. |
psf | the point spread function. Again only the length is needed. |
invalid_data_exception
size_mismatch_exception
Method Detail |
---|
public void addPair(doubleSignal1d G, doubleSignal1d F, double Weight) throws invalid_data_exception
invalid_data_exception
public double getWeight(int i)
public void normWeights(double nf)
public double sumWeights()
public void setBeta(double Beta)
public void setLambdah(double v)
public void setNormh(int n)
public void setWeight(int i, double w)
public doubleSignal1dfft getH_hat()
public doubleSignal1dfft[] getG_hat()
public double getLambdaf()
public double getLambdah()
public int getNormf()
public int getNormh()
public blursetCumFG.objectiveh getJh()
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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |