Commit 5467504f authored by Andrey Filippov's avatar Andrey Filippov

fusing sub-surfaces

parent f60cc3af
...@@ -2156,6 +2156,12 @@ public class EyesisCorrectionParameters { ...@@ -2156,6 +2156,12 @@ public class EyesisCorrectionParameters {
public double plPull = .1; // Relative weight of original (measured) plane when combing with neighbors 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 plIterations = 10; // Maximal number of smoothing iterations for each step
public int plPrecision = 6; // Maximal step difference (1/power of 10) public int plPrecision = 6; // Maximal step difference (1/power of 10)
public boolean plFuse = true; // Fuse planes together (off for debug only)
public boolean plKeepOrphans = true; // Keep unconnected supertiles
public double plMinOrphan = 2.0; // Minimal strength unconnected supertiles to keep
public double plSnapDisp = .2; // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
public double plSnapDispMax = .5; // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
public double plSnapDispWeight = .5; // Maximal disparity diff. by weight product to snap to plane
// other debug images // other debug images
...@@ -2404,6 +2410,13 @@ public class EyesisCorrectionParameters { ...@@ -2404,6 +2410,13 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plPull", this.plPull +""); properties.setProperty(prefix+"plPull", this.plPull +"");
properties.setProperty(prefix+"plIterations", this.plIterations+""); properties.setProperty(prefix+"plIterations", this.plIterations+"");
properties.setProperty(prefix+"plPrecision", this.plPrecision+""); properties.setProperty(prefix+"plPrecision", this.plPrecision+"");
properties.setProperty(prefix+"plFuse", this.plFuse+"");
properties.setProperty(prefix+"plKeepOrphans", this.plKeepOrphans+"");
properties.setProperty(prefix+"plMinOrphan", this.plMinOrphan +"");
properties.setProperty(prefix+"plSnapDisp", this.plSnapDisp +"");
properties.setProperty(prefix+"plSnapDispMax", this.plSnapDispMax +"");
properties.setProperty(prefix+"plSnapDispWeight", this.plSnapDispWeight +"");
properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+""); properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+"");
properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+""); properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+"");
...@@ -2642,6 +2655,13 @@ public class EyesisCorrectionParameters { ...@@ -2642,6 +2655,13 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"plPull")!=null) this.plPull=Double.parseDouble(properties.getProperty(prefix+"plPull")); 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+"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+"plPrecision")!=null) this.plPrecision=Integer.parseInt(properties.getProperty(prefix+"plPrecision"));
if (properties.getProperty(prefix+"plFuse")!=null) this.plFuse=Boolean.parseBoolean(properties.getProperty(prefix+"plFuse"));
if (properties.getProperty(prefix+"plKeepOrphans")!=null) this.plKeepOrphans=Boolean.parseBoolean(properties.getProperty(prefix+"plKeepOrphans"));
if (properties.getProperty(prefix+"plMinOrphan")!=null) this.plMinOrphan=Double.parseDouble(properties.getProperty(prefix+"plMinOrphan"));
if (properties.getProperty(prefix+"plSnapDisp")!=null) this.plSnapDisp=Double.parseDouble(properties.getProperty(prefix+"plSnapDisp"));
if (properties.getProperty(prefix+"plSnapDispMax")!=null) this.plSnapDispMax=Double.parseDouble(properties.getProperty(prefix+"plSnapDispMax"));
if (properties.getProperty(prefix+"plSnapDispWeight")!=null) this.plSnapDispWeight=Double.parseDouble(properties.getProperty(prefix+"plSnapDispWeight"));
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_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_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles"));
...@@ -2902,6 +2922,14 @@ public class EyesisCorrectionParameters { ...@@ -2902,6 +2922,14 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Relative weight of original (measured) plane when combing with neighbors", this.plPull, 6); 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 number of smoothing iterations for each step", this.plIterations, 0);
gd.addNumericField("Maximal step difference (1/power of 10) ", this.plPrecision, 0); gd.addNumericField("Maximal step difference (1/power of 10) ", this.plPrecision, 0);
gd.addCheckbox ("Fuse planes together (off for debug only)", this.plFuse);
gd.addCheckbox ("Keep unconnected supertiles", this.plKeepOrphans);
gd.addNumericField("Minimal strength unconnected supertiles to keep", this.plMinOrphan, 6);
gd.addMessage ("--- Snap to planes ---");
gd.addNumericField("Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength", this.plSnapDisp, 6);
gd.addNumericField("Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength", this.plSnapDispMax, 6);
gd.addNumericField("Maximal disparity diff. by weight product to snap to plane", this.plSnapDispWeight, 6);
gd.addMessage ("--- Other debug images ---"); gd.addMessage ("--- Other debug images ---");
gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine); gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine);
...@@ -3149,6 +3177,13 @@ public class EyesisCorrectionParameters { ...@@ -3149,6 +3177,13 @@ public class EyesisCorrectionParameters {
this.plPull= gd.getNextNumber(); this.plPull= gd.getNextNumber();
this.plIterations= (int) gd.getNextNumber(); this.plIterations= (int) gd.getNextNumber();
this.plPrecision= (int) gd.getNextNumber(); this.plPrecision= (int) gd.getNextNumber();
this.plFuse= gd.getNextBoolean();
this.plKeepOrphans= gd.getNextBoolean();
this.plMinOrphan= gd.getNextNumber();
this.plSnapDisp= gd.getNextNumber();
this.plSnapDispMax= gd.getNextNumber();
this.plSnapDispWeight= gd.getNextNumber();
this.show_ortho_combine= gd.getNextBoolean(); this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles=gd.getNextBoolean(); this.show_refine_supertiles=gd.getNextBoolean();
......
This diff is collapsed.
import Jama.EigenvalueDecomposition;
import Jama.Matrix;
/** /**
** **
** TilePlanes - detect planes in tile clusters ** TilePlanes - detect planes in tile clusters
...@@ -24,6 +21,9 @@ import Jama.Matrix; ...@@ -24,6 +21,9 @@ import Jama.Matrix;
** -----------------------------------------------------------------------------** ** -----------------------------------------------------------------------------**
** **
*/ */
import Jama.EigenvalueDecomposition;
import Jama.Matrix;
public class TilePlanes { public class TilePlanes {
private int tileSize = 0; // 8; private int tileSize = 0; // 8;
...@@ -120,6 +120,11 @@ public class TilePlanes { ...@@ -120,6 +120,11 @@ public class TilePlanes {
} }
} }
if (src.neib_best != null) dst.neib_best = src.neib_best.clone(); if (src.neib_best != null) dst.neib_best = src.neib_best.clone();
// also copy original plane parameters - tile selection and number of points
dst.num_points = src.num_points;
if (src.plane_sel != null) dst.plane_sel = src.plane_sel.clone();
} }
public void invalidateCalculated() public void invalidateCalculated()
...@@ -303,9 +308,11 @@ public class TilePlanes { ...@@ -303,9 +308,11 @@ public class TilePlanes {
double [] zxy = getZxy(); // {disparity, x center in pixels, y center in pixels (relative to a supertile center) double [] zxy = getZxy(); // {disparity, x center in pixels, y center in pixels (relative to a supertile center)
for (int sy = -superTileSize/2; sy < superTileSize/2; sy++){ for (int sy = -superTileSize/2; sy < superTileSize/2; sy++){
int indx_sel = (2*sy + superTileSize) * superTileSize + superTileSize/2; int indx_sel = (2*sy + superTileSize) * superTileSize + superTileSize/2;
double y = tileSize * sy - zxy[2]; // adding half-tile and half-pixel to match the center of the pixel. Supertile center is between
// pixel 31 and pixel 32 (counting from 0) in both directions
double y = tileSize * (sy + 0.5) + 0.5 - zxy[2];
for (int sx = -superTileSize/2; sx < superTileSize/2; sx++){ for (int sx = -superTileSize/2; sx < superTileSize/2; sx++){
double x = tileSize * sx - zxy[1]; double x = tileSize * (sx + 0.5) + 0.5 - zxy[1];
if (plane_sel[indx_sel] || !useNaN || (plane_sel==null)){ if (plane_sel[indx_sel] || !useNaN || (plane_sel==null)){
disparities[indx] = zxy[0] - (normal[1] * x + normal[2] * y)/normal[0]; disparities[indx] = zxy[0] - (normal[1] * x + normal[2] * y)/normal[0];
} else { } else {
...@@ -318,6 +325,94 @@ public class TilePlanes { ...@@ -318,6 +325,94 @@ public class TilePlanes {
return disparities; return disparities;
} }
/**
* Get disparity values for the tiles of this overlapping supertile as [2*superTileSize * 2*superTileSize] array
* @param useNaN replace unselected tiles with Double.NaN
* @return array of disparity values for the plane (not including overlapped areas)
*/
public double[] getDoublePlaneDisparity(
boolean useNaN)
{
double [] disparities = new double[4*superTileSize*superTileSize];
int indx = 0;
double [] normal = getVector();
double [] zxy = getZxy(); // {disparity, x center in pixels, y center in pixels (relative to a supertile center)
for (int sy = -superTileSize; sy < superTileSize; sy++){
// adding half-tile and half-pixel to match the center of the pixel. Supertile center is between
// pixel 31 and pixel 32 (counting from 0) in both directions
double y = tileSize * (sy + 0.5) + 0.5 - zxy[2];
for (int sx = -superTileSize; sx < superTileSize; sx++){
double x = tileSize * (sx + 0.5) + 0.5 - zxy[1];
if (plane_sel[indx] || !useNaN || (plane_sel==null)){
disparities[indx] = zxy[0] - (normal[1] * x + normal[2] * y)/normal[0];
} else {
disparities[indx] = Double.NaN;
}
indx++;
}
}
return disparities;
}
public double[] getDoublePlaneDisparity(
int dir,
boolean useNaN)
{
double [] plane_all = getDoublePlaneDisparity(useNaN);
double [] plane = new double [superTileSize * superTileSize];
int [] start_index = {
superTileSize/2, // N 4
superTileSize, // NE 8
(superTileSize + 1) * superTileSize, // E 72
(2* superTileSize + 1) * superTileSize, // SE 136
(4* superTileSize + 1) * superTileSize / 2, // S 132
2* superTileSize * superTileSize, // SW 128
superTileSize * superTileSize, // W 64
0}; // NW 0
for (int y = 0; y < superTileSize; y++) {
System.arraycopy(plane_all, start_index[dir] + 2 * superTileSize * y, plane, superTileSize * y, superTileSize);
}
return plane;
}
public double[] getTriplePlaneDisparity()
{
double [] disparities = new double[9*superTileSize*superTileSize];
int indx = 0;
double [] normal = getVector();
double [] zxy = getZxy(); // {disparity, x center in pixels, y center in pixels (relative to a supertile center)
for (int sy = -3 * superTileSize / 2; sy < 3* superTileSize / 2; sy++){
// adding half-tile and half-pixel to match the center of the pixel. Supertile center is between
// pixel 31 and pixel 32 (counting from 0) in both directions
double y = tileSize * (sy + 0.5) + 0.5 - zxy[2];
for (int sx = -3 * superTileSize/2; sx < 3 * superTileSize / 2; sx++){
double x = tileSize * (sx + 0.5) + 0.5 - zxy[1];
disparities[indx] = zxy[0] - (normal[1] * x + normal[2] * y)/normal[0];
indx++;
}
}
return disparities;
}
public double[] getTriplePlaneDisparity(
int dir)
{
double [] plane_all = getTriplePlaneDisparity();
double [] plane = new double [superTileSize * superTileSize];
int [] start_index = {
superTileSize, // N 8
2 * superTileSize, // NE 16
(3 * superTileSize + 2) * superTileSize, // E 208
(3 * superTileSize + 1) * superTileSize * 2, // SE 400
(6 * superTileSize + 1) * superTileSize , // S 392
6 * superTileSize * superTileSize, // SW 384
3 * superTileSize * superTileSize, // W 192
0}; // NW 0
for (int y = 0; y < superTileSize; y++) {
System.arraycopy(plane_all, start_index[dir] + 3 * superTileSize * y, plane, superTileSize * y, superTileSize);
}
return plane;
}
// double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile // double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile
...@@ -798,8 +893,9 @@ public class TilePlanes { ...@@ -798,8 +893,9 @@ public class TilePlanes {
numPoints++; numPoints++;
double w = weight[indx]; double w = weight[indx];
double d = data[indx]; double d = data[indx];
int x = ((indx % stSize2) - stSize) * tileSize; // in pixels, not in tiles // referencing samples to centers of pixels
int y = ((indx / stSize2) - stSize) * tileSize; double x = ((indx % stSize2) - stSize + 0.5) * tileSize + 0.5; // in pixels, not in tiles
double y = ((indx / stSize2) - stSize + 0.5) * tileSize + 0.5;
sw += w; sw += w;
swz += w * d; swz += w * d;
swx += w * x; swx += w * x;
...@@ -825,8 +921,8 @@ public class TilePlanes { ...@@ -825,8 +921,8 @@ public class TilePlanes {
double w = weight[indx] / sw; double w = weight[indx] / sw;
double d = kz * (data[indx] - swz); double d = kz * (data[indx] - swz);
double wd = w*d; double wd = w*d;
double x = ((indx % stSize2) - stSize) * tileSize - swx; double x = ((indx % stSize2) - stSize + 0.5) * tileSize + 0.5 - swx;
double y = ((indx / stSize2) - stSize) * tileSize - swy; double y = ((indx / stSize2) - stSize + 0.5) * tileSize + 0.5 - swy;
acovar [0][0] += wd * d; acovar [0][0] += wd * d;
acovar [0][1] += wd * x; acovar [0][1] += wd * x;
acovar [0][2] += wd * y; acovar [0][2] += wd * y;
......
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