Commit 6368816c authored by Andrey Filippov's avatar Andrey Filippov

minor cleanup

parent 6f9c91ce
...@@ -48,15 +48,6 @@ public class EyesisDCT { ...@@ -48,15 +48,6 @@ public class EyesisDCT {
/// public int extra_items = 8; // number of extra items saved with kernels (center offset (partial, full, derivatives) /// public int extra_items = 8; // number of extra items saved with kernels (center offset (partial, full, derivatives)
public ImagePlus eyesisKernelImage = null; public ImagePlus eyesisKernelImage = null;
public long startTime; public long startTime;
/// 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;
/// public void setTilesXY(int tilesX, int tilesY){
/// if (tp == null){
/// tp = new TileProcessor(tp.tilesX,tp.tilesY);
/// }
/// }
public EyesisDCT( public EyesisDCT(
Properties properties, Properties properties,
......
...@@ -48,6 +48,8 @@ public class ImageDtt { ...@@ -48,6 +48,8 @@ public class ImageDtt {
{0,1,2,3,4,5}, // mottom middle {0,1,2,3,4,5}, // mottom middle
{0,1,3,4}}; // bottom right {0,1,3,4}}; // bottom right
// public static int FORCE_DISPARITY_BIT = 8; // move to parameters? // public static int FORCE_DISPARITY_BIT = 8; // move to parameters?
static int QUAD = 4; // number of cameras in camera
static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho
static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction) static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction)
static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed
......
...@@ -31,7 +31,6 @@ import java.io.IOException; ...@@ -31,7 +31,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet; import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
......
...@@ -52,15 +52,20 @@ public class QuadCLT { ...@@ -52,15 +52,20 @@ public class QuadCLT {
TileProcessor tp = null; TileProcessor tp = null;
public void setTilesXY(int tilesX, int tilesY){ // magic scale should be set before using TileProcessor (calculated disparities depend on it)
if (tp == null){
tp = new TileProcessor(tilesX, tilesY);
}
}
public void setTiles (ImagePlus imp, // set tp.tilesX, tp.tilesY public void setTiles (ImagePlus imp, // set tp.tilesX, tp.tilesY
EyesisCorrectionParameters.CLTParameters clt_parameters EyesisCorrectionParameters.CLTParameters clt_parameters,
int threadsMax
){ ){
setTilesXY(imp.getWidth()/clt_parameters.transform_size, imp.getHeight()/clt_parameters.transform_size); if (tp == null){
tp = new TileProcessor(imp.getWidth()/clt_parameters.transform_size,
imp.getHeight()/clt_parameters.transform_size,
clt_parameters.transform_size,
clt_parameters.stSize,
clt_parameters.corr_magic_scale,
threadsMax);
}
} }
public QuadCLT( public QuadCLT(
...@@ -3171,11 +3176,9 @@ public class QuadCLT { ...@@ -3171,11 +3176,9 @@ public class QuadCLT {
} }
} }
// tp.tilesY = imp_quad[0].getHeight()/clt_parameters.transform_size;
// tp.tilesX = imp_quad[0].getWidth()/clt_parameters.transform_size;
// setTilesXY(imp_quad[0].getWidth()/clt_parameters.transform_size, imp_quad[0].getHeight()/clt_parameters.transform_size);
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);
// temporary setting up tile task file (one integer per tile, bitmask // temporary setting up tile task file (one integer per tile, bitmask
...@@ -3191,12 +3194,15 @@ public class QuadCLT { ...@@ -3191,12 +3194,15 @@ public class QuadCLT {
double [][] clt_mismatch = null; // [3*4][tp.tilesY * tp.tilesX] // transpose unapplied double [][] clt_mismatch = null; // [3*4][tp.tilesY * tp.tilesX] // transpose unapplied
double [][][][] texture_tiles = null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualizaion mode full 16 or overlapped double [][][][] texture_tiles = null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualizaion mode full 16 or overlapped
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
if (clt_parameters.correlate){ if (clt_parameters.correlate){
// clt_corr_combo = new double [2][tp.tilesY][tp.tilesX][]; // clt_corr_combo = new double [2][tp.tilesY][tp.tilesX][];
clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tp.tilesY][tp.tilesX][]; clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][];
texture_tiles = new double [tp.tilesY][tp.tilesX][][]; // ["RGBA".length()][]; texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
for (int i = 0; i < tp.tilesY; i++){ for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tp.tilesX; j++){ for (int j = 0; j < tilesX; j++){
for (int k = 0; k<clt_corr_combo.length; k++){ for (int k = 0; k<clt_corr_combo.length; k++){
clt_corr_combo[k][i][j] = null; clt_corr_combo[k][i][j] = null;
} }
...@@ -3205,9 +3211,9 @@ public class QuadCLT { ...@@ -3205,9 +3211,9 @@ public class QuadCLT {
} }
} }
if (clt_parameters.corr_keep){ if (clt_parameters.corr_keep){
clt_corr_partial = new double [tp.tilesY][tp.tilesX][][][]; clt_corr_partial = new double [tilesY][tilesX][][][];
for (int i = 0; i < tp.tilesY; i++){ for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tp.tilesX; j++){ for (int j = 0; j < tilesX; j++){
clt_corr_partial[i][j] = null; clt_corr_partial[i][j] = null;
} }
} }
...@@ -3301,8 +3307,8 @@ public class QuadCLT { ...@@ -3301,8 +3307,8 @@ public class QuadCLT {
debugLevel); debugLevel);
sdfa_instance.showArrays( sdfa_instance.showArrays(
texture_nonoverlap, texture_nonoverlap,
tp.tilesX * (2 * clt_parameters.transform_size), tilesX * (2 * clt_parameters.transform_size),
tp.tilesY * (2 * clt_parameters.transform_size), tilesY * (2 * clt_parameters.transform_size),
true, true,
name + "-TXTNOL-D"+clt_parameters.disparity, name + "-TXTNOL-D"+clt_parameters.disparity,
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles)); (clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
...@@ -3331,8 +3337,8 @@ public class QuadCLT { ...@@ -3331,8 +3337,8 @@ public class QuadCLT {
if (clt_parameters.show_overlap) { if (clt_parameters.show_overlap) {
sdfa_instance.showArrays( sdfa_instance.showArrays(
texture_overlap, texture_overlap,
tp.tilesX * clt_parameters.transform_size, tilesX * clt_parameters.transform_size,
tp.tilesY * clt_parameters.transform_size, tilesY * clt_parameters.transform_size,
true, true,
name + "-TXTOL-D"+clt_parameters.disparity, name + "-TXTOL-D"+clt_parameters.disparity,
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles)); (clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
...@@ -3353,8 +3359,8 @@ public class QuadCLT { ...@@ -3353,8 +3359,8 @@ public class QuadCLT {
true, // boolean saveShowIntermediate, // save/show if set globally true, // boolean saveShowIntermediate, // save/show if set globally
true, // boolean saveShowFinal, // save/show result (color image?) true, // boolean saveShowFinal, // save/show result (color image?)
((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb), ((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb),
tp.tilesX * clt_parameters.transform_size, tilesX * clt_parameters.transform_size,
tp.tilesY * clt_parameters.transform_size, tilesY * clt_parameters.transform_size,
1.0, // double scaleExposure, // is it needed? 1.0, // double scaleExposure, // is it needed?
debugLevel ); debugLevel );
} }
...@@ -3366,8 +3372,8 @@ public class QuadCLT { ...@@ -3366,8 +3372,8 @@ public class QuadCLT {
if (clt_parameters.show_map){ if (clt_parameters.show_map){
sdfa_instance.showArrays( sdfa_instance.showArrays(
disparity_map, disparity_map,
tp.tilesX, tilesX,
tp.tilesY, tilesY,
true, true,
name+"-DISP_MAP-D"+clt_parameters.disparity, name+"-DISP_MAP-D"+clt_parameters.disparity,
ImageDtt.DISPARITY_TITLES); ImageDtt.DISPARITY_TITLES);
...@@ -3379,8 +3385,8 @@ public class QuadCLT { ...@@ -3379,8 +3385,8 @@ public class QuadCLT {
String [] disparity_titles = {"dx0", "dy0","strength0","dx1", "dy1","strength1","dx2", "dy2","strength2","dx3", "dy3","strength3"}; String [] disparity_titles = {"dx0", "dy0","strength0","dx1", "dy1","strength1","dx2", "dy2","strength2","dx3", "dy3","strength3"};
sdfa_instance.showArrays( sdfa_instance.showArrays(
clt_mismatch, clt_mismatch,
tp.tilesX, tilesX,
tp.tilesY, tilesY,
true, true,
name+"-MISMATCH_XYW-D"+clt_parameters.disparity, name+"-MISMATCH_XYW-D"+clt_parameters.disparity,
disparity_titles); disparity_titles);
...@@ -3391,7 +3397,7 @@ public class QuadCLT { ...@@ -3391,7 +3397,7 @@ public class QuadCLT {
clt_parameters, clt_parameters,
disparity_map, disparity_map,
clt_mismatch, clt_mismatch,
tp.tilesX, tilesX,
clt_parameters.corr_magic_scale, // stil not understood coefficent that reduces reported disparity value. Seems to be around 8.5 clt_parameters.corr_magic_scale, // stil not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
apply_fine_corr( apply_fine_corr(
...@@ -3416,8 +3422,8 @@ public class QuadCLT { ...@@ -3416,8 +3422,8 @@ public class QuadCLT {
sdfa_instance.showArrays( sdfa_instance.showArrays(
corr_rslt, corr_rslt,
tp.tilesX*(2*clt_parameters.transform_size), tilesX*(2*clt_parameters.transform_size),
tp.tilesY*(2*clt_parameters.transform_size), tilesY*(2*clt_parameters.transform_size),
true, true,
name + "-CORR-D"+clt_parameters.disparity, name + "-CORR-D"+clt_parameters.disparity,
titles ); titles );
...@@ -3440,8 +3446,8 @@ public class QuadCLT { ...@@ -3440,8 +3446,8 @@ public class QuadCLT {
debugLevel); debugLevel);
sdfa_instance.showArrays( sdfa_instance.showArrays(
corr_rslt_partial, corr_rslt_partial,
tp.tilesX*(2*clt_parameters.transform_size), tilesX*(2*clt_parameters.transform_size),
tp.tilesY*(2*clt_parameters.transform_size), tilesY*(2*clt_parameters.transform_size),
true, true,
name+"-PART_CORR-D"+clt_parameters.disparity, name+"-PART_CORR-D"+clt_parameters.disparity,
titles); titles);
...@@ -3470,8 +3476,8 @@ public class QuadCLT { ...@@ -3470,8 +3476,8 @@ public class QuadCLT {
// int tp.tilesY = imp_quad[iQuad].getHeight()/clt_parameters.transform_size; // int tp.tilesY = imp_quad[iQuad].getHeight()/clt_parameters.transform_size;
// int tp.tilesX = imp_quad[iQuad].getWidth()/clt_parameters.transform_size; // int tp.tilesX = imp_quad[iQuad].getWidth()/clt_parameters.transform_size;
if (debugLevel > 0){ if (debugLevel > 0){
System.out.println("--tp.tilesX="+tp.tilesX); System.out.println("--tilesX="+tilesX);
System.out.println("--tp.tilesY="+tp.tilesY); System.out.println("--tilesY="+tilesY);
} }
if (debugLevel > 0){ if (debugLevel > 0){
double [][] clt = new double [clt_data[iQuad].length*4][]; double [][] clt = new double [clt_data[iQuad].length*4][];
...@@ -3485,8 +3491,8 @@ public class QuadCLT { ...@@ -3485,8 +3491,8 @@ public class QuadCLT {
if (debugLevel > 0){ if (debugLevel > 0){
sdfa_instance.showArrays(clt, sdfa_instance.showArrays(clt,
tp.tilesX*clt_parameters.transform_size, tilesX*clt_parameters.transform_size,
tp.tilesY*clt_parameters.transform_size, tilesY*clt_parameters.transform_size,
true, true,
results[iQuad].getTitle()+"-CLT-D"+clt_parameters.disparity); results[iQuad].getTitle()+"-CLT-D"+clt_parameters.disparity);
} }
...@@ -3505,8 +3511,8 @@ public class QuadCLT { ...@@ -3505,8 +3511,8 @@ public class QuadCLT {
} }
if (clt_parameters.gen_chn_stacks) sdfa_instance.showArrays(iclt_data, if (clt_parameters.gen_chn_stacks) sdfa_instance.showArrays(iclt_data,
(tp.tilesX + 0) * clt_parameters.transform_size, (tilesX + 0) * clt_parameters.transform_size,
(tp.tilesY + 0) * clt_parameters.transform_size, (tilesY + 0) * clt_parameters.transform_size,
true, true,
results[iQuad].getTitle()+"-ICLT-RGB-D"+clt_parameters.disparity); results[iQuad].getTitle()+"-ICLT-RGB-D"+clt_parameters.disparity);
if (!clt_parameters.gen_chn_img) continue; if (!clt_parameters.gen_chn_img) continue;
...@@ -3522,8 +3528,8 @@ public class QuadCLT { ...@@ -3522,8 +3528,8 @@ public class QuadCLT {
true, // boolean saveShowIntermediate, // save/show if set globally true, // boolean saveShowIntermediate, // save/show if set globally
false, // boolean saveShowFinal, // save/show result (color image?) false, // boolean saveShowFinal, // save/show result (color image?)
iclt_data, iclt_data,
tp.tilesX * clt_parameters.transform_size, tilesX * clt_parameters.transform_size,
tp.tilesY * clt_parameters.transform_size, tilesY * clt_parameters.transform_size,
scaleExposures[iQuad], // double scaleExposure, // is it needed? scaleExposures[iQuad], // double scaleExposure, // is it needed?
debugLevel ); debugLevel );
...@@ -4235,12 +4241,12 @@ public class QuadCLT { ...@@ -4235,12 +4241,12 @@ public class QuadCLT {
} }
} }
// setTilesXY(imp_quad[0].getWidth()/clt_parameters.transform_size, imp_quad[0].getHeight()/clt_parameters.transform_size);
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);
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
// tp.tilesY = imp_quad[0].getHeight()/clt_parameters.transform_size;
// tp.tilesX = imp_quad[0].getWidth()/clt_parameters.transform_size;
// temporary setting up tile task file (one integer per tile, bitmask // temporary setting up tile task file (one integer per tile, bitmask
// for testing defined for a window, later the tiles to process will be calculated based on previous passes results // for testing defined for a window, later the tiles to process will be calculated based on previous passes results
int [][] tile_op = tp.setSameTileOp(clt_parameters, clt_parameters.tile_task_op, debugLevel); int [][] tile_op = tp.setSameTileOp(clt_parameters, clt_parameters.tile_task_op, debugLevel);
...@@ -4248,9 +4254,7 @@ public class QuadCLT { ...@@ -4248,9 +4254,7 @@ public class QuadCLT {
//TODO: Add array of default disparity - use for combining images in force disparity mode (no correlation), when disparity is predicted from other tiles //TODO: Add array of default disparity - use for combining images in force disparity mode (no correlation), when disparity is predicted from other tiles
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
// double [][][][] clt_corr_combo = new double [2][tp.tilesY][tp.tilesX][]; // will only be used inside? double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tp.tilesY][tp.tilesX][]; // will only be used inside?
// double min_corr_selected = clt_parameters.corr_normalize? clt_parameters.min_corr_normalized: clt_parameters.min_corr;
double min_corr_selected = clt_parameters.min_corr; double min_corr_selected = clt_parameters.min_corr;
double [][][] disparity_maps = new double [clt_parameters.disp_scan_count][ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) double [][][] disparity_maps = new double [clt_parameters.disp_scan_count][ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
...@@ -4341,8 +4345,8 @@ public class QuadCLT { ...@@ -4341,8 +4345,8 @@ public class QuadCLT {
ImageStack array_stack = sdfa_instance.makeStack( ImageStack array_stack = sdfa_instance.makeStack(
disparities_maps, disparities_maps,
tp.tilesX, tilesX,
tp.tilesY, tilesY,
disparities_titles); disparities_titles);
ImagePlus imp_stack = new ImagePlus( name+"-DISP_MAPS", array_stack); ImagePlus imp_stack = new ImagePlus( name+"-DISP_MAPS", array_stack);
...@@ -4361,8 +4365,8 @@ public class QuadCLT { ...@@ -4361,8 +4365,8 @@ public class QuadCLT {
ImageStack trends_stack = sdfa_instance.makeStack( ImageStack trends_stack = sdfa_instance.makeStack(
scan_trends, scan_trends,
tp.tilesX, tilesX,
tp.tilesY, tilesY,
trend_titles); trend_titles);
ImagePlus imp_stack_trends = new ImagePlus( name+"-DISP_TRENDS", trends_stack); ImagePlus imp_stack_trends = new ImagePlus( name+"-DISP_TRENDS", trends_stack);
imp_stack_trends.getProcessor().resetMinAndMax(); imp_stack_trends.getProcessor().resetMinAndMax();
...@@ -4691,7 +4695,9 @@ public class QuadCLT { ...@@ -4691,7 +4695,9 @@ public class QuadCLT {
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
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)
{
String name = (String) imp_quad[0].getProperty("name"); String name = (String) imp_quad[0].getProperty("name");
double [][][] image_data = new double [imp_quad.length][][]; double [][][] image_data = new double [imp_quad.length][][];
for (int i = 0; i < image_data.length; i++){ for (int i = 0; i < image_data.length; i++){
...@@ -4705,8 +4711,11 @@ public class QuadCLT { ...@@ -4705,8 +4711,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);
tp.resetCLTPasses(); tp.resetCLTPasses();
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
TileProcessor.CLTPass3d bgnd_data = CLTBackgroundMeas( // measure background TileProcessor.CLTPass3d bgnd_data = CLTBackgroundMeas( // measure background
...@@ -4790,9 +4799,9 @@ public class QuadCLT { ...@@ -4790,9 +4799,9 @@ public class QuadCLT {
TileProcessor.CLTPass3d scan = tp.clt_3d_passes.get(scanIndex); TileProcessor.CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
// TODO: use new updated disparity, for now just what was forced for the picture // TODO: use new updated disparity, for now just what was forced for the picture
double [] scan_disparity = new double [tp.tilesX * tp.tilesY]; double [] scan_disparity = new double [tilesX * tilesY];
int indx = 0; int indx = 0;
for (int ty = 0; ty < tp.tilesY; ty ++) for (int tx = 0; tx < tp.tilesX; tx ++){ for (int ty = 0; ty < tilesY; ty ++) for (int tx = 0; tx < tilesX; tx ++){
scan_disparity[indx++] = scan.disparity[ty][tx]; scan_disparity[indx++] = scan.disparity[ty][tx];
} }
if (clt_parameters.avg_cluster_disp){ if (clt_parameters.avg_cluster_disp){
...@@ -4918,6 +4927,8 @@ public class QuadCLT { ...@@ -4918,6 +4927,8 @@ public class QuadCLT {
int debugLevel int debugLevel
) )
{ {
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
showDoubleFloatArrays sdfa_instance = null; showDoubleFloatArrays sdfa_instance = null;
if (clt_parameters.debug_filters && (debugLevel > -1)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging? if (clt_parameters.debug_filters && (debugLevel > -1)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
...@@ -4948,28 +4959,28 @@ public class QuadCLT { ...@@ -4948,28 +4959,28 @@ public class QuadCLT {
bgnd_data.selected = bgnd_tiles_grown; // selected for background w/o extra transparent layer bgnd_data.selected = bgnd_tiles_grown; // selected for background w/o extra transparent layer
if (sdfa_instance!=null){ if (sdfa_instance!=null){
double [][] dbg_img = new double[3][tp.tilesY * tp.tilesX]; double [][] dbg_img = new double[3][tilesY * tilesX];
String [] titles = {"strict","grown","more_grown"}; String [] titles = {"strict","grown","more_grown"};
for (int i = 0; i<dbg_img[0].length;i++){ for (int i = 0; i<dbg_img[0].length;i++){
dbg_img[0][i] = bgnd_strict[i]?1:0; dbg_img[0][i] = bgnd_strict[i]?1:0;
dbg_img[1][i] = bgnd_tiles_grown[i]?1:0; dbg_img[1][i] = bgnd_tiles_grown[i]?1:0;
dbg_img[2][i] = bgnd_tiles[i]?1:0; dbg_img[2][i] = bgnd_tiles[i]?1:0;
} }
sdfa_instance.showArrays(dbg_img, tp.tilesX, tp.tilesY, true, "strict_grown",titles); sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "strict_grown",titles);
} }
double [][][][] texture_tiles_bgnd = new double[tp.tilesY][tp.tilesX][][]; double [][][][] texture_tiles_bgnd = new double[tilesY][tilesX][][];
double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size]; double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size];
int alpha_index = 3; int alpha_index = 3;
for (int i = 0; i < alpha_zero.length; i++) alpha_zero[i]=0.0; for (int i = 0; i < alpha_zero.length; i++) alpha_zero[i]=0.0;
for (int tileY = 0; tileY < tp.tilesY; tileY++){ for (int tileY = 0; tileY < tilesY; tileY++){
for (int tileX = 0; tileX < tp.tilesX; tileX++){ for (int tileX = 0; tileX < tilesX; tileX++){
texture_tiles_bgnd[tileY][tileX]= null; texture_tiles_bgnd[tileY][tileX]= null;
if ((texture_tiles[tileY][tileX] != null) && if ((texture_tiles[tileY][tileX] != null) &&
bgnd_tiles[tileY * tp.tilesX + tileX]) { bgnd_tiles[tileY * tilesX + tileX]) {
if (bgnd_tiles_grown[tileY * tp.tilesX + tileX]) { if (bgnd_tiles_grown[tileY * tilesX + tileX]) {
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX]; texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX];
}else{ }else{
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone(); texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
...@@ -5015,8 +5026,8 @@ public class QuadCLT { ...@@ -5015,8 +5026,8 @@ public class QuadCLT {
true, // boolean saveShowIntermediate, // save/show if set globally true, // boolean saveShowIntermediate, // save/show if set globally
false, //true, // boolean saveShowFinal, // save/show result (color image?) false, //true, // boolean saveShowFinal, // save/show result (color image?)
((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb), ((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb),
tp.tilesX * clt_parameters.transform_size, tilesX * clt_parameters.transform_size,
tp.tilesY * clt_parameters.transform_size, tilesY * clt_parameters.transform_size,
1.0, // double scaleExposure, // is it needed? 1.0, // double scaleExposure, // is it needed?
debugLevel); debugLevel);
// resize for backdrop here! // resize for backdrop here!
...@@ -5060,30 +5071,31 @@ public class QuadCLT { ...@@ -5060,30 +5071,31 @@ public class QuadCLT {
boolean updateStatus, boolean updateStatus,
int debugLevel) int debugLevel)
{ {
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
showDoubleFloatArrays sdfa_instance = null; showDoubleFloatArrays sdfa_instance = null;
// if (clt_parameters.debug_filters && (debugLevel > -1)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging? // if (clt_parameters.debug_filters && (debugLevel > -1)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging? if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
TileProcessor.CLTPass3d scan = tp.clt_3d_passes.get(scanIndex); TileProcessor.CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
boolean [] borderTiles = scan.border_tiles; boolean [] borderTiles = scan.border_tiles;
double [][][][] texture_tiles = scan.texture_tiles; double [][][][] texture_tiles = scan.texture_tiles;
// boolean [] selected = scan.getAllSelected(); // all selected, including border
scan.updateSelection(); // update .selected field (all selected, including border) and Rectangle bounds scan.updateSelection(); // update .selected field (all selected, including border) and Rectangle bounds
// scan.selected = selected; // selected for background w/o extra transparent layer
double [][]alphaFade = tp.getAlphaFade(clt_parameters.transform_size); double [][]alphaFade = tp.getAlphaFade(clt_parameters.transform_size);
if ((debugLevel > 0) && (scanIndex == 1)) { if ((debugLevel > 0) && (scanIndex == 1)) {
String [] titles = new String[16]; String [] titles = new String[16];
for (int i = 0; i<titles.length;i++) titles[i]=""+i; for (int i = 0; i<titles.length;i++) titles[i]=""+i;
sdfa_instance.showArrays(alphaFade, 2*clt_parameters.transform_size,2*clt_parameters.transform_size,true,"alphaFade",titles); sdfa_instance.showArrays(alphaFade, 2*clt_parameters.transform_size,2*clt_parameters.transform_size,true,"alphaFade",titles);
} }
double [][][][] texture_tiles_cluster = new double[tp.tilesY][tp.tilesX][][]; double [][][][] texture_tiles_cluster = new double[tilesY][tilesX][][];
double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size]; double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size];
int alpha_index = 3; int alpha_index = 3;
for (int i = 0; i < alpha_zero.length; i++) alpha_zero[i]=0.0; for (int i = 0; i < alpha_zero.length; i++) alpha_zero[i]=0.0;
for (int tileY = 0; tileY < tp.tilesY; tileY++){ for (int tileY = 0; tileY < tilesY; tileY++){
for (int tileX = 0; tileX < tp.tilesX; tileX++){ for (int tileX = 0; tileX < tilesX; tileX++){
texture_tiles_cluster[tileY][tileX]= null; texture_tiles_cluster[tileY][tileX]= null;
if (texture_tiles[tileY][tileX] != null) { if (texture_tiles[tileY][tileX] != null) {
if (borderTiles[tileY * tp.tilesX + tileX]) { if (borderTiles[tileY * tilesX + tileX]) {
texture_tiles_cluster[tileY][tileX]= texture_tiles[tileY][tileX].clone(); texture_tiles_cluster[tileY][tileX]= texture_tiles[tileY][tileX].clone();
if (clt_parameters.shAggrFade) { if (clt_parameters.shAggrFade) {
texture_tiles_cluster[tileY][tileX][alpha_index] = alpha_zero; texture_tiles_cluster[tileY][tileX][alpha_index] = alpha_zero;
...@@ -5092,10 +5104,10 @@ public class QuadCLT { ...@@ -5092,10 +5104,10 @@ public class QuadCLT {
System.out.println("getPassImage(): tileY="+tileY+", tileX = "+tileX+", tileY="+tileY); System.out.println("getPassImage(): tileY="+tileY+", tileX = "+tileX+", tileY="+tileY);
} }
int fade_mode=0; int fade_mode=0;
if ((tileY > 0) && (texture_tiles[tileY - 1][tileX] != null) && !borderTiles[(tileY - 1) * tp.tilesX + tileX]) fade_mode |= 1; if ((tileY > 0) && (texture_tiles[tileY - 1][tileX] != null) && !borderTiles[(tileY - 1) * tilesX + tileX]) fade_mode |= 1;
if ((tileX < (tp.tilesX -1)) && (texture_tiles[tileY][tileX + 1] != null) && !borderTiles[tileY * tp.tilesX + tileX + 1]) fade_mode |= 2; if ((tileX < (tilesX -1)) && (texture_tiles[tileY][tileX + 1] != null) && !borderTiles[tileY * tilesX + tileX + 1]) fade_mode |= 2;
if ((tileY < (tp.tilesY -1)) && (texture_tiles[tileY + 1][tileX] != null) && !borderTiles[(tileY + 1) * tp.tilesX + tileX]) fade_mode |= 4; if ((tileY < (tilesY -1)) && (texture_tiles[tileY + 1][tileX] != null) && !borderTiles[(tileY + 1) * tilesX + tileX]) fade_mode |= 4;
if ((tileX > 0) && (texture_tiles[tileY][tileX - 1] != null) && !borderTiles[tileY * tp.tilesX + tileX - 1]) fade_mode |= 8; if ((tileX > 0) && (texture_tiles[tileY][tileX - 1] != null) && !borderTiles[tileY * tilesX + tileX - 1]) fade_mode |= 8;
texture_tiles_cluster[tileY][tileX][alpha_index] = alphaFade[fade_mode]; // alpha_zero; texture_tiles_cluster[tileY][tileX][alpha_index] = alphaFade[fade_mode]; // alpha_zero;
} }
}else{ }else{
...@@ -5136,8 +5148,8 @@ public class QuadCLT { ...@@ -5136,8 +5148,8 @@ public class QuadCLT {
texture_rgbx = resizeGridTexture( texture_rgbx = resizeGridTexture(
texture_rgbx, texture_rgbx,
clt_parameters.transform_size, clt_parameters.transform_size,
tp.tilesX, tilesX,
tp.tilesY, tilesY,
scan.bounds); scan.bounds);
} }
...@@ -5145,8 +5157,8 @@ public class QuadCLT { ...@@ -5145,8 +5157,8 @@ public class QuadCLT {
// int width = resize ? (clt_parameters.transform_size * scan.bounds.width + 1): (clt_parameters.transform_size * tp.tilesX); // int width = resize ? (clt_parameters.transform_size * scan.bounds.width + 1): (clt_parameters.transform_size * tp.tilesX);
// int height = resize ? (clt_parameters.transform_size * scan.bounds.height + 1): (clt_parameters.transform_size * tp.tilesY); // int height = resize ? (clt_parameters.transform_size * scan.bounds.height + 1): (clt_parameters.transform_size * tp.tilesY);
int width = resize ? (clt_parameters.transform_size * scan.bounds.width): (clt_parameters.transform_size * tp.tilesX); int width = resize ? (clt_parameters.transform_size * scan.bounds.width): (clt_parameters.transform_size * tilesX);
int height = resize ? (clt_parameters.transform_size * scan.bounds.height): (clt_parameters.transform_size * tp.tilesY); int height = resize ? (clt_parameters.transform_size * scan.bounds.height): (clt_parameters.transform_size * tilesY);
// sdfa_instance = new showDoubleFloatArrays(); // just for debugging? // sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
// sdfa_instance.showArrays(texture_rgbx, width, height, true, "texture_rgbx"); // sdfa_instance.showArrays(texture_rgbx, width, height, true, "texture_rgbx");
...@@ -5223,7 +5235,8 @@ public class QuadCLT { ...@@ -5223,7 +5235,8 @@ public class QuadCLT {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) final int debugLevel)
{ {
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
TileProcessor.CLTPass3d scan_rslt = tp.new CLTPass3d(); TileProcessor.CLTPass3d scan_rslt = tp.new CLTPass3d();
int d = ImageDtt.setImgMask(0, 0xf); int d = ImageDtt.setImgMask(0, 0xf);
d = ImageDtt.setPairMask(d,0xf); d = ImageDtt.setPairMask(d,0xf);
...@@ -5231,8 +5244,7 @@ public class QuadCLT { ...@@ -5231,8 +5244,7 @@ public class QuadCLT {
int [][] tile_op = tp.setSameTileOp(clt_parameters, d, debugLevel); int [][] tile_op = tp.setSameTileOp(clt_parameters, d, debugLevel);
double [][] disparity_array = tp.setSameDisparity(0.0); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity double [][] disparity_array = tp.setSameDisparity(0.0); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
// double [][][][] clt_corr_combo = new double [2][tp.tilesY][tp.tilesX][]; // will only be used inside? double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tp.tilesY][tp.tilesX][]; // will only be used inside?
// double min_corr_selected = clt_parameters.corr_normalize? clt_parameters.min_corr_normalized: clt_parameters.min_corr; // double min_corr_selected = clt_parameters.corr_normalize? clt_parameters.min_corr_normalized: clt_parameters.min_corr;
double min_corr_selected = clt_parameters.min_corr; double min_corr_selected = clt_parameters.min_corr;
...@@ -5245,7 +5257,7 @@ public class QuadCLT { ...@@ -5245,7 +5257,7 @@ public class QuadCLT {
{clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2}, {clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2},
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}}; {clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
double [][][][] texture_tiles = new double [tp.tilesY][tp.tilesX][][]; // ["RGBA".length()][]; double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(); ImageDtt image_dtt = new ImageDtt();
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
...@@ -5258,7 +5270,7 @@ public class QuadCLT { ...@@ -5258,7 +5270,7 @@ public class QuadCLT {
// Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate // Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
disparity_map, // [12][tp.tilesY * tp.tilesX] disparity_map, // [12][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][]; texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tp.tilesX * clt_parameters.transform_size, // imp_quad[0].getWidth(), // final int width, tilesX * clt_parameters.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum clt_parameters.fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym, clt_parameters.corr_sym,
clt_parameters.corr_offset, clt_parameters.corr_offset,
...@@ -5314,12 +5326,13 @@ public class QuadCLT { ...@@ -5314,12 +5326,13 @@ public class QuadCLT {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) final int debugLevel)
{ {
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
TileProcessor.CLTPass3d scan = tp.clt_3d_passes.get(scanIndex); TileProcessor.CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
int [][] tile_op = scan.tile_op; int [][] tile_op = scan.tile_op;
double [][] disparity_array = scan.disparity; double [][] disparity_array = scan.disparity;
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tp.tilesY][tp.tilesX][]; // will only be used inside? double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
double min_corr_selected = clt_parameters.min_corr; double min_corr_selected = clt_parameters.min_corr;
...@@ -5331,7 +5344,7 @@ public class QuadCLT { ...@@ -5331,7 +5344,7 @@ public class QuadCLT {
{clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2}, {clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2},
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}}; {clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
double [][][][] texture_tiles = new double [tp.tilesY][tp.tilesX][][]; // ["RGBA".length()][]; double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(); ImageDtt image_dtt = new ImageDtt();
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
...@@ -5344,7 +5357,7 @@ public class QuadCLT { ...@@ -5344,7 +5357,7 @@ public class QuadCLT {
// Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate // Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
disparity_map, // [12][tp.tilesY * tp.tilesX] disparity_map, // [12][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][]; texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tp.tilesX * clt_parameters.transform_size, // imp_quad[0].getWidth(), // final int width, tilesX * clt_parameters.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum clt_parameters.fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym, clt_parameters.corr_sym,
clt_parameters.corr_offset, clt_parameters.corr_offset,
......
...@@ -25,28 +25,62 @@ ...@@ -25,28 +25,62 @@
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
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 tilesX; private int tilesX;
public int tilesY; private int tilesY;
private double corr_magic_scale = 0.85; // reported correlation offset vs. actual one (not yet understood)
private int tileSize = 8; // number of linear pixels in a tile (tile is square tileSize*tileSize)
private int superTileSize = 8; // number of linear tiles in a super-tile (supretile is square superTileSize*superTileSize tiles
// or (superTileSize*tileSize) * (superTileSize*tileSize) pixels, currently 64x64 pixels)
public int threadsMax = 100; // maximal number of frames to run
public int globalDebugLevel = 0;
// All parameters are set only once, during instantiation
public TileProcessor( public TileProcessor(
int tilesX, int tilesX,
int tilesY){ int tilesY,
int tileSize,
int superTileSize,
double scale,
int threadsMax)
{
this.tilesX = tilesX; this.tilesX = tilesX;
this.tilesY = tilesY; this.tilesY = tilesY;
this.tileSize = tileSize;
this.superTileSize = superTileSize;
this.corr_magic_scale = scale;
this.threadsMax = threadsMax;
} }
public int getTilesX() {return tilesX;};
public int getTilesY() {return tilesY;};
public void setMagicScale (double scale)
{
this.corr_magic_scale = scale;
}
public class CLTPass3d{ public class CLTPass3d{
public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX] public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX]
public int [][] tile_op; // what was done in the current pass public int [][] tile_op; // what was done in the current pass
public double [][] disparity_map; // add 4 layers - worst difference for the port public double [][] disparity_map; // add 4 layers - worst difference for the port
private double [] calc_disparity = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
// using horizontal features and corr_magic_scale
private double [] calc_disparity_hor = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
private double [] calc_disparity_vert = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
private double [] calc_disparity_combo = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
private double [] strength = null; // composite strength, initially uses a copy of raw 4-sensor correleation strength
public boolean [] border_tiles; // these are border tiles, zero out alpha public boolean [] border_tiles; // these are border tiles, zero out alpha
public boolean [] selected; // which tiles are selected for this layer public boolean [] selected; // which tiles are selected for this layer
public double [][][][] texture_tiles; public double [][][][] texture_tiles;
public String texture = null; // relative (to x3d) path public String texture = null; // relative (to x3d) path
public Rectangle bounds; public Rectangle bounds;
public int dbg_index; public int dbg_index;
public int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // may also be ImageDtt.DISPARITY_INDEX_POLY
SuperTiles superTiles = null;
public void updateSelection(){ // add updating border tiles? public void updateSelection(){ // add updating border tiles?
selected = new boolean[tilesY*tilesX]; selected = new boolean[tilesY*tilesX];
int minX = tilesX, minY = tilesY, maxX = -1, maxY = -1; int minX = tilesX, minY = tilesY, maxX = -1, maxY = -1;
...@@ -63,8 +97,332 @@ public class TileProcessor { ...@@ -63,8 +97,332 @@ public class TileProcessor {
} }
bounds = new Rectangle(minX, minY, maxX - minX +1, maxY - minY +1 ); bounds = new Rectangle(minX, minY, maxX - minX +1, maxY - minY +1 );
} }
/**
* Get FPGA-calculated per-tile maximal differences between the particular image and the average one.
* @return per-camera sesnor array of line-scan differences
*/
public double [][] getDiffs (){
double [][] these_diffs = new double[ImageDtt.QUAD][];
for (int i = 0; i< ImageDtt.QUAD; i++) these_diffs[i] = disparity_map[ImageDtt.IMG_DIFF0_INDEX + i];
return these_diffs;
}
public void resetCalc(){ // only needed if the same task was reused
calc_disparity = null;
strength = null;
} }
/**
* Returns per-tile correlation "strength". Initially - copy of the FPGA-generated data, b ut later may be replaced by a combination
* of the combined data from 4-sensor (4-pair) correlation and horizontal/vertical pairs only to improve detection of vertical/
* horizontal features
* @return line-scan array of per-tile correlation strength by reference (not a copy), so it can be modified
*/
public double [] getStrength(){
if (strength == null){
strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone();
}
return strength;
}
/**
* Get four pairs (original) correlation strength. Not a copy
* @return line-scan array of per-tile horizontal pairs correlation strength by reference (not a copy)
*/
public double [] getOriginalStrength(){
return disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
}
/**
* Get horizontal pairs correlation strength for vertical features. Not a copy
* @return line-scan array of per-tile horizontal pairs correlation strength by reference (not a copy)
*/
public double [] getHorStrength(){
return disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH];
}
/**
* Get veriical pairs correlation strength for horizontal features. Not a copy
* @return line-scan array of per-tile horizontal pairs correlation strength by reference (not a copy)
*/
public double [] getVertStrength(){
return disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH];
}
/**
* Get Get combine per-tile disparity values from correlation combined with pre-programmed initial disparity shift.
* @return line-scan array of per-tile disparity by reference (not a copy), so it can be modified
*/
public double [] getDisparity() // get calculated combo disparity
{
return getDisparity(0);
}
/**
* Get one of the line-scan per-tile correlation data.
* @param mode 0 - final data (initially copy FPGA generated 4-pair correation)
* 1 - original FPGA generated 4-sensor correlation
* 2 - 2 - horizontal pairs correlation, detecting vertical features
* 3 - 2 - vertical pairs correlation, detecting horizontal features
* @return line-scan array of per-tile disparity by reference (not a copy), so it can be modified
*/
public double [] getDisparity(int mode) // mode = 0 - normal disparity, 1 - hor, 2 - vert
{
if (calc_disparity == null) conditionDisparity();
switch (mode) {
case 1: return calc_disparity;
case 2: return calc_disparity_hor;
case 3: return calc_disparity_vert;
default: return calc_disparity_combo;
}
}
// methods to "condition" measured disparity values
public void conditionDisparity()
{
conditionDisparity(disparity_index);
}
public void conditionDisparity(int disparity_index)
{
this.disparity_index = disparity_index;
calc_disparity = new double[tilesY*tilesX];
calc_disparity_hor = new double[tilesY*tilesX];
calc_disparity_vert = new double[tilesY*tilesX];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
int indx = i * tilesX + j;
calc_disparity[indx] = disparity_map[disparity_index][indx]/corr_magic_scale + this.disparity[i][j];
calc_disparity_hor[indx] = disparity_map[ImageDtt.DISPARITY_INDEX_HOR][indx]/corr_magic_scale + this.disparity[i][j];
calc_disparity_vert[indx] = disparity_map[ImageDtt.DISPARITY_INDEX_VERT][indx]/corr_magic_scale + this.disparity[i][j];
}
}
calc_disparity_combo = calc_disparity.clone(); // for now - just clone, can be modified separately and combined with hor/vert
}
public void setSuperTiles(
double step_disparity,
double min_disparity,
double max_disparity,
double strength_floor,
double strength_pow,
double stBlurSigma)
{
this.superTiles = new SuperTiles(
step_disparity,
min_disparity,
max_disparity,
strength_floor,
strength_pow,
stBlurSigma);
}
public double [] showDisparityHistogram()
{
if (this.superTiles == null){
return null;
}
return this.superTiles.showDisparityHistogram();
}
public int showDisparityHistogramWidth()
{
return this.superTiles.showDisparityHistogramWidth();
}
class SuperTiles{
double step_disparity;
double min_disparity;
double max_disparity;
double strength_floor;
double strength_pow;
double stBlurSigma;
double [][] disparityHistograms = null;
public SuperTiles(
double step_disparity,
double min_disparity,
double max_disparity,
double strength_floor,
double strength_pow,
double stBlurSigma)
{
this.step_disparity = step_disparity;
this.min_disparity = min_disparity;
this.max_disparity = max_disparity;
this.strength_floor = strength_floor;
this.strength_pow = strength_pow;
this.stBlurSigma = stBlurSigma;
getDisparityHistograms(); // claculate and blur supertileas
}
// updates disparityHistograms
public double [][] getDisparityHistograms()
{
return getDisparityHistograms(selected, globalDebugLevel);
}
public double [][] getDisparityHistograms(
final boolean [] selected, // or null
final int debugLevel)
{
if (this.disparityHistograms != null) return this.disparityHistograms;
final int tilesX = getTilesX();
final int tilesY = getTilesY();
final double [] disparity = getDisparity();
final double [] strength = getStrength();
final int stilesX = (tilesX + superTileSize -1)/superTileSize;
final int stilesY = (tilesY + superTileSize -1)/superTileSize;
final int nStiles = stilesX * stilesY;
final int numBins = (int) ((max_disparity - min_disparity)/step_disparity) + 1;
final double dMin = min_disparity - step_disparity/2;
final double dMax = dMin + numBins * step_disparity;
final double [][] dispHist = new double [nStiles][numBins+1];
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
final int st_start = - superTileSize/2;
final int st_end = st_start + superTileSize;
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
int styleY = nsTile / stilesX;
int styleX = nsTile % stilesX;
double sw = 0.0; // sum weights
for (int tileY = styleY * superTileSize + st_start; tileY < styleY * superTileSize + st_end; tileY++){
if ((tileY >= 0) && (tileY < tilesY)) {
for (int tileX = styleX * superTileSize + st_start; tileX < styleX * superTileSize + st_end; tileX++){
if ((tileX >= 0) && (tileX < tilesX)) {
int indx = tileY*tilesX + tileX;
double d = disparity[indx];
if (!Double.isNaN(d) && ((selected == null) || selected[indx])){
double w = strength[indx] - strength_floor;
if (w > 0.0){
if (strength_pow != 1.0) w = Math.pow(w, strength_pow);
int bin = (int) ((d-dMin)/step_disparity);
if ((bin >= 0) && (bin < numBins)){ // maybe collect below min and above max somewhere?
dispHist[nsTile][bin+1] += w;
sw +=w;
}
}
}
}
}
}
}
dispHist[nsTile][0] = sw;
if (sw > 0){
for (int i = 0; i<numBins; i++){
dispHist[nsTile][i+1]/=sw;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
this.disparityHistograms = dispHist;
if (this.stBlurSigma > 0.0) {
this.disparityHistograms = blurDisparityHistogram(debugLevel);
}
return this.disparityHistograms; // dispHist;
}
public double [][] blurDisparityHistogram(
final int debugLevel)
{
final double [][] dispHist = this.disparityHistograms;
final double sigma = this.stBlurSigma;
final int sTiles = dispHist.length;
// final int sTilesY = sTiles / sTilesX;
final int numBins = dispHist[0].length - 1; // [0] - weight
final double [][] bluredHistogram = new double [dispHist.length][dispHist[0].length];
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] data = new double [numBins];
DoubleGaussianBlur gb=new DoubleGaussianBlur();
for (int nsTile = ai.getAndIncrement(); nsTile < sTiles; nsTile = ai.getAndIncrement()) {
System.arraycopy(dispHist[nsTile], 1, data, 0, numBins);
gb.blur1Direction(data, numBins, 1, sigma, 0.01,true);
System.arraycopy(data, 0, bluredHistogram[nsTile], 1, numBins);
bluredHistogram[nsTile][0] = dispHist[nsTile][0]; // strength
}
}
};
}
ImageDtt.startAndJoin(threads);
return bluredHistogram;
}
public int showDisparityHistogramWidth()
{
int sTilesX = (getTilesX() + superTileSize -1)/superTileSize;
return sTilesX * ((disparityHistograms[0].length - 1) + 1) + 1;
}
public double [] showDisparityHistogram()
{
if (disparityHistograms == null){
getDisparityHistograms(); // calculate and blur with the current settings, specified at instantiation
}
int sTileHeight0 = 0; // vertical pixels for each histogram (excluding borders). if <= 0 make square cells
final double [][] dispHist = disparityHistograms;
final int sTilesX = (getTilesX() + superTileSize -1)/superTileSize;
final int sTiles = dispHist.length;
final int sTilesY = sTiles / sTilesX;
final int numBins = dispHist[0].length - 1; // [0] - weight
final int sTileHeight = (sTileHeight0 > 0)? sTileHeight0 : numBins;
final double [] maxHist = new double [sTiles];
final int width = sTilesX * (numBins + 1) + 1;
final int height = sTilesY * (sTileHeight + 1) +1;
double [] rslt = new double [width*height];
double maxW = 0.0; // use for borders between cells
for (int i = 0; i < sTiles; i++){
if (maxW < dispHist[i][0]) maxW = dispHist[i][0];
for (int j = 1; j< (numBins + 1); j++){
if (maxHist[i] < dispHist[i][j]) maxHist[i] = dispHist[i][j];
}
}
for (int nsTile = 0; nsTile < sTiles; nsTile++){
int styleY = nsTile / sTilesX;
int styleX = nsTile % sTilesX;
int x0 = styleX * (numBins + 1);
int y0 = styleY * (numBins + 1);
int indx0 = x0 + y0*width;
// draw rectangular frame - horisontal dotted lines
for (int j = 0; j < numBins + 2; j+=2) {
rslt [indx0 + j] = maxW;
rslt [indx0 + (sTileHeight + 1) * width+ j] = maxW;
}
// vertical dotted lines
for (int j = 0; j < sTileHeight + 2; j+=2) {
rslt [indx0 + j * width] = maxW;
rslt [indx0 + (numBins + 1)+ j * width] = maxW;
}
// draw normalized histograms, using overall weight as intensity
for (int bin = 0; bin <numBins; bin ++){
int h = (int) (sTileHeight * dispHist[nsTile][bin+1] / maxHist[nsTile]);
int x = bin + 1;
for (int j = 0; j <= h; j++) {
int y = sTileHeight + 1 - j;
rslt [indx0 + y * width + x] = dispHist[nsTile][0];
}
}
}
return rslt;
}
}
} // end of class CLTPass3d
public void resetCLTPasses(){ public void resetCLTPasses(){
clt_3d_passes = new ArrayList<CLTPass3d>(); clt_3d_passes = new ArrayList<CLTPass3d>();
} }
...@@ -319,7 +677,8 @@ public class TileProcessor { ...@@ -319,7 +677,8 @@ public class TileProcessor {
} }
} }
if (sw >0) sd/= sw; if (sw >0) sd/= sw;
disparity[indx] = sw; ////// disparity[indx] = sw;
disparity[indx] = sd;
} }
double [] new_disparity = new double [indx2.length]; double [] new_disparity = new double [indx2.length];
for (int nrep = 0; nrep < maxrep; nrep++){ for (int nrep = 0; nrep < maxrep; nrep++){
...@@ -1023,60 +1382,43 @@ public class TileProcessor { ...@@ -1023,60 +1382,43 @@ public class TileProcessor {
return disp_array; return disp_array;
} }
public CLTPass3d secondPassSetup( // 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 public boolean [] combineHorVertDisparity(
EyesisCorrectionParameters.CLTParameters clt_parameters, final CLTPass3d scan,
// disparity range - differences from final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
double disparity_far, // final double disparity_far, //
double disparity_near, // final double disparity_near, //
double this_sure, // minimal strength to be considered definitely background final double this_sure, // minimal strength to be considered definitely background
double this_maybe, // maximal strength to ignore as non-background final double this_maybe, // maximal strength to ignore as non-background
double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd final double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
int disparity_index, // index of disparity value in disparity_map == 2 (0,2 or 4) final 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);
CLTPass3d scan_next = new CLTPass3d();
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?
int quad = 4;
int tlen = tilesY * tilesX; // scale and shift all 3 disparities - combo, vert and hor
//TODO: for next passes - combine all selected for previous passes (all passes with smaller disparity) final int tlen = tilesY * tilesX;
boolean [] bg_tiles = clt_3d_passes.get(0).selected; // selected for background w/o extra transparent layer double [] this_disparity = scan.getDisparity(); // returns a copy of the FPGA-generated disparity combined with the target one
double [] this_hor_disparity= scan.getDisparity(2);
double [] disparity = scan_prev.disparity_map[disparity_index]; double [] this_vert_disparity= scan.getDisparity(3);
double [] strength = scan_prev.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX]; double [] this_strength = scan.getStrength(); // cloned, can be modified/ read back
double [] hor_disparity = scan_prev.disparity_map[ImageDtt.DISPARITY_INDEX_HOR]; double [] strength = scan.getOriginalStrength(); // reference, not cloned
double [] hor_strength = scan_prev.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH]; double [] hor_strength = scan.getHorStrength();
double [] vert_disparity = scan_prev.disparity_map[ImageDtt.DISPARITY_INDEX_VERT]; double [] vert_strength = scan.getVertStrength();
double [] vert_strength = scan_prev.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH]; double [] dbg_orig_disparity = scan.getDisparity(0); // unmodified
double [][] these_diffs = scan.getDiffs();
double [] this_disparity = new double[tlen];
double [] this_hor_disparity = new double[tlen];
double [] this_vert_disparity = new double[tlen];
double [][] these_diffs = new double[quad][];
for (int i = 0; i< quad; i++) these_diffs[i] = scan_prev.disparity_map[ImageDtt.IMG_DIFF0_INDEX + i];
boolean [] these_tiles = new boolean [tlen]; boolean [] these_tiles = new boolean [tlen];
boolean [] near_tiles = new boolean [tlen]; boolean [] near_tiles = new boolean [tlen];
boolean [] far_tiles = new boolean [tlen]; boolean [] far_tiles = new boolean [tlen];
boolean [] block_propagate = new boolean [tlen]; boolean [] block_propagate = new boolean [tlen];
boolean [] used_hor = new boolean [tlen]; boolean [] used_hor = new boolean [tlen];
boolean [] used_vert = new boolean [tlen]; boolean [] used_vert = new boolean [tlen];
double [] this_strength = strength.clone();
boolean [] dbg_used_hor; // original, before bridging
boolean [] dbg_used_vert;
// scale and shift all 3 disparities - combo, vert and hor
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
int indx = i * tilesX + j;
this_disparity[indx] = disparity[indx]/clt_parameters.corr_magic_scale + scan_prev.disparity[i][j];
this_hor_disparity[indx] = hor_disparity[indx]/clt_parameters.corr_magic_scale + scan_prev.disparity[i][j];
this_vert_disparity[indx] = vert_disparity[indx]/clt_parameters.corr_magic_scale + scan_prev.disparity[i][j];
}
}
// convolve hor/vert strengths to emphasize multi-tile features // convolve hor/vert strengths to emphasize multi-tile features
double [] hor_strength_conv = detectOrtho( double [] hor_strength_conv = detectOrtho(
...@@ -1096,17 +1438,7 @@ public class TileProcessor { ...@@ -1096,17 +1438,7 @@ public class TileProcessor {
vert_strength_conv[i] = (clt_parameters.ortho_mix * vert_strength_conv[i] + (1.0 - clt_parameters.ortho_mix ) * vert_strength[i]); vert_strength_conv[i] = (clt_parameters.ortho_mix * vert_strength_conv[i] + (1.0 - clt_parameters.ortho_mix ) * vert_strength[i]);
} }
//getOriginalStrength()
double [] dbg_orig_disparity = this_disparity.clone();
/*
if (sdfa_instance != null){
String [] titles = {"hor_strength","hor_strength_conv", "this_hor_disparity"};
double [][] ddd = {hor_strength, hor_strength_conv, this_hor_disparity};
sdfa_instance.showArrays(ddd, tilesX, tilesY, true, "ddd",titles);
}
*/
for (int i = 0; i < tilesY; i++){ for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){ for (int j = 0; j < tilesX; j++){
...@@ -1115,16 +1447,6 @@ public class TileProcessor { ...@@ -1115,16 +1447,6 @@ public class TileProcessor {
double disp = this_disparity[indx]; double disp = this_disparity[indx];
// Enhance foreground detection: compare horizontal-only (for vertical features) and vertical (for horizontal) and replace 4-pair disparity // Enhance foreground detection: compare horizontal-only (for vertical features) and vertical (for horizontal) and replace 4-pair disparity
// with that value // with that value
/*
if ((i ==119) && (j==45)){
System.out.println("hor_strength_conv["+indx+"]= "+ hor_strength_conv[indx]);
System.out.println("vert_strength_conv["+indx+"]= "+ vert_strength_conv[indx]);
System.out.println("this_hor_disparity["+indx+"]= "+ this_hor_disparity[indx]);
System.out.println("clt_parameters.ortho_min_hor="+clt_parameters.ortho_min_hor+", clt_parameters.ortho_asym= "+ clt_parameters.ortho_asym);
System.out.println("disp= "+ disp);
}
*/
if ((hor_strength_conv[indx] >= clt_parameters.ortho_min_hor) && if ((hor_strength_conv[indx] >= clt_parameters.ortho_min_hor) &&
(hor_strength_conv[indx] / vert_strength_conv[indx]>= clt_parameters.ortho_asym) && (hor_strength_conv[indx] / vert_strength_conv[indx]>= clt_parameters.ortho_asym) &&
(this_hor_disparity[indx] > disp)) { (this_hor_disparity[indx] > disp)) {
...@@ -1137,12 +1459,13 @@ public class TileProcessor { ...@@ -1137,12 +1459,13 @@ public class TileProcessor {
disp = this_vert_disparity[indx]; disp = this_vert_disparity[indx];
used_vert[indx] = true; used_vert[indx] = true;
} }
// this_disparity[indx] = disp; // /clt_parameters.corr_magic_scale + scan_prev.disparity[i][j];
} }
} }
} }
dbg_used_hor = used_hor.clone();
dbg_used_vert = used_vert.clone(); boolean [] dbg_used_hor = used_hor.clone();
boolean [] dbg_used_vert = used_vert.clone();
if (clt_parameters.min_clstr_seed > 1){ if (clt_parameters.min_clstr_seed > 1){
removeSmallClusters( removeSmallClusters(
false, //true, // boolean diag_en, // enable diagonal directions, false only up, dowm, right,left false, //true, // boolean diag_en, // enable diagonal directions, false only up, dowm, right,left
...@@ -1150,6 +1473,7 @@ public class TileProcessor { ...@@ -1150,6 +1473,7 @@ public class TileProcessor {
null, // double [] weights_src, // or null null, // double [] weights_src, // or null
clt_parameters.min_clstr_seed, // int min_area, // minimal number of pixels clt_parameters.min_clstr_seed, // int min_area, // minimal number of pixels
0.0); // double min_weight // minimal total weight of the cluster 0.0); // double min_weight // minimal total weight of the cluster
removeSmallClusters( removeSmallClusters(
false, // true, // boolean diag_en, // enable diagonal directions, false only up, dowm, right,left false, // true, // boolean diag_en, // enable diagonal directions, false only up, dowm, right,left
used_vert, // boolean [] tiles_src, // selected tiles, will modified used_vert, // boolean [] tiles_src, // selected tiles, will modified
...@@ -1158,9 +1482,6 @@ public class TileProcessor { ...@@ -1158,9 +1482,6 @@ public class TileProcessor {
0.0); // double min_weight // minimal total weight of the cluster 0.0); // double min_weight // minimal total weight of the cluster
} }
// if (clt_parameters.ortho_bridge > 0) {
// bridge over small gaps in horizontal/vertical features // bridge over small gaps in horizontal/vertical features
int numHorBridged = bridgeFgndOrthoGap( int numHorBridged = bridgeFgndOrthoGap(
clt_parameters, clt_parameters,
...@@ -1211,11 +1532,11 @@ public class TileProcessor { ...@@ -1211,11 +1532,11 @@ public class TileProcessor {
} }
// see if the second worst variatoin exceeds sure_smth (like a window), really close object // see if the second worst variatoin exceeds sure_smth (like a window), really close object
int imax1 = 0; int imax1 = 0;
for (int ip = 1; ip< quad; ip++){ for (int ip = 1; ip < these_diffs.length; ip++){
if (these_diffs[ip][i] > these_diffs[imax1][i]) imax1 = ip; if (these_diffs[ip][i] > these_diffs[imax1][i]) imax1 = ip;
} }
int imax2 = (imax1 == 0)? 1 : 0; int imax2 = (imax1 == 0)? 1 : 0;
for (int ip = 0; ip< quad; ip++) if (ip != imax1) { for (int ip = 0; ip< these_diffs.length; ip++) if (ip != imax1) {
if (these_diffs[ip][i] > these_diffs[imax2][i]) imax2 = ip; if (these_diffs[ip][i] > these_diffs[imax2][i]) imax2 = ip;
} }
block_propagate[i] = (these_diffs[imax2][i] > sure_smth); block_propagate[i] = (these_diffs[imax2][i] > sure_smth);
...@@ -1259,17 +1580,18 @@ public class TileProcessor { ...@@ -1259,17 +1580,18 @@ public class TileProcessor {
} }
} }
double [] this_disparity_masked = this_disparity.clone(); double [] this_disparity_masked = this_disparity.clone();
for (int i = 0; i < this_disparity.length; i++){ for (int i = 0; i < this_disparity.length; i++){
if (!these_tiles[i])this_disparity_masked[i] = Double.NaN; if (!these_tiles[i])this_disparity_masked[i] = Double.NaN;
} }
if (sdfa_instance!=null){
int [] enum_clusters = enumerateClusters( int [] enum_clusters = enumerateClusters(
true, // boolean diag_en, true, // boolean diag_en,
these_tiles); // boolean [] tiles_src) these_tiles); // boolean [] tiles_src)
if (sdfa_instance!=null){
String [] titles = {"masked","map","orig_map","hor_map","vert_map","bg_sel","far","these_gaps","these","near","block", String [] titles = {"masked","map","orig_map","hor_map","vert_map","bg_sel","far","these_gaps","these","near","block",
"strength","hor-strength","hor-conv-strength","vert-strength","vert-conv-strength", "strength","hor-strength","hor-conv-strength","vert-strength","vert-conv-strength",
"hor","hor-bridged","vert","vert-bridged","diff0","diff1","diff2","diff3", "enum_clusters"}; "hor","hor-bridged","vert","vert-bridged","diff0","diff1","diff2","diff3", "enum_clusters"};
...@@ -1305,6 +1627,82 @@ public class TileProcessor { ...@@ -1305,6 +1627,82 @@ public class TileProcessor {
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "bgnd_nonbgnd",titles); sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "bgnd_nonbgnd",titles);
} }
return these_tiles;
}
public CLTPass3d secondPassSetup( // 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
EyesisCorrectionParameters.CLTParameters clt_parameters,
// disparity range - differences from
double disparity_far, //
double disparity_near, //
double this_sure, // minimal strength to be considered definitely background
double this_maybe, // maximal strength to ignore as non-background
double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
int disparity_index, // index of disparity value in disparity_map == 2 (0,2 or 4)
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);
CLTPass3d scan_next = new CLTPass3d();
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
//TODO: for next passes - combine all selected for previous passes (all passes with smaller disparity)
boolean [] these_tiles = combineHorVertDisparity(
scan_prev, // final CLTPass3d scan,
clt_3d_passes.get(0).selected, // final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
disparity_far, //
disparity_near, //
this_sure, // minimal strength to be considered definitely background
this_maybe, // maximal strength to ignore as non-background
sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
clt_parameters,
debugLevel);
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
//************************************************
// Show supertiles histograms
if (clt_parameters.stShow){
// try renovated supertiles. Do twice to show both original and blured histograms
String [] dbg_st_titles = {"raw", "blurred"+clt_parameters.stSigma};
double [][] dbg_hist = new double[dbg_st_titles.length][];
scan_prev.setSuperTiles(
clt_parameters.stStepDisparity, // double step_disparity,
clt_parameters.stMinDisparity, // double min_disparity,
clt_parameters.stMaxDisparity, // double max_disparity,
clt_parameters.stFloor, // double strength_floor,
clt_parameters.stPow, // double strength_pow,
0.0); // NO BLUR double stBlurSigma)
dbg_hist[0] = scan_prev.showDisparityHistogram();
scan_prev.setSuperTiles(
clt_parameters.stStepDisparity, // double step_disparity,
clt_parameters.stMinDisparity, // double min_disparity,
clt_parameters.stMaxDisparity, // double max_disparity,
clt_parameters.stFloor, // double strength_floor,
clt_parameters.stPow, // double strength_pow,
clt_parameters.stSigma); // with blur double stBlurSigma)
dbg_hist[1] = scan_prev.showDisparityHistogram();
int hist_width0 = scan_prev.showDisparityHistogramWidth();
int hist_height0 = dbg_hist[0].length/hist_width0;
sdfa_instance.showArrays(dbg_hist, hist_width0, hist_height0, true, "disparity_supertiles_histograms",dbg_st_titles);
}
//clt_parameters.transform_size; //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());
...@@ -1343,8 +1741,8 @@ public class TileProcessor { ...@@ -1343,8 +1741,8 @@ public class TileProcessor {
new_disparity, // final double [] disparity, // current disparity value new_disparity, // final double [] disparity, // current disparity value
this_disparity, // final double [] measured_disparity, // measured disparity this_disparity, // final double [] measured_disparity, // measured disparity
this_strength, // final double [] strength, this_strength, // final double [] strength,
this_hor_disparity, // final double hor_disparity, // not yet used null, // this_hor_disparity, // final double hor_disparity, // not yet used
hor_strength_conv, // final double hor_strength, // not yet used null, // hor_strength_conv, // final double hor_strength, // not yet used
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,
...@@ -1370,14 +1768,6 @@ public class TileProcessor { ...@@ -1370,14 +1768,6 @@ public class TileProcessor {
double breakScale = 1.0; double breakScale = 1.0;
/*
if (numCycle >= (clt_parameters.tiNumCycles -3)) {
breakScale = 0.7;
if (numCycle >= (clt_parameters.tiNumCycles -2)) {
breakScale = 0.5;
}
}
*/
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)
...@@ -1526,8 +1916,8 @@ public class TileProcessor { ...@@ -1526,8 +1916,8 @@ public class TileProcessor {
new_disparity, // final double [] disparity, // current disparity value new_disparity, // final double [] disparity, // current disparity value
this_disparity, // final double [] measured_disparity, // measured disparity this_disparity, // final double [] measured_disparity, // measured disparity
this_strength, // final double [] strength, this_strength, // final double [] strength,
this_hor_disparity, // final double hor_disparity, // not yet used null, // this_hor_disparity, // final double hor_disparity, // not yet used
hor_strength_conv, // final double hor_strength, // not yet used null, // hor_strength_conv, // final double hor_strength, // not yet used
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,
...@@ -1569,8 +1959,8 @@ public class TileProcessor { ...@@ -1569,8 +1959,8 @@ public class TileProcessor {
else if (too_near[i]) dbg_far_near[i]= 1.0; else if (too_near[i]) dbg_far_near[i]= 1.0;
else dbg_far_near[i]= 0.0; else dbg_far_near[i]= 0.0;
} }
double [][] disp_diff = new double [3][disparity.length]; double [][] disp_diff = new double [3][this_disparity.length];
for (int i = 0; i< disparity.length; i++) { for (int i = 0; i< this_disparity.length; i++) {
if (this_strength[i] > 0.0) disp_diff[0][i] = this_disparity[i]-new_disparity[i]; if (this_strength[i] > 0.0) disp_diff[0][i] = this_disparity[i]-new_disparity[i];
else disp_diff[0][i] = Double.NaN; else disp_diff[0][i] = Double.NaN;
if (too_far[i]) disp_diff[1][i] = this_disparity[i]-new_disparity[i]; if (too_far[i]) disp_diff[1][i] = this_disparity[i]-new_disparity[i];
...@@ -1632,55 +2022,6 @@ public class TileProcessor { ...@@ -1632,55 +2022,6 @@ public class TileProcessor {
true, "neighbors", titles_all); true, "neighbors", titles_all);
//disp_diff //disp_diff
//************************************************ //************************************************
// Show supertiles histograms
if (clt_parameters.stShow){
double [][] disp_hist = dp.disparityHistograms(
this_disparity, // final double [] disparity, // may have Double.NaN
this_strength, // final double [] strength,
null, // these_tiles, // final boolean [] selected, // or null
clt_parameters.stSize, // final int supertile_size, // linear size of a super tile in tiles
clt_parameters.stStepDisparity, // final double step_disparity,
clt_parameters.stMinDisparity, // final double min_disparity,
clt_parameters.stMaxDisparity, // final double max_disparity,
clt_parameters.stFloor, // final double strength_floor,
clt_parameters.stPow, // final double strength_pow,
threadsMax, // maximal number of threads to launch
debugLevel);
double [][] blured_disp_hist = dp.blurDisparityHistogram(
disp_hist, // final double [][] dispHist,
clt_parameters.stSigma, // final double sigma,
threadsMax, // maximal number of threads to launch
debugLevel);
final int stilesX = (tilesX + clt_parameters.stSize -1)/clt_parameters.stSize;
String [] dhist_titles = {"raw", "blurred"+clt_parameters.stSigma};
double [][] dbg_disp_hist = new double[dhist_titles.length][];
dbg_disp_hist[0] = dp.showDisparityHistogram(
disp_hist, // final double [][] dispHist,
stilesX, // final int sTilesX, // number of supertiles in a row
0 // final int sTileHeight0 // vertical pixels for each histogram (excluding borders). if <= 0 make square cells
);
dbg_disp_hist[1] = dp.showDisparityHistogram(
blured_disp_hist, // final double [][] dispHist,
stilesX, // final int sTilesX, // number of supertiles in a row
0 // final int sTileHeight0 // vertical pixels for each histogram (excluding borders). if <= 0 make square cells
);
final int hist_width = stilesX * ((disp_hist[0].length - 1) + 1) + 1;
final int hist_height = dbg_disp_hist[0].length/hist_width;
sdfa_instance.showArrays(dbg_disp_hist, hist_width, hist_height, true, "disparity_histograms",dhist_titles);
}
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
these_tiles, // final boolean [] selected, // only inner? these_tiles, // final boolean [] selected, // only inner?
...@@ -1762,6 +2103,9 @@ public class TileProcessor { ...@@ -1762,6 +2103,9 @@ public class TileProcessor {
debugLevel); debugLevel);
} else { } else {
int [] enum_clusters = enumerateClusters(
true, // boolean diag_en,
these_tiles); // boolean [] tiles_src)
numScans = createTileTasks( numScans = createTileTasks(
50, // int maxClusters, 50, // int maxClusters,
......
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