Commit 03feb56c authored by Andrey Filippov's avatar Andrey Filippov

more debugging of the factorization, experimenting

parent 19b8b05a
...@@ -1656,7 +1656,9 @@ public class EyesisCorrectionParameters { ...@@ -1656,7 +1656,9 @@ public class EyesisCorrectionParameters {
public int LMA_steps = 100; public int LMA_steps = 100;
public double fact_precision=0.003; // stop iterations if error rms less than this part of target kernel rms public double fact_precision=0.003; // stop iterations if error rms less than this part of target kernel rms
public double compactness = 1.0; public double compactness = 1.0;
public int asym_tax_free = 5; // "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free public int asym_tax_free = 5; // "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free
public int seed_size = 8; // number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells)
public double asym_random; // initialize asym_kernel with random numbers
public double dbg_x =0; public double dbg_x =0;
public double dbg_y =0; public double dbg_y =0;
public double dbg_x1 =0; public double dbg_x1 =0;
...@@ -1665,7 +1667,15 @@ public class EyesisCorrectionParameters { ...@@ -1665,7 +1667,15 @@ public class EyesisCorrectionParameters {
public String dbg_mask = ".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::........."; public String dbg_mask = ".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::.........";
public int dbg_mode = 1; // 0 - old LMA, 1 - new LMA public int dbg_mode = 1; // 0 - old LMA, 1 - new LMA
public DCTParameters(int dct_size, int asym_size, int asym_pixels, int asym_distance, int dct_window, double compactness, int asym_tax_free) { public DCTParameters(
int dct_size,
int asym_size,
int asym_pixels,
int asym_distance,
int dct_window,
double compactness,
int asym_tax_free,
int seed_size) {
this.dct_size = dct_size; this.dct_size = dct_size;
this.asym_size = asym_size; this.asym_size = asym_size;
this.asym_pixels = asym_pixels; this.asym_pixels = asym_pixels;
...@@ -1673,6 +1683,7 @@ public class EyesisCorrectionParameters { ...@@ -1673,6 +1683,7 @@ public class EyesisCorrectionParameters {
this.dct_window = dct_window; this.dct_window = dct_window;
this.compactness = compactness; this.compactness = compactness;
this.asym_tax_free = asym_tax_free; this.asym_tax_free = asym_tax_free;
this.seed_size = seed_size;
} }
public void setProperties(String prefix,Properties properties){ public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"dct_size",this.dct_size+""); properties.setProperty(prefix+"dct_size",this.dct_size+"");
...@@ -1683,6 +1694,9 @@ public class EyesisCorrectionParameters { ...@@ -1683,6 +1694,9 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"compactness", this.compactness+""); properties.setProperty(prefix+"compactness", this.compactness+"");
properties.setProperty(prefix+"fact_precision", this.fact_precision+""); properties.setProperty(prefix+"fact_precision", this.fact_precision+"");
properties.setProperty(prefix+"asym_tax_free", this.asym_tax_free+""); properties.setProperty(prefix+"asym_tax_free", this.asym_tax_free+"");
properties.setProperty(prefix+"seed_size", this.seed_size+"");
properties.setProperty(prefix+"asym_random", this.asym_random+"");
properties.setProperty(prefix+"LMA_steps", this.LMA_steps+""); properties.setProperty(prefix+"LMA_steps", this.LMA_steps+"");
properties.setProperty(prefix+"dbg_x", this.dbg_x+""); properties.setProperty(prefix+"dbg_x", this.dbg_x+"");
properties.setProperty(prefix+"dbg_y", this.dbg_y+""); properties.setProperty(prefix+"dbg_y", this.dbg_y+"");
...@@ -1702,6 +1716,8 @@ public class EyesisCorrectionParameters { ...@@ -1702,6 +1716,8 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"compactness")!=null) this.compactness=Double.parseDouble(properties.getProperty(prefix+"compactness")); if (properties.getProperty(prefix+"compactness")!=null) this.compactness=Double.parseDouble(properties.getProperty(prefix+"compactness"));
if (properties.getProperty(prefix+"fact_precision")!=null) this.fact_precision=Double.parseDouble(properties.getProperty(prefix+"fact_precision")); if (properties.getProperty(prefix+"fact_precision")!=null) this.fact_precision=Double.parseDouble(properties.getProperty(prefix+"fact_precision"));
if (properties.getProperty(prefix+"asym_tax_free")!=null) this.asym_tax_free=Integer.parseInt(properties.getProperty(prefix+"asym_tax_free")); if (properties.getProperty(prefix+"asym_tax_free")!=null) this.asym_tax_free=Integer.parseInt(properties.getProperty(prefix+"asym_tax_free"));
if (properties.getProperty(prefix+"seed_size")!=null) this.seed_size=Integer.parseInt(properties.getProperty(prefix+"seed_size"));
if (properties.getProperty(prefix+"asym_random")!=null) this.asym_random=Double.parseDouble(properties.getProperty(prefix+"asym_random"));
if (properties.getProperty(prefix+"LMA_steps")!=null) this.LMA_steps=Integer.parseInt(properties.getProperty(prefix+"LMA_steps")); if (properties.getProperty(prefix+"LMA_steps")!=null) this.LMA_steps=Integer.parseInt(properties.getProperty(prefix+"LMA_steps"));
if (properties.getProperty(prefix+"dbg_x")!=null) this.dbg_x=Double.parseDouble(properties.getProperty(prefix+"dbg_x")); if (properties.getProperty(prefix+"dbg_x")!=null) this.dbg_x=Double.parseDouble(properties.getProperty(prefix+"dbg_x"));
if (properties.getProperty(prefix+"dbg_y")!=null) this.dbg_y=Double.parseDouble(properties.getProperty(prefix+"dbg_y")); if (properties.getProperty(prefix+"dbg_y")!=null) this.dbg_y=Double.parseDouble(properties.getProperty(prefix+"dbg_y"));
...@@ -1722,7 +1738,8 @@ public class EyesisCorrectionParameters { ...@@ -1722,7 +1738,8 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Compactness (punish off-center asym_kernel pixels (proportional to r^2)", this.compactness, 2); //0..2 gd.addNumericField("Compactness (punish off-center asym_kernel pixels (proportional to r^2)", this.compactness, 2); //0..2
gd.addNumericField("Factorization target precision (stop if achieved)", this.fact_precision, 4); //0..2 gd.addNumericField("Factorization target precision (stop if achieved)", this.fact_precision, 4); //0..2
gd.addNumericField("Do not punish pixels in the square around center", this.asym_tax_free, 0); //0..2 gd.addNumericField("Do not punish pixels in the square around center", this.asym_tax_free, 0); //0..2
gd.addNumericField("Start asym_kernel with this number of pixels (0 - single, 4n+0 (X between cells), 4*n+1 - x around center cell", this.seed_size, 0); //0..2
gd.addNumericField("Initialize asym_kernel with random numbers (amplitude)", this.asym_random, 2); //0..2
gd.addNumericField("dbg_x", this.dbg_x, 2); //0..2 gd.addNumericField("dbg_x", this.dbg_x, 2); //0..2
gd.addNumericField("dbg_y", this.dbg_y, 2); //0..2 gd.addNumericField("dbg_y", this.dbg_y, 2); //0..2
gd.addNumericField("dbg_x1", this.dbg_x1, 2); //0..2 gd.addNumericField("dbg_x1", this.dbg_x1, 2); //0..2
...@@ -1743,6 +1760,8 @@ public class EyesisCorrectionParameters { ...@@ -1743,6 +1760,8 @@ public class EyesisCorrectionParameters {
this.compactness = gd.getNextNumber(); this.compactness = gd.getNextNumber();
this.fact_precision = gd.getNextNumber(); this.fact_precision = gd.getNextNumber();
this.asym_tax_free = (int) gd.getNextNumber(); this.asym_tax_free = (int) gd.getNextNumber();
this.seed_size = (int) gd.getNextNumber();
this.asym_random= gd.getNextNumber();
this.dbg_x= gd.getNextNumber(); this.dbg_x= gd.getNextNumber();
this.dbg_y= gd.getNextNumber(); this.dbg_y= gd.getNextNumber();
this.dbg_x1= gd.getNextNumber(); this.dbg_x1= gd.getNextNumber();
......
...@@ -90,8 +90,9 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos ...@@ -90,8 +90,9 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
10, // asym_pixels = 10; // maximal number of non-zero pixels in direct convolution kernel 10, // asym_pixels = 10; // maximal number of non-zero pixels in direct convolution kernel
2, // asym_distance = 2; // how far to try a new asym kernel pixel from existing ones 2, // asym_distance = 2; // how far to try a new asym kernel pixel from existing ones
1, // dct_window 1, // dct_window
1.0,// double compactness 1.0,// compactness
5 // asym_tax_free); 5, // asym_tax_free,
8 // seed_size
); );
public static EyesisDCT EYESIS_DCT = null; public static EyesisDCT EYESIS_DCT = null;
...@@ -2865,6 +2866,20 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos ...@@ -2865,6 +2866,20 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
if (blurSigma>0) gb=new DoubleGaussianBlur(); if (blurSigma>0) gb=new DoubleGaussianBlur();
if (blurSigma>0) gb.blurDouble(target_kernel, target_kernel_size, target_kernel_size, blurSigma, blurSigma, 0.01); if (blurSigma>0) gb.blurDouble(target_kernel, target_kernel_size, target_kernel_size, blurSigma, blurSigma, 0.01);
// SDFA_INSTANCE.showArrays(target_kernel, target_kernel_size, target_kernel_size, "target_kernel"); // SDFA_INSTANCE.showArrays(target_kernel, target_kernel_size, target_kernel_size, "target_kernel");
if (
(DCT_PARAMETERS.dbg_x == 0.0) &&
(DCT_PARAMETERS.dbg_x1 == 0.0) &&
(DCT_PARAMETERS.dbg_y == 0.0) &&
(DCT_PARAMETERS.dbg_y1 == 0.0)) {
System.out.println ("Making sure target kernel is center symmetrical (copying top-left quater)");
for (int ii = 0; ii<target_kernel_size; ii++) for (int jj = 0; jj<target_kernel_size; jj++){
int ii1 = (ii >= DCT_PARAMETERS.dct_size)? (2 * DCT_PARAMETERS.dct_size -ii -2):ii;
int jj1 = (jj >= DCT_PARAMETERS.dct_size)? (2 * DCT_PARAMETERS.dct_size -jj -2):jj;
target_kernel[target_kernel_size*ii+jj] = target_kernel[target_kernel_size*ii1+jj1];
}
}
int target_expanded_size = 2*DCT_PARAMETERS.dct_size + DCT_PARAMETERS.asym_size -2; int target_expanded_size = 2*DCT_PARAMETERS.dct_size + DCT_PARAMETERS.asym_size -2;
double [] target_expanded = new double [target_expanded_size * target_expanded_size]; double [] target_expanded = new double [target_expanded_size * target_expanded_size];
...@@ -2901,12 +2916,18 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos ...@@ -2901,12 +2916,18 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
DCT_PARAMETERS.asym_size, DCT_PARAMETERS.asym_size,
DCT_PARAMETERS.dct_size, DCT_PARAMETERS.dct_size,
DCT_PARAMETERS.fact_precision, DCT_PARAMETERS.fact_precision,
mask); mask,
DCT_PARAMETERS.seed_size,
DCT_PARAMETERS.asym_random);
System.out.println("factorConvKernel.calcKernels() returned: >>> "+result+ " <<<"); System.out.println("factorConvKernel.calcKernels() returned: >>> "+result+ " <<<");
double [] sym_kernel = factorConvKernel.getSymKernel(); double [] sym_kernel = factorConvKernel.getSymKernel();
double [] asym_kernel = factorConvKernel.getAsymKernel(); double [] asym_kernel = factorConvKernel.getAsymKernel();
double [] convolved = factorConvKernel.getConvolved(); double [] convolved = factorConvKernel.getConvolved();
double [][] compare_kernels = {target_expanded, convolved}; double [] diff100 = new double [convolved.length];
for (int ii=0;ii<convolved.length;ii++) diff100[ii]=100.0*(target_expanded[ii]-convolved[ii]);
double [][] compare_kernels = {target_expanded, convolved, diff100};
System.out.println("DCT_PARAMETERS.dct_size="+DCT_PARAMETERS.dct_size+" DCT_PARAMETERS.asym_size="+DCT_PARAMETERS.asym_size); System.out.println("DCT_PARAMETERS.dct_size="+DCT_PARAMETERS.dct_size+" DCT_PARAMETERS.asym_size="+DCT_PARAMETERS.asym_size);
System.out.println("sym_kernel.length="+ sym_kernel.length); System.out.println("sym_kernel.length="+ sym_kernel.length);
System.out.println("asym_kernel.length="+asym_kernel.length); System.out.println("asym_kernel.length="+asym_kernel.length);
...@@ -2919,7 +2940,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos ...@@ -2919,7 +2940,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
} else if (label.equals("Min Kernel Factorization")){ } else if (label.equals("Min Kernel Factorization")){
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (!DCT_PARAMETERS.showDialog()) return; if (!DCT_PARAMETERS.showDialog()) return;
FactorConvKernel factorConvKernel = new FactorConvKernel(); FactorConvKernel factorConvKernel = new FactorConvKernel(DCT_PARAMETERS.dbg_mode == 1);
factorConvKernel.setDebugLevel(DEBUG_LEVEL); factorConvKernel.setDebugLevel(DEBUG_LEVEL);
factorConvKernel.numIterations = DCT_PARAMETERS.LMA_steps; factorConvKernel.numIterations = DCT_PARAMETERS.LMA_steps;
factorConvKernel.setAsymCompactness( factorConvKernel.setAsymCompactness(
...@@ -2967,7 +2988,8 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos ...@@ -2967,7 +2988,8 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
DCT_PARAMETERS.dct_size, DCT_PARAMETERS.dct_size,
DCT_PARAMETERS.fact_precision, DCT_PARAMETERS.fact_precision,
DCT_PARAMETERS.asym_pixels, DCT_PARAMETERS.asym_pixels,
DCT_PARAMETERS.asym_distance); DCT_PARAMETERS.asym_distance,
DCT_PARAMETERS.seed_size);
/* /*
public int calcKernels( public int calcKernels(
double []target_kernel, double []target_kernel,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment