Commit 00ba5f14 authored by Andrey Filippov's avatar Andrey Filippov

Tested basic DSI generation for LWIR

parent 9a970304
...@@ -160,7 +160,8 @@ public class EyesisCorrectionParameters { ...@@ -160,7 +160,8 @@ public class EyesisCorrectionParameters {
public boolean clt_batch_genMl = true; // Generate ML output public boolean clt_batch_genMl = true; // Generate ML output
public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected
public boolean clt_batch_dsi = true; // Create and save DSI combo image with the model public boolean clt_batch_dsi = true; // Create and save DSI combo image with the model
public boolean clt_batch_dsi_aux = false; // Calculate and save aux camera DSI (currently it is offset from the main/rig data public boolean clt_batch_dsi_aux = false; // Calculate and save aux camera DSI (currently it is offset from the main/rig data
public boolean clt_batch_dsi_aux_full=false; // more than just preExpandCLTQuad3d() (same as for Lazy Eye
public boolean clt_batch_save_extrinsics = true; // Save cameras extrinsic parameters with the model public boolean clt_batch_save_extrinsics = true; // Save cameras extrinsic parameters with the model
public boolean clt_batch_save_all = true; // Save all parameters with the model public boolean clt_batch_save_all = true; // Save all parameters with the model
...@@ -302,6 +303,7 @@ public class EyesisCorrectionParameters { ...@@ -302,6 +303,7 @@ public class EyesisCorrectionParameters {
cp.clt_batch_dsi= this.clt_batch_dsi; cp.clt_batch_dsi= this.clt_batch_dsi;
cp.clt_batch_dsi_aux= this.clt_batch_dsi_aux; cp.clt_batch_dsi_aux= this.clt_batch_dsi_aux;
cp.clt_batch_dsi_aux_full= this.clt_batch_dsi_aux_full;
cp.clt_batch_save_extrinsics= this.clt_batch_save_extrinsics; cp.clt_batch_save_extrinsics= this.clt_batch_save_extrinsics;
cp.clt_batch_save_all= this.clt_batch_save_all; cp.clt_batch_save_all= this.clt_batch_save_all;
...@@ -482,6 +484,7 @@ public class EyesisCorrectionParameters { ...@@ -482,6 +484,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"clt_batch_dsi", this.clt_batch_dsi+""); properties.setProperty(prefix+"clt_batch_dsi", this.clt_batch_dsi+"");
properties.setProperty(prefix+"clt_batch_dsi_aux", this.clt_batch_dsi_aux+""); properties.setProperty(prefix+"clt_batch_dsi_aux", this.clt_batch_dsi_aux+"");
properties.setProperty(prefix+"clt_batch_dsi_aux_full", this.clt_batch_dsi_aux_full+"");
properties.setProperty(prefix+"clt_batch_save_extrinsics", this.clt_batch_save_extrinsics+""); properties.setProperty(prefix+"clt_batch_save_extrinsics", this.clt_batch_save_extrinsics+"");
properties.setProperty(prefix+"clt_batch_save_all", this.clt_batch_save_all+""); properties.setProperty(prefix+"clt_batch_save_all", this.clt_batch_save_all+"");
...@@ -640,6 +643,7 @@ public class EyesisCorrectionParameters { ...@@ -640,6 +643,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"clt_batch_dsi")!= null) this.clt_batch_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi")); if (properties.getProperty(prefix+"clt_batch_dsi")!= null) this.clt_batch_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi"));
if (properties.getProperty(prefix+"clt_batch_dsi_aux")!= null) this.clt_batch_dsi_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux")); if (properties.getProperty(prefix+"clt_batch_dsi_aux")!= null) this.clt_batch_dsi_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux"));
if (properties.getProperty(prefix+"clt_batch_dsi_aux_full")!= null) this.clt_batch_dsi_aux_full=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux_full"));
if (properties.getProperty(prefix+"clt_batch_save_extrinsics")!= null) this.clt_batch_save_extrinsics=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_extrinsics")); if (properties.getProperty(prefix+"clt_batch_save_extrinsics")!= null) this.clt_batch_save_extrinsics=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_extrinsics"));
if (properties.getProperty(prefix+"clt_batch_save_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all")); if (properties.getProperty(prefix+"clt_batch_save_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all"));
...@@ -1015,6 +1019,10 @@ public class EyesisCorrectionParameters { ...@@ -1015,6 +1019,10 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Include/genarate separate aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux, gd.addCheckbox ("Include/genarate separate aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux,
"8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+ "8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+
" EO+LWIR - generate a separate GT+AUX file"); " EO+LWIR - generate a separate GT+AUX file");
gd.addCheckbox ("Additional steps to calculate Auf DSI (more than for LY adjustment)", this.clt_batch_dsi_aux_full,
"(Not yet tested)");
gd.addCheckbox ("Save field adjustment data with the model", this.clt_batch_save_extrinsics, gd.addCheckbox ("Save field adjustment data with the model", this.clt_batch_save_extrinsics,
"This data can be used to restore specific filed-adjusted cameras extrinsics used when the model was generated"); "This data can be used to restore specific filed-adjusted cameras extrinsics used when the model was generated");
gd.addCheckbox ("Save all parameters with the model", this.clt_batch_save_all, gd.addCheckbox ("Save all parameters with the model", this.clt_batch_save_all,
...@@ -1103,6 +1111,7 @@ public class EyesisCorrectionParameters { ...@@ -1103,6 +1111,7 @@ public class EyesisCorrectionParameters {
this.clt_batch_dbg1= gd.getNextBoolean(); // 29 this.clt_batch_dbg1= gd.getNextBoolean(); // 29
this.clt_batch_dsi= gd.getNextBoolean(); this.clt_batch_dsi= gd.getNextBoolean();
this.clt_batch_dsi_aux= gd.getNextBoolean(); this.clt_batch_dsi_aux= gd.getNextBoolean();
this.clt_batch_dsi_aux_full= gd.getNextBoolean();
this.clt_batch_save_extrinsics= gd.getNextBoolean(); this.clt_batch_save_extrinsics= gd.getNextBoolean();
this.clt_batch_save_all= gd.getNextBoolean(); this.clt_batch_save_all= gd.getNextBoolean();
if (clt_parameters != null) { if (clt_parameters != null) {
...@@ -1291,6 +1300,10 @@ public class EyesisCorrectionParameters { ...@@ -1291,6 +1300,10 @@ public class EyesisCorrectionParameters {
extensions[0] = sourceSuffix; extensions[0] = sourceSuffix;
prefixes[0] = sourcePrefix; prefixes[0] = sourcePrefix;
MultipleExtensionsFileFilter setFilter = new MultipleExtensionsFileFilter(prefixes,extensions,"Image sets"); MultipleExtensionsFileFilter setFilter = new MultipleExtensionsFileFilter(prefixes,extensions,"Image sets");
MultipleExtensionsFileFilter setFilterMain = new MultipleExtensionsFileFilter(
new String[] {prefixes[0]},new String[] {extensions[0]},"Image sets main");
MultipleExtensionsFileFilter setFilterAux = new MultipleExtensionsFileFilter(
new String[] {prefixes[1]},new String[] {extensions[1]},"Image sets main");
DirectoryChoser dc = new DirectoryChoser( DirectoryChoser dc = new DirectoryChoser(
setFilter, setFilter,
...@@ -1319,16 +1332,27 @@ public class EyesisCorrectionParameters { ...@@ -1319,16 +1332,27 @@ public class EyesisCorrectionParameters {
ArrayList<File> setFilesList = new ArrayList<File>(); // list of set files ArrayList<File> setFilesList = new ArrayList<File>(); // list of set files
for (int nFile=0;nFile<files.length;nFile++) { for (int nFile=0;nFile<files.length;nFile++) {
// String [] setChnFiles = files[nFile].list(setFilter); // String [] setChnFiles = files[nFile].list(setFilter);
File [] setChnFiles = files[nFile].listFiles(setFilter); File [] setChnFiles = files[nFile].listFiles(setFilter);
File [] setMainChnFiles = files[nFile].listFiles(setFilterMain);
File [] setAuxChnFiles = files[nFile].listFiles(setFilterAux);
int num_match = setChnFiles.length; int num_match = setChnFiles.length;
if ( (num_match == num_chn_files) || // all files for main and aux if (num_match == num_chn_files) {
(num_match == num_chn_main) || // only main camera files // || // all files for main and aux
(num_match == num_chn_aux)) // only aux camera files // (setMainChnFiles.length == num_chn_main) || // has all needed main camera files
{ // only use sets of exact number of files // (setAuxChnFiles.length == num_chn_aux)) // has all needed camera files
// { // only use sets of exact number of files
setDirList.add(files[nFile]); setDirList.add(files[nFile]);
for (File f: setChnFiles) { for (File f: setChnFiles) {
setFilesList.add(f); setFilesList.add(f);
} }
} else if ((setMainChnFiles.length == num_chn_main) || (setAuxChnFiles.length == num_chn_aux)) {
setDirList.add(files[nFile]);
if (setMainChnFiles.length == num_chn_main) {
for (File f: setMainChnFiles) setFilesList.add(f);
}
if (setAuxChnFiles.length == num_chn_aux) {
for (File f: setAuxChnFiles) setFilesList.add(f);
}
} }
} }
String [] sourceSetPaths = new String[setDirList.size()]; String [] sourceSetPaths = new String[setDirList.size()];
......
...@@ -269,7 +269,7 @@ public class PolynomialApproximation { ...@@ -269,7 +269,7 @@ public class PolynomialApproximation {
this.debugLevel); this.debugLevel);
} }
public double [][] quadraticApproximation( public double [][] quadraticApproximation( // no use
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
int debugLevel int debugLevel
...@@ -312,8 +312,8 @@ public class PolynomialApproximation { ...@@ -312,8 +312,8 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) 1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel); this.debugLevel);
} }
/*
public double [][] quadraticApproximation( public double [][] quadraticApproximation( // no use
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
double thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) double thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
...@@ -328,7 +328,7 @@ public class PolynomialApproximation { ...@@ -328,7 +328,7 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail) 1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel); this.debugLevel);
} }
*/
public double [][] quadraticApproximation( public double [][] quadraticApproximation(
double [][][] data, double [][][] data,
boolean forceLinear, // use linear approximation boolean forceLinear, // use linear approximation
...@@ -441,8 +441,12 @@ public class PolynomialApproximation { ...@@ -441,8 +441,12 @@ public class PolynomialApproximation {
} }
} }
} }
int zDim=data[0][1].length; int zDim = 0; // =data[0][1].length;
for (int i = 0; i < data.length; i++) if (data[i] != null){
zDim =data[i][1].length;
break;
}
double w,z,x,x2,x3,x4,y,y2,y3,y4,wz; double w,z,x,x2,x3,x4,y,y2,y3,y4,wz;
int i,j,n=0; int i,j,n=0;
...@@ -465,7 +469,7 @@ public class PolynomialApproximation { ...@@ -465,7 +469,7 @@ public class PolynomialApproximation {
SZ02[i]=0.0; SZ02[i]=0.0;
SZ20[i]=0.0; SZ20[i]=0.0;
} }
for (i=0;i<data.length;i++) { for (i=0;i<data.length;i++) if (data[i] != null){
w=(data[i].length>2)? data[i][2][0]:1.0; w=(data[i].length>2)? data[i][2][0]:1.0;
if (w>0) { if (w>0) {
n++; n++;
...@@ -585,7 +589,7 @@ public class PolynomialApproximation { ...@@ -585,7 +589,7 @@ public class PolynomialApproximation {
} }
return ABCDEF; return ABCDEF;
} }
// calcualte "volume" made of the matrix row-vectors, placed orthogonally // calculate "volume" made of the matrix row-vectors, placed orthogonally
// to be compared to determinant // to be compared to determinant
public double normMatix(double [][] a) { public double normMatix(double [][] a) {
double d,norm=1.0; double d,norm=1.0;
......
...@@ -64,14 +64,15 @@ public class CLTPass3d{ ...@@ -64,14 +64,15 @@ public class CLTPass3d{
// texture_selection is only used for the GPU and if not null means it is for the GPU // texture_selection is only used for the GPU and if not null means it is for the GPU
public boolean [] texture_selection = null; // use by the GPU to set texture to generate public boolean [] texture_selection = null; // use by the GPU to set texture to generate
public double [][] max_tried_disparity = null; //[ty][tx] used for combined passes, shows maximal disparity for this tile, regardless of results public double [][] max_tried_disparity = null; //[ty][tx] used for combined passes, shows maximal disparity for this tile, regardless of results
public int clust_radius = 0; // 0 - no clusters, 1 = 1x1 (same as 0, just different program), 2 - 3x3, 3 - 5x5
public boolean is_combo = false; public boolean is_combo = false;
public boolean is_measured = false; public boolean is_measured = false;
public String texture = null; // relative (to x3d) path public String texture = null; // relative (to x3d) path
public Rectangle texture_bounds; // in tiles, not pixels ! public Rectangle texture_bounds; // in tiles, not pixels !
public int dbg_index; public int dbg_index;
public int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // may also be ImageDtt.DISPARITY_INDEX_POLY public int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // may also be ImageDtt.DISPARITY_INDEX_POLY
public int lma_disparity_index = ImageDtt.DISPARITY_INDEX_POLY; // set to -1 to ignore and always use just CM (also applies to lma_strength - next) public int lma_disparity_index = ImageDtt.DISPARITY_INDEX_POLY; // set to -1 to ignore and always use just CM (also applies to lma_strength - next)
public double [][] tiles_RBGA = null; public double [][] tiles_RBGA = null;
SuperTiles superTiles = null; SuperTiles superTiles = null;
...@@ -96,7 +97,14 @@ public class CLTPass3d{ ...@@ -96,7 +97,14 @@ public class CLTPass3d{
} }
} }
public int getClustRadius() {
return clust_radius;
}
public void setClustRadius (int clust_radius) {
this.clust_radius = clust_radius;
}
public TileProcessor getTileProcessor() public TileProcessor getTileProcessor()
{ {
return this.tileProcessor; return this.tileProcessor;
...@@ -606,32 +614,38 @@ public class CLTPass3d{ ...@@ -606,32 +614,38 @@ public class CLTPass3d{
return calc_disparity_combo; return calc_disparity_combo;
} }
} }
public double [] getDisparityLMA() {
if (calc_disparity == null) conditionDisparity(); // sets has_lma;
double [] disparityLMA = calc_disparity.clone();
for (int i = 0; i < disparityLMA.length; i++) {
if (!has_lma[i]) {
disparityLMA[i] = Double.NaN;
}
}
return disparityLMA;
}
// methods to "condition" measured disparity values // methods to "condition" measured disparity values
public void conditionDisparity() public void conditionDisparity()
{ {
/*
conditionDisparity(disparity_index);
}
public void conditionDisparity(int disparity_index) // only called from above
{
*/
int tilesX = tileProcessor.getTilesX(); int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY(); int tilesY = tileProcessor.getTilesY();
double corr_magic_scale = tileProcessor.getMagicScale(); double corr_magic_scale = tileProcessor.getMagicScale();
double corr_magic_scale_LMA = 1.0; double corr_magic_scale_LMA = 1.0;
// int lma_disparity_index = ImageDtt.DISPARITY_INDEX_POLY;
// this.disparity_index = disparity_index;
calc_disparity = new double[tilesY*tilesX]; calc_disparity = new double[tilesY*tilesX];
calc_disparity_hor = new double[tilesY*tilesX]; calc_disparity_hor = new double[tilesY*tilesX];
calc_disparity_vert = new double[tilesY*tilesX]; calc_disparity_vert = new double[tilesY*tilesX];
double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null; double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null;
double [] lma_strength = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index+1] : null;
has_lma = (lma_disparity != null) ? new boolean[tilesX * tilesY] : null;
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++){
int indx = i * tilesX + j; int indx = i * tilesX + j;
if ((lma_disparity != null) && !Double.isNaN(lma_disparity[indx])) { if ((lma_disparity != null) && !Double.isNaN(lma_disparity[indx]) && (lma_strength[indx] > 0.0)) {
calc_disparity[indx] = lma_disparity[indx]/corr_magic_scale_LMA + this.disparity[i][j]; calc_disparity[indx] = lma_disparity[indx]/corr_magic_scale_LMA + this.disparity[i][j];
has_lma[indx] = true;
} else { } else {
calc_disparity[indx] = disparity_map[disparity_index][indx]/corr_magic_scale + this.disparity[i][j]; calc_disparity[indx] = disparity_map[disparity_index][indx]/corr_magic_scale + this.disparity[i][j];
} }
...@@ -654,10 +668,11 @@ public class CLTPass3d{ ...@@ -654,10 +668,11 @@ public class CLTPass3d{
int tilesX = tileProcessor.getTilesX(); int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY(); int tilesY = tileProcessor.getTilesY();
double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null; double [] lma_disparity = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index] : null;
double [] lma_strength = (lma_disparity_index >= 0) ? disparity_map[lma_disparity_index+1] : null;
boolean [] lma_defined = new boolean[tilesX * tilesY]; boolean [] lma_defined = new boolean[tilesX * tilesY];
if (lma_disparity != null) { if (lma_disparity != null) {
for (int i = 0; i < lma_disparity.length; i++) { for (int i = 0; i < lma_disparity.length; i++) {
lma_defined[i] = !Double.isNaN(lma_disparity[i]); lma_defined[i] = !Double.isNaN(lma_disparity[i]) && (lma_strength[i] > 0);
} }
} }
return lma_defined; return lma_defined;
......
...@@ -2439,7 +2439,7 @@ public class ExtrinsicAdjustment { ...@@ -2439,7 +2439,7 @@ public class ExtrinsicAdjustment {
this.last_ymfx); // modifies this.last_ymfx (weights and subtracts fx) this.last_ymfx); // modifies this.last_ymfx (weights and subtracts fx)
this.initial_rms = this.last_rms.clone(); this.initial_rms = this.last_rms.clone();
this.good_or_bad_rms = this.last_rms.clone(); this.good_or_bad_rms = this.last_rms.clone();
if (debug_level > -1) { if (debug_level > 1) {
showDerivatives(0); showDerivatives(0);
showDerivatives(1); showDerivatives(1);
showDerivatives(2); showDerivatives(2);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3234,27 +3234,47 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -3234,27 +3234,47 @@ public class QuadCLT extends QuadCLTCPU {
return imp_texture_full; return imp_texture_full;
} }
// Resore to CLTMeasureCorr when done testing
public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int scanIndex, final int scanIndex,
final boolean save_textures, final boolean save_textures,
// final int clust_rasius,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) {
return CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
clt_parameters,
scanIndex,
save_textures,
0, // clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
}
public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
CLTParameters clt_parameters,
final int scanIndex,
final boolean save_textures,
final int clust_radius,
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)
{ {
if ((gpuQuad == null) || !(isAux()?clt_parameters.gpu_use_aux : clt_parameters.gpu_use_main)) { if ((gpuQuad == null) || !(isAux()?clt_parameters.gpu_use_aux : clt_parameters.gpu_use_main)) {
// TODO: implement clust_radius for GPU !
return super.CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity return super.CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scanIndex, // final int scanIndex, scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures, save_textures, // final boolean save_textures,
clust_radius, // final int clust_radius,
threadsMax, // final int threadsMax, // maximal number of threads to launch threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
} }
// GPU will not use textures. Maybe set texture_selection instead? // GPU will not use textures. Maybe set texture_selection instead?
// final int transform_size =clt_parameters.transform_size;
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex); CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY(); final int tilesY = tp.getTilesY();
...@@ -3271,20 +3291,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -3271,20 +3291,7 @@ public class QuadCLT extends QuadCLTCPU {
} }
} }
} }
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][]; double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
/*
double [][] shiftXY = new double [4][2];
// not used
if (!clt_parameters.fine_corr_ignore) {
double [][] shiftXY0 = {
{clt_parameters.fine_corr_x_0,clt_parameters.fine_corr_y_0},
{clt_parameters.fine_corr_x_1,clt_parameters.fine_corr_y_1},
{clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2},
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
shiftXY = shiftXY0;
}
*/
ImageDtt image_dtt = new ImageDtt( ImageDtt image_dtt = new ImageDtt(
getNumSensors(), getNumSensors(),
clt_parameters.transform_size, clt_parameters.transform_size,
...@@ -3305,67 +3312,126 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -3305,67 +3312,126 @@ public class QuadCLT extends QuadCLTCPU {
ImageDtt.BITS_ALL_DISPARITIES | ImageDtt.BITS_ALL_DISPARITIES |
ImageDtt.BITS_ALL_DIFFS | // needs max_diff? ImageDtt.BITS_ALL_DIFFS | // needs max_diff?
ImageDtt.BITS_OVEREXPOSED; // | ImageDtt.BITS_OVEREXPOSED; // |
// ImageDtt.BITS_TONE_RGB; if (clust_radius > 0) {
image_dtt.clt_aberrations_quad_corr_GPU( // USED in LWIR
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity,
null, // final float [][][][] corr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of 6 corr pairs
null, // final float [][][][] corr_combo_td, // [4][tilesY][tilesX][pair][4*64] TD of combo corrs: qud, cross, hor,vert
// each of the top elements may be null to skip particular combo type
null, // final float [][][][] fdisp_dist, // [tilesY][tilesX][cams][4], // disparity derivatives vectors or null
null, // final float [][][][] fpxpy, // [tilesY][tilesX][cams][2], tile {pX,pY}
//// Uses quadCLT from gpuQuad
// correlation results - final and partial
null, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [type][tilesY][tilesX] should be set by caller
// types: 0 - selected correlation (product+offset), 1 - sum
null, // clt_corr_partial,// [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [tilesY][tilesX] should be set by caller
// When clt_mismatch is non-zero, no far objects extraction will be attempted
null, // clt_mismatch, // [12][tilesY * tilesX] // ***** transpose unapplied ***** ?. null - do not calculate
// values in the "main" directions have disparity (*_CM) subtracted, in the perpendicular - as is
disparity_map, // disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
// last 2 - contrast, avg/ "geometric average)
disparity_modes, // disparity_modes, // bit mask of disparity_map slices to calculate/return
image_dtt.clt_aberrations_quad_corr_GPU( // USED in LWIR null, // final double [][][][] texture_tiles, // compatible with the CPU ones
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others null, // texture_img, // texture_img, // null or [3][] (RGB) or [4][] RGBA
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles null, // texture_woi, // texture_woi, // null or generated texture location/size
tile_op, // per-tile operation bit codes null, // iclt_fimg, // will return quad images or null to skip, use quadCLT.linearStackToColor
disparity_array, // clt_parameters.disparity, // final double disparity, // new parameters, will replace some other?
null, // final float [][][][] corr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of 6 corr pairs // clt_parameters.getFatZero(isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0\
null, // final float [][][][] corr_combo_td, // [4][tilesY][tilesX][pair][4*64] TD of combo corrs: qud, cross, hor,vert clt_parameters.gpu_corr_scale, // gpu_corr_scale, // 0.75; // reduce GPU-generated correlation values
// each of the top elements may be null to skip particular combo type clt_parameters.getGpuFatZero(isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0\
null, // final float [][][][] fdisp_dist, // [tilesY][tilesX][cams][4], // disparity derivatives vectors or null clt_parameters.gpu_sigma_r, // 0.9, 1.1
null, // final float [][][][] fpxpy, // [tilesY][tilesX][cams][2], tile {pX,pY} clt_parameters.gpu_sigma_b, // 0.9, 1.1
//// Uses quadCLT from gpuQuad clt_parameters.gpu_sigma_g, // 0.6, 0.7
// correlation results - final and partial clt_parameters.gpu_sigma_m, // = 0.4; // 0.7;
null, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate (isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr), // final double gpu_sigma_rb_corr, // = 0.5; // apply LPF after accumulating R and B correlation before G, monochrome ? 1.0 : gpu_sigma_rb_corr;
// [type][tilesY][tilesX] should be set by caller clt_parameters.gpu_sigma_corr, // = 0.9;gpu_sigma_corr_m
// types: 0 - selected correlation (product+offset), 1 - sum image_dtt.transform_size - 1, // clt_parameters.gpu_corr_rad, // = transform_size - 1 ?
null, // clt_corr_partial,// [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate clt_parameters.corr_red, // +used
// [tilesY][tilesX] should be set by caller clt_parameters.corr_blue, // +used
// When clt_mismatch is non-zero, no far objects extraction will be attempted clt_parameters.max_corr_radius,// 3.9;
null, // clt_mismatch, // [12][tilesY * tilesX] // ***** transpose unapplied ***** ?. null - do not calculate clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
// values in the "main" directions have disparity (*_CM) subtracted, in the perpendicular - as is clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
disparity_map, // disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
// last 2 - contrast, avg/ "geometric average) clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
disparity_modes, // disparity_modes, // bit mask of disparity_map slices to calculate/return clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
null, // final double [][][][] texture_tiles, // compatible with the CPU ones clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
null, // texture_img, // texture_img, // null or [3][] (RGB) or [4][] RGBA clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
null, // texture_woi, // texture_woi, // null or generated texture location/size geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // iclt_fimg, // will return quad images or null to skip, use quadCLT.linearStackToColor null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
// new parameters, will replace some other? clt_parameters.clt_window,
// clt_parameters.getFatZero(isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0\ disparity_corr, // final double disparity_corr, // disparity at infinity
clt_parameters.gpu_corr_scale, // gpu_corr_scale, // 0.75; // reduce GPU-generated correlation values clt_parameters.tileX, // final int debug_tileX,
clt_parameters.getGpuFatZero(isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0\ clt_parameters.tileY, // final int debug_tileY,
clt_parameters.gpu_sigma_r, // 0.9, 1.1 threadsMax,
clt_parameters.gpu_sigma_b, // 0.9, 1.1 debugLevel);
clt_parameters.gpu_sigma_g, // 0.6, 0.7
clt_parameters.gpu_sigma_m, // = 0.4; // 0.7; } else {
(isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr), // final double gpu_sigma_rb_corr, // = 0.5; // apply LPF after accumulating R and B correlation before G, monochrome ? 1.0 : gpu_sigma_rb_corr; image_dtt.clt_aberrations_quad_corr_GPU( // USED in LWIR
clt_parameters.gpu_sigma_corr, // = 0.9;gpu_sigma_corr_m clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
image_dtt.transform_size - 1, // clt_parameters.gpu_corr_rad, // = transform_size - 1 ? 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
clt_parameters.corr_red, // +used tile_op, // per-tile operation bit codes
clt_parameters.corr_blue, // +used disparity_array, // clt_parameters.disparity, // final double disparity,
clt_parameters.max_corr_radius,// 3.9; null, // final float [][][][] corr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of 6 corr pairs
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial null, // final float [][][][] corr_combo_td, // [4][tilesY][tilesX][pair][4*64] TD of combo corrs: qud, cross, hor,vert
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than // each of the top elements may be null to skip particular combo type
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction) null, // final float [][][][] fdisp_dist, // [tilesY][tilesX][cams][4], // disparity derivatives vectors or null
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image) null, // final float [][][][] fpxpy, // [tilesY][tilesX][cams][2], tile {pX,pY}
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image) //// Uses quadCLT from gpuQuad
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing) // correlation results - final and partial
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages) null, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average // [type][tilesY][tilesX] should be set by caller
geometryCorrection, // final GeometryCorrection geometryCorrection, // types: 0 - selected correlation (product+offset), 1 - sum
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main null, // clt_corr_partial,// [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_parameters.clt_window, // [tilesY][tilesX] should be set by caller
disparity_corr, // final double disparity_corr, // disparity at infinity // When clt_mismatch is non-zero, no far objects extraction will be attempted
clt_parameters.tileX, // final int debug_tileX, null, // clt_mismatch, // [12][tilesY * tilesX] // ***** transpose unapplied ***** ?. null - do not calculate
clt_parameters.tileY, // final int debug_tileY, // values in the "main" directions have disparity (*_CM) subtracted, in the perpendicular - as is
threadsMax, disparity_map, // disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
debugLevel); // last 2 - contrast, avg/ "geometric average)
disparity_modes, // disparity_modes, // bit mask of disparity_map slices to calculate/return
null, // final double [][][][] texture_tiles, // compatible with the CPU ones
null, // texture_img, // texture_img, // null or [3][] (RGB) or [4][] RGBA
null, // texture_woi, // texture_woi, // null or generated texture location/size
null, // iclt_fimg, // will return quad images or null to skip, use quadCLT.linearStackToColor
// new parameters, will replace some other?
// clt_parameters.getFatZero(isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0\
clt_parameters.gpu_corr_scale, // gpu_corr_scale, // 0.75; // reduce GPU-generated correlation values
clt_parameters.getGpuFatZero(isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0\
clt_parameters.gpu_sigma_r, // 0.9, 1.1
clt_parameters.gpu_sigma_b, // 0.9, 1.1
clt_parameters.gpu_sigma_g, // 0.6, 0.7
clt_parameters.gpu_sigma_m, // = 0.4; // 0.7;
(isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr), // final double gpu_sigma_rb_corr, // = 0.5; // apply LPF after accumulating R and B correlation before G, monochrome ? 1.0 : gpu_sigma_rb_corr;
clt_parameters.gpu_sigma_corr, // = 0.9;gpu_sigma_corr_m
image_dtt.transform_size - 1, // clt_parameters.gpu_corr_rad, // = transform_size - 1 ?
clt_parameters.corr_red, // +used
clt_parameters.corr_blue, // +used
clt_parameters.max_corr_radius,// 3.9;
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_parameters.clt_window,
disparity_corr, // final double disparity_corr, // disparity at infinity
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
threadsMax,
debugLevel);
}
scan.disparity_map = disparity_map; scan.disparity_map = disparity_map;
scan.texture_tiles = null; scan.texture_tiles = null;
scan.setTextureSelection(tex_sel); scan.setTextureSelection(tex_sel);
...@@ -4123,6 +4189,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -4123,6 +4189,7 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scanIndex, // final int scanIndex, scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures, save_textures, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // final int threadsMax, // maximal number of threads to launch threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
...@@ -4972,7 +5039,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -4972,7 +5039,7 @@ public class QuadCLT extends QuadCLTCPU {
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
if (debugLevel > -5){ if (debugLevel > -3){ // now -3
tp.showScan( tp.showScan(
scan, // CLTPass3d scan, scan, // CLTPass3d scan,
"LY-combo_scan-"+scan+"_post"); //String title) "LY-combo_scan-"+scan+"_post"); //String title)
......
...@@ -48,6 +48,8 @@ import java.util.Properties; ...@@ -48,6 +48,8 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.checkerframework.checker.units.qual.m;
import com.elphel.imagej.calibration.PixelMapping; import com.elphel.imagej.calibration.PixelMapping;
import com.elphel.imagej.cameras.CLTParameters; import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.cameras.ColorProcParameters; import com.elphel.imagej.cameras.ColorProcParameters;
...@@ -442,6 +444,30 @@ public class QuadCLTCPU { ...@@ -442,6 +444,30 @@ public class QuadCLTCPU {
0); // int jpegQuality) 0); // int jpegQuality)
} }
public void saveDSIAll(
double [][] dsi) // DSI_SLICES.length
{
String x3d_path= correctionsParameters.selectX3dDirectory( // for x3d and obj
correctionsParameters.getModelName(image_name), // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters.x3dModelVersion,
true, // smart,
true); //newAllowed, // save
String title = image_name+"-DSI_MAIN";
// String [] titles = {TwoQuadCLT.DSI_SLICES[TwoQuadCLT.DSI_DISPARITY_MAIN], TwoQuadCLT.DSI_SLICES[TwoQuadCLT.DSI_STRENGTH_MAIN]};
// double [][] dsi_main = {dsi[TwoQuadCLT.DSI_DISPARITY_MAIN], dsi[TwoQuadCLT.DSI_STRENGTH_MAIN]};
// ImagePlus imp = (new ShowDoubleFloatArrays()).makeArrays(dsi_main, tp.getTilesX(), tp.getTilesY(), title, titles);
ImagePlus imp = (new ShowDoubleFloatArrays()).makeArrays(dsi, tp.getTilesX(), tp.getTilesY(), title, TwoQuadCLT.DSI_SLICES);
eyesisCorrections.saveAndShow(
imp, // ImagePlus imp,
x3d_path, // String path,
false, // boolean png,
false, // boolean show,
0); // int jpegQuality)
}
// Save GT from main and AUX calculated DS // Save GT from main and AUX calculated DS
public void saveDSIGTAux( public void saveDSIGTAux(
...@@ -3750,7 +3776,9 @@ public class QuadCLTCPU { ...@@ -3750,7 +3776,9 @@ public class QuadCLTCPU {
int getTotalFiles(SetChannels [] sc) { // USED in lwir int getTotalFiles(SetChannels [] sc) { // USED in lwir
int nf = 0; int nf = 0;
for (int i = 0; i < sc.length; i++) nf+=sc[i].fileNumber().length; if (sc != null) {
for (int i = 0; i < sc.length; i++) nf+=sc[i].fileNumber().length;
}
return nf; return nf;
} }
...@@ -4747,12 +4775,7 @@ public class QuadCLTCPU { ...@@ -4747,12 +4775,7 @@ public class QuadCLTCPU {
clt_parameters.corr_red, clt_parameters.corr_red,
clt_parameters.corr_blue, clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()), clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction) clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image) clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
...@@ -7675,6 +7698,7 @@ public class QuadCLTCPU { ...@@ -7675,6 +7698,7 @@ public class QuadCLTCPU {
CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities) CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
// final double [][][] image_data, // first index - number of image in a quad // final double [][][] image_data, // first index - number of image in a quad
clt_parameters, clt_parameters,
0, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
clt_parameters.stUseRefine, // use supertiles clt_parameters.stUseRefine, // use supertiles
bg_pass, /// does it have .selected bg_pass, /// does it have .selected
// disparity range - differences from // disparity range - differences from
...@@ -7707,6 +7731,7 @@ public class QuadCLTCPU { ...@@ -7707,6 +7731,7 @@ public class QuadCLTCPU {
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes, tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass, 0, // final int firstPass,
refine_pass, // - 1, // final int lastPassPlus1, refine_pass, // - 1, // final int lastPassPlus1,
0, // final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan, tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan,
clt_parameters.grow_disp_max, // final double grow_disp_max, clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance, clt_parameters.gr_unique_tol, // final double unique_tolerance,
...@@ -7742,11 +7767,11 @@ public class QuadCLTCPU { ...@@ -7742,11 +7767,11 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
refine_pass, refine_pass,
false, // true, // final boolean save_textures, false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
if (debugLevel > -3){ if (debugLevel > -3){
System.out.println("CLTMeasure("+refine_pass+")-*"); System.out.println("CLTMeasure("+refine_pass+")-*");
} }
...@@ -7791,6 +7816,7 @@ public class QuadCLTCPU { ...@@ -7791,6 +7816,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
tp.clt_3d_passes.size() -1, // new, refine_pass+1, - just added from macro - VERIFY tp.clt_3d_passes.size() -1, // new, refine_pass+1, - just added from macro - VERIFY
true, // final boolean save_textures, true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -7800,7 +7826,6 @@ public class QuadCLTCPU { ...@@ -7800,7 +7826,6 @@ public class QuadCLTCPU {
if (show_init_refine) tp.showScan( if (show_init_refine) tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1), // CLTPass3d scan, tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1), // CLTPass3d scan,
"after_measure_macro-"+tp.clt_3d_passes.size()); "after_measure_macro-"+tp.clt_3d_passes.size());
} }
/// Refining after all added /// Refining after all added
...@@ -7814,6 +7839,7 @@ public class QuadCLTCPU { ...@@ -7814,6 +7839,7 @@ public class QuadCLTCPU {
CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities) CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
// final double [][][] image_data, // first index - number of image in a quad // final double [][][] image_data, // first index - number of image in a quad
clt_parameters, clt_parameters,
0, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
clt_parameters.stUseRefine, // use supertiles clt_parameters.stUseRefine, // use supertiles
bg_pass, bg_pass,
// disparity range - differences from // disparity range - differences from
...@@ -7845,6 +7871,7 @@ public class QuadCLTCPU { ...@@ -7845,6 +7871,7 @@ public class QuadCLTCPU {
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes, tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass, 0, // final int firstPass,
refine_pass, // - 1, // final int lastPassPlus1, refine_pass, // - 1, // final int lastPassPlus1,
0, // final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan, tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan,
clt_parameters.grow_disp_max, // final double grow_disp_max, clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance, clt_parameters.gr_unique_tol, // final double unique_tolerance,
...@@ -7862,6 +7889,7 @@ public class QuadCLTCPU { ...@@ -7862,6 +7889,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
refine_pass, refine_pass,
true, // final boolean save_textures, true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -7890,35 +7918,222 @@ public class QuadCLTCPU { ...@@ -7890,35 +7918,222 @@ public class QuadCLTCPU {
false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true, // final boolean copyDebug) true, // final boolean copyDebug)
debugLevel); debugLevel);
for (int nexpand = 0; nexpand < 20; nexpand++) { tp.clt_3d_passes.add(combo_pass);
int num_added = tp.expandCertain ( }
combo_pass, // final CLTPass3d combo_pass, // modify
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
/*
combo_pass.setSelected(combo_pass.getLMA().clone()); // store original LMA
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_compositeScan-"+tp.clt_3d_passes.size());
for (int nexpand = 0; nexpand < 50; nexpand++) {
int num_added = tp.expandCertain (
combo_pass, // final CLTPass3d combo_pass, // modify
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
-1.0, // final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
0.5, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
0.1, // final int disp_avg_rrange, // same, relative to disparity
1.0, // final int disp_arange, // look for a fit within range from the neighbor
0.1, // final int disp_rrange, // same, relative to disparity
2, // final int min_defined, // minimal number of defined neighbors that fit into the range
tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure,
debugLevel); // final int debugLevel)
if (num_added==0) {
break;
}
if (show_init_refine &&(debugLevel > 10)) tp.showScan(
combo_pass, // CLTPass3d scan,
"expanded-"+nexpand+"-added-"+num_added);
}
// combo_pass.setLMA(combo_pass.getSelected()); // restore original LMA
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_expandedCertain-"+tp.clt_3d_passes.size());
for (int nexpand = 0; nexpand < 50; nexpand++) {
int num_added = tp.expandCertain (
combo_pass, // final CLTPass3d combo_pass, // modify
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
0.5, // final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
1.0, // 0.5, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
0.2, // 0.1, // final int disp_avg_rrange, // same, relative to disparity
1.0, // final int disp_arange, // look for a fit within range from the neighbor
0.1, // final int disp_rrange, // same, relative to disparity
2, // final int min_defined, // minimal number of defined neighbors that fit into the range
tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure,
debugLevel); // final int debugLevel)
if (num_added==0) {
break;
}
if (show_init_refine &&(debugLevel > 10)) tp.showScan(
combo_pass, // CLTPass3d scan,
"expanded-"+nexpand+"-added-"+num_added);
}
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_expandedAll2-"+tp.clt_3d_passes.size());
for (int nexpand = 0; nexpand < 50; nexpand++) {
int num_added = tp.expandCertain (
combo_pass, // final CLTPass3d combo_pass, // modify
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
0.5, // final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
1.0, // 0.5, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
0.2, // 0.1, // final int disp_avg_rrange, // same, relative to disparity
1.0, // final int disp_arange, // look for a fit within range from the neighbor
0.1, // final int disp_rrange, // same, relative to disparity
1, // 2, // final int min_defined, // minimal number of defined neighbors that fit into the range
tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure,
debugLevel); // final int debugLevel)
if (num_added==0) {
break;
}
if (show_init_refine &&(debugLevel > 10)) tp.showScan(
combo_pass, // CLTPass3d scan,
"expanded-"+nexpand+"-added-"+num_added);
}
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_expandedAll-"+tp.clt_3d_passes.size());
combo_pass.setLMA(combo_pass.getSelected()); // restore original LMA
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_restoredLMA-"+tp.clt_3d_passes.size());
*/
// create and measure several variable-cluster scans from the same single-tile combo_pass
CLTPass3d combo_pass = tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1); // last pass created by tp.compositeScan
int max_clust_radius = 4; // 7x7
CLTPass3d [] combo_multi = new CLTPass3d[max_clust_radius+1];
combo_multi[0] = combo_pass;
for (int clust_radius = 2; clust_radius <= max_clust_radius; clust_radius++) {
// using combo_pass (latest)
int num_added = tp.expandCertainMulti (
combo_pass, // CLTPass3d combo_pass, // modify
tp.clt_3d_passes, //ArrayList <CLTPass3d> passes,
bg_pass, // int firstPass,
tp.clt_3d_passes.size(), // int lastPassPlus1,
0.5, // double disp_avg_arange1, // average neighbors with disparity not more than that from the lowest
0.1, // double disp_avg_rrange1, // same, relative to disparity
1.0, // double disp_avg_arange2, // average neighbors with disparity not more than that from the lowest
0.2, // double disp_avg_rrange2, // same, relative to disparity
1.0, // disp_arange, // look for a fit within range from the neighbor
0.1, // double disp_rrange, // same, relative to disparity
"single-", // String title_prefix,
0); // debugLevl = 1 for low number of images (6)
System.out.println("Added "+num_added+" tiles berore cluster radius "+clust_radius);
boolean [] has_lma = combo_pass.getLMA();
double [] disparity = combo_pass.getDisparity(1); // calc_disparity (skip NaN!)
for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
refine_pass = tp.clt_3d_passes.size();
CLTPass3d refined_multi = tp.refinePassSetupMulti( // prepare tile tasks for the second pass based on the previous one(s)
combo_pass, // CLTPass3d combo_pass,
clust_radius, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
0, // clust_radius - 1, // int shrink_from_defined,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
tp.clt_3d_passes.add(refined_multi);
if (debugLevel > -1)
tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"refined_multi_"+clust_radius+"before_makeUnique");
int [] numLeftRemoved = tp.makeUnique(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass,
refine_pass, // - 1, // final int lastPassPlus1,
clust_radius, // final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan,
clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance,
clt_parameters.show_unique); // final boolean show_unique)
if (debugLevel > -1){
System.out.println("makeUnique("+refine_pass+") -> left: "+numLeftRemoved[0]+", removed:" + numLeftRemoved[1]);
}
if (show_init_refine) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_refinePassSetup-"+tp.clt_3d_passes.size());
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
refine_pass,
false, // true, // final boolean save_textures,
clust_radius, // final int clust_radius,
threadsMax,
updateStatus,
debugLevel);
if (show_init_refine) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_measure-"+tp.clt_3d_passes.size());
combo_multi[clust_radius-1] = tp.compositeScan(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass, bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1, tp.clt_3d_passes.size(), // final int lastPassPlus1,
0.5, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
0.1, // final int disp_avg_rrange, // same, relative to disparity
1.0, // final int disp_arange, // look for a fit within range from the neighbor
0.1, // final int disp_rrange, // same, relative to disparity
2, // final int min_defined, // minimal number of defined neighbors that fit into the range
tp.getTrustedCorrelation(), // final double trustedCorrelation, tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure, tp.getMaxOverexposure(), // final double max_overexposure,
debugLevel); // final int debugLevel) -0.5, // 0.0, // clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
if (num_added==0) { clt_parameters.grow_disp_max, // final double disp_near,
break; clt_parameters.combine_min_strength, // final double minStrength,
clt_parameters.combine_min_hor, // final double minStrengthHor,
clt_parameters.combine_min_vert, // final double minStrengthVert,
false, // final boolean no_weak,
false, // final boolean use_last, //
// TODO: when useCombo - pay attention to borders (disregard)
false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true, // final boolean copyDebug)
debugLevel);
double [] disparity_LMA = combo_multi[clust_radius-1].getDisparityLMA();
for (int i = 0; i< disparity.length; i++) {
if (!Double.isNaN(disparity_LMA[i])) {
disparity[i] = disparity_LMA[i]; // update only measured, others will be removed by makeUnique
}
} }
if (show_init_refine) tp.showScan( if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan, combo_multi[clust_radius-1], // CLTPass3d scan,
"expamded-"+nexpand+"-added-"+num_added); "combo_multi-"+clust_radius+"-pass"+nnn);
}
tp.clt_3d_passes.add(combo_multi[clust_radius-1] );
combo_pass = combo_multi[clust_radius-1];
if (show_init_refine) tp.showScan(
combo_pass, // CLTPass3d scan, // combine tasks from (original) combo_pass and combo_pass_multi (use its combo_disparity, but saved getLMA from original combo_pass ?
"after_compositeScan-"+tp.clt_3d_passes.size()); // when done, grow to fill gaps from 3x3 first (by 1 step) and from 5x5 - second?(by 2 steps), ...
tp.clt_3d_passes.add(combo_pass); }
} }
int num_added = tp.expandCertainMulti (
combo_pass, // CLTPass3d combo_pass, // modify
tp.clt_3d_passes, //ArrayList <CLTPass3d> passes,
bg_pass, // int firstPass,
tp.clt_3d_passes.size(), // int lastPassPlus1,
0.5, // double disp_avg_arange1, // average neighbors with disparity not more than that from the lowest
0.1, // double disp_avg_rrange1, // same, relative to disparity
1.0, // double disp_avg_arange2, // average neighbors with disparity not more than that from the lowest
0.2, // double disp_avg_rrange2, // same, relative to disparity
1.0, // disp_arange, // look for a fit within range from the neighbor
0.1, // double disp_rrange, // same, relative to disparity
"single-", // String title_prefix,
0); // int debugLevel) // 1 - show results 2 - show stages 3 - show all
System.out.println("Added "+num_added+" tiles after cluster radius scan");
if (debugLevel > -2) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_multi-tile_disparity_extension");
///// Refining after all added - end ///// Refining after all added - end
Runtime.getRuntime().gc(); Runtime.getRuntime().gc();
...@@ -7927,6 +8142,12 @@ public class QuadCLTCPU { ...@@ -7927,6 +8142,12 @@ public class QuadCLTCPU {
return true; return true;
} }
ArrayList <CLTPass3d> prepareDisparityScan( // USED in lwir ArrayList <CLTPass3d> prepareDisparityScan( // USED in lwir
double scan_start, double scan_start,
double scan_step, double scan_step,
...@@ -8065,6 +8286,7 @@ public class QuadCLTCPU { ...@@ -8065,6 +8286,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
combo_scan, combo_scan,
false, // final boolean save_textures, false, // final boolean save_textures,
0, // final int clust_radius,
tp.threadsMax, // maximal number of threads to launch tp.threadsMax, // maximal number of threads to launch
false, // updateStatus, false, // updateStatus,
debugLevelInner - 1); debugLevelInner - 1);
...@@ -8119,7 +8341,7 @@ public class QuadCLTCPU { ...@@ -8119,7 +8341,7 @@ public class QuadCLTCPU {
combo_use[nTile] = true; combo_use[nTile] = true;
} }
} }
if ( !batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) { // true if ( !batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1+0)) { // true
String [] dbg_titles = {"fdisp", "fstr", "disp", "str", "overexp","sel","use"}; String [] dbg_titles = {"fdisp", "fstr", "disp", "str", "overexp","sel","use"};
double [][] ddd = {filtered_combo_scand_isp_strength[0],filtered_combo_scand_isp_strength[1],combo_disp,combo_str,combo_overexp, null, null}; double [][] ddd = {filtered_combo_scand_isp_strength[0],filtered_combo_scand_isp_strength[1],combo_disp,combo_str,combo_overexp, null, null};
ddd[5] = new double [combo_use.length]; ddd[5] = new double [combo_use.length];
...@@ -8215,6 +8437,9 @@ public class QuadCLTCPU { ...@@ -8215,6 +8437,9 @@ public class QuadCLTCPU {
data[slice][i] = pixels[i]; data[slice][i] = pixels[i];
} }
} }
boolean [] bg_sel = new boolean [width*height]; boolean [] bg_sel = new boolean [width*height];
boolean [] bg_use = new boolean [width*height]; boolean [] bg_use = new boolean [width*height];
boolean [] combo_use = new boolean [width*height]; boolean [] combo_use = new boolean [width*height];
...@@ -8616,15 +8841,17 @@ public class QuadCLTCPU { ...@@ -8616,15 +8841,17 @@ public class QuadCLTCPU {
combo_scan, combo_scan,
false, // final boolean save_textures, false, // final boolean save_textures,
true, // final boolean save_corr, true, // final boolean save_corr,
// null, // combo_mismatch, // final double [][] mismatch, // null or double [12][] 0, // clust_radius,
tp.threadsMax, // maximal number of threads to launch tp.threadsMax, // maximal number of threads to launch
false, // updateStatus, false, // updateStatus,
debugLevelInner - 1); debugLevelInner - 1);
/**/ /**/
// Why twice?
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters, clt_parameters,
combo_scan, combo_scan,
false, // final boolean save_textures, false, // final boolean save_textures,
0, // clust_radius,
tp.threadsMax, // maximal number of threads to launch tp.threadsMax, // maximal number of threads to launch
false, // updateStatus, false, // updateStatus,
debugLevelInner - 1); debugLevelInner - 1);
...@@ -8916,6 +9143,7 @@ public class QuadCLTCPU { ...@@ -8916,6 +9143,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
combo_scan + 1 + nm, combo_scan + 1 + nm,
false, // true, // final boolean save_textures, false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -8996,6 +9224,7 @@ public class QuadCLTCPU { ...@@ -8996,6 +9224,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
last_scan, last_scan,
false, // true, // final boolean save_textures, false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -9033,6 +9262,7 @@ public class QuadCLTCPU { ...@@ -9033,6 +9262,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
last_scan2, last_scan2,
false, // true, // final boolean save_textures, false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -9775,6 +10005,7 @@ public class QuadCLTCPU { ...@@ -9775,6 +10005,7 @@ public class QuadCLTCPU {
if (refine) { // currently is broken if !refine if (refine) { // currently is broken if !refine
CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities), add it to the list CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities), add it to the list
clt_parameters, clt_parameters,
0, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
stUseRefine, // use supertiles stUseRefine, // use supertiles
bg_index, // bg_scan bg_pass, bg_index, // bg_scan bg_pass,
// disparity range - differences from // disparity range - differences from
...@@ -9968,6 +10199,7 @@ public class QuadCLTCPU { ...@@ -9968,6 +10199,7 @@ public class QuadCLTCPU {
passes, // final ArrayList <CLTPass3d> passes, passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass, 0, // final int firstPass,
refine_pass, // - 1, // final int lastPassPlus1, refine_pass, // - 1, // final int lastPassPlus1,
0, // final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
extended_pass, // tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan, extended_pass, // tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan,
clt_parameters.grow_disp_max, // final double grow_disp_max, clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance, clt_parameters.gr_unique_tol, // final double unique_tolerance,
...@@ -10004,6 +10236,7 @@ public class QuadCLTCPU { ...@@ -10004,6 +10236,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
refine_pass, refine_pass,
false, // final boolean save_textures, false, // final boolean save_textures,
0, // final int clust_radius,
tp.threadsMax, // maximal number of threads to launch tp.threadsMax, // maximal number of threads to launch
false, // updateStatus, false, // updateStatus,
debugLevel - 1); debugLevel - 1);
...@@ -11086,129 +11319,66 @@ public class QuadCLTCPU { ...@@ -11086,129 +11319,66 @@ public class QuadCLTCPU {
clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib, clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib,
clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor, clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor,
clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert); clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert);
if (USE_PRE_2021) {
// clt_corr_combo = null; // Something is broke in old code, tries to use color==3 ==colors.weights.length
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity,
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_partial, // null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // [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]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
/// image_dtt.transform_size,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax,
debugLevel);
} else {
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity,
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
// 2021 replaced next 3
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
null, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
null, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
disparity_map, // [12][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
/// image_dtt.transform_size,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
// 2021 new next 5 image_dtt.clt_aberrations_quad_corr(
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height tile_op, // per-tile operation bit codes
clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height) disparity_array, // clt_parameters.disparity, // final double disparity,
clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters.tileX, // final int debug_tileX, // correlation results - final and partial
clt_parameters.tileY, // final int debug_tileY, // 2021 replaced next 3
(clt_parameters.dbg_mode & 64) != 0, // no fract shift null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
(clt_parameters.dbg_mode & 128) != 0, // no convolve null, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve null, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
threadsMax, disparity_map, // [12][tp.tilesY * tp.tilesX]
debugLevel); texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
} clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
/// image_dtt.transform_size,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
// 2021 new next 5
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax,
debugLevel);
scan_rslt.disparity = disparity_array; scan_rslt.disparity = disparity_array;
scan_rslt.tile_op = tile_op; scan_rslt.tile_op = tile_op;
scan_rslt.disparity_map = disparity_map; scan_rslt.disparity_map = disparity_map;
...@@ -11229,37 +11399,39 @@ public class QuadCLTCPU { ...@@ -11229,37 +11399,39 @@ public class QuadCLTCPU {
return CLTMeasure( // measure background // USED in lwir return CLTMeasure( // measure background // USED in lwir
clt_parameters, clt_parameters,
scanIndex, scanIndex,
true, // save_textures, true, // save_textures,
false, // save_corr, false, // save_corr,
0, // clust_radius,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
} }
/* /*
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // not used in lwir public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int scanIndex, final int scanIndex,
final boolean save_textures, final boolean save_textures,
final boolean save_corr, // final int clust_radius,
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) {
{ return CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
return CLTMeasure( // perform single pass according to prepared tiles operations and disparity clt_parameters,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, scanIndex,
scanIndex, // final int scanIndex, save_textures,
save_textures, // final boolean save_textures, 0, // clust_radius,
save_corr, // final boolean save_corr, threadsMax, // maximal number of threads to launch
// null, // final double [][] mismatch, // null or double [12][] updateStatus,
threadsMax, // final int threadsMax, // maximal number of threads to launch debugLevel);
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
} }
*/ */
public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int scanIndex, final int scanIndex,
final boolean save_textures, final boolean save_textures,
final int clust_radius,
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)
...@@ -11268,8 +11440,8 @@ public class QuadCLTCPU { ...@@ -11268,8 +11440,8 @@ public class QuadCLTCPU {
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scanIndex, // final int scanIndex, scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures, save_textures, // final boolean save_textures,
true, // final boolean save_corr, true, // final boolean save_corr,
// null, // final double [][] mismatch, // null or double [12][] clust_radius, // final int clust_radius,
threadsMax, // final int threadsMax, // maximal number of threads to launch threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
...@@ -11280,11 +11452,12 @@ public class QuadCLTCPU { ...@@ -11280,11 +11452,12 @@ public class QuadCLTCPU {
final int scanIndex, final int scanIndex,
final boolean save_textures, final boolean save_textures,
final boolean save_corr, final boolean save_corr,
// final double [][] mismatch, // null or double [12][] or [numClusters][] for new LMA final int clust_radius,
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)
{ {
final boolean use_tilted = true; // Pass it (and clust_radius?) through scan properties?
// final double [][] mismatch = null; // null or double [12][] or [numClusters][] for new LMA // final double [][] mismatch = null; // null or double [12][] or [numClusters][] for new LMA
final int dbg_x = -295-debugLevel; final int dbg_x = -295-debugLevel;
final int dbg_y = -160-debugLevel; final int dbg_y = -160-debugLevel;
...@@ -11329,9 +11502,8 @@ public class QuadCLTCPU { ...@@ -11329,9 +11502,8 @@ public class QuadCLTCPU {
System.out.println("CLTMeasure("+scanIndex+"): tile_op["+dbg_y+"]["+dbg_x+"] = "+tile_op[dbg_y][dbg_x]); System.out.println("CLTMeasure("+scanIndex+"): tile_op["+dbg_y+"]["+dbg_x+"] = "+tile_op[dbg_y][dbg_x]);
} }
} }
double min_corr_selected = clt_parameters.min_corr; // double min_corr_selected = clt_parameters.min_corr;
// double [][] disparity_map = save_corr ? new double [ImageDtt.DISPARITY_TITLES.length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = save_corr ? new double [ImageDtt.getDisparityTitles(getNumSensors()).length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging) double [][] disparity_map = save_corr ? new double [ImageDtt.getDisparityTitles(getNumSensors()).length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] shiftXY = new double [getNumSensors()][2]; double [][] shiftXY = new double [getNumSensors()][2];
...@@ -11371,7 +11543,7 @@ public class QuadCLTCPU { ...@@ -11371,7 +11543,7 @@ public class QuadCLTCPU {
this.fine_corr[i] = fine_corr0[i]; this.fine_corr[i] = fine_corr0[i];
} }
} }
double [][][] fine_corr = (clt_parameters.fcorr_ignore? null: this.fine_corr);
int mcorr_sel = ImageDtt. corrSelEncode( // maybe update? int mcorr_sel = ImageDtt. corrSelEncode( // maybe update?
clt_parameters.img_dtt.getMcorrAll (getNumSensors()), // boolean sel_all, clt_parameters.img_dtt.getMcorrAll (getNumSensors()), // boolean sel_all,
clt_parameters.img_dtt.getMcorrDia (getNumSensors()), // boolean sel_dia, clt_parameters.img_dtt.getMcorrDia (getNumSensors()), // boolean sel_dia,
...@@ -11379,8 +11551,64 @@ public class QuadCLTCPU { ...@@ -11379,8 +11551,64 @@ public class QuadCLTCPU {
clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib, clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib,
clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor, clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor,
clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert); clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert);
if (USE_PRE_2021) { if (clust_radius > 0) {
image_dtt.clt_aberrations_quad_corr( if (use_tilted) {
image_dtt.clt_aberrations_quad_corr_tilted(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity,
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
// 2021 replaced next 3
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
null, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
null, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
// 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]
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
fine_corr, // null, // (clt_parameters.fcorr_ignore? null: this.fine_corr),
// clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
clust_radius, // final int clustRadius, // 1 - single tile, 2 - 3x3, 3 - 5x5, ...
1.0, // final double arange, // absolute disparity range to consolidate
0.1, // final double rrange, // relative disparity range to consolidate
0.5, // final double no_tilt, // no tilt if center disparity is lower
0.01, // final double damp_tilt, // 0.1?
// 2021 new next 5
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve
threadsMax,
debugLevel);
} else {
image_dtt.clt_aberrations_quad_corr_multi(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
...@@ -11388,12 +11616,13 @@ public class QuadCLTCPU { ...@@ -11388,12 +11616,13 @@ public class QuadCLTCPU {
image_data, // final double [][][] imade_data, // first index - number of image in a quad image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial // correlation results - final and partial
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate // 2021 replaced next 3
null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
null, // mismatch, // null, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate null, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
null, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
// 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()][];
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width, tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym, clt_parameters.corr_sym,
...@@ -11401,22 +11630,7 @@ public class QuadCLTCPU { ...@@ -11401,22 +11630,7 @@ public class QuadCLTCPU {
clt_parameters.corr_red, clt_parameters.corr_red,
clt_parameters.corr_blue, clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()), clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
// clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
// clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection, geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around) clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
...@@ -11424,18 +11638,29 @@ public class QuadCLTCPU { ...@@ -11424,18 +11638,29 @@ public class QuadCLTCPU {
clt_parameters.clt_window, clt_parameters.clt_window,
shiftXY, // shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr), fine_corr, // null, // (clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85 // clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down) clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
clust_radius, // final int clustRadius, // 1 - single tile, 2 - 3x3, 3 - 5x5, ...
1.0, // final double arange, // absolute disparity range to consolidate
0.1, // final double rrange, // relative disparity range to consolidate
// 2021 new next 5
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX, // final int debug_tileX, clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY, clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift (clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve (clt_parameters.dbg_mode & 128) != 0, // no convolve
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax, threadsMax,
debugLevel); debugLevel);
} else { }
} else { // clust_radius
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
...@@ -11458,14 +11683,7 @@ public class QuadCLTCPU { ...@@ -11458,14 +11683,7 @@ public class QuadCLTCPU {
clt_parameters.corr_red, clt_parameters.corr_red,
clt_parameters.corr_blue, clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()), clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
// clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
// clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction) clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image) clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
...@@ -11481,7 +11699,7 @@ public class QuadCLTCPU { ...@@ -11481,7 +11699,7 @@ public class QuadCLTCPU {
clt_parameters.clt_window, clt_parameters.clt_window,
shiftXY, // shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr), fine_corr,
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85 clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down) clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
...@@ -11499,11 +11717,12 @@ public class QuadCLTCPU { ...@@ -11499,11 +11717,12 @@ public class QuadCLTCPU {
threadsMax, threadsMax,
debugLevel); debugLevel);
} }
scan.disparity_map = disparity_map; scan.disparity_map = disparity_map;
scan.texture_tiles = texture_tiles; scan.texture_tiles = texture_tiles;
scan.is_measured = true; // but no disparity map/textures scan.is_measured = true; // but no disparity map/textures
scan.is_combo = false; scan.is_combo = false;
scan.has_lma = null;
scan.getLMA(); // recalculate
scan.resetProcessed(); scan.resetProcessed();
return scan; return scan;
} }
...@@ -11602,122 +11821,61 @@ public class QuadCLTCPU { ...@@ -11602,122 +11821,61 @@ public class QuadCLTCPU {
clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib, clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib,
clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor, clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor,
clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert); clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert);
if (USE_PRE_2021) { image_dtt.clt_aberrations_quad_corr(
image_dtt.clt_aberrations_quad_corr( clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles tile_op, // per-tile operation bit codes
tile_op, // per-tile operation bit codes disparity_array, // clt_parameters.disparity, // final double disparity,
disparity_array, // clt_parameters.disparity, // final double disparity, image_data, // final double [][][] imade_data, // first index - number of image in a quad
image_data, // final double [][][] imade_data, // first index - number of image in a quad saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null // correlation results - final and partial
// correlation results - final and partial // 2021 replaced next 3
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate null, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
null, // mismatch, // null, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate null, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
// 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()][];
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width, tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum clt_parameters.getFatZero(isMonochrome()), // 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,
clt_parameters.corr_red, clt_parameters.corr_red,
clt_parameters.corr_blue, clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()), clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.max_corr_radius, clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction) clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image) clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image) geometryCorrection, // final GeometryCorrection geometryCorrection,
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing) geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages) clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average clt_parameters.kernel_step,
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature) clt_parameters.clt_window,
geometryCorrection, // final GeometryCorrection geometryCorrection, shiftXY, //
geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main disparity_corr, // final double disparity_corr, // disparity at infinity
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around) (clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.kernel_step, clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.clt_window, clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
shiftXY, // clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
disparity_corr, // final double disparity_corr, // disparity at infinity // 2021 new next 5
(clt_parameters.fcorr_ignore? null: this.fine_corr), mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85 clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down) clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.tileX, // final int debug_tileX, clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileY, // final int debug_tileY, clt_parameters.tileX, // final int debug_tileX,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 128) != 0, // no convolve (clt_parameters.dbg_mode & 64) != 0, // no fract shift
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve (clt_parameters.dbg_mode & 128) != 0, // no convolve
threadsMax, // (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
debugLevel); threadsMax,
} else { debugLevel);
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // clt_parameters.disparity, // final double disparity,
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
// 2021 replaced next 3
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
null, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
null, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
// 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]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
tilesX * image_dtt.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
// 2021 new next 5
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax,
debugLevel);
}
scan.disparity_map = disparity_map; scan.disparity_map = disparity_map;
scan.texture_tiles = texture_tiles; scan.texture_tiles = texture_tiles;
scan.is_measured = true; scan.is_measured = true;
...@@ -11843,7 +12001,7 @@ public class QuadCLTCPU { ...@@ -11843,7 +12001,7 @@ public class QuadCLTCPU {
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
if (debugLevel > -5){ if (debugLevel > -3) { // -5){
tp.showScan( tp.showScan(
scan, // CLTPass3d scan, scan, // CLTPass3d scan,
"LY-combo_scan-"+scan+"_post"); //String title) "LY-combo_scan-"+scan+"_post"); //String title)
...@@ -12852,6 +13010,7 @@ public class QuadCLTCPU { ...@@ -12852,6 +13010,7 @@ public class QuadCLTCPU {
clt_parameters, clt_parameters,
scanIndex, scanIndex,
false, // final boolean save_textures, false, // final boolean save_textures,
0, // final int clust_radius,
tp.threadsMax, // maximal number of threads to launch tp.threadsMax, // maximal number of threads to launch
false, // updateStatus, false, // updateStatus,
debugLevelInner -1); // - 1); // -5-1 debugLevelInner -1); // - 1); // -5-1
......
...@@ -1062,16 +1062,18 @@ public class TileProcessor { ...@@ -1062,16 +1062,18 @@ public class TileProcessor {
double strength; double strength;
double adiff; double adiff;
boolean has_lma; boolean has_lma;
int clust_radius;
DSD (int indx){ // only index DSD (int indx){ // only index
this.indx = indx; this.indx = indx;
} }
DSD (int indx, double disparity, double strength, double adiff, boolean has_lma){ DSD (int indx, double disparity, double strength, double adiff, boolean has_lma, int clust_radius){
this.indx = indx; this.indx = indx;
this.disparity = disparity; this.disparity = disparity;
this.strength = strength; this.strength = strength;
this.adiff = adiff; this.adiff = adiff;
this.has_lma = has_lma; this.has_lma = has_lma;
this.clust_radius = clust_radius;
} }
} }
...@@ -1088,10 +1090,13 @@ public class TileProcessor { ...@@ -1088,10 +1090,13 @@ public class TileProcessor {
// if there is at least one with lma - remove all without lma measurements // if there is at least one with lma - remove all without lma measurements
boolean some_lma = false; boolean some_lma = false;
int best_clust_radius = 1000000;
for (DSD dsd : src_list) { for (DSD dsd : src_list) {
some_lma |= dsd.has_lma; if (dsd.has_lma) {
if (some_lma) { if (!some_lma || (dsd.clust_radius < best_clust_radius)) {
break; best_clust_radius = dsd.clust_radius;
}
some_lma = true;
} }
} }
...@@ -1099,7 +1104,7 @@ public class TileProcessor { ...@@ -1099,7 +1104,7 @@ public class TileProcessor {
int best_indx = 0; int best_indx = 0;
for (int i = 1; i < list_in.size(); i++) { for (int i = 1; i < list_in.size(); i++) {
DSD dsd = list_in.get(i); DSD dsd = list_in.get(i);
if (dsd.has_lma | !some_lma) { if (!some_lma || (dsd.has_lma && (dsd.clust_radius == best_clust_radius))) {
if (dsd.adiff < list_in.get(best_indx).adiff) { if (dsd.adiff < list_in.get(best_indx).adiff) {
best_indx = i; best_indx = i;
} }
...@@ -1110,7 +1115,7 @@ public class TileProcessor { ...@@ -1110,7 +1115,7 @@ public class TileProcessor {
ArrayList<DSD> list_remain = new ArrayList<DSD>(); ArrayList<DSD> list_remain = new ArrayList<DSD>();
for (DSD dsd: list_in) { for (DSD dsd: list_in) {
if (dsd.has_lma | !some_lma) { if (!some_lma || (dsd.has_lma && (dsd.clust_radius == best_clust_radius))) {
if (Math.abs(best_dsd.disparity - dsd.disparity) > disp_tolerance) { if (Math.abs(best_dsd.disparity - dsd.disparity) > disp_tolerance) {
list_remain.add(dsd); list_remain.add(dsd);
} }
...@@ -1273,6 +1278,7 @@ public class TileProcessor { ...@@ -1273,6 +1278,7 @@ public class TileProcessor {
double strongest_weak_hor = 0.0; double strongest_weak_hor = 0.0;
double strongest_weak_vert = 0.0; double strongest_weak_vert = 0.0;
boolean use_lma = false; // tile has at least one LMA-measured scan boolean use_lma = false; // tile has at least one LMA-measured scan
int best_lma = 1000000; // larger than any, the smaller - the better
combo_pass0.max_tried_disparity[ty][tx] = Double.NaN; combo_pass0.max_tried_disparity[ty][tx] = Double.NaN;
if (nt == dbg_tile) { if (nt == dbg_tile) {
...@@ -1292,6 +1298,7 @@ public class TileProcessor { ...@@ -1292,6 +1298,7 @@ public class TileProcessor {
(pass.disparity[ty][tx] > combo_pass0.max_tried_disparity[ty][tx]))){ (pass.disparity[ty][tx] > combo_pass0.max_tried_disparity[ty][tx]))){
combo_pass0.max_tried_disparity[ty][tx] = pass.disparity[ty][tx]; combo_pass0.max_tried_disparity[ty][tx] = pass.disparity[ty][tx];
} }
int clust_radius = pass.getClustRadius();
boolean last = (ipass == (lastPassPlus1-1)) && use_last; boolean last = (ipass == (lastPassPlus1-1)) && use_last;
double [] mdisp_lma_arr = pass.disparity_map[ImageDtt.DISPARITY_INDEX_POLY]; double [] mdisp_lma_arr = pass.disparity_map[ImageDtt.DISPARITY_INDEX_POLY];
boolean m_lma = (mdisp_lma_arr != null) && !Double.isNaN(mdisp_lma_arr[nt]); boolean m_lma = (mdisp_lma_arr != null) && !Double.isNaN(mdisp_lma_arr[nt]);
...@@ -1299,8 +1306,11 @@ public class TileProcessor { ...@@ -1299,8 +1306,11 @@ public class TileProcessor {
// should not, but may happen that closer measurement will not result in LMA while some other (stray?) did // should not, but may happen that closer measurement will not result in LMA while some other (stray?) did
continue; continue;
} }
boolean first_lma = !use_lma && m_lma; boolean first_lma = m_lma && (!use_lma || (clust_radius < best_lma));
use_lma = m_lma; if (first_lma) {
use_lma = true;
// best_lma = clust_radius;
}
double mdisp = m_lma? double mdisp = m_lma?
mdisp_lma_arr[nt] : pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM][nt]; mdisp_lma_arr[nt] : pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM][nt];
double corr_magic = m_lma ? corr_magic_scale_lma : corr_magic_scale; double corr_magic = m_lma ? corr_magic_scale_lma : corr_magic_scale;
...@@ -1325,11 +1335,11 @@ public class TileProcessor { ...@@ -1325,11 +1335,11 @@ public class TileProcessor {
// if ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) { // if ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) {
if ((disp >= disp_far) && (disp <= disp_near) && !Double.isNaN(adiff)){ if ((disp >= disp_far) && (disp <= disp_near) && !Double.isNaN(adiff)){
if (m_lma || (strength >= minStrength)) { if (m_lma || (strength >= minStrength)) {
if (first_lma || !(adiff >= adiff_best)){ // adiff_best == Double.NaN works too if (first_lma || ((!use_lma || (best_lma == clust_radius)) && !(adiff >= adiff_best))){ // adiff_best == Double.NaN works too
adiff_best = adiff; adiff_best = adiff;
best_index = ipass; best_index = ipass;
} }
full_list.add(new DSD(ipass, disp, strength, adiff, m_lma)); full_list.add(new DSD(ipass, disp, strength, adiff, m_lma, clust_radius));
} else { } else {
if ((last && (strength > 0.0)) || (!no_weak && (strength > strongest_weak))){ if ((last && (strength > 0.0)) || (!no_weak && (strength > strongest_weak))){
strongest_weak = strength; // definitely not LMA strongest_weak = strength; // definitely not LMA
...@@ -1348,7 +1358,7 @@ public class TileProcessor { ...@@ -1348,7 +1358,7 @@ public class TileProcessor {
adiff_best_hor = adiff_hor; adiff_best_hor = adiff_hor;
best_index_hor = ipass; best_index_hor = ipass;
} }
hor_list.add(new DSD(ipass, disp_hor, strength_hor, adiff_hor, false)); // hor_lma not yet defined hor_list.add(new DSD(ipass, disp_hor, strength_hor, adiff_hor, false, 0)); // hor_lma not yet defined
} else { } else {
if ((last && (strength_hor > 0.0)) || (!no_weak && (strength_hor > strongest_weak_hor))){ if ((last && (strength_hor > 0.0)) || (!no_weak && (strength_hor > strongest_weak_hor))){
strongest_weak_hor = strength_hor; strongest_weak_hor = strength_hor;
...@@ -1366,7 +1376,7 @@ public class TileProcessor { ...@@ -1366,7 +1376,7 @@ public class TileProcessor {
adiff_best_vert = adiff_vert; adiff_best_vert = adiff_vert;
best_index_vert = ipass; best_index_vert = ipass;
} }
vert_list.add(new DSD(ipass, disp_vert, strength_vert, adiff_vert, false)); // vert_lma not yet defined vert_list.add(new DSD(ipass, disp_vert, strength_vert, adiff_vert, false, 0)); // vert_lma not yet defined
} else { } else {
if ((last && (strength_vert > 0.0)) || (!no_weak && (strength_vert > strongest_weak_vert))){ if ((last && (strength_vert > 0.0)) || (!no_weak && (strength_vert > strongest_weak_vert))){
strongest_weak_vert = strength_vert; strongest_weak_vert = strength_vert;
...@@ -1539,6 +1549,7 @@ ImageDtt.startAndJoin(threads); ...@@ -1539,6 +1549,7 @@ ImageDtt.startAndJoin(threads);
final ArrayList <CLTPass3d> passes, final ArrayList <CLTPass3d> passes,
final int firstPass, final int firstPass,
final int lastPassPlus1, final int lastPassPlus1,
final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
final double disp_avg_arange, // average neighbors with disparity not more than that from the lowest final double disp_avg_arange, // average neighbors with disparity not more than that from the lowest
final double disp_avg_rrange, // same, relative to disparity final double disp_avg_rrange, // same, relative to disparity
final double disp_arange, // look for a fit within range from the neighbor final double disp_arange, // look for a fit within range from the neighbor
...@@ -1603,6 +1614,7 @@ ImageDtt.startAndJoin(threads); ...@@ -1603,6 +1614,7 @@ ImageDtt.startAndJoin(threads);
if (num_neibs >= min_defined) { if (num_neibs >= min_defined) {
//min_defined //min_defined
double avg_lma = swd/sw; double avg_lma = swd/sw;
sw /= num_neibs;
// Now find "best fit": smallest residual within range // Now find "best fit": smallest residual within range
double drange = Math.max(disp_arange, disp_rrange * avg_lma); double drange = Math.max(disp_arange, disp_rrange * avg_lma);
int best_index = -1; int best_index = -1;
...@@ -1641,6 +1653,10 @@ ImageDtt.startAndJoin(threads); ...@@ -1641,6 +1653,10 @@ ImageDtt.startAndJoin(threads);
} }
combo_pass.calc_disparity[nt] = pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM][nt]/corr_magic_scale + pass.disparity[ty][tx]; combo_pass.calc_disparity[nt] = pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM][nt]/corr_magic_scale + pass.disparity[ty][tx];
combo_pass.strength[nt] = pass.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][nt]; combo_pass.strength[nt] = pass.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][nt];
} else if (degrade_no_data >= 0) {
added_defined[nt] = true;
combo_pass.calc_disparity[nt] = avg_lma;
combo_pass.strength[nt] = sw * degrade_no_data;
} }
} }
} }
...@@ -1659,7 +1675,119 @@ ImageDtt.startAndJoin(threads); ...@@ -1659,7 +1675,119 @@ ImageDtt.startAndJoin(threads);
return num_new; // combo_pass_list; return num_new; // combo_pass_list;
} }
public int expandCertainMulti (
CLTPass3d combo_pass, // modify
ArrayList <CLTPass3d> passes,
int firstPass,
int lastPassPlus1,
double disp_avg_arange1, // average neighbors with disparity not more than that from the lowest
double disp_avg_rrange1, // same, relative to disparity
double disp_avg_arange2, // average neighbors with disparity not more than that from the lowest
double disp_avg_rrange2, // same, relative to disparity
double disp_arange, // look for a fit within range from the neighbor
double disp_rrange, // same, relative to disparity
String title_prefix,
int debugLevel) // 1 - show results 2 - show stages 3 - show all
{
int num_new = 0;
if (title_prefix == null) {
title_prefix = "";
}
combo_pass.setSelected(combo_pass.getLMA().clone()); // store original LMA
if (debugLevel > 0) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"before_expandCertainMulti-"+passes.size());
for (int nexpand = 0; nexpand < 100; nexpand++) { // will break
int num_added = expandCertain (
combo_pass, // final CLTPass3d combo_pass, // modify
passes, // final ArrayList <CLTPass3d> passes,
firstPass, // final int firstPass,
passes.size(), // final int lastPassPlus1,
-1.0, // final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
disp_avg_arange1, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
disp_avg_rrange1, // final int disp_avg_rrange, // same, relative to disparity
disp_arange, // final int disp_arange, // look for a fit within range from the neighbor
disp_rrange, // final int disp_rrange, // same, relative to disparity
2, // final int min_defined, // minimal number of defined neighbors that fit into the range
getTrustedCorrelation(), // final double trustedCorrelation,
getMaxOverexposure(), // final double max_overexposure,
-1); // debugLevel); // final int debugLevel)
if (num_added==0) {
break;
}
num_new += num_added;
if (debugLevel > 2) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"expanded1-"+nexpand+"-added-"+num_added);
}
if (debugLevel > 1) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"after_expandedCertain1-"+passes.size());
for (int nexpand = 0; nexpand < 50; nexpand++) {
int num_added = expandCertain (
combo_pass, // final CLTPass3d combo_pass, // modify
passes, // final ArrayList <CLTPass3d> passes,
firstPass, // final int firstPass,
passes.size(), // final int lastPassPlus1,
0.5, // final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
disp_avg_arange2, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
disp_avg_rrange2, // final int disp_avg_rrange, // same, relative to disparity
disp_arange, // final int disp_arange, // look for a fit within range from the neighbor
disp_rrange, // final int disp_rrange, // same, relative to disparity
2, // final int min_defined, // minimal number of defined neighbors that fit into the range
getTrustedCorrelation(), // final double trustedCorrelation,
getMaxOverexposure(), // final double max_overexposure,
-1); // debugLevel); // final int debugLevel)
if (num_added==0) {
break;
}
num_new += num_added;
if (debugLevel > 2) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"expanded2-"+nexpand+"-added-"+num_added);
}
if (debugLevel > 1) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"after_expandedAll1-"+passes.size());
for (int nexpand = 0; nexpand < 50; nexpand++) {
int num_added = expandCertain (
combo_pass, // final CLTPass3d combo_pass, // modify
passes, // final ArrayList <CLTPass3d> passes,
firstPass, // final int firstPass,
passes.size(), // final int lastPassPlus1,
0.5, // final double degrade_no_data, // if >=0 will expand without any measurements, using scaled down strength
disp_avg_arange2, // final int disp_avg_arange, // average neighbors with disparity not more than that from the lowest
disp_avg_rrange2, // final int disp_avg_rrange, // same, relative to disparity
disp_arange, // final int disp_arange, // look for a fit within range from the neighbor
disp_rrange, // final int disp_rrange, // same, relative to disparity
1, // final int min_defined, // minimal number of defined neighbors that fit into the range
getTrustedCorrelation(), // final double trustedCorrelation,
getMaxOverexposure(), // final double max_overexposure,
-1); // debugLevel); // final int debugLevel)
if (num_added==0) {
break;
}
num_new += num_added;
if (debugLevel > 2) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"expanded2-"+nexpand+"-added-"+num_added);
}
if (debugLevel > 1) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"after_expandedAll2-"+passes.size());
combo_pass.setLMA(combo_pass.getSelected()); // restore original LMA
if (debugLevel > 0) showScan(
combo_pass, // CLTPass3d scan,
title_prefix+"after_restoredLMA-"+passes.size());
return num_new;
}
...@@ -2333,6 +2461,7 @@ ImageDtt.startAndJoin(threads); ...@@ -2333,6 +2461,7 @@ ImageDtt.startAndJoin(threads);
final ArrayList <CLTPass3d> passes, final ArrayList <CLTPass3d> passes,
final int firstPass, final int firstPass,
final int lastPassPlus1, final int lastPassPlus1,
final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
final CLTPass3d new_scan, final CLTPass3d new_scan,
final double grow_disp_max, final double grow_disp_max,
final double unique_tolerance, final double unique_tolerance,
...@@ -2354,7 +2483,7 @@ ImageDtt.startAndJoin(threads); ...@@ -2354,7 +2483,7 @@ ImageDtt.startAndJoin(threads);
total ++; total ++;
for (int ipass = firstPass; ipass <lastPassPlus1; ipass++ ){ for (int ipass = firstPass; ipass <lastPassPlus1; ipass++ ){
CLTPass3d pass = passes.get(ipass); CLTPass3d pass = passes.get(ipass);
if ((pass.tile_op[ty][tx] != 0) && pass.isMeasured()){ if ((pass.tile_op[ty][tx] != 0) && pass.isMeasured() && (pass.getClustRadius() == clust_radius)){
// Double.isNaN should not happen // Double.isNaN should not happen
if ( Double.isNaN(pass.disparity[ty][tx]) || if ( Double.isNaN(pass.disparity[ty][tx]) ||
(Math.abs(new_scan.disparity[ty][tx] - pass.disparity[ty][tx]) < unique_tolerance) || (Math.abs(new_scan.disparity[ty][tx] - pass.disparity[ty][tx]) < unique_tolerance) ||
...@@ -2625,6 +2754,7 @@ ImageDtt.startAndJoin(threads); ...@@ -2625,6 +2754,7 @@ ImageDtt.startAndJoin(threads);
passes, // clt_3d_passes, // final ArrayList <CLTPass3d> passes, passes, // clt_3d_passes, // final ArrayList <CLTPass3d> passes,
firstPass, // final int firstPass, firstPass, // final int firstPass,
lastPassPlus1, // clt_3d_passes.size(),// last_scan, // - 1, // final int lastPassPlus1, lastPassPlus1, // clt_3d_passes.size(),// last_scan, // - 1, // final int lastPassPlus1,
0, // final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
scan, //clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan, scan, //clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan,
grow_disp_max, // final double grow_disp_max, grow_disp_max, // final double grow_disp_max,
unique_tolerance, // final double unique_tolerance, unique_tolerance, // final double unique_tolerance,
...@@ -3370,6 +3500,18 @@ ImageDtt.startAndJoin(threads); ...@@ -3370,6 +3500,18 @@ ImageDtt.startAndJoin(threads);
} }
return ds; return ds;
} }
public double [][] getDSLMA(
CLTPass3d scan,
boolean use_final)
{
double [] disparity = scan.getDisparity(use_final?0:1);
double [] disparityLMA = scan.getDisparityLMA();
if (!use_final) {
scan.setStrength(null);
}
double [] strength = scan.getStrength();
return new double [][] {disparity, strength, disparityLMA};
}
// TODO: update for variable length // TODO: update for variable length
public double [][] getShowScan( public double [][] getShowScan(
...@@ -5569,9 +5711,65 @@ ImageDtt.startAndJoin(threads); ...@@ -5569,9 +5711,65 @@ ImageDtt.startAndJoin(threads);
return null; return null;
} }
public CLTPass3d refinePassSetupMulti( // prepare tile tasks for the second pass based on the previous one(s)
CLTPass3d combo_pass,
int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
int shrink_from_defined,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) {
CLTPass3d scan_next =new CLTPass3d(this);
double [] prev_disparity = combo_pass.getDisparity(1); // (0) - calc_disparity_combo - wrong
boolean [] has_lma = combo_pass.getLMA().clone();
if (clust_radius < 1) {
throw new IllegalArgumentException ("refinePassSetupMulti(): clust_radius should be >0, it is "+clust_radius);
}
growTiles(
2 * (shrink_from_defined), // clust_radius - 1), // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
has_lma, // boolean [] tiles,
null); // boolean [] prohibit)
boolean [] need_meas = new boolean [has_lma.length];
for (int i = 0; i < need_meas.length; i++) need_meas[i] = !has_lma[i];
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
has_lma, // boolean [] tiles,
null); // boolean [] prohibit)
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
int op = ImageDtt.setImgMask(0, 0xf);
op = ImageDtt.setPairMask(op,0xf);
op = ImageDtt.setForcedDisparity(op,true);
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx;
if ( need_meas[indx]) {
borderTiles[indx] = has_lma[indx];
disparityTask[ty][tx] = prev_disparity[indx];
tile_op[ty][tx] = op;
} else {
disparityTask[ty][tx] = 0.0;
tile_op[ty][tx] = 0;
borderTiles[indx] = false;
}
}
scan_next.setClustRadius(clust_radius);
scan_next.disparity = disparityTask;
scan_next.tile_op = tile_op;
scan_next.setBorderTiles (borderTiles);
scan_next.setSelected(need_meas); // includes border_tiles
return scan_next;
}
public CLTPass3d refinePassSetup( // prepare tile tasks for the second pass based on the previous one(s) public CLTPass3d refinePassSetup( // prepare tile tasks for the second pass based on the previous one(s)
CLTParameters clt_parameters, CLTParameters clt_parameters,
int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
boolean use_supertiles, // false (2018) boolean use_supertiles, // false (2018)
int bg_scan_index, // 0 int bg_scan_index, // 0
double disparity_far, // 0.3 double disparity_far, // 0.3
......
...@@ -61,20 +61,24 @@ import ij.Prefs; ...@@ -61,20 +61,24 @@ import ij.Prefs;
import ij.io.FileSaver; import ij.io.FileSaver;
public class TwoQuadCLT { public class TwoQuadCLT {
public static int DSI_DISPARITY_MAIN = 0; public static int DSI_DISPARITY_MAIN = 0;
public static int DSI_DISPARITY_AUX = 1; public static int DSI_DISPARITY_MAIN_LMA = 1;
public static int DSI_DISPARITY_RIG = 2; public static int DSI_DISPARITY_AUX = 2;
public static int DSI_DISPARITY_X3D = 3; public static int DSI_DISPARITY_AUX_LMA = 3;
public static int DSI_STRENGTH_MAIN = 4; public static int DSI_DISPARITY_RIG = 4;
public static int DSI_STRENGTH_AUX = 5; public static int DSI_DISPARITY_X3D = 5;
public static int DSI_STRENGTH_RIG = 6; public static int DSI_STRENGTH_MAIN = 6;
public static int DSI_STRENGTH_AUX = 7;
public static int DSI_STRENGTH_RIG = 8;
public static String DSI_COMBO_SUFFIX = "-DSI_COMBO"; public static String DSI_COMBO_SUFFIX = "-DSI_COMBO";
public static String DSI_MAIN_SUFFIX = "-DSI_MAIN"; public static String DSI_MAIN_SUFFIX = "-DSI_MAIN";
public static String [] DSI_SLICES = public static String [] DSI_SLICES =
{ "disparity_main", { "disparity_main",
"disparity_lma_main",
"disparity_aux", "disparity_aux",
"disparity_lma_aux",
"disparity_rig", "disparity_rig",
"disparity_x3d", "disparity_x3d",
"strength_main", "strength_main",
...@@ -3160,8 +3164,14 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3160,8 +3164,14 @@ if (debugLevel > -100) return true; // temporarily !
// String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths(); // String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths();
String set_name = quadCLT_main.image_name; String set_name = quadCLT_main.image_name;
if (set_name == null ) {
set_name = quadCLT_aux.image_name;
}
if (set_name == null ) { if (set_name == null ) {
QuadCLT.SetChannels [] set_channels=quadCLT_main.setChannels(debugLevel); QuadCLT.SetChannels [] set_channels=quadCLT_main.setChannels(debugLevel);
if (set_channels == null) {
set_channels=quadCLT_aux.setChannels(debugLevel);
}
set_name = set_channels[0].set_name; set_name = set_channels[0].set_name;
} }
...@@ -3169,18 +3179,19 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3169,18 +3179,19 @@ if (debugLevel > -100) return true; // temporarily !
QuadCLT.SetChannels [] set_channels_aux = quadCLT_aux.setChannels(set_name,debugLevel); QuadCLT.SetChannels [] set_channels_aux = quadCLT_aux.setChannels(set_name,debugLevel);
ArrayList<String> path_list = new ArrayList<String>(); ArrayList<String> path_list = new ArrayList<String>();
for (int i = 0; i < set_channels_main.length; i++) { if (set_channels_main != null) for (int i = 0; i < set_channels_main.length; i++) {
for (int fn:set_channels_main[i].file_number) { for (int fn:set_channels_main[i].file_number) {
path_list.add(sourceFiles_main[fn]); path_list.add(sourceFiles_main[fn]);
} }
} }
for (int i = 0; i < set_channels_aux.length; i++) { if (set_channels_aux != null) for (int i = 0; i < set_channels_aux.length; i++) {
for (int fn:set_channels_aux[i].file_number) { for (int fn:set_channels_aux[i].file_number) {
path_list.add(sourceFiles_main[fn]); path_list.add(sourceFiles_main[fn]);
} }
} }
if (set_channels_main !=null) {
quadCLT_main.writeKml(debugLevel ); // also generated with x3d model quadCLT_main.writeKml(debugLevel ); // also generated with x3d model
}
String jp4_copy_path= quadCLT_main.correctionsParameters.selectX3dDirectory( String jp4_copy_path= quadCLT_main.correctionsParameters.selectX3dDirectory(
set_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false set_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
...@@ -3193,7 +3204,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3193,7 +3204,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Created "+dir); System.out.println("Created "+dir);
} }
for (String fname:path_list) { for (String fname:path_list) {
if (fname.contains(quadCLT_main.image_name)) { // only files containing set name // TODO:improve if (fname.contains(set_name)) { // only files containing set name // TODO:improve
File file = new File(fname); File file = new File(fname);
try { try {
Files.copy( Files.copy(
...@@ -9099,38 +9110,51 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9099,38 +9110,51 @@ if (debugLevel > -100) return true; // temporarily !
// Reset dsi data (only 2 slices will be used) // Reset dsi data (only 2 slices will be used)
this.dsi = new double [DSI_SLICES.length][]; this.dsi = new double [DSI_SLICES.length][];
this.dsi_aux_from_main = null; // full data, including rms, fg and bg data this.dsi_aux_from_main = null; // full data, including rms, fg and bg data
quadCLT_aux.ds_from_main = null; // this is for adjust6ment only (short) quadCLT_aux.ds_from_main = null; // this is for adjustment only (short)
final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel; final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel;
this.startTime=System.nanoTime(); this.startTime=System.nanoTime();
String [] sourceFiles=quadCLT_main.correctionsParameters.getSourcePaths(); String [] sourceFiles=quadCLT_main.correctionsParameters.getSourcePaths();
QuadCLT.SetChannels [] set_channels_main = quadCLT_main.setChannels(debugLevel); QuadCLT.SetChannels [] set_channels_main = quadCLT_main.setChannels(debugLevel);
QuadCLT.SetChannels [] set_channels_aux = quadCLT_aux.setChannels(debugLevel); QuadCLT.SetChannels [] set_channels_aux = quadCLT_aux.setChannels(debugLevel);
if ((set_channels_main == null) || (set_channels_main.length==0) || (set_channels_aux == null) || (set_channels_aux.length==0)) { QuadCLT.SetChannels [] set_channels = set_channels_main;
if (set_channels == null) {
set_channels = set_channels_aux;
}
// if ((set_channels_main == null) || (set_channels_main.length==0) || (set_channels_aux == null) || (set_channels_aux.length==0)) {
if ((set_channels == null) || (set_channels.length==0)) {
System.out.println("No files to process (of "+sourceFiles.length+")"); System.out.println("No files to process (of "+sourceFiles.length+")");
return; return;
} }
double [] referenceExposures_main = null; double [] referenceExposures_main = null;
double [] referenceExposures_aux = null; double [] referenceExposures_aux = null;
if (!colorProcParameters.lwir_islwir) referenceExposures_main = quadCLT_main.eyesisCorrections.calcReferenceExposures(debugLevel); if (!colorProcParameters.lwir_islwir && !(set_channels_main == null)) {
if (!colorProcParameters_aux.lwir_islwir) referenceExposures_aux = quadCLT_aux.eyesisCorrections.calcReferenceExposures(debugLevel); referenceExposures_main = quadCLT_main.eyesisCorrections.calcReferenceExposures(debugLevel);
for (int nSet = 0; nSet < set_channels_main.length; nSet++){ }
if (!colorProcParameters_aux.lwir_islwir && !(set_channels_aux == null)) {
referenceExposures_aux = quadCLT_aux.eyesisCorrections.calcReferenceExposures(debugLevel);
}
for (int nSet = 0; nSet < set_channels.length; nSet++){
// check it is the same set for both cameras // check it is the same set for both cameras
if (set_channels_aux.length <= nSet ) { /*
if ((set_channels_aux != null) && (set_channels_aux.length <= nSet )) {
throw new Exception ("Set names for cameras do not match: main camera: '"+set_channels_main[nSet].name()+"', aux. camera: nothing"); throw new Exception ("Set names for cameras do not match: main camera: '"+set_channels_main[nSet].name()+"', aux. camera: nothing");
} }
if (!set_channels_main[nSet].name().equals(set_channels_aux[nSet].name())) { if (!set_channels_main[nSet].name().equals(set_channels_aux[nSet].name())) {
throw new Exception ("Set names for cameras do not match: main camera: '"+set_channels_main[nSet].name()+"', aux. camera: '"+set_channels_main[nSet].name()+"'"); throw new Exception ("Set names for cameras do not match: main camera: '"+set_channels_main[nSet].name()+"', aux. camera: '"+set_channels_main[nSet].name()+"'");
} }
*/
int [] channelFiles_main = set_channels_main[nSet].fileNumber(); int [] channelFiles_main = (set_channels_main==null)? null: set_channels_main[nSet].fileNumber();
int [] channelFiles_aux = set_channels_aux[nSet].fileNumber(); int [] channelFiles_aux = (set_channels_aux ==null)? null: set_channels_aux[nSet].fileNumber();
boolean [][] saturation_imp_main = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles_main.length][] : null; boolean [][] saturation_imp_main = ((channelFiles_main != null) && (clt_parameters.sat_level > 0.0))? new boolean[channelFiles_main.length][] : null;
boolean [][] saturation_imp_aux = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles_aux.length][] : null; boolean [][] saturation_imp_aux = ((channelFiles_aux != null) && (clt_parameters.sat_level > 0.0))? new boolean[channelFiles_aux.length][] : null;
double [] scaleExposures_main = new double[channelFiles_main.length]; double [] scaleExposures_main = (channelFiles_main != null) ? (new double[channelFiles_main.length]) : null;
double [] scaleExposures_aux = new double[channelFiles_aux.length]; double [] scaleExposures_aux = (channelFiles_aux != null) ? (new double[channelFiles_aux.length]) : null;
if (updateStatus) IJ.showStatus("Conditioning main camera image set for "+quadCLT_main.image_name); if (updateStatus) IJ.showStatus("Conditioning main camera image set for "+quadCLT_main.image_name);
ImagePlus [] imp_srcs_main = quadCLT_main.conditionImageSet( ImagePlus [] imp_srcs_main = null;
if (set_channels_main != null) {quadCLT_main.conditionImageSet(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters, // colorProcParameters, // ColorProcParameters colorProcParameters, //
sourceFiles, // String [] sourceFiles, sourceFiles, // String [] sourceFiles,
...@@ -9140,7 +9164,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9140,7 +9164,8 @@ if (debugLevel > -100) return true; // temporarily !
scaleExposures_main, //output // double [] scaleExposures scaleExposures_main, //output // double [] scaleExposures
saturation_imp_main, //output // boolean [][] saturation_imp, saturation_imp_main, //output // boolean [][] saturation_imp,
threadsMax, // int threadsMax, threadsMax, // int threadsMax,
debugLevelInner); // int debugLevel); debugLevelInner);
}// int debugLevel);
if (updateStatus) IJ.showStatus("Conditioning aux camera image set for "+quadCLT_main.image_name); if (updateStatus) IJ.showStatus("Conditioning aux camera image set for "+quadCLT_main.image_name);
// optionally adjust main, aux (aux always will use main - calculate if needed // optionally adjust main, aux (aux always will use main - calculate if needed
...@@ -9150,221 +9175,222 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9150,221 +9175,222 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main.correctionsParameters.rig_batch_adjust_main : quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt; quadCLT_main.correctionsParameters.rig_batch_adjust_main : quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt;
int adjust_aux = (quadCLT_main.correctionsParameters.rig_batch_adjust_aux > quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt)? int adjust_aux = (quadCLT_main.correctionsParameters.rig_batch_adjust_aux > quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt)?
quadCLT_main.correctionsParameters.rig_batch_adjust_aux : quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt; quadCLT_main.correctionsParameters.rig_batch_adjust_aux : quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt;
double [][] main_ds = null;
for (int num_adjust_main = 0; num_adjust_main < adjust_main; num_adjust_main++) { if (set_channels_main != null) {
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+ for (int num_adjust_main = 0; num_adjust_main < adjust_main; num_adjust_main++) {
", pass "+(num_adjust_main+1)+" of "+adjust_main); if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
if (debugLevel > -5) {
System.out.println("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
", pass "+(num_adjust_main+1)+" of "+adjust_main); ", pass "+(num_adjust_main+1)+" of "+adjust_main);
} if (debugLevel > -5) {
//Generates background image in model tree - should be done later, after adjustment (It is overwritten later, so OK) System.out.println("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown ", pass "+(num_adjust_main+1)+" of "+adjust_main);
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path" }
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null //Generates background image in model tree - should be done later, after adjustment (It is overwritten later, so OK)
clt_parameters, quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
debayerParameters, imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
colorProcParameters, saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
rgbParameters, clt_parameters,
threadsMax, // maximal number of threads to launch debayerParameters,
updateStatus, colorProcParameters,
debugLevelInner); rgbParameters,
// adjust extrinsics here threadsMax, // maximal number of threads to launch
System.out.println("Adjust main extrinsics here"); updateStatus,
if (updateStatus) IJ.showStatus("Adjusting main camera image set for "+quadCLT_main.image_name+ debugLevelInner);
", pass "+(num_adjust_main+1)+" of "+adjust_main); // adjust extrinsics here
if (debugLevel > -5) { System.out.println("Adjust main extrinsics here");
System.out.println("Adjusting main camera image set for "+quadCLT_main.image_name+ if (updateStatus) IJ.showStatus("Adjusting main camera image set for "+quadCLT_main.image_name+
", pass "+(num_adjust_main+1)+" of "+adjust_main); ", pass "+(num_adjust_main+1)+" of "+adjust_main);
} if (debugLevel > -5) {
if (debugLevel > -1){ System.out.println("Adjusting main camera image set for "+quadCLT_main.image_name+
int scan_index = quadCLT_main.tp.clt_3d_passes.size() -1; ", pass "+(num_adjust_main+1)+" of "+adjust_main);
quadCLT_main.tp.showScan( }
quadCLT_main.tp.clt_3d_passes.get(scan_index), // CLTPass3d scan, if (debugLevel > -1){
"pre-adjust-extrinsic-scan-"+scan_index); //String title) int scan_index = quadCLT_main.tp.clt_3d_passes.size() -1;
for (int s = 0; (s < 5) && (s < scan_index); s++) {
quadCLT_main.tp.showScan( quadCLT_main.tp.showScan(
quadCLT_main.tp.clt_3d_passes.get(s), // CLTPass3d scan, quadCLT_main.tp.clt_3d_passes.get(scan_index), // CLTPass3d scan,
"pre-adjust-extrinsic-scan-"+s); //String title) "pre-adjust-extrinsic-scan-"+scan_index); //String title)
for (int s = 0; (s < 5) && (s < scan_index); s++) {
quadCLT_main.tp.showScan(
quadCLT_main.tp.clt_3d_passes.get(s), // CLTPass3d scan,
"pre-adjust-extrinsic-scan-"+s); //String title)
}
} }
double inf_min = clt_parameters.ly_inf_min_broad; // -0.5;
double inf_max = clt_parameters.ly_inf_max_broad; // 0.5;
if (clt_parameters.ly_inf_force_fine || (num_adjust_main >= (adjust_main/2))) {
inf_min = clt_parameters.ly_inf_min_narrow; // -0.2;
inf_max = clt_parameters.ly_inf_max_narrow; // 0.05;
System.out.println("Late adjustment, using narrow band infinity detection, inf_min="+inf_min+", inf_max="+inf_max);
} else {
System.out.println("Early adjustment, using wide band infinity detection, inf_min="+inf_min+", inf_max="+inf_max);
}
boolean ok = quadCLT_main.extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly,
inf_min, // double inf_min,
inf_max, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
if (!ok) break;
} }
double inf_min = clt_parameters.ly_inf_min_broad; // -0.5; if (quadCLT_main.correctionsParameters.clt_batch_dsi1){
double inf_max = clt_parameters.ly_inf_max_broad; // 0.5; System.out.println("Trying experimental features DSI/ERS");
if (clt_parameters.ly_inf_force_fine || (num_adjust_main >= (adjust_main/2))) { quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
inf_min = clt_parameters.ly_inf_min_narrow; // -0.2; imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
inf_max = clt_parameters.ly_inf_max_narrow; // 0.05; saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
System.out.println("Late adjustment, using narrow band infinity detection, inf_min="+inf_min+", inf_max="+inf_max); clt_parameters,
} else { debayerParameters,
System.out.println("Early adjustment, using wide band infinity detection, inf_min="+inf_min+", inf_max="+inf_max); colorProcParameters,
} rgbParameters,
boolean ok = quadCLT_main.extrinsicsCLT( threadsMax, // maximal number of threads to launch
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, updateStatus,
false, // adjust_poly, debugLevelInner);
inf_min, // double inf_min,
inf_max, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
if (!ok) break;
}
if (quadCLT_main.correctionsParameters.clt_batch_dsi1){
System.out.println("Trying experimental features DSI/ERS");
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
double [][] dsi_ly = quadCLT_main.filterByLY(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.ly_inf_min_narrow, // double inf_min,
clt_parameters.ly_inf_max_narrow, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
dsi[DSI_DISPARITY_MAIN] = dsi_ly[0];
dsi[DSI_STRENGTH_MAIN] = dsi_ly[1];
// if (quadCLT_main.correctionsParameters.clt_batch_dsi) { // Should be always enabled ?
quadCLT_main.saveDSIMain (dsi);
// }
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
// copy regardless of ML generation
// See if it will copy all files, not just the main camera ones
if (clt_parameters.rig.ml_copyJP4) { double [][] dsi_ly = quadCLT_main.filterByLY(
copyJP4src( clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set clt_parameters.ly_inf_min_narrow, // double inf_min,
quadCLT_aux, // QuadCLT quadCLT_aux, clt_parameters.ly_inf_max_narrow, // double inf_max,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, threadsMax, //final int threadsMax, // maximal number of threads to launch
debugLevel); // final int debugLevel) updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
dsi[DSI_DISPARITY_MAIN] = dsi_ly[0];
dsi[DSI_STRENGTH_MAIN] = dsi_ly[1];
// if (quadCLT_main.correctionsParameters.clt_batch_dsi) { // Should be always enabled ?
quadCLT_main.saveDSIMain (dsi);
// }
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
// copy regardless of ML generation
// See if it will copy all files, not just the main camera ones
if (clt_parameters.rig.ml_copyJP4) {
copyJP4src(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // final int debugLevel)
}
}
// Generate 4 main camera images and thumbnail
if (quadCLT_main.correctionsParameters.clt_batch_4img){
if (clt_parameters.gpu_use_main) {
if (updateStatus) IJ.showStatus("GPU: Rendering 4 image set (disparity = 0) for "+quadCLT_main.image_name+ "and a thumb nail");
quadCLT_main.processCLTQuadCorrGPU(
imp_srcs_main, // ImagePlus [] imp_quad,
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters, // CLTParameters clt_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
scaleExposures_main, // double [] scaleExposures, // probably not needed here - restores brightness of the final image
false, // boolean only4slice,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
} else {
if (updateStatus) IJ.showStatus("CPU: Rendering 4 image set (disparity = 0) for "+quadCLT_main.image_name+ "and a thumb nail");
quadCLT_main.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
scaleExposures_main,
false, // calculate and apply additional fine geometry correction
false, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
}
quadCLT_main.tp.resetCLTPasses();
} }
}
// Generate 4 main camera images and thumbnail
if (quadCLT_main.correctionsParameters.clt_batch_4img){
if (clt_parameters.gpu_use_main) {
if (updateStatus) IJ.showStatus("GPU: Rendering 4 image set (disparity = 0) for "+quadCLT_main.image_name+ "and a thumb nail");
quadCLT_main.processCLTQuadCorrGPU(
imp_srcs_main, // ImagePlus [] imp_quad,
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters, // CLTParameters clt_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
scaleExposures_main, // double [] scaleExposures, // probably not needed here - restores brightness of the final image
false, // boolean only4slice,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
} else {
if (updateStatus) IJ.showStatus("CPU: Rendering 4 image set (disparity = 0) for "+quadCLT_main.image_name+ "and a thumb nail");
quadCLT_main.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown
if (quadCLT_main.correctionsParameters.clt_batch_explore) {
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+" (after all adjustments)");
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path" imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
if (updateStatus) IJ.showStatus("Expanding DSI for the main camera image set "+quadCLT_main.image_name+" (after all adjustments)");
quadCLT_main.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters, clt_parameters,
debayerParameters, debayerParameters,
colorProcParameters, colorProcParameters,
channelGainParameters, channelGainParameters,
rgbParameters, rgbParameters,
scaleExposures_main,
false, // calculate and apply additional fine geometry correction
false, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
} double [][] main_last_scan = quadCLT_main.tp.getShowDS(
quadCLT_main.tp.resetCLTPasses(); quadCLT_main.tp.clt_3d_passes.get( quadCLT_main.tp.clt_3d_passes.size() -1),
} false); // boolean force_final);
if (quadCLT_main.correctionsParameters.clt_batch_explore) {
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+" (after all adjustments)");
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
if (updateStatus) IJ.showStatus("Expanding DSI for the main camera image set "+quadCLT_main.image_name+" (after all adjustments)");
quadCLT_main.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters,
debayerParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
double [][] main_last_scan = quadCLT_main.tp.getShowDS(
quadCLT_main.tp.clt_3d_passes.get( quadCLT_main.tp.clt_3d_passes.size() -1),
false); // boolean force_final);
if (debugLevel > -1) { //-5){
int scan_index = quadCLT_main.tp.clt_3d_passes.size() -1;
quadCLT_main.tp.showScan(
quadCLT_main.tp.clt_3d_passes.get(scan_index), // CLTPass3d scan,
"test_pre-after-"+scan_index); //String title)
}
if (debugLevel > -1) { //-5){
int scan_index = quadCLT_main.tp.clt_3d_passes.size() -1;
quadCLT_main.tp.showScan(
quadCLT_main.tp.clt_3d_passes.get(scan_index), // CLTPass3d scan,
"test_pre-after-"+scan_index); //String title)
}
dsi[DSI_DISPARITY_MAIN] = main_last_scan[0];
dsi[DSI_STRENGTH_MAIN] = main_last_scan[1];
if (quadCLT_main.correctionsParameters.clt_batch_dsi) { // Should be always enabled ?
quadCLT_main.saveDSIMain (
dsi);
}
dsi[DSI_DISPARITY_MAIN] = main_last_scan[0];
dsi[DSI_STRENGTH_MAIN] = main_last_scan[1];
if (quadCLT_main.correctionsParameters.clt_batch_dsi) { // Should be always enabled ?
quadCLT_main.saveDSIMain (
dsi);
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (quadCLT_main.correctionsParameters.clt_batch_surf) { Runtime.getRuntime().gc();
if (updateStatus) IJ.showStatus("Creating and filtering supertile plane surfaces from the DSI "+quadCLT_main.image_name); System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
quadCLT_main.tp.showPlanes(
clt_parameters,
quadCLT_main.geometryCorrection,
threadsMax,
updateStatus,
debugLevelInner);
if (quadCLT_main.correctionsParameters.clt_batch_assign) { if (quadCLT_main.correctionsParameters.clt_batch_surf) {
if (updateStatus) IJ.showStatus("Assigning tiles to candidate surfaces "+quadCLT_main.image_name); if (updateStatus) IJ.showStatus("Creating and filtering supertile plane surfaces from the DSI "+quadCLT_main.image_name);
// prepare average RGBA for the last scan quadCLT_main.tp.showPlanes(
quadCLT_main.setPassAvgRBGA( // get image from a single pass, return relative path for x3d // USED in lwir
clt_parameters, // CLTParameters clt_parameters,
quadCLT_main.tp.clt_3d_passes.size() - 1, // int scanIndex,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevelInner); // int debugLevel)
double [][] assignments_dbg = quadCLT_main.tp.assignTilesToSurfaces(
clt_parameters, clt_parameters,
quadCLT_main.geometryCorrection, quadCLT_main.geometryCorrection,
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevelInner); debugLevelInner);
if (assignments_dbg == null) continue;
dsi[DSI_DISPARITY_X3D] = assignments_dbg[TileSurface.ASGN_A_DISP];
// TODO use assignments_dbg
// generate ML data if enabled if (quadCLT_main.correctionsParameters.clt_batch_assign) {
/* if (updateStatus) IJ.showStatus("Assigning tiles to candidate surfaces "+quadCLT_main.image_name);
// prepare average RGBA for the last scan
quadCLT_main.setPassAvgRBGA( // get image from a single pass, return relative path for x3d // USED in lwir
clt_parameters, // CLTParameters clt_parameters,
quadCLT_main.tp.clt_3d_passes.size() - 1, // int scanIndex,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevelInner); // int debugLevel)
double [][] assignments_dbg = quadCLT_main.tp.assignTilesToSurfaces(
clt_parameters,
quadCLT_main.geometryCorrection,
threadsMax,
updateStatus,
debugLevelInner);
if (assignments_dbg == null) continue;
dsi[DSI_DISPARITY_X3D] = assignments_dbg[TileSurface.ASGN_A_DISP];
// TODO use assignments_dbg
// generate ML data if enabled
/*
if (quadCLT_main.correctionsParameters.clt_batch_genMl) { // rig.ml_generate) { //clt_batch_genMl if (quadCLT_main.correctionsParameters.clt_batch_genMl) { // rig.ml_generate) { //clt_batch_genMl
outputMLData( outputMLData(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
...@@ -9375,78 +9401,78 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9375,78 +9401,78 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
} }
*/ */
// copy regardless of ML generation // copy regardless of ML generation
// See if it will copy all files, not just the main camera ones // See if it will copy all files, not just the main camera ones
if (clt_parameters.rig.ml_copyJP4) {
copyJP4src(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // final int debugLevel)
}
if (quadCLT_main.correctionsParameters.clt_batch_gen3d) {
if (updateStatus) IJ.showStatus("Generating and exporting 3D scene model "+quadCLT_main.image_name);
boolean ok = quadCLT_main.output3d(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevelInner); // final int debugLevel)
if (!ok) continue;
}
// save assigned disparity also? - with "-DSI_COMBO" suffix
if (quadCLT_main.correctionsParameters.clt_batch_dsi) {
quadCLT_main.saveDSI (
dsi);
}
if (clt_parameters.rig.ml_copyJP4) {
copyJP4src(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // final int debugLevel)
} }
}
} else { // if (quadCLT_main.correctionsParameters.clt_batch_explore) {
int num_restored = 0;
try {
num_restored = quadCLT_main.restoreDSI(DSI_MAIN_SUFFIX, // "-DSI_COMBO", "-DSI_MAIN"
dsi);
} catch (Exception e) {
if (quadCLT_main.correctionsParameters.clt_batch_gen3d) { }
if (updateStatus) IJ.showStatus("Generating and exporting 3D scene model "+quadCLT_main.image_name); if (num_restored < 2) {
boolean ok = quadCLT_main.output3d( System.out.println("No DSI from the main camera is available. Please re-run with 'clt_batch_explore' enabled to generate it");
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, if (quadCLT_main.correctionsParameters.clt_batch_save_extrinsics) {
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters, saveProperties(
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters, null, // String path, // full name with extension or w/o path to use x3d directory
threadsMax, // final int threadsMax, // maximal number of threads to launch null, // Properties properties, // if null - will only save extrinsics)
updateStatus, // final boolean updateStatus, debugLevel);
debugLevelInner); // final int debugLevel)
if (!ok) continue; quadCLT_main.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory
// null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
} }
// save assigned disparity also? - with "-DSI_COMBO" suffix
if (quadCLT_main.correctionsParameters.clt_batch_dsi) {
quadCLT_main.saveDSI (
dsi); if (quadCLT_main.correctionsParameters.clt_batch_save_all) {
saveProperties(
null, // String path, // full name with extension or w/o path to use x3d directory
properties, // Properties properties, // if null - will only save extrinsics)
debugLevel);
} }
/// continue; // skipping to the next file
} }
} }
} else { // if (quadCLT_main.correctionsParameters.clt_batch_explore) {
int num_restored = 0;
try {
num_restored = quadCLT_main.restoreDSI(DSI_MAIN_SUFFIX, // "-DSI_COMBO", "-DSI_MAIN"
dsi);
} catch (Exception e) {
}
if (num_restored < 2) {
System.out.println("No DSI from the main camera is available. Please re-run with 'clt_batch_explore' enabled to generate it");
if (quadCLT_main.correctionsParameters.clt_batch_save_extrinsics) {
saveProperties(
null, // String path, // full name with extension or w/o path to use x3d directory
null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
quadCLT_main.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory
// null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_save_all) {
saveProperties(
null, // String path, // full name with extension or w/o path to use x3d directory
properties, // Properties properties, // if null - will only save extrinsics)
debugLevel);
}
/// continue; // skipping to the next file
}
}
// Process AUX (LWIR) camera data
// 1) Prepare DS for adjustments (just d/s, with ambiguous disparity tiles removed)
// 2) Prepare full D/S and FG/BG data to be embedded within the ML files
double [][] main_ds = {dsi[DSI_DISPARITY_MAIN], dsi[DSI_STRENGTH_MAIN]}; // {null, null}
// Process AUX (LWIR) camera data
// 1) Prepare DS for adjustments (just d/s, with ambiguous disparity tiles removed)
// 2) Prepare full D/S and FG/BG data to be embedded within the ML files
main_ds = new double[][] {dsi[DSI_DISPARITY_MAIN], dsi[DSI_STRENGTH_MAIN]}; // {null, null}
}
if ((adjust_aux == 0) && if ((adjust_aux == 0) &&
!quadCLT_main.correctionsParameters.clt_batch_4img_aux && !quadCLT_main.correctionsParameters.clt_batch_4img_aux &&
!quadCLT_main.correctionsParameters.clt_batch_dsi_aux && !quadCLT_main.correctionsParameters.clt_batch_dsi_aux &&
...@@ -9456,7 +9482,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9456,7 +9482,7 @@ if (debugLevel > -100) return true; // temporarily !
continue; continue;
} }
if (main_ds[0] != null) { if ((main_ds != null) && (main_ds[0] != null)) {
quadCLT_aux.ds_from_main = quadCLT_aux.depthMapMainToAux( // only 2 layers for adjustments quadCLT_aux.ds_from_main = quadCLT_aux.depthMapMainToAux( // only 2 layers for adjustments
main_ds, // double [][] ds, main_ds, // double [][] ds,
quadCLT_main.getGeometryCorrection(), // GeometryCorrection geometryCorrection_main, quadCLT_main.getGeometryCorrection(), // GeometryCorrection geometryCorrection_main,
...@@ -9476,142 +9502,162 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9476,142 +9502,162 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel); // int debug_level debugLevel); // int debug_level
} }
ImagePlus [] imp_srcs_aux = quadCLT_aux.conditionImageSet( ImagePlus [] imp_srcs_aux = null;
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, if (set_channels_aux != null) {
colorProcParameters_aux, // ColorProcParameters colorProcParameters, // imp_srcs_aux = quadCLT_aux.conditionImageSet(
sourceFiles, // String [] sourceFiles, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
set_channels_aux[nSet].name(), // String set_name, colorProcParameters_aux, // ColorProcParameters colorProcParameters, //
referenceExposures_aux, // double [] referenceExposures, sourceFiles, // String [] sourceFiles,
channelFiles_aux, // int [] channelFiles, set_channels_aux[nSet].name(), // String set_name,
scaleExposures_aux, //output // double [] scaleExposures referenceExposures_aux, // double [] referenceExposures,
saturation_imp_aux, //output // boolean [][] saturation_imp, channelFiles_aux, // int [] channelFiles,
threadsMax, // int threadsMax, scaleExposures_aux, //output // double [] scaleExposures
debugLevelInner); // int debugLevel); saturation_imp_aux, //output // boolean [][] saturation_imp,
// optionally adjust AUX extrinsics (using quadCLT_aux.ds_from_main ) threadsMax, // int threadsMax,
for (int num_adjust_aux = 0; num_adjust_aux < adjust_aux; num_adjust_aux++) { debugLevelInner); // int debugLevel);
if (updateStatus) IJ.showStatus("Building basic DSI for the AUX camera image set "+quadCLT_main.image_name+ // optionally adjust AUX extrinsics (using quadCLT_aux.ds_from_main )
" using main camera DSI, pass "+(num_adjust_aux+1)+" of "+adjust_aux); for (int num_adjust_aux = 0; num_adjust_aux < adjust_aux; num_adjust_aux++) {
if (debugLevel > -5) { if (updateStatus) IJ.showStatus("Building basic DSI for the AUX camera image set "+quadCLT_main.image_name+
System.out.println("Building basic DSI for the AUX camera image set "+quadCLT_main.image_name+
" using main camera DSI, pass "+(num_adjust_aux+1)+" of "+adjust_aux); " using main camera DSI, pass "+(num_adjust_aux+1)+" of "+adjust_aux);
if (debugLevel > -5) {
System.out.println("Building basic DSI for the AUX camera image set "+quadCLT_main.image_name+
" using main camera DSI, pass "+(num_adjust_aux+1)+" of "+adjust_aux);
}
String dbg_path = clt_parameters.lym_dbg_path; // /home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif
if (dbg_path.length()==0) {
dbg_path = null;
}
// dbg_path = "/home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif";
if (dbg_path == null) {
quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters_aux,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
// adjust extrinsics here
System.out.println("Adjust AUX extrinsics here");
if (updateStatus) IJ.showStatus("Adjusting AUX camera image set for "+quadCLT_aux.image_name+
", pass "+(num_adjust_aux+1)+" of "+adjust_aux);
if (debugLevel > -5) {
System.out.println("Adjusting AUX camera image set for "+quadCLT_aux.image_name+
", pass "+(num_adjust_aux+1)+" of "+adjust_aux);
}
}
if (quadCLT_aux.ds_from_main == null) {
System.out.println("BUG: quadCLT_aux.ds_from_main should be not null here!");
double inf_min = -1.0;
double inf_max = 1.0;
if (num_adjust_aux >= (adjust_aux/2)) {
inf_min = -0.2;
inf_max = 0.2; // 0.05; Changed for LWIR16
}
// adjust w/o main camera - maybe will be used in the future
boolean ok = quadCLT_aux.extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
dbg_path,
false, // adjust_poly,
inf_min, // double inf_min,
inf_max, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // 1); // final int debugLevel)
if (!ok) break;
} else {
boolean ok = quadCLT_aux.extrinsicsCLTfromGT(
null,
quadCLT_aux.ds_from_main, // gt_disp_strength,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel + 2); // final int debugLevel)
if (!ok) break;
}
// clear memory for AUX
quadCLT_aux.tp.resetCLTPasses();
} }
String dbg_path = clt_parameters.lym_dbg_path; // /home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif // Generate 4 AUX camera images and thumbnail
if (dbg_path.length()==0) { if (quadCLT_main.correctionsParameters.clt_batch_4img_aux){
dbg_path = null; if (updateStatus) IJ.showStatus("Rendering 4 AUX image set (disparity = 0) for "+quadCLT_aux.image_name);
}
// dbg_path = "/home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif";
if (dbg_path == null) {
quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters_aux,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
// adjust extrinsics here
System.out.println("Adjust AUX extrinsics here");
if (updateStatus) IJ.showStatus("Adjusting AUX camera image set for "+quadCLT_aux.image_name+
", pass "+(num_adjust_aux+1)+" of "+adjust_aux);
if (debugLevel > -5) {
System.out.println("Adjusting AUX camera image set for "+quadCLT_aux.image_name+
", pass "+(num_adjust_aux+1)+" of "+adjust_aux);
}
}
if (quadCLT_aux.ds_from_main == null) {
System.out.println("BUG: quadCLT_aux.ds_from_main should be not null here!");
double inf_min = -1.0;
double inf_max = 1.0;
if (num_adjust_aux >= (adjust_aux/2)) {
inf_min = -0.2;
inf_max = 0.2; // 0.05; Changed for LWIR16
}
// adjust w/o main camera - maybe will be used in the future
boolean ok = quadCLT_aux.extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
dbg_path,
false, // adjust_poly,
inf_min, // double inf_min,
inf_max, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // 1); // final int debugLevel)
if (!ok) break;
} else {
boolean ok = quadCLT_aux.extrinsicsCLTfromGT(
null,
quadCLT_aux.ds_from_main, // gt_disp_strength,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel + 2); // final int debugLevel)
if (!ok) break;
}
// clear memory for AUX
quadCLT_aux.tp.resetCLTPasses();
}
// Generate 4 AUX camera images and thumbnail
if (quadCLT_main.correctionsParameters.clt_batch_4img_aux){
if (updateStatus) IJ.showStatus("Rendering 4 AUX image set (disparity = 0) for "+quadCLT_aux.image_name);
quadCLT_aux.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown quadCLT_aux.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path" imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters, clt_parameters,
debayerParameters, debayerParameters,
colorProcParameters_aux, colorProcParameters_aux,
channelGainParameters, channelGainParameters,
rgbParameters, rgbParameters,
scaleExposures_aux, scaleExposures_aux,
false, // calculate and apply additional fine geometry correction false, // calculate and apply additional fine geometry correction
false, // calculate and apply geometry correction at infinity false, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
quadCLT_aux.tp.resetCLTPasses(); quadCLT_aux.tp.resetCLTPasses();
} }
// Currently - no LWIR 3D model generation, maybe it will be added later // Currently - no LWIR 3D model generation, maybe it will be added later
// Generate AUX DS // Generate AUX DS
if (quadCLT_main.correctionsParameters.clt_batch_dsi_aux) { if (quadCLT_main.correctionsParameters.clt_batch_dsi_aux) {
if (updateStatus) IJ.showStatus("Building basic DSI for the aux camera image set "+quadCLT_main.image_name+" (for DSI export)"); if (updateStatus) IJ.showStatus("Building basic DSI for the aux camera image set "+quadCLT_main.image_name+" (for DSI export)");
quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path" imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters, clt_parameters,
debayerParameters, debayerParameters,
colorProcParameters_aux, colorProcParameters_aux,
rgbParameters, rgbParameters,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevelInner); debugLevelInner);
if (updateStatus) IJ.showStatus("Expanding DSI for the aux camera image set "+quadCLT_main.image_name+" (for DSI export)"); if (quadCLT_main.correctionsParameters.clt_batch_dsi_aux_full) {
quadCLT_aux.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown if (updateStatus) IJ.showStatus("Expanding DSI for the aux camera image set "+quadCLT_main.image_name+" (for DSI export)");
clt_parameters, quadCLT_aux.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
debayerParameters, clt_parameters,
colorProcParameters_aux, debayerParameters,
channelGainParameters, colorProcParameters_aux,
rgbParameters, channelGainParameters,
threadsMax, // maximal number of threads to launch rgbParameters,
updateStatus, threadsMax, // maximal number of threads to launch
debugLevel); updateStatus,
double [][] aux_last_scan = quadCLT_aux.tp.getShowDS( debugLevel);
quadCLT_aux.tp.clt_3d_passes.get( quadCLT_aux.tp.clt_3d_passes.size() -1), }
false); // boolean force_final); // double [][] aux_last_scan = quadCLT_aux.tp.getShowDS(
// quadCLT_aux.tp.clt_3d_passes.get( quadCLT_aux.tp.clt_3d_passes.size() -1),
// false); // boolean force_final);
double [][] aux_last_scan = quadCLT_aux.tp.getDSLMA(
quadCLT_aux.tp.clt_3d_passes.get( quadCLT_aux.tp.clt_3d_passes.size() -1),
false); // boolean force_final);
dsi[DSI_DISPARITY_AUX] = aux_last_scan[0];
dsi[DSI_STRENGTH_AUX] = aux_last_scan[1];
dsi[DSI_DISPARITY_AUX_LMA] = aux_last_scan[2];
// quadCLT_main.saveDSIMain (dsi);
quadCLT_aux.saveDSIAll (dsi);
if (clt_parameters.rig.ml_copyJP4) {
copyJP4src(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // final int debugLevel)
}
if (dsi_aux_from_main != null) {
dsi_aux_from_main[QuadCLT.FGBG_AUX_DISP] = aux_last_scan[0];
dsi_aux_from_main[QuadCLT.FGBG_AUX_STR] = aux_last_scan[1];
// dsi[DSI_DISPARITY_AUX] = aux_last_scan[0]; // incompatible dimensions quadCLT_aux.saveDSIGTAux( // GT from main and AUX DS
// dsi[DSI_STRENGTH_AUX] = aux_last_scan[1]; // incompatible dimensions quadCLT_aux,
dsi_aux_from_main[QuadCLT.FGBG_AUX_DISP] = aux_last_scan[0]; dsi_aux_from_main);
dsi_aux_from_main[QuadCLT.FGBG_AUX_STR] = aux_last_scan[1]; }
quadCLT_main.saveDSIGTAux( // GT from main and AUX DS quadCLT_aux.tp.resetCLTPasses();
quadCLT_aux, }
dsi_aux_from_main); //
quadCLT_aux.tp.resetCLTPasses();
} }
//
// TODO: Add new ML generation here // TODO: Add new ML generation here
if (quadCLT_main.correctionsParameters.clt_batch_genMl) { // rig.ml_generate) { //clt_batch_genMl if (quadCLT_main.correctionsParameters.clt_batch_genMl) { // rig.ml_generate) { //clt_batch_genMl
outputMLDataLwir( outputMLDataLwir(
...@@ -9654,7 +9700,11 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9654,7 +9700,11 @@ if (debugLevel > -100) return true; // temporarily !
return; return;
} }
} }
System.out.println("batchLwirRig(): processing "+(quadCLT_main.getTotalFiles(set_channels_main)+quadCLT_aux.getTotalFiles(set_channels_aux))+" files ("+set_channels_main.length+" file sets) finished at "+ // System.out.println("batchLwirRig(): processing "+(quadCLT_main.getTotalFiles(set_channels_main)+quadCLT_aux.getTotalFiles(set_channels_aux))+" files ("+set_channels_main.length+" file sets) finished at "+
int num_main = (quadCLT_main==null)? 0 : quadCLT_main.getTotalFiles(set_channels_main);
int num_aux = (quadCLT_aux ==null)? 0 : quadCLT_aux.getTotalFiles(set_channels_aux);
System.out.println("batchLwirRig(): processing "+(num_main + num_aux)+" files ("+set_channels.length+" file sets) finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
...@@ -10088,7 +10138,11 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -10088,7 +10138,11 @@ if (debugLevel > -100) return true; // temporarily !
{ {
// update properties from potentially modified parameters (others should be updated // update properties from potentially modified parameters (others should be updated
if (path == null) { if (path == null) {
path = quadCLT_main.image_name + ((properties == null) ? "-EXTRINSICS":"")+".corr-xml"; if (quadCLT_main.image_name != null) {
path = quadCLT_main.image_name + ((properties == null) ? "-EXTRINSICS":"")+".corr-xml";
} else if (quadCLT_aux.image_name != null) {
path = quadCLT_aux.image_name + ((properties == null) ? "-EXTRINSICS":"")+".corr-xml";
}
} }
if (!path.contains(Prefs.getFileSeparator())) { if (!path.contains(Prefs.getFileSeparator())) {
......
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