Commit 8991226b authored by Andrey Filippov's avatar Andrey Filippov

Tweaking software to handle more precise disparity measurements

parent 957badd3
...@@ -539,6 +539,7 @@ public class CLTPass3d{ ...@@ -539,6 +539,7 @@ public class CLTPass3d{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
if (((strength[nTile] < weakStrength) || if (((strength[nTile] < weakStrength) ||
...@@ -597,6 +598,7 @@ public class CLTPass3d{ ...@@ -597,6 +598,7 @@ public class CLTPass3d{
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
if (nTile == dbg_nTile){ if (nTile == dbg_nTile){
...@@ -656,6 +658,7 @@ public class CLTPass3d{ ...@@ -656,6 +658,7 @@ public class CLTPass3d{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
if (known[nTile]){ if (known[nTile]){
...@@ -688,6 +691,7 @@ public class CLTPass3d{ ...@@ -688,6 +691,7 @@ public class CLTPass3d{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
int tX = nTile % tilesX; int tX = nTile % tilesX;
...@@ -790,6 +794,7 @@ public class CLTPass3d{ ...@@ -790,6 +794,7 @@ public class CLTPass3d{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
int imax1 = 0; int imax1 = 0;
...@@ -813,6 +818,7 @@ public class CLTPass3d{ ...@@ -813,6 +818,7 @@ public class CLTPass3d{
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) if (measured[nTile]) { for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) if (measured[nTile]) {
double sw = 0.0; double sw = 0.0;
...@@ -851,6 +857,7 @@ public class CLTPass3d{ ...@@ -851,6 +857,7 @@ public class CLTPass3d{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
if (known[nTile]){ if (known[nTile]){
...@@ -897,6 +904,15 @@ public class CLTPass3d{ ...@@ -897,6 +904,15 @@ public class CLTPass3d{
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // use window functions for the samples 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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
{ {
this.superTiles = new SuperTiles( this.superTiles = new SuperTiles(
...@@ -914,6 +930,14 @@ public class CLTPass3d{ ...@@ -914,6 +930,14 @@ public class CLTPass3d{
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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,
measSel); measSel);
return this.superTiles; return this.superTiles;
} }
...@@ -926,6 +950,15 @@ public class CLTPass3d{ ...@@ -926,6 +950,15 @@ public class CLTPass3d{
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // use window functions for the samples 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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
{ {
if (this.superTiles == null){ if (this.superTiles == null){
...@@ -940,6 +973,15 @@ public class CLTPass3d{ ...@@ -940,6 +973,15 @@ public class CLTPass3d{
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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.
...@@ -572,6 +572,7 @@ private Panel panel1, ...@@ -572,6 +572,7 @@ private Panel panel1,
addButton("Infinity offset", panelClt3, color_configure); addButton("Infinity offset", panelClt3, color_configure);
addButton("Setup CLT Batch parameters", panelClt3, color_configure); addButton("Setup CLT Batch parameters", panelClt3, color_configure);
addButton("CLT batch process", panelClt3, color_process); addButton("CLT batch process", panelClt3, color_process);
addButton("CM Test", panelClt3, color_stop);
// addButton("JTabbed", panelClt3, color_stop); // addButton("JTabbed", panelClt3, color_stop);
// addButton("Demo", panelClt3, color_process); // addButton("Demo", panelClt3, color_process);
...@@ -3752,7 +3753,7 @@ private Panel panel1, ...@@ -3752,7 +3753,7 @@ private Panel panel1,
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("Setup CLT parameters")) { } else if (label.equals("Setup CLT parameters")) {
CLT_PARAMETERS.showDialog(); CLT_PARAMETERS.showJDialog();
return; return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("Setup CLT")) { } else if (label.equals("Setup CLT")) {
...@@ -3769,7 +3770,7 @@ private Panel panel1, ...@@ -3769,7 +3770,7 @@ private Panel panel1,
} else if (label.equals("Select CLT image")) { } else if (label.equals("Select CLT image")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
// IJ.showMessage("DCT test 1"); // IJ.showMessage("DCT test 1");
if (!CLT_PARAMETERS.showDialog()) return; if (!CLT_PARAMETERS.showJDialog()) return;
// process selected image stack // process selected image stack
ImagePlus imp_src = WindowManager.getCurrentImage(); ImagePlus imp_src = WindowManager.getCurrentImage();
if (imp_src==null){ if (imp_src==null){
...@@ -3802,7 +3803,7 @@ private Panel panel1, ...@@ -3802,7 +3803,7 @@ private Panel panel1,
} else if (label.equals("Select second CLT image")) { } else if (label.equals("Select second CLT image")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
// IJ.showMessage("DCT test 1"); // IJ.showMessage("DCT test 1");
if (!CLT_PARAMETERS.showDialog()) return; if (!CLT_PARAMETERS.showJDialog()) return;
// process selected image stack // process selected image stack
ImagePlus imp_src = WindowManager.getCurrentImage(); ImagePlus imp_src = WindowManager.getCurrentImage();
if (imp_src==null){ if (imp_src==null){
...@@ -3837,7 +3838,7 @@ private Panel panel1, ...@@ -3837,7 +3838,7 @@ private Panel panel1,
} else if (label.equals("CLT stack")) { } else if (label.equals("CLT stack")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
// IJ.showMessage("DCT test 1"); // IJ.showMessage("DCT test 1");
if (!CLT_PARAMETERS.showDialog()) return; if (!CLT_PARAMETERS.showJDialog()) return;
// process selected image stack // process selected image stack
if (DBG_IMP == null) { if (DBG_IMP == null) {
ImagePlus imp_src = WindowManager.getCurrentImage(); ImagePlus imp_src = WindowManager.getCurrentImage();
...@@ -3937,7 +3938,7 @@ private Panel panel1, ...@@ -3937,7 +3938,7 @@ private Panel panel1,
System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")"); System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
// IJ.showMessage("DCT test 1"); // IJ.showMessage("DCT test 1");
if (!CLT_PARAMETERS.showDialog()) return; if (!CLT_PARAMETERS.showJDialog()) return;
// process selected image stack // process selected image stack
if (DBG_IMP == null) { if (DBG_IMP == null) {
ImagePlus imp_src = WindowManager.getCurrentImage(); ImagePlus imp_src = WindowManager.getCurrentImage();
...@@ -4191,7 +4192,7 @@ private Panel panel1, ...@@ -4191,7 +4192,7 @@ private Panel panel1,
//============================================================================== //==============================================================================
} else if (label.equals("Create CLT kernels")) { } else if (label.equals("Create CLT kernels")) {
if (!CLT_PARAMETERS.showDialog()) return; if (!CLT_PARAMETERS.showJDialog()) return;
if (QUAD_CLT == null){ if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT ( QUAD_CLT = new QuadCLT (
PROPERTIES, PROPERTIES,
...@@ -4250,7 +4251,7 @@ private Panel panel1, ...@@ -4250,7 +4251,7 @@ private Panel panel1,
} }
} else if (label.equals("Read CLT kernels")) { } else if (label.equals("Read CLT kernels")) {
if (!CLT_PARAMETERS.showDialog()) return; if (!CLT_PARAMETERS.showJDialog()) return;
if (QUAD_CLT == null){ if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT ( QUAD_CLT = new QuadCLT (
PROPERTIES, PROPERTIES,
...@@ -5161,6 +5162,9 @@ private Panel panel1, ...@@ -5161,6 +5162,9 @@ private Panel panel1,
PROPERTIES); PROPERTIES);
} }
return; return;
} else if (label.equals("CM Test")) {
cm_test();
return;
//JTabbedTest //JTabbedTest
// End of buttons code // End of buttons code
...@@ -5185,8 +5189,137 @@ private Panel panel1, ...@@ -5185,8 +5189,137 @@ private Panel panel1,
return true; return true;
} }
public boolean cm_test() {
double hsize_x = 1.5;
double hsize_y = 1.5;
int steps = 20;
double sigma = 0.0;
boolean separable = true; // false;
double pwr = 1.0;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",400,300);
gd.addNumericField("Half size X", hsize_x, 6, 8, "pix",
"Correlation maximum half width in disparity direction");
gd.addNumericField("Half size Y", hsize_y, 6, 8, "pix",
"Correlation maximum half width in orthogonal direction");
gd.addNumericField("Number of steps", steps, 0, 6, "",
"Number of steps to subdivide [0,1) half-interval");
gd.addNumericField("Low pass sigma", sigma, 3, 6, "pix",
"Correlation maximum half width in orthogonal direction");
gd.addCheckbox ("X/Y separable", separable);
gd.addNumericField("Value power", pwr, 6, 8, "",
"Raise values to this power before calculating CM");
gd.showDialog();
if (gd.wasCanceled()) return false;
DoubleGaussianBlur gb=new DoubleGaussianBlur();
hsize_x = gd.getNextNumber();
hsize_y = gd.getNextNumber();
steps = (int) gd.getNextNumber();
sigma = gd.getNextNumber();
separable = gd.getNextBoolean();
pwr = gd.getNextNumber();
int size_x = 2*((int) Math.round(hsize_x+ 2*sigma+1)) + 1;
int size_y = 2*((int) Math.round(hsize_y+ 2*sigma+1)) + 1;
System.out.println("size_x="+size_x+", size_y="+size_y+" sigma = "+sigma+" separable "+separable+" pwr=" + pwr);
String [] titles = new String[steps];
double [][] data = new double [steps][size_x*size_y];
for (int i = 0;i<steps; i++) {
double dx = 1.0*i/steps;
titles[i] = IJ.d2s(dx,3);
for (int iy = 0; iy < size_y; iy++) {
double y = (iy - (size_y - 1)/2)/hsize_y;
if ((y >= -1.0) && (y <= 1.0)) {
double ay = separable ? (0.5*(Math.cos(y * Math.PI) + 1.0)):1.0;
for (int ix = 0; ix < size_x; ix++) {
double x = (ix - (size_x - 1)/2 - dx)/hsize_x;
double r = separable? Math.abs(x) : Math.sqrt(x*x+y*y);
// if ((r >= -hsize_x) && (x <= hsize_x)) {
if (r <= 1.0) {
double ax = 0.5*(Math.cos(r * Math.PI) + 1.0);
data[i][iy*size_x+ix] = ax*ay;
}
}
}
}
}
(new showDoubleFloatArrays()) .showArrays(data, size_x, size_y, true, "pre-gauss", titles);
if (sigma > 0.0) {
for (int i = 0; i < steps; i++) {
gb.blurDouble(
data[i],
size_x,
size_y,
sigma,
sigma,
0.01);
}
(new showDoubleFloatArrays()) .showArrays(data, size_x, size_y, true, "blured", titles);
}
double [] cm_x = new double [steps];
for (int i = 0;i<steps; i++) {
double s0=0,sx=0;
for (int iy = 0; iy < size_y; iy++ ) {
for (int ix = 0; ix < size_x; ix++ ) {
double d = Math.pow(data[i][iy*size_y+ix], pwr);
s0+=d;
sx+=ix*d;
}
}
cm_x[i] = sx/s0 - (size_x - 1)/2;
}
for (int i = 0;i <= steps/2; i++) {
double dx = 1.0*i/steps;
System.out.println(String.format("%3d %8.5f %8.5f %8.5f %8.5f %8.5f", i, dx, cm_x[i],cm_x[i]-dx, cm_x[i]/(dx+0.00000001), dx/(cm_x[i]+0.00000001)));
}
return true;
/*
double s0 = 0, sx=0,sy = 0;
for (int y = - iradius ; y <= iradius; y++){
int dataY = icenter[1] +y;
if ((dataY >= 0) && (dataY < data_size)){
int y2 = y*y;
for (int x = - iradius ; x <= iradius; x++){
int dataX = icenter[0] +x;
double r2 = y2 + x * x;
// if ((dataX >= 0) && (dataX < data_size) && (square || ((y2 + x * x) <= ir2))){
if ((dataX >= 0) && (dataX < data_size) && (square || (r2 <= ir2))){
// double w = max_corr_double? (1.0 - r2/ir2):1.0;
// double d = w* data[dataY * data_size + dataX];
double d = data[dataY * data_size + dataX];
s0 += d;
sx += d * dataX;
sy += d * dataY;
}
}
}
}
double [] rslt = {sx / s0, sy / s0};
*
* showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
sdfa_instance.showArrays(double_stack, imp_src.getWidth(), imp_src.getHeight(), true, "BEFORE_CLT_PROC", rbg_titles);
*
gb.blurDouble(
results[indexVar],
size,
size,
blurVarianceSigma,
blurVarianceSigma,
0.01);
*/
}
private boolean loadCorrelations(){ private boolean loadCorrelations(){
String []patterns={".corr-tiff",".tiff",".tif"}; String []patterns={".corr-tiff",".tiff",".tif"};
String path= selectFile( String path= selectFile(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
...@@ -109,7 +110,13 @@ public class GenericJTabbedDialog implements ActionListener { ...@@ -109,7 +110,13 @@ public class GenericJTabbedDialog implements ActionListener {
} }
if (tooltip != null) { if (tooltip != null) {
label.setToolTipText(tooltip); label.setToolTipText(tooltip);
if (component != null) component.setToolTipText(tooltip); if (component != null) {
component.setToolTipText(tooltip);
Component [] comps = component.getComponents();
if ((comps != null) && (comps.length >0)) {
((JComponent) comps[0]).setToolTipText(tooltip);
}
}
} }
labels.get(labels.size()-1).add(label); labels.get(labels.size()-1).add(label);
components.get(components.size()-1).add(component); components.get(components.size()-1).add(component);
...@@ -148,6 +155,7 @@ public class GenericJTabbedDialog implements ActionListener { ...@@ -148,6 +155,7 @@ public class GenericJTabbedDialog implements ActionListener {
inp_units.putClientProperty("type", "String"); inp_units.putClientProperty("type", "String");
inp_units.setLayout(new FlowLayout(FlowLayout.LEFT)); inp_units.setLayout(new FlowLayout(FlowLayout.LEFT));
addLine(label, inp_units, tooltip); addLine(label, inp_units, tooltip);
} }
public void addNumericField(String label, double defaultValue, int digits) { // as in IJ public void addNumericField(String label, double defaultValue, int digits) { // as in IJ
......
...@@ -67,12 +67,18 @@ public class ImageDtt { ...@@ -67,12 +67,18 @@ public class ImageDtt {
static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6 static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6
static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map
static int OVEREXPOSED = 16; // index of overexposed fraction of all pixels static int OVEREXPOSED = 16; // index of overexposed fraction of all pixels
// remove when not needed
static int DBG0_INDEX = 17; // index of dbg0 data (copy of CM)
static int DBG1_INDEX = 18; // index of dbg1 data (poly 1)
static int DBG2_INDEX = 19; // index of dbg2 data (poly 2)
static int DBG3_INDEX = 20; // index of dbg3 data (poly 3)
static String [] DISPARITY_TITLES = { static String [] DISPARITY_TITLES = {
"int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength", "int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength",
"poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp"}; "poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp",
"dbg0","dbg1","dbg2","dbg3"};
static int TCORR_COMBO_RSLT = 0; // normal combined correlation from all selected pairs (mult/sum) static int TCORR_COMBO_RSLT = 0; // normal combined correlation from all selected pairs (mult/sum)
static int TCORR_COMBO_SUM = 1; // sum of channle correlations from all selected pairs static int TCORR_COMBO_SUM = 1; // sum of channel correlations from all selected pairs
static int TCORR_COMBO_HOR = 2; // combined correlation from 2 horizontal pairs (0,1). Used to detect vertical features static int TCORR_COMBO_HOR = 2; // combined correlation from 2 horizontal pairs (0,1). Used to detect vertical features
static int TCORR_COMBO_VERT = 3; // combined correlation from 2 vertical pairs (0,1). Used to detect horizontal features static int TCORR_COMBO_VERT = 3; // combined correlation from 2 vertical pairs (0,1). Used to detect horizontal features
static String [] TCORR_TITLES = {"combo","sum","hor","vert"}; static String [] TCORR_TITLES = {"combo","sum","hor","vert"};
...@@ -1365,6 +1371,7 @@ public class ImageDtt { ...@@ -1365,6 +1371,7 @@ public class ImageDtt {
public double [][][][][][] clt_aberrations_quad_corr( public double [][][][][][] clt_aberrations_quad_corr(
final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
...@@ -1539,6 +1546,7 @@ public class ImageDtt { ...@@ -1539,6 +1546,7 @@ public class ImageDtt {
} }
// add optional initialization of debug layers here
if (disparity_map != null){ if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){ for (int i = 0; i<disparity_map.length;i++){
if ((i != OVEREXPOSED) || (saturation_imp!= null)){ if ((i != OVEREXPOSED) || (saturation_imp!= null)){
...@@ -2138,6 +2146,11 @@ public class ImageDtt { ...@@ -2138,6 +2146,11 @@ public class ImageDtt {
clt_mismatch[3*pair + 2 ][tIndex] = Double.NaN; clt_mismatch[3*pair + 2 ][tIndex] = Double.NaN;
} }
} }
if (disparity_map[DBG0_INDEX] != null) disparity_map[DBG0_INDEX][tIndex] = Double.NaN;
if (disparity_map[DBG1_INDEX] != null) disparity_map[DBG1_INDEX][tIndex] = Double.NaN;
if (disparity_map[DBG2_INDEX] != null) disparity_map[DBG2_INDEX][tIndex] = Double.NaN;
if (disparity_map[DBG3_INDEX] != null) disparity_map[DBG3_INDEX][tIndex] = Double.NaN;
} else { } else {
double [] corr_max_XYi = {icorr_max[0],icorr_max[1]}; double [] corr_max_XYi = {icorr_max[0],icorr_max[1]};
disparity_map[DISPARITY_INDEX_INT][tIndex] = transform_size - 1 -corr_max_XYi[0]; disparity_map[DISPARITY_INDEX_INT][tIndex] = transform_size - 1 -corr_max_XYi[0];
...@@ -2149,7 +2162,7 @@ public class ImageDtt { ...@@ -2149,7 +2162,7 @@ public class ImageDtt {
// disparity_map[DISPARITY_VARIATIONS_INDEX][tIndex] = (rms[1]*tcorr_combo[1][max_index])/(rms[0]*tcorr_combo[0][max_index]); // correlation combo value at the integer maximum // disparity_map[DISPARITY_VARIATIONS_INDEX][tIndex] = (rms[1]*tcorr_combo[1][max_index])/(rms[0]*tcorr_combo[0][max_index]); // correlation combo value at the integer maximum
disparity_map[DISPARITY_VARIATIONS_INDEX][tIndex] = (tcorr_combo[TCORR_COMBO_SUM][max_index])/(tcorr_combo[TCORR_COMBO_RSLT][max_index]); // correlation combo value at the integer maximum disparity_map[DISPARITY_VARIATIONS_INDEX][tIndex] = (tcorr_combo[TCORR_COMBO_SUM][max_index])/(tcorr_combo[TCORR_COMBO_RSLT][max_index]); // correlation combo value at the integer maximum
// Calculate "center of mass" coordinates // Calculate "center of mass" coordinates
double [] corr_max_XYm = getMaxXYCm( // get fractiona center as a "center of mass" inside circle/square from the integer max double [] corr_max_XYm = getMaxXYCm( // get fractional center as a "center of mass" inside circle/square from the integer max
tcorr_combo[TCORR_COMBO_RSLT], // [data_size * data_size] tcorr_combo[TCORR_COMBO_RSLT], // [data_size * data_size]
corr_size, corr_size,
icorr_max, // integer center coordinates (relative to top left) icorr_max, // integer center coordinates (relative to top left)
...@@ -2159,7 +2172,7 @@ public class ImageDtt { ...@@ -2159,7 +2172,7 @@ public class ImageDtt {
disparity_map[DISPARITY_INDEX_CM][tIndex] = transform_size - 1 -corr_max_XYm[0]; disparity_map[DISPARITY_INDEX_CM][tIndex] = transform_size - 1 -corr_max_XYm[0];
disparity_map[DISPARITY_INDEX_CM+1][tIndex] = transform_size - 1 -corr_max_XYm[1]; disparity_map[DISPARITY_INDEX_CM+1][tIndex] = transform_size - 1 -corr_max_XYm[1];
// returns x and strength, not x,y // returns x and strength, not x,y
double [] corr_max_XS_hor = getMaxXSOrtho( // get fractiona center as a "center of mass" inside circle/square from the integer max double [] corr_max_XS_hor = getMaxXSOrtho( // get fractional center as a "center of mass" inside circle/square from the integer max
tcorr_combo[TCORR_COMBO_HOR], // [data_size * data_size] tcorr_combo[TCORR_COMBO_HOR], // [data_size * data_size]
enh_ortho_scale, // [data_size] enh_ortho_scale, // [data_size]
corr_size, corr_size,
...@@ -2168,7 +2181,7 @@ public class ImageDtt { ...@@ -2168,7 +2181,7 @@ public class ImageDtt {
(globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)); // debugMax); (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)); // debugMax);
disparity_map[DISPARITY_INDEX_HOR][tIndex] = transform_size - 1 - corr_max_XS_hor[0]; disparity_map[DISPARITY_INDEX_HOR][tIndex] = transform_size - 1 - corr_max_XS_hor[0];
disparity_map[DISPARITY_INDEX_HOR_STRENGTH][tIndex] = corr_max_XS_hor[1]; disparity_map[DISPARITY_INDEX_HOR_STRENGTH][tIndex] = corr_max_XS_hor[1];
double [] corr_max_XS_vert = getMaxXSOrtho( // get fractiona center as a "center of mass" inside circle/square from the integer max double [] corr_max_XS_vert = getMaxXSOrtho( // get fractional center as a "center of mass" inside circle/square from the integer max
tcorr_combo[TCORR_COMBO_VERT], // [data_size * data_size] tcorr_combo[TCORR_COMBO_VERT], // [data_size * data_size]
enh_ortho_scale, // [data_size] enh_ortho_scale, // [data_size]
corr_size, corr_size,
...@@ -2185,7 +2198,20 @@ public class ImageDtt { ...@@ -2185,7 +2198,20 @@ public class ImageDtt {
icorr_max, // integer center coordinates (relative to top left) icorr_max, // integer center coordinates (relative to top left)
corr_max_weights_poly, // [(radius+1) * (radius+1)] corr_max_weights_poly, // [(radius+1) * (radius+1)]
max_search_radius_poly, // max_search_radius, for polynomial - always use 1 max_search_radius_poly, // max_search_radius, for polynomial - always use 1
imgdtt_params.poly_pwr, // double value_pwr, // raise value to this power (trying to compensate sticking to integer values)
imgdtt_params.poly_value_to_weight, //boolean poly_value_to_weight, // multiply weight by value
debugMax); debugMax);
//double
if (corr_max_XY != null){
corr_max_XY[0] = transform_size - 1 -corr_max_XY[0];
corr_max_XY[1] = transform_size - 1 -corr_max_XY[1];
} else {
corr_max_XY = new double[2];
corr_max_XY[0] = Double.NaN;
corr_max_XY[1] = Double.NaN;
}
/*
if (corr_max_XY != null){ if (corr_max_XY != null){
disparity_map[DISPARITY_INDEX_POLY][tIndex] = transform_size - 1 -corr_max_XY[0]; disparity_map[DISPARITY_INDEX_POLY][tIndex] = transform_size - 1 -corr_max_XY[0];
disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = transform_size - 1 -corr_max_XY[1]; disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = transform_size - 1 -corr_max_XY[1];
...@@ -2193,6 +2219,42 @@ public class ImageDtt { ...@@ -2193,6 +2219,42 @@ public class ImageDtt {
disparity_map[DISPARITY_INDEX_POLY][tIndex] = Double.NaN; disparity_map[DISPARITY_INDEX_POLY][tIndex] = Double.NaN;
disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = Double.NaN; disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = Double.NaN;
} }
*/
disparity_map[DISPARITY_INDEX_POLY][tIndex] = corr_max_XY[0];
disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = corr_max_XY[1];
// just debug (up to 4 layers)
if (disparity_map[DBG0_INDEX] != null) {
disparity_map[DBG0_INDEX][tIndex] = transform_size - 1 -corr_max_XYm[0];
}
if (disparity_map[DBG2_INDEX] != null) {
disparity_map[DBG2_INDEX][tIndex] = corr_max_XY[0];
}
if (disparity_map[DBG1_INDEX] != null) {
disparity_map[DBG1_INDEX][tIndex] = disparity_map[DBG0_INDEX][tIndex];
if (!Double.isNaN(corr_max_XY[0]) &&
(Math.abs(disparity_map[DISPARITY_INDEX_CM][tIndex] - corr_max_XY[0]) < imgdtt_params.max_poly_diff) &&
(disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] > imgdtt_params.min_poly_strength)) { // debug threshold
disparity_map[DBG1_INDEX][tIndex] = corr_max_XY[0];
disparity_map[DBG3_INDEX][tIndex] = Double.NaN;
} else { // show only "bad" and strong poly
if (disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] > imgdtt_params.min_poly_strength) {
disparity_map[DBG3_INDEX][tIndex] = disparity_map[DBG2_INDEX][tIndex];
} else {
disparity_map[DBG3_INDEX][tIndex] = Double.NaN;
}
}
// if (disparity_map[DBG3_INDEX] != null) {
// disparity_map[DBG3_INDEX][tIndex] = disparity_map[DBG2_INDEX][tIndex] - disparity_map[DBG0_INDEX][tIndex];
// }
}
if (imgdtt_params.mix_corr_poly) {
// apply
disparity_map[DISPARITY_INDEX_CM][tIndex] = disparity_map[DBG1_INDEX][tIndex];
// TODO: add Y for correction !!!!
}
//
if (corr_mode == 0) extra_disparity = disparity_map[DISPARITY_INDEX_INT][tIndex]; if (corr_mode == 0) extra_disparity = disparity_map[DISPARITY_INDEX_INT][tIndex];
else if (corr_mode == 1) extra_disparity = disparity_map[DISPARITY_INDEX_CM][tIndex]; else if (corr_mode == 1) extra_disparity = disparity_map[DISPARITY_INDEX_CM][tIndex];
else if (corr_mode == 2) extra_disparity = disparity_map[DISPARITY_INDEX_POLY][tIndex]; else if (corr_mode == 2) extra_disparity = disparity_map[DISPARITY_INDEX_POLY][tIndex];
...@@ -2912,6 +2974,8 @@ public class ImageDtt { ...@@ -2912,6 +2974,8 @@ public class ImageDtt {
int [] icenter, // integer center coordinates (relative to top left) int [] icenter, // integer center coordinates (relative to top left)
double [] weights, // [(radius+1) * (radius+1)] double [] weights, // [(radius+1) * (radius+1)]
int radius, int radius,
double value_pwr, // raise value to this power (trying to compensate sticking to integer values)
boolean poly_value_to_weight, // multiply weight by value
boolean debug) boolean debug)
{ {
// TODO: make sure it is within 1pxx1px square from the integer maximum? If not - return null and use center of mass instead? // TODO: make sure it is within 1pxx1px square from the integer maximum? If not - return null and use center of mass instead?
...@@ -2935,8 +2999,16 @@ public class ImageDtt { ...@@ -2935,8 +2999,16 @@ public class ImageDtt {
mdata[indx][0][1] = dataY; mdata[indx][0][1] = dataY;
mdata[indx][1] = new double [1]; mdata[indx][1] = new double [1];
mdata[indx][1][0] = data[dataY * data_size + dataX]; mdata[indx][1][0] = data[dataY * data_size + dataX];
if (value_pwr != 1.0) {
if (mdata[indx][1][0] > 0) {
mdata[indx][1][0] = Math.pow(mdata[indx][1][0], value_pwr);
} else {
mdata[indx][1][0] = 0.0;
}
}
mdata[indx][2] = new double [1]; mdata[indx][2] = new double [1];
mdata[indx][2][0] = weights[ay * (radius + 1) + ax]; mdata[indx][2][0] = weights[ay * (radius + 1) + ax];
if (poly_value_to_weight) mdata[indx][2][0] *= mdata[indx][1][0];
indx++; indx++;
} }
} }
......
...@@ -222,6 +222,7 @@ public class MacroCorrelation { ...@@ -222,6 +222,7 @@ public class MacroCorrelation {
// double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][]; // double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(); ImageDtt image_dtt = new ImageDtt();
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
8, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 8, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
macro_scan.tile_op, // per-tile operation bit codes macro_scan.tile_op, // per-tile operation bit codes
macro_scan.disparity, // clt_parameters.disparity, // final double disparity, macro_scan.disparity, // clt_parameters.disparity, // final double disparity,
...@@ -410,6 +411,7 @@ public class MacroCorrelation { ...@@ -410,6 +411,7 @@ public class MacroCorrelation {
double [] arr = {disparity, strength}; double [] arr = {disparity, strength};
return arr; return arr;
} }
@Override
public String toString(){ public String toString(){
return String.format("disparity=%7.3f strength=%7.4f",disparity, strength); return String.format("disparity=%7.3f strength=%7.4f",disparity, strength);
} }
...@@ -447,6 +449,7 @@ public class MacroCorrelation { ...@@ -447,6 +449,7 @@ public class MacroCorrelation {
final double kexp = (mc_trust_sigma == 0.0) ? 0.0: (0.5/mc_trust_sigma/mc_trust_sigma); final double kexp = (mc_trust_sigma == 0.0) ? 0.0: (0.5/mc_trust_sigma/mc_trust_sigma);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int this_thread = ai_thread.getAndIncrement(); int this_thread = ai_thread.getAndIncrement();
...@@ -557,6 +560,7 @@ public class MacroCorrelation { ...@@ -557,6 +560,7 @@ public class MacroCorrelation {
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
// int this_thread = ai_thread.getAndIncrement(); // int this_thread = ai_thread.getAndIncrement();
int tileSize = tp.getTileSize(); int tileSize = tp.getTileSize();
......
...@@ -796,7 +796,7 @@ public class MeasuredLayers { ...@@ -796,7 +796,7 @@ public class MeasuredLayers {
} }
} }
if (iworst < 0){ if (iworst < 0){
System.out.println("**** this is a BUG in getDisparityStrengthML() ****"); System.out.println("**** this is a BUG1 in getDisparityStrengthML() ****");
break; break;
} }
// remove worst sample // remove worst sample
...@@ -895,7 +895,15 @@ public class MeasuredLayers { ...@@ -895,7 +895,15 @@ public class MeasuredLayers {
int smplNum, // = 3; // Number after removing worst (should be >1) int smplNum, // = 3; // Number after removing worst (should be >1)
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // boolean smplWnd, //
double damp_tilt, //
double max_abs_tilt, // 2.0; // pix per tile
double max_rel_tilt, // 0.2; // (pix / disparity) per tile
double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
boolean null_if_none, boolean null_if_none,
int debugLevel) int debugLevel)
{ {
...@@ -914,9 +922,13 @@ public class MeasuredLayers { ...@@ -914,9 +922,13 @@ public class MeasuredLayers {
smplNum, // int smplNum, // = 3; // Number after removing worst (should be >1) smplNum, // int smplNum, // = 3; // Number after removing worst (should be >1)
smplRms, // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // boolean smplWnd, // smplWnd, // boolean smplWnd, //
2.0, // double max_abs_tilt, // = 2.0; // pix per tile max_abs_tilt, // double max_abs_tilt, // = 2.0; // pix per tile
0.2, // double max_rel_tilt, // = 0.2; // (pix / disparity) per tile max_rel_tilt, // double max_rel_tilt, // = 0.2; // (pix / disparity) per tile
damp_tilt, // double damp_tilt, // damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
null_if_none, // boolean null_if_none, null_if_none, // boolean null_if_none,
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
} else { } else {
...@@ -940,6 +952,11 @@ public class MeasuredLayers { ...@@ -940,6 +952,11 @@ public class MeasuredLayers {
} }
} }
// Try two modes of operation: Far tiles (disparity <~4?) use power of disparity, no tilts. Near tiles - current.
// For far tiles power can use closest (lowest disparity) - either power or just census or smth.
// Detect strong background?
public double[][] getDisparityStrengthMLTilted ( public double[][] getDisparityStrengthMLTilted (
int num_layer, int num_layer,
int stX, int stX,
...@@ -950,13 +967,17 @@ public class MeasuredLayers { ...@@ -950,13 +967,17 @@ public class MeasuredLayers {
// to be per-tile of a supertile array // to be per-tile of a supertile array
double strength_floor, double strength_floor,
double strength_pow, double strength_pow,
int smplSide, // = 2; // Sample size (side of a square) int smplSide, // = 3; // Sample size (side of a square)
int smplNum, // = 3; // Number after removing worst (should be >1) int smplNum, // = 5; // Number after removing worst (should be >1)
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.3; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // boolean smplWnd, //
double max_abs_tilt, // = 2.0; // pix per tile double max_abs_tilt, // 2.0; // pix per tile
double max_rel_tilt, // = 0.2; // (pix / disparity) per tile double max_rel_tilt, // 0.2; // (pix / disparity) per tile
double damp_tilt, // double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
boolean null_if_none, boolean null_if_none,
int debugLevel) int debugLevel)
{ {
...@@ -986,6 +1007,21 @@ public class MeasuredLayers { ...@@ -986,6 +1007,21 @@ public class MeasuredLayers {
double thresholdLin = 1.0E-20; // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) double thresholdLin = 1.0E-20; // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
double thresholdQuad = 1.0E-30; // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) double thresholdQuad = 1.0E-30; // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
double disp_pwr_far = min_tilt_disp - transition/2.0;
double disp_pwr_near = min_tilt_disp + transition/2.0;
double disp_pwr_near2 = disp_pwr_near + smplRms;
double [] disp_pwr = null;
boolean far_mode_en = (far_mode == 1) || (far_mode == 2);
boolean remove_far_only = (far_mode == 2);
if (far_mode_en) {
disp_pwr = new double [st2e * st2e];
}
int num_far = 0;
boolean [] smpl_far_sel = null;
double [] smpl_pwr_d = null;
double [] smpl_far_d = null;
double [] smpl_far_w = null;
int num_in_sample_far = 0;
if (layers[num_layer] != null) { if (layers[num_layer] != null) {
for (int dy = 0; dy < st2e; dy ++){ for (int dy = 0; dy < st2e; dy ++){
...@@ -1003,9 +1039,13 @@ public class MeasuredLayers { ...@@ -1003,9 +1039,13 @@ public class MeasuredLayers {
if (w > 0) { if (w > 0) {
if (strength_pow != 1.0) w = Math.pow(w, strength_pow); if (strength_pow != 1.0) w = Math.pow(w, strength_pow);
// w *= lapWeight[dy][dx]; // w *= lapWeight[dy][dx];
disp[indx_ste] = layers[num_layer][indx].getDisparity(); disp[indx_ste] = layers[num_layer][indx].getDisparity(); // same?
weight[indx_ste] = w; weight[indx_ste] = w;
num_selected ++; num_selected ++;
if (far_mode_en && (disp[indx_ste] < disp_pwr_near2) && (disp[indx_ste] > 0)) {
disp_pwr[indx_ste] = Math.pow(disp[indx_ste], far_power);
num_far++;
}
} }
} }
} }
...@@ -1029,6 +1069,12 @@ public class MeasuredLayers { ...@@ -1029,6 +1069,12 @@ public class MeasuredLayers {
double [] smpl_d = new double [smplLen]; double [] smpl_d = new double [smplLen];
double [] smpl_p = new double [smplLen]; double [] smpl_p = new double [smplLen];
double [] smpl_w = new double [smplLen]; double [] smpl_w = new double [smplLen];
if (far_mode_en ) {
smpl_far_sel = new boolean [smplLen];
smpl_pwr_d = new double [smplLen];
smpl_far_w = new double [smplLen];
num_in_sample_far = 0;
}
for (int sy = 0; sy < smplSide; sy++){ for (int sy = 0; sy < smplSide; sy++){
int y = dy + sy; // - smpl_center; int y = dy + sy; // - smpl_center;
for (int sx = 0; sx < smplSide; sx++){ for (int sx = 0; sx < smplSide; sx++){
...@@ -1041,8 +1087,17 @@ public class MeasuredLayers { ...@@ -1041,8 +1087,17 @@ public class MeasuredLayers {
smpl_w[indxs] = weight[indxe] * smpl_weights[indxs]; smpl_w[indxs] = weight[indxe] * smpl_weights[indxs];
sum_wnd += smpl_weights[indxs]; sum_wnd += smpl_weights[indxs];
num_in_sample ++; num_in_sample ++;
if (far_mode_en && (disp_pwr[indxe]>0.0)) {
smpl_far_sel[indxs] = true;
smpl_pwr_d[indxs] = disp_pwr[indxe];
smpl_far_w[indxs] = smpl_w[indxs];
num_in_sample_far++;
}
}
} }
} }
if (far_mode_en ) {
smpl_far_d = smpl_d.clone();
} }
if (num_in_sample >= smplNum){ // try, remove worst if (num_in_sample >= smplNum){ // try, remove worst
sample_loop: sample_loop:
...@@ -1140,11 +1195,11 @@ public class MeasuredLayers { ...@@ -1140,11 +1195,11 @@ public class MeasuredLayers {
// remove worst - it should not make remaining set // remove worst - it should not make remaining set
if (num_in_sample > smplNum) { // remove worst if it is not the last run where only calculations are needed if (num_in_sample > smplNum) { // remove worst if it is not the last run where only calculations are needed
// double d_mean = sd/sw; // double d_mean = sd/sw;
int iworst = -1; int iworst = -1;
double dworst2 = 0.0; double dworst2 = 0.0;
for (int indxs = 0; indxs < smplLen; indxs++) if (smpl_sel[indxs]) { for (int indxs = 0; indxs < smplLen; indxs++) if (smpl_sel[indxs]) {
// double d2 = (smpl_d[i] - d_mean); // double d2 = (smpl_d[i] - d_mean);
double d2 = smpl_d[indxs] - smpl_p[indxs]; double d2 = smpl_d[indxs] - smpl_p[indxs];
d2 *=d2; d2 *=d2;
if (d2 > dworst2) { if (d2 > dworst2) {
...@@ -1166,10 +1221,10 @@ public class MeasuredLayers { ...@@ -1166,10 +1221,10 @@ public class MeasuredLayers {
} }
// remove worst sample // remove worst sample
smpl_sel[iworst] = false; smpl_sel[iworst] = false;
// double dw = smpl_d[iworst] * smpl_w[iworst]; // double dw = smpl_d[iworst] * smpl_w[iworst];
// sd -= dw; // sd -= dw;
// sd2 -= dw * smpl_d[iworst]; // sd2 -= dw * smpl_d[iworst];
// sw -= smpl_w[iworst]; // sw -= smpl_w[iworst];
sum_wnd -= smpl_weights[iworst]; sum_wnd -= smpl_weights[iworst];
num_in_sample --; num_in_sample --;
} else { } else {
...@@ -1179,8 +1234,8 @@ public class MeasuredLayers { ...@@ -1179,8 +1234,8 @@ public class MeasuredLayers {
} // removing worst tiles, all done, } // removing worst tiles, all done,
// calculate variance of the remaining set // calculate variance of the remaining set
if (sw > 0.0) { if (sw > 0.0) {
// sd /= sw; // sd /= sw;
// sd2 /= sw; // sd2 /= sw;
double var = sd2/sw; // - sd * sd; double var = sd2/sw; // - sd * sd;
if (var < smplVar) { // good, save in the result array if (var < smplVar) { // good, save in the result array
ds[0][indx] = d_center; ds[0][indx] = d_center;
...@@ -1232,9 +1287,10 @@ public class MeasuredLayers { ...@@ -1232,9 +1287,10 @@ public class MeasuredLayers {
iworst = i; iworst = i;
dworst2 = d2; dworst2 = d2;
} }
//remove_far_only
} }
if (iworst < 0){ if (iworst < 0){
System.out.println("**** this is a BUG in getDisparityStrengthML() ****"); System.out.println("**** this is a BUG2 in getDisparityStrengthML() ****");
break; break;
} }
// remove worst sample // remove worst sample
...@@ -1263,10 +1319,83 @@ public class MeasuredLayers { ...@@ -1263,10 +1319,83 @@ public class MeasuredLayers {
} }
} }
} }
// now apply far if needed
if (num_in_sample_far > 0) { // calculate small far disparity, then merge with normal one
// remove extra
// smpl_pwr_d - disparity to power
// smpl_far_d - just disparity
if (num_in_sample_far >= smplNum){ // try, remove worst
double sd=0.0, sd2 = 0.0, sw = 0.0;
double sdp =0.0; // , sdp2 = 0.0;
for (int i = 0; i < smplLen; i++) if (smpl_far_sel[i]) {
double dw = smpl_far_d[i] * smpl_far_w[i];
sd += dw;
sd2 += dw * smpl_far_d[i];
sw += smpl_far_w[i];
double dpw = smpl_pwr_d[i] * smpl_far_w[i];
sdp += dpw;
// sdp2 += dpw * smpl_pwr_d[i];
}
// remove worst (before power), update sd2, sd and sw
while ((num_in_sample_far > smplNum) && (sw > 0)){ // try, remove worst
double d_mean = sd/sw;
int iworst = -1;
double dworst2 = 0.0;
for (int i = 0; i < smplLen; i++) if (smpl_far_sel[i]) {
double d2 = (smpl_far_d[i] - d_mean);
d2 *=d2;
if ((d2 > dworst2) && (!remove_far_only ||(smpl_far_d[i] < d_mean))) {
iworst = i;
dworst2 = d2;
}
}
if (iworst < 0){
System.out.println("**** this is a BUG3 in getDisparityStrengthML() ****");
break;
}
// remove worst sample
smpl_far_sel[iworst] = false;
double dw = smpl_far_d[iworst] * smpl_far_w[iworst];
sd -= dw;
sd2 -= dw * smpl_far_d[iworst];
sw -= smpl_far_w[iworst];
sum_wnd -= smpl_weights[iworst];
num_in_sample_far --;
// Remove from the power average too
sdp -= smpl_pwr_d[iworst] * smpl_far_w[iworst];
}
// calculate variance of the remaining set
if (sw > 0.0) {
sd /= sw;
sd2 /= sw;
double var = sd2 - sd * sd;
if (var < smplVar) { // good, save in the result array (here use linear disparity
// here need to combine two filtering modes - "tilted" and "far"
sdp = Math.pow(sdp/sw, 1.0/far_power);
if (sdp < disp_pwr_near) { // otherwise keep tilted mode result
double far_w = sw * lapWeight[dy][dx] /sum_wnd; // average weights, multiply by window //** TODO: change
if (sdp < disp_pwr_far) {
ds[0][indx] = sdp;
ds[1][indx] = far_w;
} else { // interpolate
double k = (sdp - disp_pwr_far) / transition;
ds[0][indx] = (1.0 - k) * sdp + k * ds[0][indx];
ds[1][indx] = (1.0 - k) * far_w + k * ds[1][indx];
}
}
ds[0][indx] = sd;
ds[1][indx] = sw * lapWeight[dy][dx] /sum_wnd; // average weights, multiply by window //** TODO: change
}
} else {
num_in_sample = 0;
System.out.println("**** this is a BUG4 in getDisparityStrengthML(), shoud not happen ? ****");
}
}
}
} }
} }
} }
......
...@@ -3572,7 +3572,7 @@ public class QuadCLT { ...@@ -3572,7 +3572,7 @@ public class QuadCLT {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
// may use this.StartTime to report intermediate steps execution times // may use this.StartTime to report intermediate steps execution times
String name=(String) imp_quad[0].getProperty("name"); String name=this.correctionsParameters.getModelName((String) imp_quad[0].getProperty("name"));
// int channel= Integer.parseInt((String) imp_src.getProperty("channel")); // int channel= Integer.parseInt((String) imp_src.getProperty("channel"));
// int channel= (Integer) imp_quad[0].getProperty("channel"); // int channel= (Integer) imp_quad[0].getProperty("channel");
String path= (String) imp_quad[0].getProperty("path"); String path= (String) imp_quad[0].getProperty("path");
...@@ -3666,6 +3666,7 @@ public class QuadCLT { ...@@ -3666,6 +3666,7 @@ public class QuadCLT {
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr( double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
disparity_array, // final double disparity, disparity_array, // final double disparity,
...@@ -4740,6 +4741,7 @@ public class QuadCLT { ...@@ -4740,6 +4741,7 @@ public class QuadCLT {
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity, disparity_array, // clt_parameters.disparity, // final double disparity,
...@@ -5632,13 +5634,13 @@ public class QuadCLT { ...@@ -5632,13 +5634,13 @@ public class QuadCLT {
debugLevel); debugLevel);
tp.clt_3d_passes.add(bgnd_data); tp.clt_3d_passes.add(bgnd_data);
// if (show_init_refine) // if (show_init_refine)
if (debugLevel > -1) { if ((debugLevel > -2) && clt_parameters.show_first_bg) {
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(0), // CLTPass3d scan, tp.clt_3d_passes.get(0), // CLTPass3d scan,
"bgnd_data-"+tp.clt_3d_passes.size()); "bgnd_data-"+tp.clt_3d_passes.size());
} }
//TODO: Move away form here? //TODO: Move away from here?
ImagePlus imp_bgnd = getBackgroundImage( ImagePlus imp_bgnd = getBackgroundImage(
clt_parameters, clt_parameters,
colorProcParameters, colorProcParameters,
...@@ -5827,7 +5829,8 @@ public class QuadCLT { ...@@ -5827,7 +5829,8 @@ public class QuadCLT {
tp.clt_3d_passes.add(refined); tp.clt_3d_passes.add(refined);
/// if (debugLevel > 1) /// if (debugLevel > 1)
if (debugLevel > 0) // if (debugLevel > 0)
if ((debugLevel > -2) && clt_parameters.show_first_bg)
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan, tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"before_makeUnique-"+refine_pass); "before_makeUnique-"+refine_pass);
...@@ -5973,8 +5976,9 @@ public class QuadCLT { ...@@ -5973,8 +5976,9 @@ public class QuadCLT {
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
if (debugLevel > -1){ // if (debugLevel > -1){
System.out.println("CLTMeasure("+refine_pass+")"); if (debugLevel > -2){
System.out.println("?.CLTMeasure("+refine_pass+")");
} }
if (show_init_refine) tp.showScan( if (show_init_refine) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan, tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
...@@ -7041,7 +7045,7 @@ public class QuadCLT { ...@@ -7041,7 +7045,7 @@ public class QuadCLT {
"after_pass3-"+(next_pass-1)); //String title) "after_pass3-"+(next_pass-1)); //String title)
} }
String x3d_path= correctionsParameters.selectX3dDirectory( // for x3d and obj String x3d_path= correctionsParameters.selectX3dDirectory( // for x3d and obj
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false correctionsParameters.getModelName(this.image_name), // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters.x3dModelVersion, correctionsParameters.x3dModelVersion,
true, // smart, true, // smart,
true); //newAllowed, // save true); //newAllowed, // save
...@@ -7058,7 +7062,7 @@ public class QuadCLT { ...@@ -7058,7 +7062,7 @@ public class QuadCLT {
try { try {
wfOutput = new WavefrontExport( wfOutput = new WavefrontExport(
x3d_path, x3d_path,
this.image_name, correctionsParameters.getModelName(this.image_name),
clt_parameters, clt_parameters,
correctionsParameters, correctionsParameters,
geometryCorrection, geometryCorrection,
...@@ -7117,7 +7121,7 @@ public class QuadCLT { ...@@ -7117,7 +7121,7 @@ public class QuadCLT {
clt_parameters, clt_parameters,
colorProcParameters, colorProcParameters,
rgbParameters, rgbParameters,
this.image_name+"-img_infinity", // +scanIndex, correctionsParameters.getModelName(this.image_name)+"-img_infinity", // +scanIndex,
bgndIndex, bgndIndex,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
...@@ -7198,7 +7202,7 @@ public class QuadCLT { ...@@ -7198,7 +7202,7 @@ public class QuadCLT {
clt_parameters, clt_parameters,
colorProcParameters, colorProcParameters,
rgbParameters, rgbParameters,
this.image_name+"-img"+scanIndex, correctionsParameters.getModelName(this.image_name)+"-img"+scanIndex,
scanIndex, scanIndex,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
...@@ -7275,9 +7279,9 @@ public class QuadCLT { ...@@ -7275,9 +7279,9 @@ public class QuadCLT {
if ((x3d_path != null) && (x3dOutput != null)){ if ((x3d_path != null) && (x3dOutput != null)){
// x3d_path+=Prefs.getFileSeparator()+this.image_name+".x3d"; // x3d_path+=Prefs.getFileSeparator()+correctionsParameters.getModelName(this.image_name)+".x3d";
// x3dOutput.generateX3D(x3d_path); // x3dOutput.generateX3D(x3d_path);
x3dOutput.generateX3D(x3d_path+Prefs.getFileSeparator()+this.image_name+".x3d"); x3dOutput.generateX3D(x3d_path+Prefs.getFileSeparator()+correctionsParameters.getModelName(this.image_name)+".x3d");
} }
if (wfOutput != null){ if (wfOutput != null){
wfOutput.close(); wfOutput.close();
...@@ -7562,7 +7566,7 @@ public class QuadCLT { ...@@ -7562,7 +7566,7 @@ public class QuadCLT {
debugLevel); debugLevel);
String path= correctionsParameters.selectX3dDirectory( String path= correctionsParameters.selectX3dDirectory(
//TODO: Which one to use - name or this.image_name ? //TODO: Which one to use - name or this.image_name ?
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false correctionsParameters.getModelName(this.image_name), // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters.x3dModelVersion, correctionsParameters.x3dModelVersion,
// name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false // name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
true, // smart, true, // smart,
...@@ -7711,7 +7715,7 @@ public class QuadCLT { ...@@ -7711,7 +7715,7 @@ public class QuadCLT {
String path= correctionsParameters.selectX3dDirectory( String path= correctionsParameters.selectX3dDirectory(
//TODO: Which one to use - name or this.image_name ? //TODO: Which one to use - name or this.image_name ?
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false correctionsParameters.getModelName(this.image_name), // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters.x3dModelVersion, correctionsParameters.x3dModelVersion,
// name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false // name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
true, // smart, true, // smart,
...@@ -7841,6 +7845,7 @@ public class QuadCLT { ...@@ -7841,6 +7845,7 @@ public class QuadCLT {
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity, disparity_array, // clt_parameters.disparity, // final double disparity,
...@@ -8054,6 +8059,7 @@ public class QuadCLT { ...@@ -8054,6 +8059,7 @@ public class QuadCLT {
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity, disparity_array, // clt_parameters.disparity, // final double disparity,
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
** -----------------------------------------------------------------------------** ** -----------------------------------------------------------------------------**
** **
*/ */
import java.awt.Point;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
...@@ -57,6 +56,13 @@ public class SuperTiles{ ...@@ -57,6 +56,13 @@ public class SuperTiles{
double smplRms = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd = false; // final boolean smplWnd, // use window functions for the samples boolean smplWnd = false; // final boolean smplWnd, // use window functions for the samples
double max_abs_tilt = 2.0; // Maximal absolute tilt in pixels/tile
double max_rel_tilt = 0.2; // Maximal relative tilt in pixels/tile/disparity
double damp_tilt = 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp = 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition = 1.0; // Mode transition range (between tilted and maximal disparity)
int far_mode = 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
double far_power = 1.0; // Raise disparity to this power before averaging for far objects
MeasuredLayers measuredLayers = null; MeasuredLayers measuredLayers = null;
...@@ -97,6 +103,16 @@ public class SuperTiles{ ...@@ -97,6 +103,16 @@ public class SuperTiles{
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // use window functions for the samples 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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
// boolean null_if_none,
int measSel) int measSel)
{ {
this.cltPass3d = cltPass3d; this.cltPass3d = cltPass3d;
...@@ -113,7 +129,21 @@ public class SuperTiles{ ...@@ -113,7 +129,21 @@ public class SuperTiles{
this.smplSide = smplSide; // Sample size (side of a square) this.smplSide = smplSide; // Sample size (side of a square)
this.smplNum = smplNum; // Number after removing worst this.smplNum = smplNum; // Number after removing worst
this.smplRms = smplRms; // Maximal RMS of the remaining tiles in a sample this.smplRms = smplRms; // Maximal RMS of the remaining tiles in a sample
this.max_abs_tilt = max_abs_tilt;
this.max_rel_tilt = max_rel_tilt;
this.damp_tilt = damp_tilt;
this.min_tilt_disp = min_tilt_disp;
this.transition = transition;
this.far_mode = far_mode;
this.far_power = far_power;
this.smplWnd = smplWnd; // Use window functions for the samples this.smplWnd = smplWnd; // Use window functions for the samples
this.measSel = measSel; this.measSel = measSel;
this.step_threshold_near = this.step_threshold_far * step_near / this.step_far ; this.step_threshold_near = this.step_threshold_far * step_near / this.step_far ;
this.bin_far = this.step_threshold_far / this.step_far; this.bin_far = this.step_threshold_far / this.step_far;
...@@ -164,6 +194,15 @@ public class SuperTiles{ ...@@ -164,6 +194,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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); // calculate and blur supertiles (for all, not just selected?) measSel); // calculate and blur supertiles (for all, not just selected?)
if (tileProcessor.globalDebugLevel > 0){ if (tileProcessor.globalDebugLevel > 0){
System.out.println("SuperTiles(): min_disparity = "+min_disparity+", max_disparity="+max_disparity); System.out.println("SuperTiles(): min_disparity = "+min_disparity+", max_disparity="+max_disparity);
...@@ -396,6 +435,15 @@ public class SuperTiles{ ...@@ -396,6 +435,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // final boolean smplWnd, //
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final int measSel) // final int measSel) //
{ {
if (disparity_strength != null) { if (disparity_strength != null) {
...@@ -406,6 +454,15 @@ public class SuperTiles{ ...@@ -406,6 +454,15 @@ public class SuperTiles{
(smplSide == this.smplSide) && (smplSide == this.smplSide) &&
(smplNum == this.smplNum) && (smplNum == this.smplNum) &&
(smplRms == this.smplRms) && (smplRms == this.smplRms) &&
(max_abs_tilt == this.max_abs_tilt) &&
(max_rel_tilt == this.max_rel_tilt) &&
(damp_tilt == this.damp_tilt) &&
(min_tilt_disp == this.min_tilt_disp) &&
(transition == this.transition) &&
(far_mode == this.far_mode) &&
(far_power == this.far_power) &&
(measSel == this.measSel)){ (measSel == this.measSel)){
return this.disparityHistograms; return this.disparityHistograms;
} }
...@@ -413,6 +470,15 @@ public class SuperTiles{ ...@@ -413,6 +470,15 @@ public class SuperTiles{
this.smplSide = smplSide; // Sample size (side of a square) this.smplSide = smplSide; // Sample size (side of a square)
this.smplNum = smplNum; // Number after removing worst this.smplNum = smplNum; // Number after removing worst
this.smplRms = smplRms; // Maximal RMS of the remaining tiles in a sample this.smplRms = smplRms; // Maximal RMS of the remaining tiles in a sample
this.max_abs_tilt = max_abs_tilt;
this.max_rel_tilt = max_rel_tilt;
this.damp_tilt = damp_tilt;
this.min_tilt_disp = min_tilt_disp;
this.transition = transition;
this.far_mode = far_mode;
this.far_power = far_power;
this.measSel = measSel; this.measSel = measSel;
final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX();
...@@ -429,6 +495,7 @@ public class SuperTiles{ ...@@ -429,6 +495,7 @@ public class SuperTiles{
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
...@@ -454,7 +521,16 @@ public class SuperTiles{ ...@@ -454,7 +521,16 @@ public class SuperTiles{
smplNum, //int smplNum, // = 3; // Number after removing worst (should be >1) smplNum, //int smplNum, // = 3; // Number after removing worst (should be >1)
smplRms, //double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, //double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, smplWnd,
0.001, // double damp_tilt, //
max_abs_tilt, // = 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // = 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // = 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // = 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // = 1.0; // Mode transition range (between tilted and maximal disparity)
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);
-1); // int debugLevel -1); // int debugLevel
} else { } else {
...@@ -524,6 +600,7 @@ public class SuperTiles{ ...@@ -524,6 +600,7 @@ public class SuperTiles{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
DoubleGaussianBlur gb=new DoubleGaussianBlur(); DoubleGaussianBlur gb=new DoubleGaussianBlur();
for (int nsTile = ai.getAndIncrement(); nsTile < sTiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < sTiles; nsTile = ai.getAndIncrement()) {
...@@ -552,6 +629,15 @@ public class SuperTiles{ ...@@ -552,6 +629,15 @@ public class SuperTiles{
this.smplNum, // final int smplNum, // = 3; // Number after removing worst this.smplNum, // final int smplNum, // = 3; // Number after removing worst
this.smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample this.smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
this.smplWnd, // final boolean smplWnd, // use window functions for the samples this.smplWnd, // final boolean smplWnd, // use window functions for the samples
this.max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
this.max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
this.damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
this.min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
this.transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
this.far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
this.far_power, // 1.0; // Raise disparity to this power before averaging for far objects
this.measSel); this.measSel);
final int globalDebugLevel = tileProcessor.globalDebugLevel; final int globalDebugLevel = tileProcessor.globalDebugLevel;
maxMinMax = new double [disparityHistograms.length][][]; maxMinMax = new double [disparityHistograms.length][][];
...@@ -559,6 +645,7 @@ public class SuperTiles{ ...@@ -559,6 +645,7 @@ public class SuperTiles{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
DoubleGaussianBlur gb=new DoubleGaussianBlur(); DoubleGaussianBlur gb=new DoubleGaussianBlur();
for (int nsTile = ai.getAndIncrement(); nsTile < maxMinMax.length; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < maxMinMax.length; nsTile = ai.getAndIncrement()) {
...@@ -690,6 +777,15 @@ public class SuperTiles{ ...@@ -690,6 +777,15 @@ public class SuperTiles{
this.smplNum, // final int smplNum, // = 3; // Number after removing worst this.smplNum, // final int smplNum, // = 3; // Number after removing worst
this.smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample this.smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
this.smplWnd, // final boolean smplWnd, // this.smplWnd, // final boolean smplWnd, //
this.max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
this.max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
this.damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
this.min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
this.transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
this.far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
this.far_power, // 1.0; // Raise disparity to this power before averaging for far objects
this.measSel); // calculate and blur with the current settings, specified at instantiation this.measSel); // calculate and blur with the current settings, specified at instantiation
} }
return showDisparityHistogram(disparityHistograms); return showDisparityHistogram(disparityHistograms);
...@@ -705,6 +801,15 @@ public class SuperTiles{ ...@@ -705,6 +801,15 @@ public class SuperTiles{
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // boolean smplWnd, //
double max_abs_tilt, // 2.0; // pix per tile
double max_rel_tilt, // 0.2; // (pix / disparity) per tile
double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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) // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert int measSel) // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
{ {
getDisparityHistograms( // will recalculate if does not exist or some parameters changed getDisparityHistograms( // will recalculate if does not exist or some parameters changed
...@@ -716,6 +821,15 @@ public class SuperTiles{ ...@@ -716,6 +821,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // smplWnd, // final boolean smplWnd, //
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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); // calculate and blur with the current settings, specified at instantiation measSel); // calculate and blur with the current settings, specified at instantiation
return showDisparityHistogram(disparityHistograms); return showDisparityHistogram(disparityHistograms);
} }
...@@ -893,6 +1007,7 @@ public class SuperTiles{ ...@@ -893,6 +1007,7 @@ public class SuperTiles{
bgStrength = new double[sTiles]; bgStrength = new double[sTiles];
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < sTiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < sTiles; nsTile = ai.getAndIncrement()) {
if (nsTile == 49) { // 414){ // 331){ if (nsTile == 49) { // 414){ // 331){
...@@ -971,6 +1086,7 @@ public class SuperTiles{ ...@@ -971,6 +1086,7 @@ public class SuperTiles{
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
int stileY = nsTile / stilesX; int stileY = nsTile / stilesX;
...@@ -1417,6 +1533,15 @@ public class SuperTiles{ ...@@ -1417,6 +1533,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // final boolean smplWnd, //
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
...@@ -1443,6 +1568,7 @@ public class SuperTiles{ ...@@ -1443,6 +1568,7 @@ public class SuperTiles{
final double [][] zero_tilts = {{0.0,0.0}}; // set to null for float final double [][] zero_tilts = {{0.0,0.0}}; // set to null for float
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
double [][][] plane_tilts = null; // used only forworld_plane_norm != null double [][][] plane_tilts = null; // used only forworld_plane_norm != null
// to get tile disparities needed to calculate tilts // to get tile disparities needed to calculate tilts
...@@ -1530,9 +1656,13 @@ public class SuperTiles{ ...@@ -1530,9 +1656,13 @@ public class SuperTiles{
smplRms, //double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, //double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// true, // boolean null_if_none); // true, // boolean null_if_none);
smplWnd, // boolean smplWnd, // smplWnd, // boolean smplWnd, //
2.0, // double max_abs_tilt, // = 2.0; // pix per tile max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
0.2, // double max_rel_tilt, // = 0.2; // (pix / disparity) per tile max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
0.001, // double damp_tilt, // damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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);
dl); dl);
} else { } else {
...@@ -1634,6 +1764,7 @@ public class SuperTiles{ ...@@ -1634,6 +1764,7 @@ public class SuperTiles{
final double max_diff2 = Double.isNaN(max_diff)? Double.NaN: (max_diff*max_diff); final double max_diff2 = Double.isNaN(max_diff)? Double.NaN: (max_diff*max_diff);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
if (disparity_strengths[nsTile] != null){ if (disparity_strengths[nsTile] != null){
...@@ -1931,6 +2062,15 @@ public class SuperTiles{ ...@@ -1931,6 +2062,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions fro the samples final boolean smplWnd, // use window functions fro the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins) final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins)
final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins) final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
// TODO: scale down max_diff_hor, max_diff_vert for large disparities? // TODO: scale down max_diff_hor, max_diff_vert for large disparities?
...@@ -2011,7 +2151,16 @@ public class SuperTiles{ ...@@ -2011,7 +2151,16 @@ public class SuperTiles{
smplSide, // final int smplSide, // = 2; // Sample size (side of a square) smplSide, // final int smplSide, // = 2; // Sample size (side of a square)
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions fro the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel, debugLevel,
dbg_X, dbg_X,
dbg_Y); dbg_Y);
...@@ -2026,7 +2175,16 @@ public class SuperTiles{ ...@@ -2026,7 +2175,16 @@ public class SuperTiles{
smplSide, // final int smplSide, // = 2; // Sample size (side of a square) smplSide, // final int smplSide, // = 2; // Sample size (side of a square)
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions fro the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel, debugLevel,
dbg_X, dbg_X,
dbg_Y); dbg_Y);
...@@ -2110,6 +2268,7 @@ public class SuperTiles{ ...@@ -2110,6 +2268,7 @@ public class SuperTiles{
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
// int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 3 : 0; // int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 3 : 0;
...@@ -2230,6 +2389,13 @@ public class SuperTiles{ ...@@ -2230,6 +2389,13 @@ public class SuperTiles{
* @param smplNum number of best samples used fro averaging * @param smplNum number of best samples used fro averaging
* @param smplRms maximal sample disparity rms to consider sample valid * @param smplRms maximal sample disparity rms to consider sample valid
* @param smplWnd use window functions for the samples * @param smplWnd use window functions for the samples
* @param max_abs_tilt pix per tile
* @param max_rel_tilt pix / disparity) per tile
* @param damp_tilt Damp tilt to handle insufficient (co-linear)data
* @param min_tilt_disp Disparity switch between filtering modes - near objects use tilts, far - use max disparity
* @param transition Mode transition range (between tilted and maximal disparity)
* @param far_mode Far objects filtering mode (0 - off, 1 - power of disparity)
* @param far_power Raise disparity to this power before averaging for far objects
* @param plDiscrTolerance maximal disparity difference from the plane to consider tile * @param plDiscrTolerance maximal disparity difference from the plane to consider tile
* @param plDiscrDispRange parallel move known planes around original know value for the best overall fit * @param plDiscrDispRange parallel move known planes around original know value for the best overall fit
* @param plDiscrSteps number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) * @param plDiscrSteps number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -2260,6 +2426,14 @@ public class SuperTiles{ ...@@ -2260,6 +2426,14 @@ public class SuperTiles{
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions for the samples final boolean smplWnd, // use window functions for the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 1.0; // Raise disparity to this power before averaging for far objects
final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile
final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit
final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -2299,6 +2473,7 @@ public class SuperTiles{ ...@@ -2299,6 +2473,7 @@ public class SuperTiles{
final boolean [][][][] planes_selections = new boolean [nStiles][][][]; // num_tiles final boolean [][][][] planes_selections = new boolean [nStiles][][][]; // num_tiles
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
// int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 3 : 1; // int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 3 : 1;
...@@ -2334,6 +2509,15 @@ public class SuperTiles{ ...@@ -2334,6 +2509,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
plDiscrTolerance, // final double disp_tolerance, // maximal disparity difference from the plane to consider tile plDiscrTolerance, // final double disp_tolerance, // maximal disparity difference from the plane to consider tile
plDiscrVarFloor, // final double disp_var_floor, // squared add to variance to calculate reverse flatness (used mostly for single-cell clusters) plDiscrVarFloor, // final double disp_var_floor, // squared add to variance to calculate reverse flatness (used mostly for single-cell clusters)
plDiscrSigma, // final double disp_sigma, // G.sigma to compare how measured data is attracted to planes plDiscrSigma, // final double disp_sigma, // G.sigma to compare how measured data is attracted to planes
...@@ -2444,6 +2628,15 @@ public class SuperTiles{ ...@@ -2444,6 +2628,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions for the samples final boolean smplWnd, // use window functions for the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
...@@ -2468,6 +2661,7 @@ public class SuperTiles{ ...@@ -2468,6 +2661,7 @@ public class SuperTiles{
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
// int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel; // int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
...@@ -2511,6 +2705,15 @@ public class SuperTiles{ ...@@ -2511,6 +2705,15 @@ public class SuperTiles{
smplNum, // int smplNum, // = 3; // Number after removing worst smplNum, // int smplNum, // = 3; // Number after removing worst
smplRms, // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
dl); // int debugLevel); dl); // int debugLevel);
if ((st_planes != null) && (!st_planes.isEmpty())){ if ((st_planes != null) && (!st_planes.isEmpty())){
...@@ -2554,6 +2757,15 @@ public class SuperTiles{ ...@@ -2554,6 +2757,15 @@ public class SuperTiles{
smplNum, // int smplNum, // = 3; // Number after removing worst smplNum, // int smplNum, // = 3; // Number after removing worst
smplRms, // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
dl - 1); // int debugLevel); dl - 1); // int debugLevel);
} }
...@@ -2634,6 +2846,15 @@ public class SuperTiles{ ...@@ -2634,6 +2846,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions fro the samples final boolean smplWnd, // use window functions fro the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins) final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins)
final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins) final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes
...@@ -2673,6 +2894,15 @@ public class SuperTiles{ ...@@ -2673,6 +2894,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions fro the samples smplWnd, // final boolean smplWnd, // use window functions fro 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
bin_blur_hor, // final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins) bin_blur_hor, // final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins)
bin_blur_vert, // final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins) bin_blur_vert, // final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
max_diff_hor, // final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes max_diff_hor, // final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes
...@@ -2702,6 +2932,15 @@ public class SuperTiles{ ...@@ -2702,6 +2932,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions fro the samples smplWnd, // final boolean smplWnd, // use window functions fro 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel, // final int debugLevel, debugLevel, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
...@@ -2726,6 +2965,14 @@ public class SuperTiles{ ...@@ -2726,6 +2965,14 @@ public class SuperTiles{
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel + 0, // 1, // + 2, // 1, // final int debugLevel, debugLevel + 0, // 1, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
...@@ -2751,6 +2998,14 @@ public class SuperTiles{ ...@@ -2751,6 +2998,14 @@ public class SuperTiles{
* @param smplSide sample side for averaging/filtering tile disparities * @param smplSide sample side for averaging/filtering tile disparities
* @param smplNum number of best samples used fro averaging * @param smplNum number of best samples used fro averaging
* @param smplRms maximal sample disparity rms to consider sample valid * @param smplRms maximal sample disparity rms to consider sample valid
* @param smplWnd use window functions for the samples
* @param max_abs_tilt pix per tile
* @param max_rel_tilt pix / disparity) per tile
* @param damp_tilt Damp tilt to handle insufficient (co-linear)data
* @param min_tilt_disp Disparity switch between filtering modes - near objects use tilts, far - use max disparity
* @param transition Mode transition range (between tilted and maximal disparity)
* @param far_mode Far objects filtering mode (0 - off, 1 - power of disparity)
* @param far_power Raise disparity to this power before averaging for far objects
* @param plDiscrTolerance maximal disparity difference from the plane to consider tile * @param plDiscrTolerance maximal disparity difference from the plane to consider tile
* @param plDiscrDispRange parallel move known planes around original know value for the best overall fit * @param plDiscrDispRange parallel move known planes around original know value for the best overall fit
* @param plDiscrSteps number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) * @param plDiscrSteps number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -2782,6 +3037,15 @@ public class SuperTiles{ ...@@ -2782,6 +3037,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions for the samples final boolean smplWnd, // use window functions for the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile
final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit
final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -2824,6 +3088,15 @@ public class SuperTiles{ ...@@ -2824,6 +3088,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
plDiscrTolerance, //final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile plDiscrTolerance, //final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile
plDiscrDispRange, // final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit plDiscrDispRange, // final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit
plDiscrSteps, // final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) plDiscrSteps, // final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -2862,6 +3135,15 @@ public class SuperTiles{ ...@@ -2862,6 +3135,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel, // final int debugLevel, debugLevel, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
...@@ -2885,6 +3167,15 @@ public class SuperTiles{ ...@@ -2885,6 +3167,15 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel, // + 2, // 1, // final int debugLevel, debugLevel, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
...@@ -4461,6 +4752,7 @@ public class SuperTiles{ ...@@ -4461,6 +4752,7 @@ public class SuperTiles{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
ConnectionCosts connectionCosts = new ConnectionCosts( ConnectionCosts connectionCosts = new ConnectionCosts(
orthoWeight, // double orthoWeight, orthoWeight, // double orthoWeight,
...@@ -4516,6 +4808,7 @@ public class SuperTiles{ ...@@ -4516,6 +4808,7 @@ public class SuperTiles{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
ConnectionCosts connectionCosts = new ConnectionCosts( ConnectionCosts connectionCosts = new ConnectionCosts(
orthoWeight, // double orthoWeight, orthoWeight, // double orthoWeight,
...@@ -6146,6 +6439,7 @@ public class SuperTiles{ ...@@ -6146,6 +6439,7 @@ public class SuperTiles{
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < planes.length; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < planes.length; nsTile = ai.getAndIncrement()) {
// int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 4:0; // int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 4:0;
...@@ -6178,6 +6472,15 @@ public class SuperTiles{ ...@@ -6178,6 +6472,15 @@ public class SuperTiles{
smplNum, smplNum,
smplRms, smplRms,
smplWnd, smplWnd,
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
dl - 2); // int debugLevel) dl - 2); // int debugLevel)
if (disp_strength == null) { if (disp_strength == null) {
System.out.println("=== BUG in applyMergePlanes(): failed to getPlaneFromMeas() for merged planes"); System.out.println("=== BUG in applyMergePlanes(): failed to getPlaneFromMeas() for merged planes");
...@@ -6199,6 +6502,17 @@ public class SuperTiles{ ...@@ -6199,6 +6502,17 @@ public class SuperTiles{
smplSide, smplSide,
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // was not here
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
dl - 2); // int debugLevel) dl - 2); // int debugLevel)
...@@ -6335,6 +6649,15 @@ public class SuperTiles{ ...@@ -6335,6 +6649,15 @@ public class SuperTiles{
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions for the samples final boolean smplWnd, // use window functions for the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final int debugLevel, final int debugLevel,
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
...@@ -6351,6 +6674,7 @@ public class SuperTiles{ ...@@ -6351,6 +6674,7 @@ public class SuperTiles{
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
double [][] dbg_img = null; double [][] dbg_img = null;
String [] dbg_titles = null; String [] dbg_titles = null;
...@@ -6489,6 +6813,15 @@ public class SuperTiles{ ...@@ -6489,6 +6813,15 @@ public class SuperTiles{
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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, // int measSel, // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert measSel, // int measSel, // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
allow_parallel, //boolean allow_parallel, allow_parallel, //boolean allow_parallel,
dl); // int debugLevel) dl); // int debugLevel)
...@@ -6528,6 +6861,15 @@ public class SuperTiles{ ...@@ -6528,6 +6861,15 @@ public class SuperTiles{
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // final boolean smplWnd, // use window functions for the samples smplWnd, // final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
dl); // int debugLevel) dl); // int debugLevel)
if (disp_strength == null) break; if (disp_strength == null) break;
// remove outliers //removeOutliers // remove outliers //removeOutliers
...@@ -6563,6 +6905,16 @@ public class SuperTiles{ ...@@ -6563,6 +6905,16 @@ public class SuperTiles{
smplSide, smplSide,
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // was not here: final boolean 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
dl); // int debugLevel) dl); // int debugLevel)
} }
if (!OK) { if (!OK) {
...@@ -6684,6 +7036,7 @@ public class SuperTiles{ ...@@ -6684,6 +7036,7 @@ public class SuperTiles{
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
double [][] dbg_img=null; double [][] dbg_img=null;
for (int nsTile0 = ai.getAndIncrement(); nsTile0 < center_planes.length; nsTile0 = ai.getAndIncrement()) { for (int nsTile0 = ai.getAndIncrement(); nsTile0 < center_planes.length; nsTile0 = ai.getAndIncrement()) {
...@@ -7135,6 +7488,7 @@ public class SuperTiles{ ...@@ -7135,6 +7488,7 @@ public class SuperTiles{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < disparity.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < disparity.length; nTile = ai.getAndIncrement()) {
if ((selection == null) || selection[nTile]) { if ((selection == null) || selection[nTile]) {
...@@ -7405,6 +7759,7 @@ public class SuperTiles{ ...@@ -7405,6 +7759,7 @@ public class SuperTiles{
final int emptyTile = -256; final int emptyTile = -256;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < snap_surf.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < snap_surf.length; nTile = ai.getAndIncrement()) {
neibs[nTile] = emptyTile; neibs[nTile] = emptyTile;
...@@ -7521,6 +7876,7 @@ public class SuperTiles{ ...@@ -7521,6 +7876,7 @@ public class SuperTiles{
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
for (int nTile = ai.getAndIncrement(); nTile < disparity.length; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < disparity.length; nTile = ai.getAndIncrement()) {
if ((selection == null) || selection[nTile]) { if ((selection == null) || selection[nTile]) {
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
*/ */
import java.awt.Point; import java.awt.Point;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
...@@ -96,6 +95,16 @@ public class TilePlanes { ...@@ -96,6 +95,16 @@ public class TilePlanes {
double smplRms = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd = false; // Use sample mode (false - regular tile mode) boolean smplWnd = false; // Use sample mode (false - regular tile mode)
double max_abs_tilt = 2.0; // Maximal absolute tilt in pixels/tile
double max_rel_tilt = 0.2; // Maximal relative tilt in pixels/tile/disparity
double damp_tilt = 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp = 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition = 1.0; // Mode transition range (between tilted and maximal disparity)
int far_mode = 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
double far_power = 1.0; // Raise disparity to this power before averaging for far objects
double [] starValueWeight = null; double [] starValueWeight = null;
PlaneData starPlane = null; PlaneData starPlane = null;
PlaneData nonexclusiveStar = null; PlaneData nonexclusiveStar = null;
...@@ -115,6 +124,7 @@ public class TilePlanes { ...@@ -115,6 +124,7 @@ public class TilePlanes {
int mark0 = -1; // just for temporary labeling the plane int mark0 = -1; // just for temporary labeling the plane
@Override
public PlaneData clone(){ public PlaneData clone(){
PlaneData pd = new PlaneData( PlaneData pd = new PlaneData(
this.sTileXY, this.sTileXY,
...@@ -159,6 +169,14 @@ public class TilePlanes { ...@@ -159,6 +169,14 @@ public class TilePlanes {
pd.smplNum = this.smplNum; pd.smplNum = this.smplNum;
pd.smplRms = this.smplRms; pd.smplRms = this.smplRms;
pd.max_abs_tilt = this.max_abs_tilt;
pd.max_rel_tilt = this.max_rel_tilt;
pd.damp_tilt = this.damp_tilt;
pd.min_tilt_disp = this.min_tilt_disp;
pd.transition = this.transition;
pd.far_mode = this.far_mode;
pd.far_power = this.far_power;
pd.preferDisparity = this.preferDisparity; pd.preferDisparity = this.preferDisparity;
copyNeib(this,pd); copyNeib(this,pd);
...@@ -265,6 +283,7 @@ public class TilePlanes { ...@@ -265,6 +283,7 @@ public class TilePlanes {
return cp2/(this_wv2 * other_wv2); return cp2/(this_wv2 * other_wv2);
} }
@Override
public String toString() public String toString()
{ {
...@@ -749,6 +768,15 @@ public class TilePlanes { ...@@ -749,6 +768,15 @@ public class TilePlanes {
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // use window functions for the samples 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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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, // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert int measSel, // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
boolean allow_parallel, boolean allow_parallel,
int debugLevel) int debugLevel)
...@@ -791,7 +819,13 @@ public class TilePlanes { ...@@ -791,7 +819,13 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples smplWnd, // use window functions for the samples
0.001, // double damp_tilt, // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} else { } else {
...@@ -918,7 +952,13 @@ public class TilePlanes { ...@@ -918,7 +952,13 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples smplWnd, // use window functions for the samples
0.001, // double damp_tilt, // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} else { } else {
...@@ -1170,7 +1210,15 @@ public class TilePlanes { ...@@ -1170,7 +1210,15 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples smplWnd, // use window functions for the samples
0.001, // double damp_tilt, //
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} }
...@@ -1250,6 +1298,13 @@ public class TilePlanes { ...@@ -1250,6 +1298,13 @@ public class TilePlanes {
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // use window functions for the samples 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel-1) != null); debugLevel-1) != null);
if (!OK){ // restore last selection, re-run getPlaneFromMeas if (!OK){ // restore last selection, re-run getPlaneFromMeas
...@@ -1269,6 +1324,13 @@ public class TilePlanes { ...@@ -1269,6 +1324,13 @@ public class TilePlanes {
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // use window functions for the samples 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel-1) != null); debugLevel-1) != null);
if (!OK) { if (!OK) {
System.out.println("This is a BUG in removePlaneOutliers() - run with previous selection and failed"); System.out.println("This is a BUG in removePlaneOutliers() - run with previous selection and failed");
...@@ -1322,6 +1384,15 @@ public class TilePlanes { ...@@ -1322,6 +1384,15 @@ public class TilePlanes {
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // use window functions for the samples 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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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 debugLevel) int debugLevel)
{ {
double mindet = 1E-15; double mindet = 1E-15;
...@@ -1345,6 +1416,15 @@ public class TilePlanes { ...@@ -1345,6 +1416,15 @@ public class TilePlanes {
this.smplNum = smplNum; // = 3; // Number after removing worst this.smplNum = smplNum; // = 3; // Number after removing worst
this.smplRms = smplRms; // = 0.1; // Maximal RMS of the remaining tiles in a sample this.smplRms = smplRms; // = 0.1; // Maximal RMS of the remaining tiles in a sample
this.max_abs_tilt = max_abs_tilt;
this.max_rel_tilt = max_rel_tilt;
this.damp_tilt = damp_tilt;
this.min_tilt_disp = min_tilt_disp;
this.transition = transition;
this.far_mode = far_mode;
this.far_power = far_power;
if (debugLevel > 2){ if (debugLevel > 2){
System.out.println("getPlaneFromMeas()"); System.out.println("getPlaneFromMeas()");
} }
...@@ -1369,7 +1449,13 @@ public class TilePlanes { ...@@ -1369,7 +1449,13 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // final boolean smplWnd, // use window functions fro the samples smplWnd, // final boolean smplWnd, // use window functions fro the samples
0.001, // double damp_tilt, // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} }
...@@ -1632,6 +1718,17 @@ public class TilePlanes { ...@@ -1632,6 +1718,17 @@ public class TilePlanes {
int smplSide, // = 2; // Sample size (side of a square) int smplSide, // = 2; // Sample size (side of a square)
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
/* was not here */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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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 debugLevel) int debugLevel)
{ {
double mindet = 1E-15; double mindet = 1E-15;
...@@ -1654,6 +1751,16 @@ public class TilePlanes { ...@@ -1654,6 +1751,16 @@ public class TilePlanes {
this.smplNum = smplNum; // = 3; // Number after removing worst this.smplNum = smplNum; // = 3; // Number after removing worst
this.smplRms = smplRms; // = 0.1; // Maximal RMS of the remaining tiles in a sample this.smplRms = smplRms; // = 0.1; // Maximal RMS of the remaining tiles in a sample
this.smplWnd = smplWnd; // was not here !
this.max_abs_tilt = max_abs_tilt;
this.max_rel_tilt = max_rel_tilt;
this.damp_tilt = damp_tilt;
this.min_tilt_disp = min_tilt_disp;
this.transition = transition;
this.far_mode = far_mode;
this.far_power = far_power;
if (debugLevel > 2){ if (debugLevel > 2){
System.out.println("getWorldPlaneFromMeas()"); System.out.println("getWorldPlaneFromMeas()");
} }
...@@ -1678,8 +1785,14 @@ public class TilePlanes { ...@@ -1678,8 +1785,14 @@ public class TilePlanes {
smplSide, // = 2; // Sample size (side of a square) smplSide, // = 2; // Sample size (side of a square)
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples /*was using this. */ smplWnd, // use window functions for the samples
0.001, // double damp_tilt, // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} }
...@@ -3878,6 +3991,15 @@ public class TilePlanes { ...@@ -3878,6 +3991,15 @@ public class TilePlanes {
int smplNum, // = 3; // Number after removing worst int smplNum, // = 3; // Number after removing worst
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
boolean smplWnd, // use window functions for the samples 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 damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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 debugLevel) int debugLevel)
{ {
if (debugLevel > 2) { if (debugLevel > 2) {
...@@ -3908,6 +4030,15 @@ public class TilePlanes { ...@@ -3908,6 +4030,15 @@ public class TilePlanes {
smplNum, smplNum,
smplRms, smplRms,
smplWnd, // use window functions for the samples 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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel) != null); // int debugLevel) debugLevel) != null); // int debugLevel)
if (OK) { if (OK) {
if (debugLevel > 0) { if (debugLevel > 0) {
...@@ -3978,6 +4109,18 @@ public class TilePlanes { ...@@ -3978,6 +4109,18 @@ public class TilePlanes {
smplSide, smplSide,
smplNum, smplNum,
smplRms, smplRms,
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
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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
debugLevel); debugLevel);
} }
} }
...@@ -4006,6 +4149,14 @@ public class TilePlanes { ...@@ -4006,6 +4149,14 @@ public class TilePlanes {
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions for the samples final boolean smplWnd, // use window functions for the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final double max_disp_diff, // maximal disparity difference from the plane to consider tile final double max_disp_diff, // maximal disparity difference from the plane to consider tile
final double disp_range, // parallel move known planes around original know value for the best overall fit final double disp_range, // parallel move known planes around original know value for the best overall fit
final int amplitude_steps, // number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) final int amplitude_steps, // number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -4122,7 +4273,15 @@ public class TilePlanes { ...@@ -4122,7 +4273,15 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples smplWnd, // use window functions for the samples
0.001, // double damp_tilt, //
max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} else { } else {
...@@ -4388,6 +4547,16 @@ public class TilePlanes { ...@@ -4388,6 +4547,16 @@ public class TilePlanes {
* @param smplSide sample size (side of a square) * @param smplSide sample size (side of a square)
* @param smplNum number after removing worst * @param smplNum number after removing worst
* @param smplRms maximal RMS of the remaining tiles in a sample * @param smplRms maximal RMS of the remaining tiles in a sample
* @param smplWnd use window functions for the samples
*
* @param max_abs_tilt pix per tile
* @param max_rel_tilt pix / disparity) per tile
* @param damp_tilt Damp tilt to handle insufficient (co-linear)data
* @param min_tilt_disp Disparity switch between filtering modes - near objects use tilts, far - use max disparity
* @param transition Mode transition range (between tilted and maximal disparity)
* @param far_mode Far objects filtering mode (0 - off, 1 - power of disparity)
* @param far_power Raise disparity to this power before averaging for far objects
*
* @param disp_tolerance maximal disparity difference from the plane to consider tile * @param disp_tolerance maximal disparity difference from the plane to consider tile
* @param disp_var_floor squared add to variance to calculate reverse flatness (used mostly for single-cell clusters) (reuse disp_sigma)? * @param disp_var_floor squared add to variance to calculate reverse flatness (used mostly for single-cell clusters) (reuse disp_sigma)?
* @param disp_sigma Gaussian sigma to compare how measured data is attracted to planes * @param disp_sigma Gaussian sigma to compare how measured data is attracted to planes
...@@ -4419,6 +4588,15 @@ public class TilePlanes { ...@@ -4419,6 +4588,15 @@ public class TilePlanes {
final int smplNum, // = 3; // Number after removing worst final int smplNum, // = 3; // Number after removing worst
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final boolean smplWnd, // use window functions for the samples final boolean smplWnd, // use window functions for the samples
final double max_abs_tilt, // 2.0; // pix per tile
final double max_rel_tilt, // 0.2; // (pix / disparity) per tile
final double damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
final double min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
final double transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
final int far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
final double far_power, // 3.0; // Raise disparity to this power before averaging for far objects
final double disp_tolerance, // maximal disparity difference from the plane to consider tile final double disp_tolerance, // maximal disparity difference from the plane to consider tile
final double disp_var_floor, // squared add to variance to calculate reverse flatness (used mostly for single-cell clusters) final double disp_var_floor, // squared add to variance to calculate reverse flatness (used mostly for single-cell clusters)
final double disp_sigma, // G.sigma to compare how measured data is attracted to planes final double disp_sigma, // G.sigma to compare how measured data is attracted to planes
...@@ -4550,7 +4728,13 @@ public class TilePlanes { ...@@ -4550,7 +4728,13 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples smplWnd, // use window functions for the samples
0.001, // double damp_tilt, // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} else { } else {
...@@ -5339,7 +5523,13 @@ public class TilePlanes { ...@@ -5339,7 +5523,13 @@ public class TilePlanes {
smplNum, // = 3; // Number after removing worst smplNum, // = 3; // Number after removing worst
smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
smplWnd, // use window functions for the samples smplWnd, // use window functions for the samples
0.001, // double damp_tilt, // max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
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)
debugLevel); debugLevel);
} else { } else {
......
...@@ -3518,7 +3518,7 @@ public class TileProcessor { ...@@ -3518,7 +3518,7 @@ public class TileProcessor {
final boolean show_scan = show_filter_scan || (debugLevel > 1); final boolean show_scan = show_filter_scan || (debugLevel > 1);
showDoubleFloatArrays sdfa_instance = null; showDoubleFloatArrays sdfa_instance = null;
if ((debugLevel > -2) && ((debugLevel > -1) || show_scan)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging? if ((debugLevel > -2) && ((debugLevel > -1) || show_scan)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
if (debugLevel > 0){ if (debugLevel > -2){
System.out.println("FilterScan(,,"+disparity_far+", " +disparity_near+", "+ sure_smth); System.out.println("FilterScan(,,"+disparity_far+", " +disparity_near+", "+ sure_smth);
} }
final int tlen = tilesY * tilesX; final int tlen = tilesY * tilesX;
...@@ -3747,7 +3747,8 @@ public class TileProcessor { ...@@ -3747,7 +3747,8 @@ public class TileProcessor {
return these_tiles; return these_tiles;
} }
// Next runs before filter, maybe should be after or combined otherwise (i.e filter strengths, but keep original disparities. Or use disparity
// to some power when averaging here)
public int [] combineOrthoDisparity( public int [] combineOrthoDisparity(
final CLTPass3d scan, // scan data final CLTPass3d scan, // scan data
final boolean or_hor, // true; // Apply ortho correction to horizontal correlation (vertical features) final boolean or_hor, // true; // Apply ortho correction to horizontal correlation (vertical features)
...@@ -3760,6 +3761,8 @@ public class TileProcessor { ...@@ -3760,6 +3761,8 @@ public class TileProcessor {
final double or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement final double or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement
final double or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement final double or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement
final double or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement final double or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement
final double or_maxDisp, // 5.0; // Maximal disparity to apply ortho correction
final boolean show_ortho, // show replacement of disparity/strength by those of hor/vert
final int debugLevel) final int debugLevel)
{ {
double [] disparity = scan.getDisparity(0); // calculated, to be modified double [] disparity = scan.getDisparity(0); // calculated, to be modified
...@@ -3769,6 +3772,31 @@ public class TileProcessor { ...@@ -3769,6 +3772,31 @@ public class TileProcessor {
double [] strength_hor = scan.getHorStrength(); // .clone(); double [] strength_hor = scan.getHorStrength(); // .clone();
double [] strength_vert = scan.getVertStrength(); // .clone(); double [] strength_vert = scan.getVertStrength(); // .clone();
int [] replaced = new int[strength.length]; int [] replaced = new int[strength.length];
double [][] dbg_img = null;
String [] dbg_titles = {"disparity", // 0
"orig_disparity", // 1
"hor_disparity", // 2
"hor_disparity_mod", // 3
"vert_disparity", // 4
"vert_disparity_mod",// 5
"strength", // 6
"orig_strength", // 7
"hor_strength", // 8
"hor_strength_mod", // 9
"vert_strength", // 10
"vert_strength_mod", // 11
"replaced"}; // 12
if (show_ortho) {
dbg_img=new double [dbg_titles.length][];
dbg_img[1] = disparity.clone();
dbg_img[2] = disparity_hor.clone();
dbg_img[4] = disparity_vert.clone();
dbg_img[7] = strength.clone();
dbg_img[8] = strength_hor.clone();
dbg_img[10] = strength_vert.clone();
}
if (or_hor){ if (or_hor){
for (int i = 0; i < strength_hor.length; i++){ for (int i = 0; i < strength_hor.length; i++){
strength_hor[i] *= or_scale; strength_hor[i] *= or_scale;
...@@ -3780,6 +3808,11 @@ public class TileProcessor { ...@@ -3780,6 +3808,11 @@ public class TileProcessor {
or_sharp, // double k, // sharpen in orthogonal direction with (-k,2*k-1,-k). 0 - no sharpening or_sharp, // double k, // sharpen in orthogonal direction with (-k,2*k-1,-k). 0 - no sharpening
or_offset, // double offset, // subtract from strength, limit by 0.0 or_offset, // double offset, // subtract from strength, limit by 0.0
false); // boolean vert) // true - sharpen vertically, blur horizontally. False - sharpen horizontally, blur vertically false); // boolean vert) // true - sharpen vertically, blur horizontally. False - sharpen horizontally, blur vertically
if (show_ortho) {
dbg_img[3] = disparity_hor.clone();
dbg_img[9] = strength_hor.clone();
}
} }
if (or_vert){ if (or_vert){
for (int i = 0; i < strength_vert.length; i++){ for (int i = 0; i < strength_vert.length; i++){
...@@ -3792,12 +3825,16 @@ public class TileProcessor { ...@@ -3792,12 +3825,16 @@ public class TileProcessor {
or_sharp, // double k, // sharpen in orthogonal direction with (-k,2*k-1,-k). 0 - no sharpening or_sharp, // double k, // sharpen in orthogonal direction with (-k,2*k-1,-k). 0 - no sharpening
or_offset, // double offset, // subtract from strength, limit by 0.0 or_offset, // double offset, // subtract from strength, limit by 0.0
true); // boolean vert) // true - sharpen vertically, blur horizontally. False - sharpen horizontally, blur vertically true); // boolean vert) // true - sharpen vertically, blur horizontally. False - sharpen horizontally, blur vertically
if (show_ortho) {
dbg_img[5] = disparity_vert.clone();
dbg_img[11] = strength_vert.clone();
}
} }
double ko = (or_threshold - 1) * or_offset; double ko = (or_threshold - 1) * or_offset;
double ao = (or_asym - 1) * or_offset; double ao = (or_asym - 1) * or_offset;
if (or_hor){ if (or_hor){
for (int i = 0; i < strength_hor.length; i++){ for (int i = 0; i < strength_hor.length; i++){
if ( if ( (disparity_hor[i] < or_maxDisp) &&
(strength_hor[i] > or_absHor) && (strength_hor[i] > or_absHor) &&
(strength_hor[i] > or_threshold * strength[i] - ko) && (strength_hor[i] > or_threshold * strength[i] - ko) &&
(!or_vert || (strength_hor[i] > or_asym * strength_vert[i] - ao))){ (!or_vert || (strength_hor[i] > or_asym * strength_vert[i] - ao))){
...@@ -3809,7 +3846,7 @@ public class TileProcessor { ...@@ -3809,7 +3846,7 @@ public class TileProcessor {
} }
if (or_vert){ if (or_vert){
for (int i = 0; i < strength_vert.length; i++){ for (int i = 0; i < strength_vert.length; i++){
if ( if ( (disparity_vert[i] < or_maxDisp) &&
(strength_vert[i] > or_absVert) && (strength_vert[i] > or_absVert) &&
(strength_vert[i] > or_threshold * strength[i] - ko) && (strength_vert[i] > or_threshold * strength[i] - ko) &&
(!or_hor || (strength_vert[i] > or_asym * strength_hor[i] - ao))){ (!or_hor || (strength_vert[i] > or_asym * strength_hor[i] - ao))){
...@@ -3819,6 +3856,15 @@ public class TileProcessor { ...@@ -3819,6 +3856,15 @@ public class TileProcessor {
} }
} }
} }
if (show_ortho) {
dbg_img[0] = disparity.clone();
dbg_img[6] = strength.clone();
dbg_img[12] = new double [replaced.length];
for (int i = 0; i < replaced.length; i++) {
dbg_img[12][i] = replaced[i];
}
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX, tilesY, true, "ortho_internal",dbg_titles);
}
return replaced; return replaced;
} }
...@@ -4192,6 +4238,8 @@ public class TileProcessor { ...@@ -4192,6 +4238,8 @@ public class TileProcessor {
clt_parameters.or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement clt_parameters.or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement
clt_parameters.or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement clt_parameters.or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement
clt_parameters.or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement clt_parameters.or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement
clt_parameters.or_maxDisp, // 5.0; // Maximal disparity to apply ortho correction
show_ortho, // show replacement of disparity/strength by those of hor/vert
debugLevel); debugLevel);
if (clt_parameters.poles_fix) { if (clt_parameters.poles_fix) {
...@@ -4311,6 +4359,13 @@ public class TileProcessor { ...@@ -4311,6 +4359,13 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram();
...@@ -4328,6 +4383,13 @@ public class TileProcessor { ...@@ -4328,6 +4383,13 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram();
...@@ -4457,7 +4519,7 @@ public class TileProcessor { ...@@ -4457,7 +4519,7 @@ public class TileProcessor {
for (int i = 0; i < masked_filtered.length; i++){ for (int i = 0; i < masked_filtered.length; i++){
if (!grown[i]) masked_filtered[i] = Double.NaN; if (!grown[i]) masked_filtered[i] = Double.NaN;
} }
if (show_super){ if (show_super && false){ // something is broken, java.lang.NullPointerException at TileProcessor.refinePassSetup(TileProcessor.java:4488)
String [] dbg_disp_tiltes={"masked", "filtered", "disp_combo", "disparity","st_disparity", "strength", String [] dbg_disp_tiltes={"masked", "filtered", "disp_combo", "disparity","st_disparity", "strength",
"st_strength","outlayers","these","border","border_tiles"}; // ,"before","after","after1","after2","after3","neib"}; "st_strength","outlayers","these","border","border_tiles"}; // ,"before","after","after1","after2","after3","neib"};
double [][] dbg_disp = new double [dbg_disp_tiltes.length][]; double [][] dbg_disp = new double [dbg_disp_tiltes.length][];
...@@ -5083,7 +5145,7 @@ public class TileProcessor { ...@@ -5083,7 +5145,7 @@ public class TileProcessor {
// if (use_supertiles || show_st) { // if (use_supertiles || show_st) {
String [] dbg_st_titles = {"raw", "sampled", "blurred"+clt_parameters.stSigma,"max-min-max"}; String [] dbg_st_titles = {"raw", "sampled", "blurred"+clt_parameters.stSigma,"max-min-max"};
double [][] dbg_hist = new double[dbg_st_titles.length][]; double [][] dbg_hist = new double[dbg_st_titles.length][];
if (show_st) { // otherwise only blured version is needed if (show_st) { // otherwise only blurred version is needed
scan_prev.setSuperTiles( scan_prev.setSuperTiles(
clt_parameters.stStepNear, // double step_disparity, clt_parameters.stStepNear, // double step_disparity,
clt_parameters.stStepFar, // double step_near, clt_parameters.stStepFar, // double step_near,
...@@ -5098,6 +5160,13 @@ public class TileProcessor { ...@@ -5098,6 +5160,13 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram();
scan_prev.setSuperTiles( scan_prev.setSuperTiles(
...@@ -5114,6 +5183,13 @@ public class TileProcessor { ...@@ -5114,6 +5183,13 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram();
} }
...@@ -5133,6 +5209,13 @@ public class TileProcessor { ...@@ -5133,6 +5209,13 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
if (show_st) { // otherwise only blured version is needed if (show_st) { // otherwise only blured version is needed
dbg_hist[2] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[2] = scan_prev.getSuperTiles().showDisparityHistogram();
...@@ -5162,6 +5245,13 @@ public class TileProcessor { ...@@ -5162,6 +5245,13 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
} }
...@@ -5187,6 +5277,14 @@ public class TileProcessor { ...@@ -5187,6 +5277,14 @@ public class TileProcessor {
clt_parameters.stSmplRms , // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms , // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.plBlurBinHor, // final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins) clt_parameters.plBlurBinHor, // final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins)
clt_parameters.plBlurBinVert, // final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins) clt_parameters.plBlurBinVert, // final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
clt_parameters.plMaxDiffHor, // final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes clt_parameters.plMaxDiffHor, // final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes
...@@ -5261,6 +5359,14 @@ public class TileProcessor { ...@@ -5261,6 +5359,14 @@ public class TileProcessor {
clt_parameters.stSmplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // final boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // final boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.plDiscrTolerance, // final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile clt_parameters.plDiscrTolerance, // final double plDiscrTolerance, // = 0.4; // Maximal disparity difference from the plane to consider tile
clt_parameters.plDiscrDispRange, // final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit clt_parameters.plDiscrDispRange, // final double plDiscrDispRange, // = 0.6; // Parallel move known planes around original know value for the best overall fit
clt_parameters.plDiscrSteps, // final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side) clt_parameters.plDiscrSteps, // final int plDiscrSteps, // = 3; // Number of steps (each direction) for each plane to search for the best fit (0 - single, 1 - 1 each side)
...@@ -5375,6 +5481,15 @@ public class TileProcessor { ...@@ -5375,6 +5481,15 @@ public class TileProcessor {
clt_parameters.stSmplNum , // final int smplNum, // = 3; // Number after removing worst clt_parameters.stSmplNum , // final int smplNum, // = 3; // Number after removing worst
clt_parameters.stSmplRms , // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms , // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
debugLevel, // 1, // final int debugLevel) debugLevel, // 1, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
...@@ -5967,6 +6082,9 @@ public class TileProcessor { ...@@ -5967,6 +6082,9 @@ public class TileProcessor {
clt_parameters.or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement clt_parameters.or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement
clt_parameters.or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement clt_parameters.or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement
clt_parameters.or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement clt_parameters.or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement
clt_parameters.or_maxDisp, // 5.0; // Maximal disparity to apply ortho correction
clt_parameters.show_ortho_combine, // show replacement of disparity/strength by those of hor/vert
debugLevelInner); debugLevelInner);
if (clt_parameters.poles_fix) { if (clt_parameters.poles_fix) {
...@@ -6026,7 +6144,7 @@ public class TileProcessor { ...@@ -6026,7 +6144,7 @@ public class TileProcessor {
// final int threadsMax, // maximal number of threads to launch // final int threadsMax, // maximal number of threads to launch
// final boolean updateStatus, // final boolean updateStatus,
batch_mode ? -5: 2); //debugLevel); batch_mode ? -5: 2); //debugLevel);
} else { } else { //!ortho_old
these_tiles= combineHorVertDisparity_old( these_tiles= combineHorVertDisparity_old(
scan_prev, // final CLTPass3d scan, scan_prev, // final CLTPass3d scan,
scan_bg.selected, // clt_3d_passes.get(0).selected, // final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0); scan_bg.selected, // clt_3d_passes.get(0).selected, // final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
...@@ -6091,6 +6209,15 @@ public class TileProcessor { ...@@ -6091,6 +6209,15 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // Use window functions for the samples clt_parameters.stSmplWnd, // Use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[0] = scan_prev.getSuperTiles().showDisparityHistogram();
...@@ -6108,6 +6235,15 @@ public class TileProcessor { ...@@ -6108,6 +6235,15 @@ public class TileProcessor {
clt_parameters.stSmplNum, // Number after removing worst clt_parameters.stSmplNum, // Number after removing worst
clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample clt_parameters.stSmplRms, // Maximal RMS of the remaining tiles in a sample
clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples clt_parameters.stSmplWnd, // boolean smplWnd, // use window functions for the samples
clt_parameters.fs_max_abs_tilt, // 2.0; // Maximal absolute tilt in pixels/tile
clt_parameters.fs_max_rel_tilt, // 0.2; // Maximal relative tilt in pixels/tile/disparity
clt_parameters.fs_damp_tilt, // 0.001; // Damp tilt to handle insufficient (co-linear)data
clt_parameters.fs_min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
clt_parameters.fs_transition, // 1.0; // Mode transition range (between tilted and maximal disparity)
clt_parameters.fs_far_mode, // 1; // Far objects filtering mode (0 - off, 1 - power of disparity)
clt_parameters.fs_far_power, // 1.0; // Raise disparity to this power before averaging for far objects
clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert clt_parameters.stMeasSel); // bitmask of the selected measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram(); dbg_hist[1] = scan_prev.getSuperTiles().showDisparityHistogram();
......
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