Commit b267218c authored by Andrey Filippov's avatar Andrey Filippov

testing planes

parent 5467504f
...@@ -143,9 +143,14 @@ public class CLTPass3d{ ...@@ -143,9 +143,14 @@ public class CLTPass3d{
superTiles = null; superTiles = null;
} }
public boolean [] getSelected(){ public boolean [] getSelected(){
return selected; return selected;
} }
public void setSelected (boolean [] selected) {
this.selected = selected;
}
public void fixNaNDisparity() public void fixNaNDisparity()
{ {
......
...@@ -34,7 +34,7 @@ public class DisparityProcessor { ...@@ -34,7 +34,7 @@ public class DisparityProcessor {
0b11111111, // middle 0b11111111, // middle
0b11110001, // middle right 0b11110001, // middle right
0b00000111, // bottom left 0b00000111, // bottom left
0b11000111, // mottom middle 0b11000111, // bottom middle
0b11000001}; // bottom right 0b11000001}; // bottom right
TileProcessor tp; TileProcessor tp;
...@@ -48,12 +48,26 @@ public class DisparityProcessor { ...@@ -48,12 +48,26 @@ public class DisparityProcessor {
this.scale_dz_dx = scale_dz_dx; this.scale_dz_dx = scale_dz_dx;
} }
public int [] getNeighbors( // creates neighbors mask from bitmask
int [] surf_indices,
int indx,
int tilesX)
{
boolean [] selected = new boolean [surf_indices.length];
for (int i = 0; i < surf_indices.length; i++){
selected[i] = surf_indices[i] == indx;
}
return getNeighbors(selected, tilesX);
}
public int [] getNeighbors( // creates neighbors mask from bitmask public int [] getNeighbors( // creates neighbors mask from bitmask
boolean [] selected, boolean [] selected,
int tilesX int tilesX
) )
{ {
int [] neibs = new int [selected.length]; int [] neibs = new int [selected.length];
int tilesY = selected.length/tilesX;
final int [] dirs8 = {-tilesX, -tilesX + 1, 1, tilesX +1, tilesX, tilesX - 1, -1, -tilesX - 1}; final int [] dirs8 = {-tilesX, -tilesX + 1, 1, tilesX +1, tilesX, tilesX - 1, -1, -tilesX - 1};
for (int nTile = 0; nTile < selected.length; nTile++) { for (int nTile = 0; nTile < selected.length; nTile++) {
...@@ -68,7 +82,7 @@ public class DisparityProcessor { ...@@ -68,7 +82,7 @@ public class DisparityProcessor {
} else { } else {
tileType = 1; tileType = 1;
} }
} else if (tileX == (tilesX - 1)) { } else if (tileY == (tilesY - 1)) {
if (tileX == 0){ if (tileX == 0){
tileType = 6; tileType = 6;
} else if (tileX == (tilesX - 1)) { } else if (tileX == (tilesX - 1)) {
...@@ -93,11 +107,10 @@ public class DisparityProcessor { ...@@ -93,11 +107,10 @@ public class DisparityProcessor {
} }
} }
else { else {
neibs[nTile] = 0; neibs[nTile] = 0; // change to -1?
} }
} }
return neibs; return neibs;
} }
public double [] dbgShowNeighbors( public double [] dbgShowNeighbors(
...@@ -114,19 +127,21 @@ public class DisparityProcessor { ...@@ -114,19 +127,21 @@ public class DisparityProcessor {
int height = tilesY * tile_size; int height = tilesY * tile_size;
double [] rslt = new double [width*height]; double [] rslt = new double [width*height];
for (int i = 0; i < rslt.length; i++) rslt[i] = bgnd; for (int i = 0; i < rslt.length; i++) rslt[i] = bgnd;
for (int nTile = 0; nTile < neighbors.length; nTile++)if (selected[nTile]) { // if (neighbors[nTile] != 0) { for (int nTile = 0; nTile < neighbors.length; nTile++) {
int tileY = nTile / tilesX; if ((neighbors [nTile] >=0) && ((selected == null) || selected[nTile])) { // if (neighbors[nTile] != 0) {
int tileX = nTile % tilesX; int tileY = nTile / tilesX;
for (int i = -1; i<= 1; i++){ int tileX = nTile % tilesX;
for (int j = -1; j<= 1; j++){ for (int i = -1; i<= 1; i++){
rslt[(tileY*tile_size + tile_size/2 + i) * width + (tileX*tile_size + tile_size/2 + j)] = fgnd; for (int j = -1; j<= 1; j++){
rslt[(tileY*tile_size + tile_size/2 + i) * width + (tileX*tile_size + tile_size/2 + j)] = fgnd;
}
} }
} for (int ib = 0; ib < dirXY8.length; ib++) if ((neighbors[nTile] & (1 << ib)) != 0){
for (int ib = 0; ib < dirXY8.length; ib++) if ((neighbors[nTile] & (1 << ib)) != 0){ for (int i = 0; i <= tile_size/2; i++){
for (int i = 0; i <= tile_size/2; i++){ int x = tileX*tile_size + tile_size/2 + i * dirXY8[ib][0];
int x = tileX*tile_size + tile_size/2 + i * dirXY8[ib][0]; int y = tileY*tile_size + tile_size/2 + i * dirXY8[ib][1];
int y = tileY*tile_size + tile_size/2 + i * dirXY8[ib][1]; rslt[y*width+x] = fgnd;
rslt[y*width+x] = fgnd; }
} }
} }
} }
...@@ -267,7 +282,7 @@ public class DisparityProcessor { ...@@ -267,7 +282,7 @@ public class DisparityProcessor {
int numBorder = 0, numInternal = 0; int numBorder = 0, numInternal = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if ((border != null) && border[i]) numBorder++; if ((border != null) && border[i]) numBorder++;
else if (selected[i]) numInternal++; // only if not border else if (selected[i] && (neighbors[i] >= 0)) numInternal++; // only if not border
} }
final int numTiles = (((mask & 1) != 0)? numInternal : 0) + (((mask & 2) != 0)? numBorder : 0); final int numTiles = (((mask & 1) != 0)? numInternal : 0) + (((mask & 2) != 0)? numBorder : 0);
final int [] indices = new int [numBorder + numInternal]; // internal excludes border final int [] indices = new int [numBorder + numInternal]; // internal excludes border
...@@ -275,7 +290,7 @@ public class DisparityProcessor { ...@@ -275,7 +290,7 @@ public class DisparityProcessor {
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if ((border != null) && border[i]){ if ((border != null) && border[i]){
if ((mask & 2) != 0) indices[indx++] = i; if ((mask & 2) != 0) indices[indx++] = i;
} else if (selected[i]) { } else if (selected[i] && (neighbors[i] >= 0)) {
if ((mask & 1) != 0) indices[indx++] = i; if ((mask & 1) != 0) indices[indx++] = i;
} }
} }
...@@ -329,7 +344,7 @@ public class DisparityProcessor { ...@@ -329,7 +344,7 @@ public class DisparityProcessor {
if ((debugLevel > 0) &&(nTile == dbg_tile)) { if ((debugLevel > 0) &&(nTile == dbg_tile)) {
System.out.println("smoothDisparity() nTile = "+nTile+" tileX="+tileX+" tileY="+tileY); System.out.println("smoothDisparity() nTile = "+nTile+" tileX="+tileX+" tileY="+tileY);
} }
for (int i = 0; i < dirs8.length; i++) if ((neighbors[nTile] & (1 << i)) !=0) { for (int i = 0; i < dirs8.length; i++) if ((neighbors[nTile] >= 0) && ((neighbors[nTile] & (1 << i)) != 0)) {
double w = rigid8[i]; // no strength here strength[nTile + dirs8[i]] double w = rigid8[i]; // no strength here strength[nTile + dirs8[i]]
int dbg_dirs8 = nTile + dirs8[i]; int dbg_dirs8 = nTile + dirs8[i];
double dbg_d = disp_data[0][nTile + dirs8[i]]; double dbg_d = disp_data[0][nTile + dirs8[i]];
...@@ -475,12 +490,12 @@ public class DisparityProcessor { ...@@ -475,12 +490,12 @@ public class DisparityProcessor {
final int len = disparity.length; final int len = disparity.length;
int numTiles = 0; int numTiles = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i]) numTiles++; // only if not border if (selected[i] && (neighbors[i] >= 0)) numTiles++; // only if not border
} }
final int [] indices = new int [numTiles]; // internal excludes border final int [] indices = new int [numTiles]; // internal excludes border
int indx = 0; int indx = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i]) { if (selected[i] && (neighbors[i] >= 0)) {
indices[indx++] = i; indices[indx++] = i;
} }
} }
...@@ -488,9 +503,6 @@ public class DisparityProcessor { ...@@ -488,9 +503,6 @@ public class DisparityProcessor {
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY(); final int tilesY = tp.getTilesY();
final double [][] deriv3HV = new double [2][len]; // 4-th derivative [0] - horizontal, 1 - vertical final double [][] deriv3HV = new double [2][len]; // 4-th derivative [0] - horizontal, 1 - vertical
// neighbors
// final int [][] neib_data = {neighbors, new int [len]};
// final double [] k4_3 = { 1.0, -3.0, 3.0, -1.0}; // 3-rd
final double [] k4_3 = {-1.0, 3.0, -3.0, 1.0}; // 3-rd final double [] k4_3 = {-1.0, 3.0, -3.0, 1.0}; // 3-rd
final double [] k4_2 = {-1.0, 1.0, 1.0, -1.0}; // - 2-nd (average for 2 sides) final double [] k4_2 = {-1.0, 1.0, 1.0, -1.0}; // - 2-nd (average for 2 sides)
final double [] k4 = (mode == 2)? k4_2 : k4_3; final double [] k4 = (mode == 2)? k4_2 : k4_3;
...@@ -503,7 +515,8 @@ public class DisparityProcessor { ...@@ -503,7 +515,8 @@ public class DisparityProcessor {
// int tileY = nTile/tilesX; // int tileY = nTile/tilesX;
// int tileX = nTile - (tileY * tilesX); // int tileX = nTile - (tileY * tilesX);
// double deriv4; // double deriv4;
int neib = neighbors[nTile]; int neib = neighbors[nTile];
if (neib < 0) neib = 0; // should not get here
// try break horizontally (always - to the right) // try break horizontally (always - to the right)
int b = (1 << 2); // "E" (right) int b = (1 << 2); // "E" (right)
int rb = (1 << 6); // "W" (left) int rb = (1 << 6); // "W" (left)
...@@ -518,8 +531,8 @@ public class DisparityProcessor { ...@@ -518,8 +531,8 @@ public class DisparityProcessor {
if ((neib & rb) != 0) deriv += k4[0]*disparity[nTile - 1]; if ((neib & rb) != 0) deriv += k4[0]*disparity[nTile - 1];
else if (extend_flat) deriv += k4[0]*disparity[nTile]; else if (extend_flat) deriv += k4[0]*disparity[nTile];
else break hor_label; else break hor_label;
if ((neighbors[nTile + 1] & b) != 0) deriv += k4[3]* disparity[nTile + 2]; if ((neighbors[nTile + 1] >=0) && ((neighbors[nTile + 1] & b) != 0)) deriv += k4[3]* disparity[nTile + 2];
else if (extend_flat) deriv += k4[3]* disparity[nTile + 1]; else if (extend_flat) deriv += k4[3]* disparity[nTile + 1];
else break hor_label; else break hor_label;
switch (mode){ switch (mode){
case 1: case 1:
...@@ -547,8 +560,8 @@ public class DisparityProcessor { ...@@ -547,8 +560,8 @@ public class DisparityProcessor {
if ((neib & rb) != 0) deriv += k4[0]*disparity[nTile - tilesX]; if ((neib & rb) != 0) deriv += k4[0]*disparity[nTile - tilesX];
else if (extend_flat) deriv += k4[0]*disparity[nTile]; else if (extend_flat) deriv += k4[0]*disparity[nTile];
else break vert_label; else break vert_label;
if ((neighbors[nTile + tilesX] & b) != 0) deriv += k4[3]*disparity[nTile + 2 * tilesX]; if ((neighbors[nTile + + tilesX] >=0) && ((neighbors[nTile + tilesX] & b) != 0)) deriv += k4[3] * disparity[nTile + 2 * tilesX];
else if (extend_flat) deriv += k4[3]*disparity[nTile + tilesX]; else if (extend_flat) deriv += k4[3] * disparity[nTile + tilesX];
else break vert_label; else break vert_label;
switch (mode){ switch (mode){
case 1: case 1:
...@@ -624,6 +637,7 @@ public class DisparityProcessor { ...@@ -624,6 +637,7 @@ public class DisparityProcessor {
int tileY = nTile/tilesX; int tileY = nTile/tilesX;
int tileX = nTile - (tileY * tilesX); int tileX = nTile - (tileY * tilesX);
int neib = neighbors_in[nTile]; int neib = neighbors_in[nTile];
if (neib < 0) neib = 0;
if (Math.abs(deriv3HV[0][nTile]) >= break3) neib &= ~0b00001110; // break all right side if (Math.abs(deriv3HV[0][nTile]) >= break3) neib &= ~0b00001110; // break all right side
if (Math.abs(deriv3HV[1][nTile]) >= break3) neib &= ~0b00111000; // break all down side if (Math.abs(deriv3HV[1][nTile]) >= break3) neib &= ~0b00111000; // break all down side
if ((tileX > 0) && selected[nTile - 1] && (Math.abs(deriv3HV[0][nTile - 1]) >= break3)) neib &= ~0b11100000; // break all left side if ((tileX > 0) && selected[nTile - 1] && (Math.abs(deriv3HV[0][nTile - 1]) >= break3)) neib &= ~0b11100000; // break all left side
...@@ -655,6 +669,7 @@ public class DisparityProcessor { ...@@ -655,6 +669,7 @@ public class DisparityProcessor {
int tileY = nTile/tilesX; int tileY = nTile/tilesX;
int tileX = nTile - (tileY * tilesX); int tileX = nTile - (tileY * tilesX);
int neib = neighbors_in[nTile]; int neib = neighbors_in[nTile];
if (neib < 0) neib = 0;
if (deriv3HV[0][nTile] >= break3) neib &= ~0b00001110; // break all right side if (deriv3HV[0][nTile] >= break3) neib &= ~0b00001110; // break all right side
if (deriv3HV[1][nTile] >= break3) neib &= ~0b00111000; // break all down side if (deriv3HV[1][nTile] >= break3) neib &= ~0b00111000; // break all down side
if ((tileX > 0) && selected[nTile - 1] && (deriv3HV[0][nTile - 1] >= break3)) neib &= ~0b11100000; // break all left side if ((tileX > 0) && selected[nTile - 1] && (deriv3HV[0][nTile - 1] >= break3)) neib &= ~0b11100000; // break all left side
...@@ -709,12 +724,12 @@ public class DisparityProcessor { ...@@ -709,12 +724,12 @@ public class DisparityProcessor {
final int len = disparity.length; final int len = disparity.length;
int numTiles = 0; int numTiles = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i]) numTiles++; // only if not border if (selected[i] && (neighbors[i] >= 0)) numTiles++; // only if not border
} }
final int [] indices = new int [numTiles]; // internal excludes border final int [] indices = new int [numTiles]; // internal excludes border
int indx = 0; int indx = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i]) { if (selected[i] && (neighbors[i] >= 0)) {
indices[indx++] = i; indices[indx++] = i;
} }
} }
...@@ -730,7 +745,7 @@ public class DisparityProcessor { ...@@ -730,7 +745,7 @@ public class DisparityProcessor {
int tileY = nTile/tilesX; int tileY = nTile/tilesX;
int tileX = nTile - (tileY * tilesX); int tileX = nTile - (tileY * tilesX);
int neib = neighbors[nTile]; int neib = neighbors[nTile];
if (neib < 0) neib = 0;
int b = (1 << 2); // "E" (right) int b = (1 << 2); // "E" (right)
if (((neib & b) == 0) && (tileX < (tilesX - 1) && selected[nTile + 1])) { if (((neib & b) == 0) && (tileX < (tilesX - 1) && selected[nTile + 1])) {
if (Math.abs(disparity[nTile] - disparity[nTile + 1]) < maxDiffOrto){ if (Math.abs(disparity[nTile] - disparity[nTile + 1]) < maxDiffOrto){
...@@ -806,12 +821,12 @@ public class DisparityProcessor { ...@@ -806,12 +821,12 @@ public class DisparityProcessor {
final int len = neighbors.length; final int len = neighbors.length;
int numTiles = 0; int numTiles = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i]) numTiles++; // only if not border if (selected[i] && (neighbors[i] >= 0)) numTiles++; // only if not border
} }
final int [] indices = new int [numTiles]; // internal excludes border final int [] indices = new int [numTiles]; // internal excludes border
int indx = 0; int indx = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i]) { if (selected[i] && (neighbors[i] >= 0)) {
indices[indx++] = i; indices[indx++] = i;
} }
} }
...@@ -823,7 +838,7 @@ public class DisparityProcessor { ...@@ -823,7 +838,7 @@ public class DisparityProcessor {
for (int iTile = ai.getAndIncrement(); iTile < indices.length; iTile = ai.getAndIncrement()) { for (int iTile = ai.getAndIncrement(); iTile < indices.length; iTile = ai.getAndIncrement()) {
int nTile = indices[iTile]; int nTile = indices[iTile];
int neib = neighbors[nTile]; int neib = neighbors[nTile];
if (neib < 0) neib = 0;
if ( if (
((neib & (1 << 0)) != 0) && ((neib & (1 << 0)) != 0) &&
((neighbors[nTile - tilesX] & (1 << 2)) != 0)){ ((neighbors[nTile - tilesX] & (1 << 2)) != 0)){
...@@ -943,6 +958,7 @@ public class DisparityProcessor { ...@@ -943,6 +958,7 @@ public class DisparityProcessor {
for (int ty = 0; ty < tilesY; ty++){ for (int ty = 0; ty < tilesY; ty++){
for (int tx = 0; tx < tilesX; tx++){ for (int tx = 0; tx < tilesX; tx++){
int neib = neighbors[ty * tilesX + tx]; int neib = neighbors[ty * tilesX + tx];
if (neib < 0) neib = 0;
int []cell = field[ty + 1][tx + 1]; int []cell = field[ty + 1][tx + 1];
if ( neib!= 0) { if ( neib!= 0) {
cell[0] = ((neib & NEIB_RIGHT) == 0)? FLD_EMPTY:FLD_CONN; cell[0] = ((neib & NEIB_RIGHT) == 0)? FLD_EMPTY:FLD_CONN;
...@@ -1070,7 +1086,7 @@ public class DisparityProcessor { ...@@ -1070,7 +1086,7 @@ public class DisparityProcessor {
int numTilesAll = 0; int numTilesAll = 0;
// final boolean [] selectedAll = new boolean[len]; // final boolean [] selectedAll = new boolean[len];
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i] || border[i]) { if ((selected[i] && (neighbors[i] >= 0)) || border[i]) {
// selectedAll[i] = true; // selectedAll[i] = true;
numTilesAll++; numTilesAll++;
if (!border[i]) numTiles++; if (!border[i]) numTiles++;
...@@ -1081,7 +1097,7 @@ public class DisparityProcessor { ...@@ -1081,7 +1097,7 @@ public class DisparityProcessor {
int indx = 0; int indx = 0;
int indxAll = 0; int indxAll = 0;
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
if (selected[i] || border[i]) { if ((selected[i] && (neighbors[i] >= 0)) || border[i]) {
indicesAll[indxAll++] = i; indicesAll[indxAll++] = i;
if (!border[i]) indices[indx++] = i; if (!border[i]) indices[indx++] = i;
} }
...@@ -1204,7 +1220,7 @@ public class DisparityProcessor { ...@@ -1204,7 +1220,7 @@ public class DisparityProcessor {
* For each cluster returns 3 arrays: indiced of internal cells, indices of fixed border cells (alpha = 0, disparity fixed) * For each cluster returns 3 arrays: indiced of internal cells, indices of fixed border cells (alpha = 0, disparity fixed)
* and floating border cells (alpha = 0, disparity - from neighbors) * and floating border cells (alpha = 0, disparity - from neighbors)
* @param diag_en true - 8 directions, false - only 4 orthogonal * @param diag_en true - 8 directions, false - only 4 orthogonal
* @param neighbors array of per-cell bitmaps - which neighbors curtrent cell is connected to (+1 - to N, +2 - to NE,...+128 = to NW) * @param neighbors array of per-cell bitmaps - which neighbors current cell is connected to (+1 - to N, +2 - to NE,...+128 = to NW)
* @param selected boolean array of celected (internal) cells * @param selected boolean array of celected (internal) cells
* @param border boolean array of border cells (added for alpha) * @param border boolean array of border cells (added for alpha)
* @param threadsMax maximal number of threads for multi-threaded application * @param threadsMax maximal number of threads for multi-threaded application
......
...@@ -2152,16 +2152,26 @@ public class EyesisCorrectionParameters { ...@@ -2152,16 +2152,26 @@ public class EyesisCorrectionParameters {
public boolean plDbgMerge = true; // Combine 'other' plane with current public boolean plDbgMerge = true; // Combine 'other' plane with current
public double plWorstWorsening = 1.0; // Worst case worsening after merge public double plWorstWorsening = 1.0; // Worst case worsening after merge
public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict
public boolean plFillSquares = true; // Add diagonals to full squares
public boolean plCutCorners = true; // Add ortho to 45-degree corners
public double plPull = .1; // Relative weight of original (measured) plane when combing with neighbors public double plPull = .1; // Relative weight of original (measured) plane when combing with neighbors
public int plIterations = 10; // Maximal number of smoothing iterations for each step public int plIterations = 10; // Maximal number of smoothing iterations for each step
public int plPrecision = 6; // Maximal step difference (1/power of 10) public int plPrecision = 6; // Maximal step difference (1/power of 10)
public boolean plFuse = true; // Fuse planes together (off for debug only) public boolean plFuse = true; // Fuse planes together (off for debug only)
public boolean plKeepOrphans = true; // Keep unconnected supertiles public boolean plKeepOrphans = true; // Keep unconnected supertiles
public double plMinOrphan = 2.0; // Minimal strength unconnected supertiles to keep public double plMinOrphan = 2.0; // Minimal strength unconnected supertiles to keep
public double plSnapDisp = .2; // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
public double plSnapDispAny = .2; // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
public double plSnapStrengthAny = .2; // Maximal strength to fit any distance (if does not fit otherwise - treat as zero str4ength
public double plSnapNegAny = .5; // Maximal negative disparity difference from the best match
public double plSnapDispMax = .5; // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength public double plSnapDispMax = .5; // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
public double plSnapDispWeight = .5; // Maximal disparity diff. by weight product to snap to plane public double plSnapDispWeight = .5; // Maximal disparity diff. by weight product to snap to plane
public int plSnapZeroMode = 1; // Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest
public boolean replaceWeakOutlayers = true; // false;
// other debug images // other debug images
...@@ -2407,16 +2417,22 @@ public class EyesisCorrectionParameters { ...@@ -2407,16 +2417,22 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +""); properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+""); properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+"");
properties.setProperty(prefix+"plFillSquares", this.plFillSquares+"");
properties.setProperty(prefix+"plCutCorners", this.plCutCorners+"");
properties.setProperty(prefix+"plPull", this.plPull +""); properties.setProperty(prefix+"plPull", this.plPull +"");
properties.setProperty(prefix+"plIterations", this.plIterations+""); properties.setProperty(prefix+"plIterations", this.plIterations+"");
properties.setProperty(prefix+"plPrecision", this.plPrecision+""); properties.setProperty(prefix+"plPrecision", this.plPrecision+"");
properties.setProperty(prefix+"plFuse", this.plFuse+""); properties.setProperty(prefix+"plFuse", this.plFuse+"");
properties.setProperty(prefix+"plKeepOrphans", this.plKeepOrphans+""); properties.setProperty(prefix+"plKeepOrphans", this.plKeepOrphans+"");
properties.setProperty(prefix+"plMinOrphan", this.plMinOrphan +""); properties.setProperty(prefix+"plMinOrphan", this.plMinOrphan +"");
properties.setProperty(prefix+"plSnapDisp", this.plSnapDisp +"");
properties.setProperty(prefix+"plSnapDispAny", this.plSnapDispAny +"");
properties.setProperty(prefix+"plSnapStrengthAny",this.plSnapStrengthAny +"");
properties.setProperty(prefix+"plSnapNegAny", this.plSnapNegAny +"");
properties.setProperty(prefix+"plSnapDispMax", this.plSnapDispMax +""); properties.setProperty(prefix+"plSnapDispMax", this.plSnapDispMax +"");
properties.setProperty(prefix+"plSnapDispWeight", this.plSnapDispWeight +""); properties.setProperty(prefix+"plSnapDispWeight", this.plSnapDispWeight +"");
properties.setProperty(prefix+"plSnapZeroMode", this.plSnapZeroMode+"");
properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+""); properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+"");
properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+""); properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+"");
...@@ -2652,16 +2668,22 @@ public class EyesisCorrectionParameters { ...@@ -2652,16 +2668,22 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"plWorstWorsening")!=null) this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening")); if (properties.getProperty(prefix+"plWorstWorsening")!=null) this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening"));
if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly")); if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly"));
if (properties.getProperty(prefix+"plFillSquares")!=null) this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares"));
if (properties.getProperty(prefix+"plCutCorners")!=null) this.plCutCorners=Boolean.parseBoolean(properties.getProperty(prefix+"plCutCorners"));
if (properties.getProperty(prefix+"plPull")!=null) this.plPull=Double.parseDouble(properties.getProperty(prefix+"plPull")); if (properties.getProperty(prefix+"plPull")!=null) this.plPull=Double.parseDouble(properties.getProperty(prefix+"plPull"));
if (properties.getProperty(prefix+"plIterations")!=null) this.plIterations=Integer.parseInt(properties.getProperty(prefix+"plIterations")); if (properties.getProperty(prefix+"plIterations")!=null) this.plIterations=Integer.parseInt(properties.getProperty(prefix+"plIterations"));
if (properties.getProperty(prefix+"plPrecision")!=null) this.plPrecision=Integer.parseInt(properties.getProperty(prefix+"plPrecision")); if (properties.getProperty(prefix+"plPrecision")!=null) this.plPrecision=Integer.parseInt(properties.getProperty(prefix+"plPrecision"));
if (properties.getProperty(prefix+"plFuse")!=null) this.plFuse=Boolean.parseBoolean(properties.getProperty(prefix+"plFuse")); if (properties.getProperty(prefix+"plFuse")!=null) this.plFuse=Boolean.parseBoolean(properties.getProperty(prefix+"plFuse"));
if (properties.getProperty(prefix+"plKeepOrphans")!=null) this.plKeepOrphans=Boolean.parseBoolean(properties.getProperty(prefix+"plKeepOrphans")); if (properties.getProperty(prefix+"plKeepOrphans")!=null) this.plKeepOrphans=Boolean.parseBoolean(properties.getProperty(prefix+"plKeepOrphans"));
if (properties.getProperty(prefix+"plMinOrphan")!=null) this.plMinOrphan=Double.parseDouble(properties.getProperty(prefix+"plMinOrphan")); if (properties.getProperty(prefix+"plMinOrphan")!=null) this.plMinOrphan=Double.parseDouble(properties.getProperty(prefix+"plMinOrphan"));
if (properties.getProperty(prefix+"plSnapDisp")!=null) this.plSnapDisp=Double.parseDouble(properties.getProperty(prefix+"plSnapDisp"));
if (properties.getProperty(prefix+"plSnapDispAny")!=null) this.plSnapDispAny=Double.parseDouble(properties.getProperty(prefix+"plSnapDispAny"));
if (properties.getProperty(prefix+"plSnapStrengthAny")!=null) this.plSnapStrengthAny=Double.parseDouble(properties.getProperty(prefix+"plSnapStrengthAny"));
if (properties.getProperty(prefix+"plSnapNegAny")!=null) this.plSnapNegAny=Double.parseDouble(properties.getProperty(prefix+"plSnapNegAny"));
if (properties.getProperty(prefix+"plSnapDispMax")!=null) this.plSnapDispMax=Double.parseDouble(properties.getProperty(prefix+"plSnapDispMax")); if (properties.getProperty(prefix+"plSnapDispMax")!=null) this.plSnapDispMax=Double.parseDouble(properties.getProperty(prefix+"plSnapDispMax"));
if (properties.getProperty(prefix+"plSnapDispWeight")!=null) this.plSnapDispWeight=Double.parseDouble(properties.getProperty(prefix+"plSnapDispWeight")); if (properties.getProperty(prefix+"plSnapDispWeight")!=null) this.plSnapDispWeight=Double.parseDouble(properties.getProperty(prefix+"plSnapDispWeight"));
if (properties.getProperty(prefix+"plSnapZeroMode")!=null) this.plPrecision=Integer.parseInt(properties.getProperty(prefix+"plSnapZeroMode"));
if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine")); if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles")); if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles"));
...@@ -2919,17 +2941,23 @@ public class EyesisCorrectionParameters { ...@@ -2919,17 +2941,23 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Worst case worsening after merge", this.plWorstWorsening, 6); gd.addNumericField("Worst case worsening after merge", this.plWorstWorsening, 6);
gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly); gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly);
gd.addCheckbox ("Add diagonals to full squares", this.plFillSquares);
gd.addCheckbox ("Add ortho to 45-degree corners", this.plCutCorners);
gd.addNumericField("Relative weight of original (measured) plane when combing with neighbors", this.plPull, 6); gd.addNumericField("Relative weight of original (measured) plane when combing with neighbors", this.plPull, 6);
gd.addNumericField("Maximal number of smoothing iterations for each step", this.plIterations, 0); gd.addNumericField("Maximal number of smoothing iterations for each step", this.plIterations, 0);
gd.addNumericField("Maximal step difference (1/power of 10) ", this.plPrecision, 0); gd.addNumericField("Maximal step difference (1/power of 10)", this.plPrecision, 0);
gd.addCheckbox ("Fuse planes together (off for debug only)", this.plFuse); gd.addCheckbox ("Fuse planes together (off for debug only)", this.plFuse);
gd.addCheckbox ("Keep unconnected supertiles", this.plKeepOrphans); gd.addCheckbox ("Keep unconnected supertiles", this.plKeepOrphans);
gd.addNumericField("Minimal strength unconnected supertiles to keep", this.plMinOrphan, 6); gd.addNumericField("Minimal strength unconnected supertiles to keep", this.plMinOrphan, 6);
gd.addMessage ("--- Snap to planes ---"); gd.addMessage ("--- Snap to planes ---");
gd.addNumericField("Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength", this.plSnapDisp, 6); gd.addNumericField("Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength", this.plSnapDispAny, 6);
gd.addNumericField("Maximal strength to fit any distance (if does not fit otherwise - treat as zero strength", this.plSnapStrengthAny, 6);
gd.addNumericField("Maximal negative disparity difference from the best match", this.plSnapNegAny, 6);
gd.addNumericField("Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength", this.plSnapDispMax, 6); gd.addNumericField("Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength", this.plSnapDispMax, 6);
gd.addNumericField("Maximal disparity diff. by weight product to snap to plane", this.plSnapDispWeight, 6); gd.addNumericField("Maximal disparity diff. by weight product to snap to plane", this.plSnapDispWeight, 6);
gd.addNumericField("Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest",this.plSnapZeroMode, 0);
gd.addMessage ("--- Other debug images ---"); gd.addMessage ("--- Other debug images ---");
gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine); gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine);
...@@ -3174,16 +3202,22 @@ public class EyesisCorrectionParameters { ...@@ -3174,16 +3202,22 @@ public class EyesisCorrectionParameters {
this.plWorstWorsening= gd.getNextNumber(); this.plWorstWorsening= gd.getNextNumber();
this.plMutualOnly= gd.getNextBoolean(); this.plMutualOnly= gd.getNextBoolean();
this.plFillSquares= gd.getNextBoolean();
this.plCutCorners= gd.getNextBoolean();
this.plPull= gd.getNextNumber(); this.plPull= gd.getNextNumber();
this.plIterations= (int) gd.getNextNumber(); this.plIterations= (int) gd.getNextNumber();
this.plPrecision= (int) gd.getNextNumber(); this.plPrecision= (int) gd.getNextNumber();
this.plFuse= gd.getNextBoolean(); this.plFuse= gd.getNextBoolean();
this.plKeepOrphans= gd.getNextBoolean(); this.plKeepOrphans= gd.getNextBoolean();
this.plMinOrphan= gd.getNextNumber(); this.plMinOrphan= gd.getNextNumber();
this.plSnapDisp= gd.getNextNumber();
this.plSnapDispAny= gd.getNextNumber();
this.plSnapStrengthAny= gd.getNextNumber();
this.plSnapNegAny= gd.getNextNumber();
this.plSnapDispMax= gd.getNextNumber(); this.plSnapDispMax= gd.getNextNumber();
this.plSnapDispWeight= gd.getNextNumber(); this.plSnapDispWeight= gd.getNextNumber();
this.plSnapZeroMode= (int) gd.getNextNumber();
this.show_ortho_combine= gd.getNextBoolean(); this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles=gd.getNextBoolean(); this.show_refine_supertiles=gd.getNextBoolean();
......
...@@ -507,6 +507,7 @@ private Panel panel1, ...@@ -507,6 +507,7 @@ private Panel panel1,
addButton("CLT reset 3D", panelClt1, color_stop); addButton("CLT reset 3D", panelClt1, color_stop);
addButton("CLT 3D", panelClt1, color_conf_process); addButton("CLT 3D", panelClt1, color_conf_process);
addButton("CLT planes", panelClt1, color_conf_process); addButton("CLT planes", panelClt1, color_conf_process);
addButton("CLT OUT 3D", panelClt1, color_process);
add(panelClt1); add(panelClt1);
} }
...@@ -4756,6 +4757,9 @@ private Panel panel1, ...@@ -4756,6 +4757,9 @@ private Panel panel1,
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel); DEBUG_LEVEL); //final int debugLevel);
if (configPath!=null) { if (configPath!=null) {
saveTimestampedProperties( // save config again saveTimestampedProperties( // save config again
configPath, // full path or null configPath, // full path or null
...@@ -4772,14 +4776,88 @@ private Panel panel1, ...@@ -4772,14 +4776,88 @@ private Panel panel1,
System.out.println("QUAD_CLT is null, nothing to show"); System.out.println("QUAD_CLT is null, nothing to show");
return; return;
} }
//"CLT planes"
QUAD_CLT.showCLTPlanes( QUAD_CLT.showCLTPlanes(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters, CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel); DEBUG_LEVEL); //final int debugLevel);
return; return;
} else if (label.equals("CLT OUT 3D")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
System.out.println("QUAD_CLT is null, nothing to show (will add previous steps)");
return;
}
String configPath=null;
if (EYESIS_CORRECTIONS.correctionsParameters.saveSettings) {
configPath=EYESIS_CORRECTIONS.correctionsParameters.selectResultsDirectory(
true,
true);
if (configPath==null){
String msg="No results directory selected, command aborted";
System.out.println("Warning: "+msg);
IJ.showMessage("Warning",msg);
return;
}
configPath+=Prefs.getFileSeparator()+"autoconfig";
try {
saveTimestampedProperties(
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
} catch (Exception e){
String msg="Failed to save configuration to "+configPath+", command aborted";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
return;
}
}
/*
public boolean output3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
*/
boolean OK = QUAD_CLT.output3d(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
if (!OK) {
String msg="Image data not initialized, run 'CLT 3D' command first";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
}
/*
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
*/
return;
// //
// End of buttons code // End of buttons code
} }
......
...@@ -51,6 +51,9 @@ public class QuadCLT { ...@@ -51,6 +51,9 @@ public class QuadCLT {
public double [][][] fine_corr = new double [4][2][6]; // per port, per x/y, set of 6 coefficient for fine geometric corrections public double [][][] fine_corr = new double [4][2][6]; // per port, per x/y, set of 6 coefficient for fine geometric corrections
TileProcessor tp = null; TileProcessor tp = null;
String image_name = null;
double [][][] image_data = null;
// magic scale should be set before using TileProcessor (calculated disparities depend on it) // magic scale should be set before using TileProcessor (calculated disparities depend on it)
...@@ -4474,6 +4477,30 @@ public class QuadCLT { ...@@ -4474,6 +4477,30 @@ public class QuadCLT {
} }
tp.showPlanes( tp.showPlanes(
clt_parameters, clt_parameters,
geometryCorrection,
threadsMax,
updateStatus,
debugLevel);
// CLTPass3d last_scan = tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1); // get last one
}
public void out3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
if (tp == null){
System.out.println("showCLTPlanes(): tp is null");
return;
}
if (tp.clt_3d_passes == null){
System.out.println("showCLTPlanes(): tp.clt_3d_passes is null");
return;
}
tp.showPlanes(
clt_parameters,
geometryCorrection,
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -4683,7 +4710,7 @@ public class QuadCLT { ...@@ -4683,7 +4710,7 @@ public class QuadCLT {
clt_parameters.colors_equalize, clt_parameters.colors_equalize,
channelFiles, channelFiles,
imp_srcs, imp_srcs,
setNames.get(nSet), // just for debug messeges == setNames.get(nSet) setNames.get(nSet), // just for debug messages == setNames.get(nSet)
debugLevel); debugLevel);
} }
// once per quad here // once per quad here
...@@ -4740,6 +4767,11 @@ public class QuadCLT { ...@@ -4740,6 +4767,11 @@ public class QuadCLT {
setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY
clt_parameters, clt_parameters,
threadsMax); threadsMax);
this.image_name = name;
this.image_data = image_data;
tp.resetCLTPasses(); tp.resetCLTPasses();
tp.setTrustedCorrelation(clt_parameters.grow_disp_trust); tp.setTrustedCorrelation(clt_parameters.grow_disp_trust);
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
...@@ -5083,16 +5115,20 @@ public class QuadCLT { ...@@ -5083,16 +5115,20 @@ public class QuadCLT {
geometryCorrection, geometryCorrection,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
2); // debugLevel); 0); // 2); // debugLevel);
// get images for predefined regions and disparities. First - with just fixed scans 1 .. list.size() // get images for predefined regions and disparities. First - with just fixed scans 1 .. list.size()
// TEMPORARY EXIT // TEMPORARY EXIT
if (tp.clt_3d_passes.size() > 0) { // Save tp.clt_3d_passes.size() to roll back without restarting the program
System.out.println("-------- temporary exit after secondPassSetup() ------- "); tp.saveCLTPasses();
return null; // just to fool compiler
}
if (tp.clt_3d_passes.size() > 0) {
System.out.println("-------- temporary exit after secondPassSetup() ------- ");
return null; // just to fool compiler
}
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan, tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
...@@ -5206,6 +5242,167 @@ public class QuadCLT { ...@@ -5206,6 +5242,167 @@ public class QuadCLT {
return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name"); return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name");
} }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// public ImagePlus output3d(
public boolean output3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
if (this.image_data == null){
return false;
}
tp.trimCLTPasses(); // make possible to run this method multiple time - remove extra passes added by it last time
int next_pass = tp.clt_3d_passes.size(); //
tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
"after_pass2-"+(next_pass-1)); //String title)
tp.thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
clt_parameters,
clt_parameters.bgnd_range, // double disparity_far,
clt_parameters.grow_disp_max, // other_range, //double disparity_near, //
geometryCorrection,
threadsMax, // maximal number of threads to launch
updateStatus,
0); // final int debugLevel)
tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
"after_pass3-"+(next_pass-1)); //String title)
// create x3d file
X3dOutput x3dOutput = new X3dOutput(
clt_parameters,
correctionsParameters,
geometryCorrection,
tp.clt_3d_passes);
x3dOutput.generateBackground();
String x3d_path= correctionsParameters.selectX3dDirectory(
true, // smart,
true); //newAllowed, // save
for (int scanIndex = next_pass; scanIndex < tp.clt_3d_passes.size(); scanIndex++){
if (debugLevel > 0){
System.out.println("FPGA processing scan #"+scanIndex);
}
CLTPass3d scan = CLTMeasure( // perform single pass according to prepared tiles operations and disparity
image_data, // first index - number of image in a quad
clt_parameters,
scanIndex,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
/**
if ((scanIndex == 49) || (scanIndex == 54) ) tp.showScan(
scan, // tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"MEASURED-"+scanIndex);
*/
}
// TEMPORARY EXIT
// if (tp.clt_3d_passes.size() > 0) return null; // just to fool compiler
// int scan_limit = 10;
for (int scanIndex = next_pass; (scanIndex < tp.clt_3d_passes.size()) && (scanIndex < clt_parameters.max_clusters); scanIndex++){ // just temporary limiting
if (debugLevel > -1){
System.out.println("Generating cluster images (limit is set to "+clt_parameters.max_clusters+") largest, scan #"+scanIndex);
}
// ImagePlus cluster_image = getPassImage( // get image form a single pass
String texturePath = getPassImage( // get image from a single pass
clt_parameters,
colorProcParameters,
rgbParameters,
this.image_name+"-img"+scanIndex,
scanIndex,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
if ((scanIndex == 73) ) {
tp.showScan(
tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"SELECTED-"+scanIndex);
}
// TODO: use new updated disparity, for now just what was forced for the picture
double [] scan_disparity = new double [tilesX * tilesY];
int indx = 0;
// boolean [] scan_selected = scan.getSelected();
for (int ty = 0; ty < tilesY; ty ++) for (int tx = 0; tx < tilesX; tx ++){
// scan_selected[indx] = scan.tile_op[ty][tx] != 0;
scan_disparity[indx++] = scan.disparity[ty][tx];
}
if (clt_parameters.avg_cluster_disp){
double sw = 0.0, sdw = 0.0;
for (int i = 0; i< scan_disparity.length; i++){
if (scan.selected[i] && !scan.border_tiles[i]){
double w = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][i];
sw +=w;
sdw += scan_disparity[i]*w;
}
}
sdw/=sw;
for (int i = 0; i< scan_disparity.length; i++){
scan_disparity[i] = sdw;
}
}
if ((scanIndex == 73)) {
tp.showScan(
tp.clt_3d_passes.get(scanIndex), // CLTPass3d scan,
"X3D-"+scanIndex);
}
boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 73);
// boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 49) || (scanIndex == 54);
generateClusterX3d(
x3dOutput,
texturePath,
scan.bounds,
scan.selected,
scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
clt_parameters.transform_size,
clt_parameters.correct_distortions, // requires backdrop image to be corrected also
showTri, // (scanIndex < next_pass + 1) && clt_parameters.show_triangles,
clt_parameters.bgnd_range, // 0.3
clt_parameters.grow_disp_max, // other_range, // 2.0 'other_range - difference from the specified (*_CM)
clt_parameters.maxDispTriangle);
}
// now generate and save texture files (start with full, later use bounding rectangle?)
if (x3d_path != null){
x3d_path+=Prefs.getFileSeparator()+this.image_name+".x3d";
x3dOutput.generateX3D(x3d_path);
}
return true;
// return imp_bgnd; // relative (to x3d directory) path - (String) imp_bgnd.getProperty("name");
}
//*****************************************************************
public void generateClusterX3d( public void generateClusterX3d(
X3dOutput x3dOutput, X3dOutput x3dOutput,
String texturePath, String texturePath,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -764,10 +764,10 @@ public class TilePlanes { ...@@ -764,10 +764,10 @@ public class TilePlanes {
// double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile // double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile
// double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2]; // double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2];
double [] px_py = getCenterPxPy(); double [] px_py = getCenterPxPy();
if ((px_py[0] == 1760) && (px_py[1] == 1056)){ // 27, 15 // if ((px_py[0] == 1760) && (px_py[1] == 1056)){ // 27, 15
System.out.println("getWorldXYZ, px_py = {"+px_py[0]+","+px_py[1]+"}"); // System.out.println("getWorldXYZ, px_py = {"+px_py[0]+","+px_py[1]+"}");
debugLevel = 2; // debugLevel = 2;
} // }
double px = px_py[0] + zxy[1]; double px = px_py[0] + zxy[1];
double py = px_py[1] + zxy[2]; double py = px_py[1] + zxy[2];
...@@ -780,6 +780,10 @@ public class TilePlanes { ...@@ -780,6 +780,10 @@ public class TilePlanes {
Matrix xyz = new Matrix(center_xyz, 3); // column matrix Matrix xyz = new Matrix(center_xyz, 3); // column matrix
Matrix dpxpy = new Matrix(vectors[0],3); // 3 rows, 1 column Matrix dpxpy = new Matrix(vectors[0],3); // 3 rows, 1 column
if (debugLevel > 0){ if (debugLevel > 0){
// if (sTileXY[0] == 27 ){
// System.out.println("STOP");
//
// }
System.out.println("getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"), correctDistortions="+correctDistortions+", xyz= {"+ System.out.println("getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"), correctDistortions="+correctDistortions+", xyz= {"+
xyz.get(0, 0)+","+xyz.get(1, 0)+","+xyz.get(2, 0)+"}, weight = "+getWeight()); xyz.get(0, 0)+","+xyz.get(1, 0)+","+xyz.get(2, 0)+"}, weight = "+getWeight());
// xyz.print(10, 6); // w,d // xyz.print(10, 6); // w,d
...@@ -842,7 +846,7 @@ public class TilePlanes { ...@@ -842,7 +846,7 @@ public class TilePlanes {
} }
norm_xyz.timesEquals(1.0/norm_xyz.normF()); // unity normal vector; norm_xyz.timesEquals(1.0/norm_xyz.normF()); // unity normal vector;
if (debugLevel > 0){ if (debugLevel > 1){
System.out.println("+getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"): unit plane normal={"+ System.out.println("+getWorldXYZ("+sTileXY[0]+","+sTileXY[1]+"): unit plane normal={"+
norm_xyz.get(0, 0)+", "+norm_xyz.get(1, 0)+", "+norm_xyz.get(2, 0)+"})"); norm_xyz.get(0, 0)+", "+norm_xyz.get(1, 0)+", "+norm_xyz.get(2, 0)+"})");
double dotprod = xyz.transpose().times(norm_xyz).get(0,0); double dotprod = xyz.transpose().times(norm_xyz).get(0,0);
...@@ -1070,7 +1074,7 @@ public class TilePlanes { ...@@ -1070,7 +1074,7 @@ public class TilePlanes {
int numRemoved = 0; int numRemoved = 0;
for (; (pd.getValue() > targetEigen) && (numRemoved < maxRemoved); numRemoved++){ for (; (pd.getValue() > targetEigen) && (numRemoved < maxRemoved); numRemoved++){
if (debugLevel > 2){ if (debugLevel > 2){
System.out.println("removePlaneOutliers(): numRemoved = "+numRemoved+" eigenValue = "+pd.getValue()+" target = "+targetEigen); System.out.println("removePlaneOutliers("+sTileXY[0]+":"+sTileXY[1]+"): numRemoved = "+numRemoved+" eigenValue = "+pd.getValue()+" target = "+targetEigen);
} }
// make a plane and find the worst (largest disparity difference) tile // make a plane and find the worst (largest disparity difference) tile
// z = -(x*Vx + y*Vy)/Vz // z = -(x*Vx + y*Vy)/Vz
......
...@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class TileProcessor { public class TileProcessor {
public ArrayList <CLTPass3d> clt_3d_passes = null; public ArrayList <CLTPass3d> clt_3d_passes = null;
public int clt_3d_passes_size = 0; //clt_3d_passes size after initial processing
private int tilesX; private int tilesX;
private int tilesY; private int tilesY;
private double corr_magic_scale = 0.85; // reported correlation offset vs. actual one (not yet understood) private double corr_magic_scale = 0.85; // reported correlation offset vs. actual one (not yet understood)
...@@ -82,8 +83,22 @@ public class TileProcessor { ...@@ -82,8 +83,22 @@ public class TileProcessor {
public void resetCLTPasses(){ public void resetCLTPasses(){
clt_3d_passes = new ArrayList<CLTPass3d>(); clt_3d_passes = new ArrayList<CLTPass3d>();
clt_3d_passes_size = 0;
} }
public void saveCLTPasses(){
clt_3d_passes_size = clt_3d_passes.size();
}
public void trimCLTPasses(){
while (clt_3d_passes.size() > clt_3d_passes_size){
clt_3d_passes.remove(clt_3d_passes_size);
}
}
/** /**
* Basic combining: find smallest residual disparity and use the tile data from it * Basic combining: find smallest residual disparity and use the tile data from it
* Copy link to texture tile from the same pass, "forced" bit in tile_op is copied too * Copy link to texture tile from the same pass, "forced" bit in tile_op is copied too
...@@ -1319,7 +1334,7 @@ public class TileProcessor { ...@@ -1319,7 +1334,7 @@ public class TileProcessor {
clusterSize++; clusterSize++;
bcluster[i] = true; bcluster[i] = true;
} }
if (debugLevel > 1) { if (debugLevel > -1) {
System.out.println("createTileTasks(), cluster #"+ncl+", cluster size = "+clusterSize); System.out.println("createTileTasks(), cluster #"+ncl+", cluster size = "+clusterSize);
} }
if ((clusterSize < minClusterArea) || (clusterSize == 0)) break; if ((clusterSize < minClusterArea) || (clusterSize == 0)) break;
...@@ -1437,6 +1452,116 @@ public class TileProcessor { ...@@ -1437,6 +1452,116 @@ public class TileProcessor {
public int createTileTasks(
int maxClusters,
int minClusterArea,
double [] disparity_in,
int [] clusters_in,
int debugLevel)
{
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
// adding 1-tile frame around to avoid checking for the borders
int tilesX4 = tilesX + 4;
int tilesY4 = tilesY + 4;
int tlen4 = tilesX4*tilesY4;
double [] disparity0 = new double [tlen4];
int [] clusters = new int [tlen4];
for (int i = 0; i < tlen4; i++) {
clusters[i] = 0;
}
for (int i = 0; i < tilesY; i++) {
for (int j = 0; j < tilesX; j++) {
clusters[(i + 2) * tilesX4 + j + 2] = clusters_in[i * tilesX + j];
disparity0[(i + 2) * tilesX4 + j + 2] = disparity_in[i * tilesX + j];
}
}
int [] dirs8 = {-tilesX4, -tilesX4 + 1, 1, tilesX4 +1, tilesX4, tilesX4 - 1, -1, -tilesX4 - 1};
int [] dirs = dirs8;
int op = ImageDtt.setImgMask(0, 0xf);
op = ImageDtt.setPairMask(op,0xf);
op = ImageDtt.setForcedDisparity(op,true);
int tlen = clusters.length;
int numClusters = 0;
for (int ncl = 0; (maxClusters == 0) || (ncl < maxClusters); ncl++){ // need to break;
double [] disparity = disparity0.clone();
boolean [] bcluster = new boolean [tlen];
int clusterSize = 0;
int cindx = ncl + 1;
for (int i = 0; i < tlen; i++) if (clusters[i] == cindx) {
clusterSize++;
bcluster[i] = true;
}
if (debugLevel > -1) {
System.out.println("createTileTasks(), cluster #"+ncl+", cluster size = "+clusterSize);
}
if ((clusterSize < minClusterArea) || (clusterSize == 0)) break;
boolean [] grown_clusters = bcluster.clone();
growTiles(
2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
grown_clusters,
null,
tilesX4,
tilesY4);
// now fill border pixels disparity disregarding known for that tile
for (int i = 0; i < tlen ; i++){
if (!bcluster[i] && grown_clusters[i]){ // only border
double sd = 0.0;
int n = 0;
for (int d = 0; d < dirs.length; d++){
int indx = i + dirs[d];
if (bcluster[indx]){
sd += disparity[indx];
n++;
}
}
if (n > 0){
disparity[i] = sd/n;
} else {
System.out.println("**** Program BUG, should not happen ****");
disparity[i] = 0.0;
}
}
}
// return to original dimensions
double [][] disparityTask = new double [tilesY][tilesX];
int [][] tile_op = new int [tilesY][tilesX];
boolean [] borderTiles = new boolean[tilesY*tilesX]; // to zero alpha in the images
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx;
int indx4 = tilesX4 * (ty+2) + (tx + 2);
if (grown_clusters[indx4]){
disparityTask[ty][tx] = disparity[indx4];
tile_op[ty][tx] = op;
borderTiles[indx] = !bcluster[indx4];
} else {
disparityTask[ty][tx] = 0.0;
tile_op[ty][tx] = 0;
borderTiles[indx] = false;
}
}
// Create FPGA task for this cluster
CLTPass3d scan_next =new CLTPass3d(this);
scan_next.disparity = disparityTask;
scan_next.tile_op = tile_op;
scan_next.border_tiles = borderTiles;
clt_3d_passes.add(scan_next);
numClusters++;
}
return numClusters;
}
// temporary - simple separation until continuous tile areas are split along disparity steps // temporary - simple separation until continuous tile areas are split along disparity steps
...@@ -2810,12 +2935,31 @@ public class TileProcessor { ...@@ -2810,12 +2935,31 @@ public class TileProcessor {
//====================== //======================
public void showPlanes( public void showPlanes(
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) final int debugLevel)
{ {
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
SuperTiles st = scan_prev.getSuperTiles(); SuperTiles st = scan_prev.getSuperTiles();
// moved here
st.processPlanes2(
null, // final boolean [] selected, // or null
0.3, // final double min_disp,
false, // final boolean invert_disp, // use 1/disparity
clt_parameters.plDispNorm, // = 2.0; // Normalize disparities to the average if above
clt_parameters.plMinPoints, // = 5; // Minimal number of points for plane detection
clt_parameters.plTargetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers, // = 20; // Maximal number of outliers to remove
geometryCorrection,
clt_parameters.correct_distortions,
0, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
showDoubleFloatArrays sdfa_instance = null; showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging? if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
...@@ -2830,7 +2974,16 @@ public class TileProcessor { ...@@ -2830,7 +2974,16 @@ public class TileProcessor {
clt_parameters.plMinStrength, clt_parameters.plMinStrength,
0, // final int debugLevel) 0, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
if (clt_parameters.plFillSquares){
st.fillSquares();
}
if (clt_parameters.plCutCorners){
st.cutCorners();
}
TilePlanes.PlaneData [][] planes_mod = null; TilePlanes.PlaneData [][] planes_mod = null;
// smooth planes (by averaging with neighbors and the "measured" one with variable "pull") // smooth planes (by averaging with neighbors and the "measured" one with variable "pull")
...@@ -2936,6 +3089,104 @@ public class TileProcessor { ...@@ -2936,6 +3089,104 @@ public class TileProcessor {
10.0, // double arrow_dark, 10.0, // double arrow_dark,
10.0); // double arrow_white) 10.0); // double arrow_white)
sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells"); sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells");
// also test snap here
int [] snap_surf = st.snapSort(
st.cltPass3d.getDisparity(), // final double [] disparity,
st.cltPass3d.getStrength(), // final double [] strength,
st.cltPass3d.getSelected(), // null, // this_selection, // final boolean [] selection, // can be null
clt_parameters.plDispNorm, // final double dispNorm, // plDispNorm
clt_parameters.plSnapDispAny, //final double snapDispAny, // = .2, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
clt_parameters.plSnapStrengthAny,//final double snapStrengthAny, // = .2, // Maximal strength to fit any distance (if does not fit otherwise - treat as zero strength
clt_parameters.plSnapNegAny, //final double snapNegAny, // = .2, // Maximal negative disparity difference from the best match
clt_parameters.plSnapDispMax, // final double snapDispMax, // = .5, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
clt_parameters.plSnapDispWeight, // final double snapDispWeight, // = .5, // Maximal disparity diff. by weight product to snap to plane
clt_parameters.plSnapZeroMode, // final int snapZeroMode, // Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest
1); // final int debugLevel)
double [] snap_disparity = st.snapDisparity(
st.cltPass3d.getDisparity(), // final double [] disparity,
st.cltPass3d.getStrength(), // final double [] strength,
null, // this_selection, // final boolean [] selection, // can be null
clt_parameters.plDispNorm, // final double dispNorm, // plDispNorm
clt_parameters.plSnapDispAny, //final double snapDispAny, // = .2, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
clt_parameters.plSnapStrengthAny,//final double snapStrengthAny, // = .2, // Maximal strength to fit any distance (if does not fit otherwise - treat as zero strength
clt_parameters.plSnapNegAny, //final double snapNegAny, // = .2, // Maximal negative disparity difference from the best match
clt_parameters.plSnapDispMax, // final double snapDispMax, // = .5, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
clt_parameters.plSnapDispWeight, // final double snapDispWeight, // = .5, // Maximal disparity diff. by weight product to snap to plane
clt_parameters.plSnapZeroMode, // final int snapZeroMode, // Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest
1); // final int debugLevel)
double [] snap_disparity_masked = snap_disparity.clone();
double [] disparity_masked = st.cltPass3d.getDisparity().clone();
double [] strength_masked = st.cltPass3d.getStrength().clone();
boolean [] selected = st.cltPass3d.getSelected();
for (int i = 0; i < snap_disparity_masked.length; i++){
if ( !selected[i]){
disparity_masked[i] = Double.NaN;
snap_disparity_masked[i] = Double.NaN;
strength_masked[i] = Double.NaN;
}
}
String [] snap_titles = {"disp","snap_disp","strength","disp_masked","snap_disp_masked","unmatched","strength_masked"};
double [][] snap_img = new double [snap_titles.length][];
snap_img[5] = new double [snap_surf.length];
for (int i = 0; i < snap_surf.length; i++){
snap_img[5][i] = (selected[i] && (snap_surf[i] == 0)) ? 10.0: 0.0;
}
snap_img[0] = st.cltPass3d.getDisparity();
snap_img[1] = snap_disparity;
snap_img[2] = st.cltPass3d.getStrength();
snap_img[3] = disparity_masked;
snap_img[4] = snap_disparity_masked;
snap_img[6] = strength_masked;
sdfa_instance.showArrays(snap_img, tilesX, tilesY, true, "snap",snap_titles);
boolean [] these_tiles = scan_prev.getSelected();
DisparityProcessor dp = new DisparityProcessor(this, clt_parameters.transform_size * geometryCorrection.getScaleDzDx());
boolean [] grown = these_tiles.clone();
growTiles(
2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
grown, // boolean [] tiles,
null); // boolean [] prohibit)
boolean [] border = grown.clone();
for (int i = 0; i < border.length; i++) border[i] &= !these_tiles[i];
int num_unmatched = st.getNumNotMatched(
snap_surf,
these_tiles);
int num_surf = st.getNumSurf(
snap_surf,
null); // these_tiles);
if (debugLevel > -1){
System.out.println("thirdPassSetup(): surfaces = "+num_surf+" left unmatched="+num_unmatched);
}
int [][] neib_surf = new int [num_surf][];
double [][] dbg_neibs = new double [num_surf][];
for (int ns = 0 ; ns < num_surf; ns ++){
neib_surf[ns] = st.getNeighbors( // creates neighbors mask from bitmask
these_tiles, // final boolean [] selected, // or null
snap_surf, // final int [] snap_surf, // use this size - it matches image, not supertiles
ns); // final int surf_index)
dbg_neibs[ns]= dp.dbgShowNeighbors(
these_tiles, // grown, // these_tiles,
neib_surf[ns], // _orig, // int [] neighbors,
clt_parameters.transform_size, // int tile_size,
-1.0, // Double.NaN, // double bgnd,
10.0); // double fgnd)
}
sdfa_instance.showArrays(dbg_neibs,
tilesX*clt_parameters.transform_size,
tilesY*clt_parameters.transform_size,
true,
"surf-neighbors");
} }
} }
...@@ -3043,8 +3294,27 @@ public class TileProcessor { ...@@ -3043,8 +3294,27 @@ public class TileProcessor {
scan_prev.combineHorVertStrength(true, false); // strength now max of original and horizontal. Use scale instead of boolean? scan_prev.combineHorVertStrength(true, false); // strength now max of original and horizontal. Use scale instead of boolean?
} }
double [] this_disparity = scan_prev.getDisparity(); // returns a copy of the FPGA-generated disparity combined with the target one double [] this_disparity = scan_prev.getDisparity(); // returns a copy of the FPGA-generated disparity combined with the target one
double [] this_strength = scan_prev.getStrength(); // cloned, can be modified/ read back double [] this_strength = scan_prev.getStrength(); // cloned, can be modified/ read back
String [] dbg_test_titles = {"was_selected","these_tiles", "disparity","strength"};
double [][] dbg_test_img = new double [dbg_test_titles.length][];
dbg_test_img[0] = new double [tilesX * tilesY];
dbg_test_img[1] = new double [tilesX * tilesY];
boolean [] dbg_test_selected = scan_prev.getSelected();
for (int i = 0; i < dbg_test_img[0].length; i++){
if (dbg_test_selected != null) dbg_test_img[0][i] = dbg_test_selected[i]?1.0:0.0;
dbg_test_img[1][i] = these_tiles[i]?1.0:0.0;
}
dbg_test_img[2] = this_disparity;
dbg_test_img[3] = this_strength;
if (sdfa_instance != null) sdfa_instance.showArrays(dbg_test_img, tilesX, tilesY, true, "dbg_test_img",dbg_test_titles);
scan_prev.setSelected(these_tiles); // New
//************************************************ //************************************************
// Show supertiles histograms // Show supertiles histograms
...@@ -3090,7 +3360,7 @@ public class TileProcessor { ...@@ -3090,7 +3360,7 @@ public class TileProcessor {
if (show_st){ if (show_st){
sdfa_instance.showArrays(dbg_hist, hist_width0, hist_height0, true, "disparity_supertiles_histograms",dbg_st_titles); sdfa_instance.showArrays(dbg_hist, hist_width0, hist_height0, true, "disparity_supertiles_histograms",dbg_st_titles);
} }
/**
st.processPlanes2( st.processPlanes2(
null, // final boolean [] selected, // or null null, // final boolean [] selected, // or null
0.3, // final double min_disp, 0.3, // final double min_disp,
...@@ -3104,14 +3374,7 @@ public class TileProcessor { ...@@ -3104,14 +3374,7 @@ public class TileProcessor {
clt_parameters.correct_distortions, clt_parameters.correct_distortions,
0, // -1, // debugLevel, // final int debugLevel) 0, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
if (debugLevel < 100) {
return; // just temporarily
}
if (use_supertiles) { if (use_supertiles) {
...@@ -3131,41 +3394,318 @@ public class TileProcessor { ...@@ -3131,41 +3394,318 @@ public class TileProcessor {
if (dbg_with_super_disp != null) dbg_with_super_disp = dbg_with_super_disp.clone(); // else no super disparity available if (dbg_with_super_disp != null) dbg_with_super_disp = dbg_with_super_disp.clone(); // else no super disparity available
} }
*/
} }
// replace weak outlier tiles with weighted averages (modifies disparity)
boolean[] outlayers = scan_prev.replaceWeakOutlayers( // return scan_next;
null, // final boolean [] selection, }
clt_parameters.outlayerStrength , //final double weakStrength, // strength to be considered weak, subject to this replacement
clt_parameters.outlayerDiff, // final double maxDiff) //==================
clt_parameters.outlayerDiffPos, // final double maxDiff) public void thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
clt_parameters.outlayerDiffNeg, // final double maxDiff) EyesisCorrectionParameters.CLTParameters clt_parameters,
0.5 * disparity_far, double disparity_far, //
2.0 * disparity_near, double disparity_near, //
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
/// double [] dbg_orig_disparity = null;
/// double [] dbg_with_super_disp = null;
/// double [] dbg_outlayers = null;
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
boolean [] these_tiles = scan_prev.getSelected();
double [] this_disparity = scan_prev.getDisparity(); // returns a copy of the FPGA-generated disparity combined with the target one
double [] this_strength = scan_prev.getStrength(); // cloned, can be modified/ read back
scan_prev.fixNaNDisparity(
null, // border, // boolean [] select, // which tiles to correct (null - all)
scan_prev.getDisparity(), // double [] disparity,
scan_prev.getStrength()); // double [] strength)
/// dbg_orig_disparity = this_disparity.clone();
SuperTiles st = scan_prev.getSuperTiles();
// if (clt_parameters.plSnapDispAny >= 0.0) {
double [] snap_disparity = st.snapDisparity(
this_disparity, // final double [] disparity,
this_strength, // final double [] strength,
null, // this_selection, // final boolean [] selection, // can be null
clt_parameters.plDispNorm, // final double dispNorm, // plDispNorm
clt_parameters.plSnapDispAny, //final double snapDispAny, // = .2, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
clt_parameters.plSnapStrengthAny,//final double snapStrengthAny, // = .2, // Maximal strength to fit any distance (if does not fit otherwise - treat as zero strength
clt_parameters.plSnapNegAny, //final double snapNegAny, // = .2, // Maximal negative disparity difference from the best match
clt_parameters.plSnapDispMax, // final double snapDispMax, // = .5, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
clt_parameters.plSnapDispWeight, // final double snapDispWeight, // = .5, // Maximal disparity diff. by weight product to snap to plane
clt_parameters.plSnapZeroMode, // final int snapZeroMode, // Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest
1); // final int debugLevel)
System.arraycopy(snap_disparity, 0, this_disparity, 0, snap_disparity.length);
// }
/**
// Replace weak outlayers
if (clt_parameters.replaceWeakOutlayers) {
// boolean[] outlayers =
scan_prev.replaceWeakOutlayers(
null, // final boolean [] selection,
clt_parameters.outlayerStrength , //final double weakStrength, // strength to be considered weak, subject to this replacement
clt_parameters.outlayerDiff, // final double maxDiff)
clt_parameters.outlayerDiffPos, // final double maxDiff)
clt_parameters.outlayerDiffNeg, // final double maxDiff)
0.5 * disparity_far,
2.0 * disparity_near,
debugLevel);
}
*/
int [] snap_surf = st.snapSort(
this_disparity, // final double [] disparity,
this_strength, // final double [] strength,
null, // this_selection, // final boolean [] selection, // can be null
clt_parameters.plDispNorm, // final double dispNorm, // plDispNorm
clt_parameters.plSnapDispAny, //final double snapDispAny, // = .2, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
clt_parameters.plSnapStrengthAny,//final double snapStrengthAny, // = .2, // Maximal strength to fit any distance (if does not fit otherwise - treat as zero strength
clt_parameters.plSnapNegAny, //final double snapNegAny, // = .2, // Maximal negative disparity difference from the best match
clt_parameters.plSnapDispMax, // final double snapDispMax, // = .5, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
clt_parameters.plSnapDispWeight, // final double snapDispWeight, // = .5, // Maximal disparity diff. by weight product to snap to plane
clt_parameters.plSnapZeroMode, // final int snapZeroMode, // Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest
1); // final int debugLevel)
//
DisparityProcessor dp = new DisparityProcessor(this, clt_parameters.transform_size * geometryCorrection.getScaleDzDx());
boolean [] grown = these_tiles.clone();
growTiles(
2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
grown, // boolean [] tiles,
null); // boolean [] prohibit)
boolean [] border = grown.clone();
for (int i = 0; i < border.length; i++) border[i] &= !these_tiles[i];
int num_unmatched = st.getNumNotMatched(
snap_surf,
these_tiles);
int num_surf = st.getNumSurf(
snap_surf,
null); // these_tiles);
if (debugLevel > -1){
System.out.println("thirdPassSetup(): surfaces = "+num_surf+" left unmatched="+num_unmatched);
}
int [][] neib_surf = new int [num_surf][];
double [][] dbg_neibs = new double [num_surf][];
for (int ns = 0 ; ns < num_surf; ns ++){
neib_surf[ns] = st.getNeighbors( // creates neighbors mask from bitmask
these_tiles, // final boolean [] selected, // or null
snap_surf, // final int [] snap_surf, // use this size - it matches image, not supertiles
ns); // final int surf_index)
dbg_neibs[ns]= dp.dbgShowNeighbors(
these_tiles, // grown, // these_tiles,
neib_surf[ns], // _orig, // int [] neighbors,
clt_parameters.transform_size, // int tile_size,
-1.0, // Double.NaN, // double bgnd,
10.0); // double fgnd)
}
sdfa_instance.showArrays(dbg_neibs,
tilesX*clt_parameters.transform_size,
tilesY*clt_parameters.transform_size,
true,
"surf-neighbors");
int numScans0 = 0;
for (int ns = 0 ; ns < num_surf; ns ++){
// for (int ns = 1 ; (ns < num_surf) && (ns < 2); ns ++){
boolean [] surface_selection = new boolean [these_tiles.length];
for (int i = 0; i < surface_selection.length; i++) {
surface_selection[i] = these_tiles[i] && (neib_surf[ns][i] >= 0);
}
grown = surface_selection.clone();
growTiles(
2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
grown, // boolean [] tiles,
null); // boolean [] prohibit)
border = grown.clone();
for (int i = 0; i < border.length; i++) border[i] &= !these_tiles[i];
int [] enum_clusters = enumerateClusters(
true, // boolean diag_en,
surface_selection); // grown); // these_tiles); // boolean [] tiles_src)
double [] new_disparity0 = this_disparity.clone();
numScans0 += createTileTasks(
50, // int maxClusters,
0, // int minClusterArea,
new_disparity0, // this_disparity, // [] disparity_in, masked ok too
enum_clusters, // int [] clusters_in,
(ns == 1)?2:0); // debugLevel);
if (debugLevel > -1){
System.out.println("thirdPassSetup(): surface=" + ns + " created "+ numScans0+ " FPGA passes.");
}
}
/**
int [] neighbors = dp.getNeighbors( // creates neighbors mask from bitmask
grown, // these_tiles, // grown, // these_tiles, // boolean [] selected,
tilesX);
// int [] neighbors_orig = neighbors.clone();
double [] dbg_neib = dp.dbgShowNeighbors(
grown, // these_tiles, // grown, // these_tiles,
neighbors, // _orig, // int [] neighbors,
clt_parameters.transform_size, // int tile_size,
-1.0, // double bgnd,
1.0); // double fgnd)
double [] new_disparity = this_disparity.clone();
double [][]dbgDeriv = new double [2][]; // [these_tiles.length];
// sdfa_instance.showArrays(dbg_neib,tilesX*clt_parameters.transform_size, tilesY*clt_parameters.transform_size,"neighbors");
dp.smoothDisparity(
clt_parameters.tiDispPull, // final double dispPull, // clt_parameters.tiDispPull or 0.0
3, // final int mask, // 1 - work on internal elements, 2 - on border elements, 3 - both (internal first);
clt_parameters.tiIterations, // final int num_passes,
Math.pow(10.0, -clt_parameters.tiPrecision), // final double maxDiff, // maximal change in any of the disparity values
neighbors, // final int [] neighbors, // +1 - up (N), +2 - up-right - NE, ... +0x80 - NW
new_disparity, // final double [] disparity, // current disparity value
this_disparity, // final double [] measured_disparity, // measured disparity
this_strength, // final double [] strength,
null, // this_hor_disparity, // final double hor_disparity, // not yet used
null, // hor_strength_conv, // final double hor_strength, // not yet used
these_tiles, // grown, // these_tiles, // final boolean [] selected,
border, // final boolean [] border,
clt_parameters,
// dbgDeriv, // final double [][] dbgDeriv, //double [2][len] or null;
threadsMax, // maximal number of threads to launch
debugLevel);
int [][][] clustersNO= dp.extractNonOlerlap(
true, // diag_en,
neighbors, // +1 - up (N), +2 - up-right - NE, ... +0x80 - NW
grown, // these_tiles, // final boolean [] selected, // only inner?
border, // border should be diagonal!
threadsMax, // maximal number of threads to launch
debugLevel); debugLevel);
dbg_outlayers = new double[outlayers.length];
int numScans= 0;
for (int i = 0; i < outlayers.length; i++){ if (clt_parameters.shUseFlaps) {
dbg_outlayers[i] = outlayers[i]? 1.0:0.0; numScans = createTileOverlapTasks(
} clt_parameters.max_clusters, // 50, // int maxClusters,
clt_parameters.shMinArea, // int minClusterArea,
new_disparity, // [] disparity_in, masked ok too
this_strength, // double [] strength_in,
Math.pow(10.0, -clt_parameters.tiPrecision), // double maxChange, // adjust border disparity until change is below this.
clt_parameters.shMinStrength, // double minStrength,
clustersNO, // int [] clusters_in,
disparity_far,
disparity_near,
clt_parameters.show_shells,
debugLevel);
} else {
int [] enum_clusters = enumerateClusters(
true, // boolean diag_en,
grown); // these_tiles); // boolean [] tiles_src)
numScans = createTileTasks(
50, // int maxClusters,
0, // int minClusterArea,
new_disparity, // this_disparity, // [] disparity_in, masked ok too
this_strength, // double [] strength_in,
0.0, // double minStrength,
enum_clusters, // int [] clusters_in,
disparity_far,
disparity_near,
debugLevel);
}
if (debugLevel > -1){
System.out.println("thirdPassSetup(): created "+ numScans+ " FPGA passes.");
}
*/
}
public void thirdPassSetupOld( // prepare tile tasks for the second pass based on the previous one(s)
EyesisCorrectionParameters.CLTParameters clt_parameters,
double disparity_far, //
double disparity_near, //
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
double [] dbg_orig_disparity = null;
double [] dbg_with_super_disp = null;
double [] dbg_outlayers = null;
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
boolean [] these_tiles = scan_prev.getSelected();
double [] this_disparity = scan_prev.getDisparity(); // returns a copy of the FPGA-generated disparity combined with the target one
double [] this_strength = scan_prev.getStrength(); // cloned, can be modified/ read back
double [] masked_filtered = scan_prev.getDisparity().clone();
if (clt_parameters.stShow){
String [] dbg_disp_tiltes={"masked", "filtered", "disp_combo", "disparity","st_disparity", "strength", "st_strength","outlayers"};
double [][] dbg_disp = new double [dbg_disp_tiltes.length][];
dbg_disp[0] = masked_filtered;
dbg_disp[1] = scan_prev.getDisparity();
dbg_disp[2] = dbg_with_super_disp;
dbg_disp[3] = dbg_orig_disparity;
dbg_disp[4] = scan_prev.getBgDisparity();
dbg_disp[5] = scan_prev.getStrength();
dbg_disp[6] = scan_prev.getBgStrength();
dbg_disp[7] = dbg_outlayers;
sdfa_instance.showArrays(dbg_disp, tilesX, tilesY, true, "disparity_supertiles",dbg_disp_tiltes);
}
dbg_orig_disparity = this_disparity.clone();
//clt_parameters.transform_size; SuperTiles st = scan_prev.getSuperTiles();
if (clt_parameters.plSnapDispAny >= 0.0) {
double [] snap_disparity = st.snapDisparity(
this_disparity, // final double [] disparity,
this_strength, // final double [] strength,
null, // this_selection, // final boolean [] selection, // can be null
clt_parameters.plDispNorm, // final double dispNorm, // plDispNorm
clt_parameters.plSnapDispAny, //final double snapDispAny, // = .2, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at any strength
clt_parameters.plSnapStrengthAny,//final double snapStrengthAny, // = .2, // Maximal strength to fit any distance (if does not fit otherwise - treat as zero strength
clt_parameters.plSnapNegAny, //final double snapNegAny, // = .2, // Maximal negative disparity difference from the best match
clt_parameters.plSnapDispMax, // final double snapDispMax, // = .5, // Maximal (scaled by plDispNorm) disparity difference to snap to plane at low strength
clt_parameters.plSnapDispWeight, // final double snapDispWeight, // = .5, // Maximal disparity diff. by weight product to snap to plane
clt_parameters.plSnapZeroMode, // final int snapZeroMode, // Zero strength snap mode: 0: no special treatment, 1 - strongest, 2 - farthest
1); // final int debugLevel)
System.arraycopy(snap_disparity, 0, this_disparity, 0, snap_disparity.length);
}
if (clt_parameters.replaceWeakOutlayers) {
boolean[] outlayers = scan_prev.replaceWeakOutlayers(
null, // final boolean [] selection,
clt_parameters.outlayerStrength , //final double weakStrength, // strength to be considered weak, subject to this replacement
clt_parameters.outlayerDiff, // final double maxDiff)
clt_parameters.outlayerDiffPos, // final double maxDiff)
clt_parameters.outlayerDiffNeg, // final double maxDiff)
0.5 * disparity_far,
2.0 * disparity_near,
debugLevel);
dbg_outlayers = new double[outlayers.length];
for (int i = 0; i < outlayers.length; i++){
dbg_outlayers[i] = outlayers[i]? 1.0:0.0;
}
double [] masked_filtered = scan_prev.getDisparity().clone();
if (clt_parameters.stShow){
String [] dbg_disp_tiltes={"masked", "filtered", "disp_combo", "disparity","st_disparity", "strength", "st_strength","outlayers"};
double [][] dbg_disp = new double [dbg_disp_tiltes.length][];
dbg_disp[0] = masked_filtered; //+
dbg_disp[1] = scan_prev.getDisparity(); //+
dbg_disp[2] = dbg_with_super_disp; // -
dbg_disp[3] = dbg_orig_disparity; //+
dbg_disp[4] = scan_prev.getBgDisparity();
dbg_disp[5] = scan_prev.getStrength(); //+
dbg_disp[6] = scan_prev.getBgStrength();
dbg_disp[7] = dbg_outlayers; // + (all 0)
sdfa_instance.showArrays(dbg_disp, tilesX, tilesY, true, "disparity_supertiles",dbg_disp_tiltes);
}
}
//clt_parameters.transform_size;
DisparityProcessor dp = new DisparityProcessor(this, clt_parameters.transform_size * geometryCorrection.getScaleDzDx()); DisparityProcessor dp = new DisparityProcessor(this, clt_parameters.transform_size * geometryCorrection.getScaleDzDx());
boolean [] grown = these_tiles.clone(); boolean [] grown = these_tiles.clone();
...@@ -3175,20 +3715,21 @@ public class TileProcessor { ...@@ -3175,20 +3715,21 @@ public class TileProcessor {
null); // boolean [] prohibit) null); // boolean [] prohibit)
boolean [] border = grown.clone(); boolean [] border = grown.clone();
for (int i = 0; i < border.length; i++) border[i] &= !these_tiles[i]; for (int i = 0; i < border.length; i++) border[i] &= !these_tiles[i];
// double [] dbg_before = scan_prev.getDisparity().clone(); // double [] dbg_before = scan_prev.getDisparity().clone();
scan_prev.fixNaNDisparity( scan_prev.fixNaNDisparity(
grown, // border, // boolean [] select, // which tiles to correct (null - all) grown, // border, // boolean [] select, // which tiles to correct (null - all)
scan_prev.getDisparity(), // double [] disparity, scan_prev.getDisparity(), // double [] disparity,
scan_prev.getStrength()); // double [] strength) scan_prev.getStrength()); // double [] strength)
// double [] dbg_after = scan_prev.getDisparity().clone();
for (int i = 0; i < masked_filtered.length; i++){
if (!grown[i]) masked_filtered[i] = Double.NaN;
}
// double [] dbg_after = scan_prev.getDisparity().clone();
/// for (int i = 0; i < masked_filtered.length; i++){
/// if (!grown[i]) masked_filtered[i] = Double.NaN;
/// }
int [] neighbors = dp.getNeighbors( // creates neighbors mask from bitmask int [] neighbors = dp.getNeighbors( // creates neighbors mask from bitmask
grown, // these_tiles, // grown, // these_tiles, // boolean [] selected, grown, // these_tiles, // grown, // these_tiles, // boolean [] selected,
tilesX); tilesX);
// int [] neighbors_orig = neighbors.clone(); // int [] neighbors_orig = neighbors.clone();
double [] dbg_neib = dp.dbgShowNeighbors( double [] dbg_neib = dp.dbgShowNeighbors(
grown, // these_tiles, // grown, // these_tiles, grown, // these_tiles, // grown, // these_tiles,
neighbors, // _orig, // int [] neighbors, neighbors, // _orig, // int [] neighbors,
...@@ -3198,8 +3739,8 @@ public class TileProcessor { ...@@ -3198,8 +3739,8 @@ public class TileProcessor {
double [] new_disparity = this_disparity.clone(); double [] new_disparity = this_disparity.clone();
double [][]dbgDeriv = new double [2][]; // [these_tiles.length]; double [][]dbgDeriv = new double [2][]; // [these_tiles.length];
// sdfa_instance.showArrays(dbg_neib,tilesX*clt_parameters.transform_size, tilesY*clt_parameters.transform_size,"neighbors"); // sdfa_instance.showArrays(dbg_neib,tilesX*clt_parameters.transform_size, tilesY*clt_parameters.transform_size,"neighbors");
dp.smoothDisparity( dp.smoothDisparity(
clt_parameters.tiDispPull, // final double dispPull, // clt_parameters.tiDispPull or 0.0 clt_parameters.tiDispPull, // final double dispPull, // clt_parameters.tiDispPull or 0.0
3, // final int mask, // 1 - work on internal elements, 2 - on border elements, 3 - both (internal first); 3, // final int mask, // 1 - work on internal elements, 2 - on border elements, 3 - both (internal first);
...@@ -3214,14 +3755,14 @@ public class TileProcessor { ...@@ -3214,14 +3755,14 @@ public class TileProcessor {
these_tiles, // grown, // these_tiles, // final boolean [] selected, these_tiles, // grown, // these_tiles, // final boolean [] selected,
border, // final boolean [] border, border, // final boolean [] border,
clt_parameters, clt_parameters,
// dbgDeriv, // final double [][] dbgDeriv, //double [2][len] or null; // dbgDeriv, // final double [][] dbgDeriv, //double [2][len] or null;
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
debugLevel); debugLevel);
double [] measured_disparity = dp.dbgRescaleToPixels( double [] measured_disparity = dp.dbgRescaleToPixels(
this_disparity, this_disparity,
clt_parameters.transform_size); // int tile_size) clt_parameters.transform_size); // int tile_size)
// break once //break once
double [][] stresses = new double [clt_parameters.tiNumCycles + 1][]; double [][] stresses = new double [clt_parameters.tiNumCycles + 1][];
double [][] neibs_broken = new double [clt_parameters.tiNumCycles][]; double [][] neibs_broken = new double [clt_parameters.tiNumCycles][];
double [][] smooth_disparities = new double [clt_parameters.tiNumCycles + 1][]; double [][] smooth_disparities = new double [clt_parameters.tiNumCycles + 1][];
...@@ -3232,25 +3773,22 @@ public class TileProcessor { ...@@ -3232,25 +3773,22 @@ public class TileProcessor {
boolean [] too_near = new boolean [this_strength.length]; boolean [] too_near = new boolean [this_strength.length];
double [] true_strength = this_strength.clone(); // this strength will be modified to remove too near tiles (too far - TBD) double [] true_strength = this_strength.clone(); // this strength will be modified to remove too near tiles (too far - TBD)
for (int numCycle = 0; numCycle < clt_parameters.tiNumCycles; numCycle++) { // = 5; // Number of cycles break-smooth (after the first smooth) /** */
/* // for (int numCycle = 0; numCycle < clt_parameters.tiNumCycles; numCycle++) { // = 5; // Number of cycles break-smooth (after the first smooth)
public double tiDispPull = .1; // 10.0 tiDispPull: multiply strength*disparity difference to pull force for (int numCycle = 0; numCycle < 1; numCycle++) { // = 5; // Number of cycles break-smooth (after the first smooth)
public double tiDispPullPreFinal= .1; // 5.0 Scale tiDispPull for pre-final pass
public double tiDispPullFinal = .01; // 2.0 Scale tiDispPull for final pass
*/
// more smoothing // more smoothing
double disp_pull = clt_parameters.tiDispPull; double disp_pull = clt_parameters.tiDispPull;
if (numCycle >= (clt_parameters.tiNumCycles -2)) { if (numCycle >= (clt_parameters.tiNumCycles -2)) {
disp_pull = clt_parameters.tiDispPullPreFinal; // 0.1 * clt_parameters.tiDispPull; disp_pull = clt_parameters.tiDispPullPreFinal; // 0.1 * clt_parameters.tiDispPull;
if (numCycle >= (clt_parameters.tiNumCycles -1)) { if (numCycle >= (clt_parameters.tiNumCycles -1)) {
disp_pull = clt_parameters.tiDispPullPreFinal; // 0.01 * clt_parameters.tiDispPull; disp_pull = clt_parameters.tiDispPullPreFinal; // 0.01 * clt_parameters.tiDispPull;
} }
} }
double breakScale = disp_pull / clt_parameters.tiDispPull; // 1.0; double breakScale = disp_pull / clt_parameters.tiDispPull; // 1.0;
/** */
if ((clt_parameters.tiBreakMode & 1) != 0) { if ((clt_parameters.tiBreakMode & 1) != 0) {
dp.breakDisparity( // break using derivatives dp.breakDisparity( // break using derivatives
clt_parameters.tiBreak3 * breakScale, // clt_parameters.tiBreak, // final double break4, // clt_parameters.tiBreak/0 allow disconnecting from neighbors (fg/bg) clt_parameters.tiBreak3 * breakScale, // clt_parameters.tiBreak, // final double break4, // clt_parameters.tiBreak/0 allow disconnecting from neighbors (fg/bg)
...@@ -3314,8 +3852,8 @@ public class TileProcessor { ...@@ -3314,8 +3852,8 @@ public class TileProcessor {
} }
} }
} }
if ((clt_parameters.tiBreakMode & 16) != 0) { // remove too near if ((clt_parameters.tiBreakMode & 16) != 0) { // remove too near
boolean [] found = dp.findNearFar( boolean [] found = dp.findNearFar(
false, // boolean findFar, false, // boolean findFar,
...@@ -3331,7 +3869,7 @@ public class TileProcessor { ...@@ -3331,7 +3869,7 @@ public class TileProcessor {
} }
} }
} }
/* */
if ((dbgDeriv != null) && (dbgDeriv[0] != null)) { if ((dbgDeriv != null) && (dbgDeriv[0] != null)) {
stresses[numCycle] = dp.dbgShowStress( stresses[numCycle] = dp.dbgShowStress(
dbgDeriv, // double [][] stress, dbgDeriv, // double [][] stress,
...@@ -3341,13 +3879,13 @@ public class TileProcessor { ...@@ -3341,13 +3879,13 @@ public class TileProcessor {
} }
// Now heal some broken gaps back // Now heal some broken gaps back
double healOrtho = 0.0; double healOrtho = 0.0;
if (numCycle >= (clt_parameters.tiNumCycles -2)) { if (numCycle >= (clt_parameters.tiNumCycles -2)) {
healOrtho = clt_parameters.tiHealPreLast; healOrtho = clt_parameters.tiHealPreLast;
if (numCycle >= (clt_parameters.tiNumCycles -1)) { if (numCycle >= (clt_parameters.tiNumCycles -1)) {
healOrtho =clt_parameters.tiHealLast; healOrtho =clt_parameters.tiHealLast;
} }
} }
if (healOrtho > 0.0){ if (healOrtho > 0.0){
dp.reconnectDisparity( // connect disconnected tiles if they have close approximated disparity dp.reconnectDisparity( // connect disconnected tiles if they have close approximated disparity
...@@ -3401,13 +3939,11 @@ public class TileProcessor { ...@@ -3401,13 +3939,11 @@ public class TileProcessor {
smooth_disparities[numCycle+1] = dp.dbgRescaleToPixels( smooth_disparities[numCycle+1] = dp.dbgRescaleToPixels(
new_disparity, new_disparity,
clt_parameters.transform_size); clt_parameters.transform_size);
} }
/** */
// Just calculate stress, do not actually break (after last smoothing) // Just calculate stress, do not actually break (after last smoothing)
dp.breakDisparity( dp.breakDisparity(
0.0, // final double break4, // clt_parameters.tiBreak/0 allow disconnecting from neighbors (fg/bg) 0.0, // final double break4, // clt_parameters.tiBreak/0 allow disconnecting from neighbors (fg/bg)
...@@ -3425,8 +3961,8 @@ public class TileProcessor { ...@@ -3425,8 +3961,8 @@ public class TileProcessor {
stresses[clt_parameters.tiNumCycles] = dp.dbgShowStress( stresses[clt_parameters.tiNumCycles] = dp.dbgShowStress(
dbgDeriv, // double [][] stress, dbgDeriv, // double [][] stress,
clt_parameters.transform_size); // int tile_size) clt_parameters.transform_size); // int tile_size)
// String [] titles0 = {"neib", "neib_broken", "stress", "stress1", "disp-measured", "disp-result","disp-result1"}; // String [] titles0 = {"neib", "neib_broken", "stress", "stress1", "disp-measured", "disp-result","disp-result1"};
double [] dbg_far_near=new double[too_far.length]; double [] dbg_far_near=new double[too_far.length];
for (int i = 0; i < dbg_far_near.length; i++){ for (int i = 0; i < dbg_far_near.length; i++){
if (!these_tiles[i]) dbg_far_near[i]= Double.NaN; if (!these_tiles[i]) dbg_far_near[i]= Double.NaN;
...@@ -3443,7 +3979,7 @@ public class TileProcessor { ...@@ -3443,7 +3979,7 @@ public class TileProcessor {
if (too_near[i]) disp_diff[2][i] = this_disparity[i]-new_disparity[i]; if (too_near[i]) disp_diff[2][i] = this_disparity[i]-new_disparity[i];
else disp_diff[2][i] = Double.NaN; else disp_diff[2][i] = Double.NaN;
} }
if (clt_parameters.show_neighbors) { if (clt_parameters.show_neighbors) {
int numImages = 2 + 3*clt_parameters.tiNumCycles+2+3 + 3; int numImages = 2 + 3*clt_parameters.tiNumCycles+2+3 + 3;
String [] titles_all = new String[numImages]; String [] titles_all = new String[numImages];
...@@ -3496,8 +4032,8 @@ public class TileProcessor { ...@@ -3496,8 +4032,8 @@ public class TileProcessor {
sdfa_instance.showArrays(dbg_img, tilesX*clt_parameters.transform_size, tilesY*clt_parameters.transform_size, sdfa_instance.showArrays(dbg_img, tilesX*clt_parameters.transform_size, tilesY*clt_parameters.transform_size,
true, "neighbors", titles_all); true, "neighbors", titles_all);
} }
//disp_diff //disp_diff
//************************************************ //************************************************
int [][] flaps = dp.createOverlapGeometry( int [][] flaps = dp.createOverlapGeometry(
neighbors, // +1 - up (N), +2 - up-right - NE, ... +0x80 - NW neighbors, // +1 - up (N), +2 - up-right - NE, ... +0x80 - NW
grown, // these_tiles, // final boolean [] selected, // only inner? grown, // these_tiles, // final boolean [] selected, // only inner?
...@@ -3566,7 +4102,7 @@ public class TileProcessor { ...@@ -3566,7 +4102,7 @@ public class TileProcessor {
sdfa_instance.showArrays(dbg_clusters_show, tilesX, tilesY, true, "first "+dbg_max_cluster_show+" clusters",titleClusters); sdfa_instance.showArrays(dbg_clusters_show, tilesX, tilesY, true, "first "+dbg_max_cluster_show+" clusters",titleClusters);
} }
int numScans= 0; int numScans= 0;
if (clt_parameters.shUseFlaps) { if (clt_parameters.shUseFlaps) {
numScans = createTileOverlapTasks( numScans = createTileOverlapTasks(
clt_parameters.max_clusters, // 50, // int maxClusters, clt_parameters.max_clusters, // 50, // int maxClusters,
...@@ -3580,7 +4116,7 @@ public class TileProcessor { ...@@ -3580,7 +4116,7 @@ public class TileProcessor {
disparity_near, disparity_near,
clt_parameters.show_shells, clt_parameters.show_shells,
debugLevel); debugLevel);
} else { } else {
int [] enum_clusters = enumerateClusters( int [] enum_clusters = enumerateClusters(
true, // boolean diag_en, true, // boolean diag_en,
...@@ -3597,7 +4133,7 @@ public class TileProcessor { ...@@ -3597,7 +4133,7 @@ public class TileProcessor {
disparity_near, disparity_near,
debugLevel); debugLevel);
} }
if (debugLevel > -1){ if (debugLevel > -1){
System.out.println("secondPassSetup(): created "+ numScans+ " FPGA passes."); System.out.println("secondPassSetup(): created "+ numScans+ " FPGA passes.");
} }
...@@ -3613,11 +4149,14 @@ public class TileProcessor { ...@@ -3613,11 +4149,14 @@ public class TileProcessor {
} }
sdfa_instance.showArrays(disparities, tilesX, tilesY, true, "disparities_scans",titles); sdfa_instance.showArrays(disparities, tilesX, tilesY, true, "disparities_scans",titles);
} }
// return scan_next; // return scan_next;
} }
//================== //==================
public void secondPassSetupOld( // prepare tile tasks for the second pass based on the previous one(s) public void secondPassSetupOld( // prepare tile tasks for the second pass based on the previous one(s)
// final double [][][] image_data, // first index - number of image in a quad // final double [][][] image_data, // first index - number of image in a quad
......
...@@ -160,10 +160,11 @@ public class X3dOutput { ...@@ -160,10 +160,11 @@ public class X3dOutput {
Element el_appearance = x3dDoc.createElement("Appearance"); Element el_appearance = x3dDoc.createElement("Appearance");
el_shape.appendChild(el_appearance); el_shape.appendChild(el_appearance);
/*
Element el_material = x3dDoc.createElement("Material"); Element el_material = x3dDoc.createElement("Material");
el_appearance.appendChild(el_material); el_appearance.appendChild(el_material);
el_material.setAttribute("diffuseColor", "0.376471 0.5 0.376471"); el_material.setAttribute("diffuseColor", "0.376471 0.5 0.376471");
*/
Element el_imageTexture = x3dDoc.createElement("ImageTexture"); Element el_imageTexture = x3dDoc.createElement("ImageTexture");
el_imageTexture.setAttribute("url",url); el_imageTexture.setAttribute("url",url);
...@@ -182,8 +183,6 @@ public class X3dOutput { ...@@ -182,8 +183,6 @@ public class X3dOutput {
el_texCoordinate.setAttribute("point", stcoord); el_texCoordinate.setAttribute("point", stcoord);
el_IFC.appendChild(el_texCoordinate); el_IFC.appendChild(el_texCoordinate);
} }
......
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