Commit f60cc3af authored by Andrey Filippov's avatar Andrey Filippov

merging planes

parent cee97f1b
......@@ -2150,8 +2150,12 @@ public class EyesisCorrectionParameters {
public double plMinStrength = 0.1; // Minimal total strength of a plane
public double plMaxEigen = 0.3; // Maximal eigenvalue of a plane
public boolean plDbgMerge = true; // Combine 'other' plane with current
public double plWorstWorsening = 2.0; // Worst case worsening after merge
public double plWorstWorsening = 1.0; // Worst case worsening after merge
public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict
public double plPull = .1; // Relative weight of original (measured) plane when combing with neighbors
public int plIterations = 10; // Maximal number of smoothing iterations for each step
public int plPrecision = 6; // Maximal step difference (1/power of 10)
// other debug images
......@@ -2397,6 +2401,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+"");
properties.setProperty(prefix+"plPull", this.plPull +"");
properties.setProperty(prefix+"plIterations", this.plIterations+"");
properties.setProperty(prefix+"plPrecision", this.plPrecision+"");
properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+"");
properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+"");
properties.setProperty(prefix+"show_bgnd_nonbgnd", this.show_bgnd_nonbgnd+"");
......@@ -2631,6 +2639,10 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"plWorstWorsening")!=null) this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening"));
if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly"));
if (properties.getProperty(prefix+"plPull")!=null) this.plPull=Double.parseDouble(properties.getProperty(prefix+"plPull"));
if (properties.getProperty(prefix+"plIterations")!=null) this.plIterations=Integer.parseInt(properties.getProperty(prefix+"plIterations"));
if (properties.getProperty(prefix+"plPrecision")!=null) this.plPrecision=Integer.parseInt(properties.getProperty(prefix+"plPrecision"));
if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles"));
if (properties.getProperty(prefix+"show_bgnd_nonbgnd")!=null) this.show_bgnd_nonbgnd=Boolean.parseBoolean(properties.getProperty(prefix+"show_bgnd_nonbgnd"));
......@@ -2887,6 +2899,10 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Worst case worsening after merge", this.plWorstWorsening, 6);
gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly);
gd.addNumericField("Relative weight of original (measured) plane when combing with neighbors", this.plPull, 6);
gd.addNumericField("Maximal number of smoothing iterations for each step", this.plIterations, 0);
gd.addNumericField("Maximal step difference (1/power of 10) ", this.plPrecision, 0);
gd.addMessage ("--- Other debug images ---");
gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine);
gd.addCheckbox ("Show 'refine_disparity_supertiles'", this.show_refine_supertiles);
......@@ -3130,19 +3146,23 @@ public class EyesisCorrectionParameters {
this.plWorstWorsening= gd.getNextNumber();
this.plMutualOnly= gd.getNextBoolean();
this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles= gd.getNextBoolean();
this.show_bgnd_nonbgnd= gd.getNextBoolean(); // first on second pass
this.show_filter_scan= gd.getNextBoolean(); // first on refine
this.show_combined= gd.getNextBoolean();
this.show_unique= gd.getNextBoolean();
this.show_init_refine= gd.getNextBoolean();
this.show_expand= gd.getNextBoolean();
this.show_shells= gd.getNextBoolean();
this.show_neighbors= gd.getNextBoolean();
this.show_flaps_dirs= gd.getNextBoolean();
this.show_first_clusters= gd.getNextBoolean();
this.show_planes= gd.getNextBoolean();
this.plPull= gd.getNextNumber();
this.plIterations= (int) gd.getNextNumber();
this.plPrecision= (int) gd.getNextNumber();
this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles=gd.getNextBoolean();
this.show_bgnd_nonbgnd= gd.getNextBoolean(); // first on second pass
this.show_filter_scan= gd.getNextBoolean(); // first on refine
this.show_combined= gd.getNextBoolean();
this.show_unique= gd.getNextBoolean();
this.show_init_refine= gd.getNextBoolean();
this.show_expand= gd.getNextBoolean();
this.show_shells= gd.getNextBoolean();
this.show_neighbors= gd.getNextBoolean();
this.show_flaps_dirs= gd.getNextBoolean();
this.show_first_clusters= gd.getNextBoolean();
this.show_planes= gd.getNextBoolean();
return true;
}
}
......
......@@ -5126,7 +5126,7 @@ public class QuadCLT {
System.out.println("Generating cluster images (limit is set to "+clt_parameters.max_clusters+") largest, scan #"+scanIndex);
}
// ImagePlus cluster_image = getPassImage( // get image form a single pass
String texturePath = getPassImage( // get image form a single pass
String texturePath = getPassImage( // get image from a single pass
clt_parameters,
colorProcParameters,
rgbParameters,
......
This diff is collapsed.
......@@ -57,8 +57,8 @@ public class TilePlanes {
double [] world_v1 = null; // world in-plane vector, corresponding to vectors[1]
double [] world_v2 = null; // world in-plane vector, corresponding to vectors[1]
// double [] daxy = null; // disparity and 2 relative angles (ax and ay) corresponding to fisheye view, near (0,0) scale is pixel size
double [][] neib_match = null; // for each of the directions (N, NE, .. NW) quality match for each layer
int [] neib_best = new int [8]; // for each of the directions (N, NE, .. NW) index of best match, -1 if none
double [][] merged_eig_val = null; // for each of the directions (N, NE, .. NW) quality match for each layer
int [] neib_best = null; // new int [8]; // for each of the directions (N, NE, .. NW) index of best match, -1 if none
// stores "worsening" of merging 2 planes. if L1,L2,L = values[0] of plane1, plane2 plane composite: w1, w2 - weights for plane1, plane2
// Lav = Math.sqrt((L1 * L1 * w1 + L2 * L2 * w2)/(w1 + w2))
// worsening_12 = (L - Lav) * (w1 + w2) * (w1 + w2) / (Lav * x1 * w2)
......@@ -92,18 +92,44 @@ public class TilePlanes {
pd.vectors[1] = this.vectors[1].clone();
pd.vectors[2] = this.vectors[2].clone();
}
if (this.neib_match != null){
pd.neib_match = this.neib_match.clone();
for (int i = 0; i<this.neib_match.length; i++){
if (this.neib_match[i] != null){
pd.neib_match[i] = this.neib_match[i].clone();
copyNeib(this,pd);
/*
if (this.merged_eig_val != null){
pd.merged_eig_val = this.merged_eig_val.clone();
for (int i = 0; i<this.merged_eig_val.length; i++){
if (this.merged_eig_val[i] != null){
pd.merged_eig_val[i] = this.merged_eig_val[i].clone();
}
}
}
if (this.neib_best != null) pd.neib_best = this.neib_best.clone();
*/
return pd;
}
public void copyNeib(
PlaneData src,
PlaneData dst)
{
if (src.merged_eig_val != null){
dst.merged_eig_val = src.merged_eig_val.clone();
for (int i = 0; i < src.merged_eig_val.length; i++){
if (src.merged_eig_val[i] != null){
dst.merged_eig_val[i] = src.merged_eig_val[i].clone();
}
}
}
if (src.neib_best != null) dst.neib_best = src.neib_best.clone();
}
public void invalidateCalculated()
{
this.center_xyz = null; // center of this supertile this plane center in world coordinates
this.world_xyz = null; // world coordinates of the nearest point of the plane, in meters
this.world_v1 = null; // world in-plane vector, corresponding to vectors[1]
this.world_v2 = null; // world in-plane vector, corresponding to vectors[1]
}
public PlaneData (
int [] sTileXY,
......@@ -117,40 +143,40 @@ public class TilePlanes {
this.sTileXY = sTileXY.clone();
}
public double [][] initNeibMatch()
public double [][] initMergedValue()
{
this.neib_match = new double[8][];
return this.neib_match;
this.merged_eig_val = new double[8][];
return this.merged_eig_val;
}
public double [][] getNeibMatch()
public double [][] getMergedValue()
{
return this.neib_match;
return this.merged_eig_val;
}
public double [] initNeibMatch(int dir, int leng)
public double [] initMergedValue(int dir, int leng)
{
this.neib_match[dir] = new double[leng];
for (int i = 0; i < leng; i++) this.neib_match[dir][i] = Double.NaN;
return getNeibMatch(dir);
this.merged_eig_val[dir] = new double[leng];
for (int i = 0; i < leng; i++) this.merged_eig_val[dir][i] = Double.NaN;
return getMergedValue(dir);
}
public double [] getNeibMatch(int dir)
public double [] getMergedValue(int dir)
{
if (this.neib_match == null) {
if (this.merged_eig_val == null) {
return null;
}
return this.neib_match[dir];
return this.merged_eig_val[dir];
}
public double getNeibMatch(int dir, int plane)
public double getMergedValue(int dir, int plane)
{
if ((this.neib_match == null) ||(this.neib_match[dir] == null)){
if ((this.merged_eig_val == null) ||(this.merged_eig_val[dir] == null)){
return Double.NaN;
}
return this.neib_match[dir][plane];
return this.merged_eig_val[dir][plane];
}
public void setNeibMatch(int dir, int plane, double value)
{
this.neib_match[dir][plane] = value;
this.merged_eig_val[dir][plane] = value;
}
public int [] initNeibBest()
......@@ -452,6 +478,7 @@ public class TilePlanes {
PlaneData pd = this.clone(); // will copy selections too
pd.invalidateCalculated(); // real world vectors
pd.setValues(eig_val[oindx][oindx],eig_val[vindx][vindx],eig_val[hindx][hindx]); // eigenvalues [0] - thickness, 2 other to detect skinny (poles)
pd.setVectors(plane);
......@@ -477,7 +504,8 @@ public class TilePlanes {
PlaneData otherPd,
int debugLevel)
{
PlaneData pd = otherPd.clone();
PlaneData pd = otherPd.clone(); // TODO: use clone of this, copy only needed info from otherPD
// keep world vectors from otherPd
if (debugLevel > 0) {
System.out.println("getPlaneToThis()");
}
......@@ -596,6 +624,7 @@ public class TilePlanes {
// System.out.println("getPlaneToThis(): "+pd.sTileXY[0]+":"+pd.sTileXY[1]+" -> "+pd.vectors[0][0]+", disp = "+disp+
// ", other_det = "+((new Matrix(otherPd.vectors).det()) +", pdr_det = "+((new Matrix(pd.vectors).det()))));
}
copyNeib(this, pd);
return pd; // make sure pd are updated // "this" is not used. Should it be used instead of pd?
}
......
......@@ -2823,27 +2823,37 @@ public class TileProcessor {
clt_parameters.tileX,
clt_parameters.tileY);
if (clt_parameters.plMutualOnly) {
st.selectNeighborPlanesMutual(
clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plMaxEigen,
clt_parameters.plMinStrength,
st.selectNeighborPlanesMutual(
clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plMaxEigen,
clt_parameters.plMinStrength,
0, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
TilePlanes.PlaneData [][] planes_mod = null;
if (clt_parameters.plMutualOnly) { // temporarily re-use obsolete parameter to test smoothing
planes_mod = st.planesSmooth(
clt_parameters.plPull, // final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors
clt_parameters.plIterations, // final int num_passes,
Math.pow(10.0, -clt_parameters.plPrecision), // final double maxDiff, // maximal change in any of the disparity values
0, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
} else {
st.selectNeighborPlanes(
clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plMutualOnly, // final boolean mutual_only,
0); // final int debugLevel)
// } else {
// st.selectNeighborPlanes(
// clt_parameters.plWorstWorsening, // final double worst_worsening,
// clt_parameters.plMutualOnly, // final boolean mutual_only,
// 0); // final int debugLevel)
}
if (clt_parameters.show_planes){
int [] wh = st.getShowPlanesWidthHeight();
double [][] plane_data_nonan = st.getShowPlanes(
st.getPlanes(),
(planes_mod != null) ? st.getPlanesMod():st.getPlanes(),
clt_parameters.plMinStrength, // minWeight,
clt_parameters.plMaxEigen, // maxEigen,
clt_parameters.plDispNorm,
......@@ -2851,7 +2861,7 @@ public class TileProcessor {
0.0,
10.0);
double [][] plane_data_nan = st.getShowPlanes(
st.getPlanes(),
(planes_mod != null) ? st.getPlanesMod():st.getPlanes(),
clt_parameters.plMinStrength, // minWeight,
clt_parameters.plMaxEigen, // maxEigen,
clt_parameters.plDispNorm,
......@@ -2870,6 +2880,12 @@ public class TileProcessor {
// sdfa_instance.showArrays(plane_data_nonan, wh[0], wh[1], true, "plane_data_noNaN");
// sdfa_instance.showArrays(plane_data_nan, wh[0], wh[1], true, "plane_data_NaN");
sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "plane_data");
// show plane data
/*
......
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