Commit 421e0704 authored by Andrey Filippov's avatar Andrey Filippov

Extracted filter parameters to a class, working on far objects

parent 8991226b
...@@ -896,22 +896,23 @@ public class CLTPass3d{ ...@@ -896,22 +896,23 @@ public class CLTPass3d{
double step_threshold, double step_threshold,
double min_disparity, double min_disparity,
double max_disparity, double max_disparity,
double strength_floor, // double strength_floor,
double strength_pow, // double strength_pow,
double stBlurSigma, double stBlurSigma,
boolean smplMode, // = true; // Use sample mode (false - regular tile mode) boolean smplMode, // = true; // Use sample mode (false - regular tile mode)
int smplSide, // = 2; // Sample size (side of a square) MeasuredLayersFilterParameters mlfp,
int smplNum, // = 3; // Number after removing worst // int smplSide, // = 2; // Sample size (side of a square)
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample // int smplNum, // = 3; // Number after removing worst
boolean smplWnd, // use window functions for the samples // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// boolean smplWnd, // use window functions for the samples
double max_abs_tilt, // 2.0; // pix per tile
double max_rel_tilt, // 0.2; // (pix / disparity) per tile // double max_abs_tilt, // 2.0; // pix per tile
double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data // double max_rel_tilt, // 0.2; // (pix / disparity) per tile
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity // double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity) // double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity) // double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
double far_power, // 3.0; // Raise disparity to this power before averaging for far objects // int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
// double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
int measSel) int measSel)
{ {
...@@ -922,21 +923,22 @@ public class CLTPass3d{ ...@@ -922,21 +923,22 @@ public class CLTPass3d{
step_threshold, step_threshold,
min_disparity, min_disparity,
max_disparity, max_disparity,
strength_floor, // strength_floor,
strength_pow, // strength_pow,
stBlurSigma, stBlurSigma,
smplMode, // = true; // Use sample mode (false - regular tile mode) smplMode, // = true; // Use sample mode (false - regular tile mode)
smplSide, // = 2; // Sample size (side of a square) mlfp,
smplNum, // = 3; // Number after removing worst // smplSide, // = 2; // Sample size (side of a square)
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample // smplNum, // = 3; // Number after removing worst
smplWnd, // final boolean smplWnd, // use window functions for the samples // smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile // smplWnd, // final boolean smplWnd, // use window functions for the samples
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data // max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity // damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
transition, // 1.0; // Mode transition range (between tilted and maximal disparity) // min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity) // transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
far_power, // 1.0; // Raise disparity to this power before averaging for far objects // far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
// far_power, // 1.0; // Raise disparity to this power before averaging for far objects
// true, // boolean null_if_none, // true, // boolean null_if_none,
measSel); measSel);
return this.superTiles; return this.superTiles;
...@@ -946,18 +948,19 @@ public class CLTPass3d{ ...@@ -946,18 +948,19 @@ public class CLTPass3d{
boolean [][] tile_sel, // null or per-measurement layer, per-tile selection. For each layer null - do not use, {} - use all boolean [][] tile_sel, // null or per-measurement layer, per-tile selection. For each layer null - do not use, {} - use all
boolean smplMode, // = true; // Use sample mode (false - regular tile mode) boolean smplMode, // = true; // Use sample mode (false - regular tile mode)
int smplSide, // = 2; // Sample size (side of a square) MeasuredLayersFilterParameters mlfp,
int smplNum, // = 3; // Number after removing worst // int smplSide, // = 2; // Sample size (side of a square)
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample // int smplNum, // = 3; // Number after removing worst
boolean smplWnd, // use window functions for the samples // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// boolean smplWnd, // use window functions for the samples
double max_abs_tilt, // 2.0; // pix per tile
double max_rel_tilt, // 0.2; // (pix / disparity) per tile // double max_abs_tilt, // 2.0; // pix per tile
double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data // double max_rel_tilt, // 0.2; // (pix / disparity) per tile
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity // double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity) // double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity) // double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
double far_power, // 3.0; // Raise disparity to this power before averaging for far objects // int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
// double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
int measSel) int measSel)
{ {
...@@ -969,18 +972,19 @@ public class CLTPass3d{ ...@@ -969,18 +972,19 @@ public class CLTPass3d{
tile_sel, // null or per-measurement layer, per-tile selection. For each layer null - do not use, {} - use all tile_sel, // null or per-measurement layer, per-tile selection. For each layer null - do not use, {} - use all
smplMode, // = true; // Use sample mode (false - regular tile mode) smplMode, // = true; // Use sample mode (false - regular tile mode)
smplSide, // = 2; // Sample size (side of a square) mlfp,
smplNum, // = 3; // Number after removing worst // smplSide, // = 2; // Sample size (side of a square)
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample // smplNum, // = 3; // Number after removing worst
smplWnd, // use window functions for the samples // smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// smplWnd, // use window functions for the samples
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data // max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity // damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
transition, // 1.0; // Mode transition range (between tilted and maximal disparity) // min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity) // transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
far_power, // 1.0; // Raise disparity to this power before averaging for far objects // far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
// far_power, // 1.0; // Raise disparity to this power before averaging for far objects
measSel); measSel);
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
...@@ -246,8 +246,8 @@ public class MacroCorrelation { ...@@ -246,8 +246,8 @@ public class MacroCorrelation {
min_corr_selected, // 0.0001; // minimal correlation value to consider valid min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius, clt_parameters.max_corr_radius,
clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center) // clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width) // clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
......
This diff is collapsed.
import java.util.Properties;
/**
**
** MeasuredLayersFilterParameters - parameters defining tile filters
**
** Copyright (C) 2018 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** ImageDtt.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
public class MeasuredLayersFilterParameters {
public double strength_sure = 0.25; // Do not filter disparity above this strength
public double strength_floor = 0.1; // Subtract from strength, discard negative
public double strength_pow = 1.0; // raise strength to this power
public int smplSide = 3; // Sample size (side of a square)
public int smplNum = 5; // Number after removing worst
public double smplRms = 0.3; // Maximal RMS of the remaining tiles in a sample
public boolean smplWnd = false; // Use window function for the samples (TODO: change default to true after testing)
public double max_abs_tilt = 2.0; // Maximal absolute tilt in pixels/tile
public double max_rel_tilt = 0.2; // Maximal relative tilt in pixels/tile/disparity
public double damp_tilt = 0.001; // Tilt cost for damping insufficient plane data
public double min_tilt_disp = 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
public double transition = 1.0; // Mode transition range (between tilted and maximal disparity)
public int far_mode = 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
public double far_power = 3.0; // Raise disparity to this power before averaging for far objects
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"strength_sure", this.strength_sure +"");
properties.setProperty(prefix+"strength_floor", this.strength_floor +"");
properties.setProperty(prefix+"strength_pow", this.strength_pow +"");
properties.setProperty(prefix+"smplSide", this.smplSide+"");
properties.setProperty(prefix+"smplNum", this.smplNum+"");
properties.setProperty(prefix+"smplRms", this.smplRms +"");
properties.setProperty(prefix+"smplWnd", this.smplWnd+"");
properties.setProperty(prefix+"max_abs_tilt", this.max_abs_tilt+"");
properties.setProperty(prefix+"max_rel_tilt", this.max_rel_tilt+"");
properties.setProperty(prefix+"damp_tilt", this.damp_tilt+"");
properties.setProperty(prefix+"min_tilt_disp", this.min_tilt_disp+"");
properties.setProperty(prefix+"transition", this.transition+"");
properties.setProperty(prefix+"far_mode", this.far_mode+"");
properties.setProperty(prefix+"far_power", this.far_power+"");
}
public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"strength_sure")!=null) this.strength_sure=Double.parseDouble(properties.getProperty(prefix+"strength_sure"));
if (properties.getProperty(prefix+"strength_floor")!=null) this.strength_floor=Double.parseDouble(properties.getProperty(prefix+"strength_floor"));
if (properties.getProperty(prefix+"strength_pow")!=null) this.strength_pow=Double.parseDouble(properties.getProperty(prefix+"strength_pow"));
if (properties.getProperty(prefix+"smplSide")!=null) this.smplSide=Integer.parseInt(properties.getProperty(prefix+"smplSide"));
if (properties.getProperty(prefix+"smplNum")!=null) this.smplNum=Integer.parseInt(properties.getProperty(prefix+"smplNum"));
if (properties.getProperty(prefix+"smplRms")!=null) this.smplRms=Double.parseDouble(properties.getProperty(prefix+"smplRms"));
if (properties.getProperty(prefix+"smplWnd")!=null) this.smplWnd=Boolean.parseBoolean(properties.getProperty(prefix+"smplWnd"));
if (properties.getProperty(prefix+"max_abs_tilt")!=null) this.max_abs_tilt=Double.parseDouble(properties.getProperty(prefix+"max_abs_tilt"));
if (properties.getProperty(prefix+"max_rel_tilt")!=null) this.max_rel_tilt=Double.parseDouble(properties.getProperty(prefix+"max_rel_tilt"));
if (properties.getProperty(prefix+"damp_tilt")!=null) this.damp_tilt=Double.parseDouble(properties.getProperty(prefix+"damp_tilt"));
if (properties.getProperty(prefix+"min_tilt_disp")!=null) this.min_tilt_disp=Double.parseDouble(properties.getProperty(prefix+"min_tilt_disp"));
if (properties.getProperty(prefix+"transition")!=null) this.transition=Double.parseDouble(properties.getProperty(prefix+"transition"));
if (properties.getProperty(prefix+"far_mode")!=null) this.far_mode=Integer.parseInt(properties.getProperty(prefix+"far_mode"));
if (properties.getProperty(prefix+"far_power")!=null) this.far_power=Double.parseDouble(properties.getProperty(prefix+"far_power"));
}
@Override
public MeasuredLayersFilterParameters clone() {
MeasuredLayersFilterParameters mlfp = new MeasuredLayersFilterParameters();
mlfp.strength_sure = this.strength_sure;
mlfp.strength_floor = this.strength_floor;
mlfp.strength_pow = this.strength_pow;
mlfp.smplSide = this.smplSide;
mlfp.smplNum = this.smplNum;
mlfp.smplRms = this.smplRms;
mlfp.smplWnd = this.smplWnd;
mlfp.max_abs_tilt = this.max_abs_tilt;
mlfp.max_rel_tilt = this.max_rel_tilt;
mlfp.damp_tilt = this.damp_tilt;
mlfp.min_tilt_disp = this.min_tilt_disp;
mlfp.transition = this.transition;
mlfp.far_mode = this.far_mode;
mlfp.far_power = this.far_power;
return mlfp;
}
public boolean equals(MeasuredLayersFilterParameters mlfp) {
return
(mlfp.strength_sure == this.strength_sure ) &&
(mlfp.strength_floor == this.strength_floor ) &&
(mlfp.strength_pow == this.strength_pow ) &&
(mlfp.smplSide == this.smplSide ) &&
(mlfp.smplNum == this.smplNum ) &&
(mlfp.smplRms == this.smplRms ) &&
(mlfp.smplWnd == this.smplWnd ) &&
(mlfp.max_abs_tilt == this.max_abs_tilt ) &&
(mlfp.max_rel_tilt == this.max_rel_tilt ) &&
(mlfp.damp_tilt == this.damp_tilt ) &&
(mlfp.min_tilt_disp == this.min_tilt_disp ) &&
(mlfp.transition == this.transition ) &&
(mlfp.far_mode == this.far_mode ) &&
(mlfp.far_power == this.far_power);
}
}
...@@ -76,12 +76,12 @@ public class PolynomialApproximation { ...@@ -76,12 +76,12 @@ public class PolynomialApproximation {
M.solve(B).print(10, 12); M.solve(B).print(10, 12);
} }
double []result=new double [N+1]; double []result=new double [N+1];
for (int i=0;i<=N;i++) result[i]=(i<=N1)?aR[i][0]:0.0; for (int i=0;i<=N;i++) result[i]=(i<=N1)?aR[i][0]:0.0;
return result; return result;
} }
/** /**
* Linear approximates each of 3 functions of 3 variables and finds where they are all zero * Linear approximates each of 3 functions of 3 variables and finds where they are all zero
* @param data: for each sample (1-st index): * @param data: for each sample (1-st index):
* 0 - {x,y,z} * 0 - {x,y,z}
* 1 - {f1, f2, f3}, * 1 - {f1, f2, f3},
...@@ -91,7 +91,7 @@ public class PolynomialApproximation { ...@@ -91,7 +91,7 @@ public class PolynomialApproximation {
public double [] linear3d(double [][][] data){ public double [] linear3d(double [][][] data){
/* /*
* Approximating each of the 3 measured parameters (Far/near, tilt x and tilt y) with linear approximation in the vicinity of the last position * Approximating each of the 3 measured parameters (Far/near, tilt x and tilt y) with linear approximation in the vicinity of the last position
* For each parameter F(x,y,z)=A*x + B*y +C*z + D, using Gaussian weight function with sigma= motorsSigma * For each parameter F(x,y,z)=A*x + B*y +C*z + D, using Gaussian weight function with sigma= motorsSigma
*/ */
double [][] aM3=new double [3][3]; double [][] aM3=new double [3][3];
double [][] aB3=new double [3][1]; double [][] aB3=new double [3][1];
...@@ -164,7 +164,7 @@ public class PolynomialApproximation { ...@@ -164,7 +164,7 @@ public class PolynomialApproximation {
} }
return result; return result;
} }
public double[] quadraticMax2d (double [][][] data){ public double[] quadraticMax2d (double [][][] data){
...@@ -196,6 +196,31 @@ public class PolynomialApproximation { ...@@ -196,6 +196,31 @@ public class PolynomialApproximation {
return xy; return xy;
} }
// returns maximum's coordinates, value, and coefficients for x2, y2 and xy
public double[] quadraticMaxV2dX2Y2XY (double [][][] data,double thresholdQuad, int debugLevel){
double [][] coeff=quadraticApproximation(data, false, 1.0E-20, thresholdQuad,debugLevel);
if (coeff==null) return null;
if (coeff[0].length<6) return null;
double [][] aM={
{2*coeff[0][0], coeff[0][2]}, // | 2A, C |
{ coeff[0][2],2*coeff[0][1]}}; // | C, 2B |
Matrix M=(new Matrix(aM));
double nmQ=normMatix(aM);
if (debugLevel>3) System.out.println("M.det()="+M.det()+" normMatix(aM)="+nmQ+" data.length="+data.length);
if ((nmQ==0.0) || (Math.abs(M.det())/normMatix(aM)<thresholdQuad)) {
if (debugLevel>3) System.out.println("quadraticMax2d() failed: M.det()="+M.det()+" normMatix(aM)="+normMatix(aM));
return null;
}
double [][] aB={
{-coeff[0][3]}, // | - D |
{-coeff[0][4]}}; // | - E |
double [] xy=M.solve(new Matrix(aB)).getColumnPackedCopy();
double vmax = coeff[0][0]*xy[0]*xy[0]+coeff[0][1]*xy[1]*xy[1]+coeff[0][2]*xy[0]*xy[1]+coeff[0][3]*xy[0]+coeff[0][4]*xy[1]+coeff[0][5];
double [] xyx2y2 = {xy[0],xy[1], vmax, coeff[0][0], coeff[0][1], coeff[0][2]};
return xyx2y2;
}
/* ======================================================================== */ /* ======================================================================== */
/** /**
* See below, this version is for backward compatibility with no damping * See below, this version is for backward compatibility with no damping
...@@ -210,13 +235,13 @@ public class PolynomialApproximation { ...@@ -210,13 +235,13 @@ public class PolynomialApproximation {
return quadraticApproximation( return quadraticApproximation(
data, data,
forceLinear, forceLinear,
null); null);
} }
/** /**
* Approximate function z(x,y) as a second degree polynomial (or just linear) * Approximate function z(x,y) as a second degree polynomial (or just linear)
* f(x,y)=A*x^2+B*y^2+C*x*y+D*x+E*y+F or f(x,y)=D*x+E*y+F * f(x,y)=A*x^2+B*y^2+C*x*y+D*x+E*y+F or f(x,y)=D*x+E*y+F
* @param data array consists of lines of either 2 or 3 vectors: * @param data array consists of lines of either 2 or 3 vectors:
* 2-element vector x,y * 2-element vector x,y
* variable length vector z (should be the same for all samples) * variable length vector z (should be the same for all samples)
...@@ -225,7 +250,7 @@ public class PolynomialApproximation { ...@@ -225,7 +250,7 @@ public class PolynomialApproximation {
* @param damping optional (may be null) array of 3 (for linear) or 6 (quadratic) values that adds cost * @param damping optional (may be null) array of 3 (for linear) or 6 (quadratic) values that adds cost
* for corresponding coefficient be non-zero. This can be used to find reasonable solutions when * for corresponding coefficient be non-zero. This can be used to find reasonable solutions when
* data is insufficient. Just one data point would result in a plane of constant z, co-linear * data is insufficient. Just one data point would result in a plane of constant z, co-linear
* points will produce a plane with a gradient along this line * points will produce a plane with a gradient along this line
* @return array of vectors or null * @return array of vectors or null
* each vector (one per each z component) is either 6-element- (A,B,C,D,E,F) if quadratic is possible and enabled * each vector (one per each z component) is either 6-element- (A,B,C,D,E,F) if quadratic is possible and enabled
* or 3-element - (D,E,F) if linear is possible and quadratic is not possible or disabled * or 3-element - (D,E,F) if linear is possible and quadratic is not possible or disabled
...@@ -242,7 +267,7 @@ public class PolynomialApproximation { ...@@ -242,7 +267,7 @@ public class PolynomialApproximation {
damping, damping,
this.debugLevel); this.debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -254,8 +279,8 @@ public class PolynomialApproximation { ...@@ -254,8 +279,8 @@ public class PolynomialApproximation {
null, null,
debugLevel); debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -271,7 +296,7 @@ public class PolynomialApproximation { ...@@ -271,7 +296,7 @@ public class PolynomialApproximation {
debugLevel); debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -302,7 +327,7 @@ public class PolynomialApproximation { ...@@ -302,7 +327,7 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) 1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel); this.debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -317,10 +342,10 @@ public class PolynomialApproximation { ...@@ -317,10 +342,10 @@ public class PolynomialApproximation {
thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't? thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
thresholdQuad, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) thresholdQuad, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
debugLevel); debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -333,9 +358,9 @@ public class PolynomialApproximation { ...@@ -333,9 +358,9 @@ public class PolynomialApproximation {
/* ix, iy - the location of the point with maximal value. We'll approximate the vicinity of that maximum using a /* ix, iy - the location of the point with maximal value. We'll approximate the vicinity of that maximum using a
* second degree polynomial: * second degree polynomial:
Z(x,y)~=A*x^2+B*y^2+C*x*y+D*x+E*y+F Z(x,y)~=A*x^2+B*y^2+C*x*y+D*x+E*y+F
by minimizing sum of squared differenceS00between the actual (Z(x,uy)) and approximated values. by minimizing sum of squared differenceS00between the actual (Z(x,uy)) and approximated values.
and then find the maximum on the approximated surface. Here iS00the math: and then find the maximum on the approximated surface. Here iS00the math:
Z(x,y)~=A*x^2+B*y^2+C*x*y+D*x+E*y+F Z(x,y)~=A*x^2+B*y^2+C*x*y+D*x+E*y+F
minimizing squared error, using W(x,y) aS00weight function minimizing squared error, using W(x,y) aS00weight function
...@@ -402,18 +427,18 @@ public class PolynomialApproximation { ...@@ -402,18 +427,18 @@ public class PolynomialApproximation {
mDampingLin = new Matrix(3,3); mDampingLin = new Matrix(3,3);
for (int i = 0; i < 3; i++){ for (int i = 0; i < 3; i++){
int j = damping.length + i - 3; int j = damping.length + i - 3;
if (j >= 0) mDampingLin.set(i,i,damping[j]); if (j >= 0) mDampingLin.set(i,i,damping[j]);
} }
if (!forceLinear) { if (!forceLinear) {
mDampingQuad = new Matrix(6,6); mDampingQuad = new Matrix(6,6);
for (int i = 0; i < 6; i++){ for (int i = 0; i < 6; i++){
int j = damping.length + i - 6; int j = damping.length + i - 6;
if (j >= 0) mDampingQuad.set(i,i,damping[j]); if (j >= 0) mDampingQuad.set(i,i,damping[j]);
} }
} }
} }
int zDim=data[0][1].length; int zDim=data[0][1].length;
double w,z,x,x2,x3,x4,y,y2,y3,y4,wz; double w,z,x,x2,x3,x4,y,y2,y3,y4,wz;
int i,j,n=0; int i,j,n=0;
...@@ -477,7 +502,7 @@ public class PolynomialApproximation { ...@@ -477,7 +502,7 @@ public class PolynomialApproximation {
SZ02[j]+=wz*y2; SZ02[j]+=wz*y2;
} }
} }
} }
} }
//need to decide if there is enough data for linear and quadratic //need to decide if there is enough data for linear and quadratic
...@@ -486,7 +511,7 @@ public class PolynomialApproximation { ...@@ -486,7 +511,7 @@ public class PolynomialApproximation {
{S11,S02,S01}, {S11,S02,S01},
{S10,S01,S00}}; {S10,S01,S00}};
Matrix mLin=new Matrix (mAarrayL); Matrix mLin=new Matrix (mAarrayL);
if (mDampingLin != null){ if (mDampingLin != null){
mLin.plusEquals(mDampingLin); mLin.plusEquals(mDampingLin);
} }
...@@ -516,7 +541,7 @@ public class PolynomialApproximation { ...@@ -516,7 +541,7 @@ public class PolynomialApproximation {
ABCDEF[i]= mLin.solve(Z).getRowPackedCopy(); ABCDEF[i]= mLin.solve(Z).getRowPackedCopy();
} }
if (forceLinear) return ABCDEF; if (forceLinear) return ABCDEF;
// quote try quadratic approximation // quote try quadratic approximation
double [][] mAarrayQ= { double [][] mAarrayQ= {
{S40,S22,S31,S30,S21,S20}, {S40,S22,S31,S30,S21,S20},
{S22,S04,S13,S12,S03,S02}, {S22,S04,S13,S12,S03,S02},
...@@ -528,7 +553,7 @@ public class PolynomialApproximation { ...@@ -528,7 +553,7 @@ public class PolynomialApproximation {
if (mDampingQuad != null){ if (mDampingQuad != null){
mQuad.plusEquals(mDampingQuad); mQuad.plusEquals(mDampingQuad);
} }
if (debugLevel>3) { if (debugLevel>3) {
System.out.println(" n="+n+" det_quad="+mQuad.det()+" norm_quad="+normMatix(mAarrayQ)+" data.length="+data.length); System.out.println(" n="+n+" det_quad="+mQuad.det()+" norm_quad="+normMatix(mAarrayQ)+" data.length="+data.length);
mQuad.print(10,5); mQuad.print(10,5);
...@@ -557,7 +582,7 @@ public class PolynomialApproximation { ...@@ -557,7 +582,7 @@ public class PolynomialApproximation {
return ABCDEF; return ABCDEF;
} }
// calcualte "volume" made of the matrix row-vectors, placed orthogonally // calcualte "volume" made of the matrix row-vectors, placed orthogonally
// to be compared to determinant // to be compared to determinant
public double normMatix(double [][] a) { public double normMatix(double [][] a) {
double d,norm=1.0; double d,norm=1.0;
for (int i=0;i<a.length;i++) { for (int i=0;i<a.length;i++) {
......
...@@ -3690,8 +3690,8 @@ public class QuadCLT { ...@@ -3690,8 +3690,8 @@ public class QuadCLT {
min_corr_selected, // 0.0001; // minimal correlation value to consider valid min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius, clt_parameters.max_corr_radius,
clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center) // clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width) // clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
...@@ -4766,8 +4766,8 @@ public class QuadCLT { ...@@ -4766,8 +4766,8 @@ public class QuadCLT {
min_corr_selected, // 0.0001; // minimal correlation value to consider valid min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius, clt_parameters.max_corr_radius,
clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center) // clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width) // clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
...@@ -7869,8 +7869,8 @@ public class QuadCLT { ...@@ -7869,8 +7869,8 @@ public class QuadCLT {
min_corr_selected, // 0.0001; // minimal correlation value to consider valid min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius, clt_parameters.max_corr_radius,
clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center) // clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width) // clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
...@@ -8083,8 +8083,8 @@ public class QuadCLT { ...@@ -8083,8 +8083,8 @@ public class QuadCLT {
min_corr_selected, // 0.0001; // minimal correlation value to consider valid min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius, clt_parameters.max_corr_radius,
clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center) // clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width) // clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
......
This diff is collapsed.
This diff is collapsed.
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