Commit 770a8d96 authored by Andrey Filippov's avatar Andrey Filippov

batch mode for multiple image sets

parent f5a43005
......@@ -110,6 +110,19 @@ public class EyesisCorrectionParameters {
public String cltKernelDirectory="";
public String cltKernelPrefix="clt-";
public String cltSuffix=".clt-tiff";
public boolean use_x3d_subdirs = true;
// CLT 3d batch parameters
public boolean clt_batch_4img = true; // Create a set of 4 images, usually for disparity = 0
public boolean clt_batch_extrinsic = false; // Calibrate extrinsic parameters for each set
public boolean clt_batch_poly = false; // Calculate fine polynomial correction for each set
public boolean clt_batch_explore = true; // 1-st step of 3d reconstruction - explore disparities for each tile
public boolean clt_batch_surf = true; // Create super-tile 2.5d surfaces
public boolean clt_batch_assign = true; // Assign tiles to surfaces
public boolean clt_batch_gen3d = true; // Generate 3d output: x3d and/or obj+mtl
public String x3dDirectory="";
......@@ -200,7 +213,15 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"cltSuffix", this.cltSuffix);
properties.setProperty(prefix+"x3dDirectory", this.x3dDirectory);
properties.setProperty(prefix+"use_x3d_subdirs", this.use_x3d_subdirs+"");
properties.setProperty(prefix+"clt_batch_4img", this.clt_batch_4img+"");
properties.setProperty(prefix+"clt_batch_extrinsic", this.clt_batch_extrinsic+"");
properties.setProperty(prefix+"clt_batch_poly", this.clt_batch_poly+"");
properties.setProperty(prefix+"clt_batch_explore", this.clt_batch_explore+"");
properties.setProperty(prefix+"clt_batch_surf", this.clt_batch_surf+"");
properties.setProperty(prefix+"clt_batch_assign", this.clt_batch_assign+"");
properties.setProperty(prefix+"clt_batch_gen3d", this.clt_batch_gen3d+"");
}
public void getProperties(String prefix,Properties properties){
......@@ -294,6 +315,15 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"x3dDirectory")!= null) this.x3dDirectory=properties.getProperty(prefix+"x3dDirectory");
if (properties.getProperty(prefix+"use_x3d_subdirs")!= null) this.use_x3d_subdirs=Boolean.parseBoolean((String) properties.getProperty(prefix+"use_x3d_subdirs"));
if (properties.getProperty(prefix+"clt_batch_4img")!= null) this.clt_batch_4img=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_4img"));
if (properties.getProperty(prefix+"clt_batch_extrinsic")!= null) this.clt_batch_extrinsic=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_extrinsic"));
if (properties.getProperty(prefix+"clt_batch_poly")!= null) this.clt_batch_poly=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_poly"));
if (properties.getProperty(prefix+"clt_batch_explore")!= null) this.clt_batch_explore=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_explore"));
if (properties.getProperty(prefix+"clt_batch_surf")!= null) this.clt_batch_surf=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_surf"));
if (properties.getProperty(prefix+"clt_batch_assign")!= null) this.clt_batch_assign=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_assign"));
if (properties.getProperty(prefix+"clt_batch_gen3d")!= null) this.clt_batch_gen3d=Boolean.parseBoolean((String) properties.getProperty(prefix+"clt_batch_gen3d"));
}
public boolean showDialog(String title) {
......@@ -365,6 +395,7 @@ public class EyesisCorrectionParameters {
gd.addStringField ("x3d output directory", this.x3dDirectory, 60);
gd.addCheckbox ("Select x3d output directory", false);
gd.addCheckbox ("Use individual subdirectory for each 3d model (timestamp as name)", this.use_x3d_subdirs);
gd.addStringField("Equirectangular maps directory (may be empty)", this.equirectangularDirectory, 60);
gd.addCheckbox("Select equirectangular maps directory", false);
......@@ -450,6 +481,7 @@ public class EyesisCorrectionParameters {
this.dctKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectDCTKernelDirectory(false, true);
this.cltKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true);
this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true);
this.use_x3d_subdirs= gd.getNextBoolean();
this.equirectangularDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectEquirectangularDirectory(false, false);
this.resultsDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true);
this.sourcePrefix= gd.getNextString();
......@@ -488,20 +520,29 @@ public class EyesisCorrectionParameters {
gd.addStringField ("x3d output directory", this.x3dDirectory, 60); // 8
gd.addCheckbox ("Select x3d output directory", false); // 9
gd.addStringField("Results directory", this.resultsDirectory, 60); // 10
gd.addCheckbox("Select results directory", false); // 11
gd.addCheckbox ("Use individual subdirectory for each 3d model (timestamp as name)", this.use_x3d_subdirs); //10
gd.addStringField("Results directory", this.resultsDirectory, 60); // 11
gd.addCheckbox("Select results directory", false); // 12
gd.addStringField("Source files prefix", this.sourcePrefix, 60); // 12
gd.addStringField("Source files suffix", this.sourceSuffix, 60); // 13
gd.addNumericField("First subcamera (in the source filename)", this.firstSubCamera, 0); // 14
gd.addStringField("Source files prefix", this.sourcePrefix, 60); // 13
gd.addStringField("Source files suffix", this.sourceSuffix, 60); // 14
gd.addNumericField("First subcamera (in the source filename)", this.firstSubCamera, 0); // 15
gd.addStringField("Sensor files prefix", this.sensorPrefix, 40); // 15
gd.addStringField("Sensor files suffix", this.sensorSuffix, 40); // 16
gd.addStringField("Sensor files prefix", this.sensorPrefix, 40); // 16
gd.addStringField("Sensor files suffix", this.sensorSuffix, 40); // 17
gd.addStringField("CLT kernel files prefix", this.cltKernelPrefix, 40); // 17
gd.addStringField("CLT symmetical kernel files", this.cltSuffix, 40); // 18
gd.addStringField("CLT kernel files prefix", this.cltKernelPrefix, 40); // 18
gd.addStringField("CLT symmetical kernel files", this.cltSuffix, 40); // 19
gd.addMessage("============ batch parameters ============");
gd.addCheckbox ("Create a set of 4 images, usually for disparity = 0", this.clt_batch_4img); // 20
gd.addCheckbox ("Calibrate extrinsic parameters for each set", this.clt_batch_extrinsic); // 21
gd.addCheckbox ("Calculate fine polynomial correction for each set", this.clt_batch_poly); // 22
gd.addCheckbox ("1-st step of 3d reconstruction - explore disparities for each tile", this.clt_batch_explore); // 23
gd.addCheckbox ("Create super-tile 2.5d surfaces", this.clt_batch_surf); // 24
gd.addCheckbox ("Assign tiles to surfaces", this.clt_batch_assign); // 25
gd.addCheckbox ("Generate 3d output: x3d and/or obj+mtl", this.clt_batch_gen3d); // 26
WindowTools.addScrollBars(gd);
......@@ -516,14 +557,23 @@ public class EyesisCorrectionParameters {
this.sensorDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSensorDirectory(false, false); // 5
this.cltKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true); // 7
this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true); // 9
this.resultsDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true); // 11
this.sourcePrefix= gd.getNextString(); // 12
this.sourceSuffix= gd.getNextString(); // 13
this.firstSubCamera= (int) gd.getNextNumber(); // 14
this.sensorPrefix= gd.getNextString(); // 15
this.sensorSuffix= gd.getNextString(); // 16
this.cltKernelPrefix= gd.getNextString(); // 17
this.cltSuffix= gd.getNextString(); // 18
this.use_x3d_subdirs= gd.getNextBoolean(); // 10
this.resultsDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true); // 12
this.sourcePrefix= gd.getNextString(); // 13
this.sourceSuffix= gd.getNextString(); // 14
this.firstSubCamera= (int) gd.getNextNumber(); // 15
this.sensorPrefix= gd.getNextString(); // 16
this.sensorSuffix= gd.getNextString(); // 17
this.cltKernelPrefix= gd.getNextString(); // 18
this.cltSuffix= gd.getNextString(); // 19
this.clt_batch_4img= gd.getNextBoolean(); // 20
this.clt_batch_extrinsic= gd.getNextBoolean(); // 21
this.clt_batch_poly= gd.getNextBoolean(); // 22
this.clt_batch_explore= gd.getNextBoolean(); // 23
this.clt_batch_surf= gd.getNextBoolean(); // 24
this.clt_batch_assign= gd.getNextBoolean(); // 25
this.clt_batch_gen3d= gd.getNextBoolean(); // 26
return true;
}
......@@ -1061,6 +1111,31 @@ public class EyesisCorrectionParameters {
return dir;
}
// select qualified (by 'name' - quad timestamp) x3d subdirectory
public String selectX3dDirectory(String name, boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"x3d output directory", // title
"Select x3d output directory", // button
null, // filter
this.x3dDirectory); //this.sourceDirectory);
if (dir!=null) {
this.x3dDirectory=dir;
if (this.use_x3d_subdirs &&(name != null) && !name.equals("")) {
dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"x3d output sub-directory", // title
"Select x3d output sub-directory", // button
null, // filter
this.x3dDirectory + Prefs.getFileSeparator()+name); //this.sourceDirectory);
}
}
return dir;
}
public String selectEquirectangularDirectory(boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
......
......@@ -544,7 +544,7 @@ private Panel panel1,
panelClt3.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Setup CLT Batch parameters", panelClt3, color_configure);
addButton("Setup CLT parameters", panelClt3, color_configure);
addButton("CLT Batch process", panelClt3, color_process);
addButton("CLT batch process", panelClt3, color_process);
add(panelClt3);
}
pack();
......@@ -4937,22 +4937,13 @@ private Panel panel1,
return;
}
}
/*
public boolean output3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
*/
boolean OK = QUAD_CLT.output3d(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
RGB_PARAMETERS, // EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, // final boolean updateStatus,
false, // final boolean batch_mode,
DEBUG_LEVEL); //final int debugLevel);
if (!OK) {
String msg="Image data not initialized, run 'CLT 3D' command first";
......@@ -4970,7 +4961,98 @@ private Panel panel1,
}
*/
} else if (label.equals("CLT batch process")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
PROPERTIES,
EYESIS_CORRECTIONS,
CORRECTION_PARAMETERS);
if (DEBUG_LEVEL > 0){
System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
}
}
String configPath=null;
if (EYESIS_CORRECTIONS.correctionsParameters.saveSettings) {
configPath=EYESIS_CORRECTIONS.correctionsParameters.selectResultsDirectory(
true,
true);
if (configPath==null){
String msg="No results directory selected, command aborted";
System.out.println("Warning: "+msg);
IJ.showMessage("Warning",msg);
return;
}
configPath+=Prefs.getFileSeparator()+"autoconfig"+Prefs.getFileSeparator()+"autoconfig";
try {
saveTimestampedProperties(
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
} catch (Exception e){
String msg="Failed to save configuration to "+configPath+", command aborted";
System.out.println("Error: "+msg);
IJ.showMessage("Error",msg);
return;
}
}
EYESIS_CORRECTIONS.initSensorFiles(DEBUG_LEVEL);
int numChannels=EYESIS_CORRECTIONS.getNumChannels();
NONLIN_PARAMETERS.modifyNumChannels(numChannels);
CHANNEL_GAINS_PARAMETERS.modifyNumChannels(numChannels);
if (!QUAD_CLT.CLTKernelsAvailable()){
if (DEBUG_LEVEL > 0){
System.out.println("Reading CLT kernels");
}
QUAD_CLT.readCLTKernels(
CLT_PARAMETERS,
THREADS_MAX,
UPDATE_STATUS, // update status info
DEBUG_LEVEL);
if (DEBUG_LEVEL > 1){
QUAD_CLT.showCLTKernels(
THREADS_MAX,
UPDATE_STATUS, // update status info
DEBUG_LEVEL);
}
}
if (!QUAD_CLT.geometryCorrectionAvailable()){
if (DEBUG_LEVEL > 0){
System.out.println("Calculating geometryCorrection");
}
if (!QUAD_CLT.initGeometryCorrection(DEBUG_LEVEL+2)){
return;
}
}
///========================================
QUAD_CLT.batchCLT3d(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
CONVOLVE_FFT_SIZE, //int convolveFFTSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
return;
......
......@@ -1042,7 +1042,7 @@ public class ImageDtt {
final int corr_size = transform_size * 2 -1;
final int [][] transpose_indices = new int [corr_size*(corr_size-1)/2][2];
int indx = 0;
if (disparity_corr != 0.0){
if ((globalDebugLevel > -1) && (disparity_corr != 0.0)){
System.out.println(String.format("Using manual infinity disparity correction of %8.5f pixels",disparity_corr));
}
for (int i =0; i < corr_size-1; i++){
......
......@@ -45,6 +45,7 @@ public class QuadCLT {
static String [] fine_corr_coeff_names = {"A","B","C","D","E","F"};
static String [] fine_corr_dir_names = {"X","Y"};
static String prefix = "EYESIS_DCT."; // change later (first on save)
static int QUAD = 4; // number of cameras
public Properties properties = null;
public EyesisCorrections eyesisCorrections = null;
public EyesisCorrectionParameters.CorrectionParameters correctionsParameters=null;
......@@ -53,7 +54,10 @@ public class QuadCLT {
double [] extrinsic_corr = new double [GeometryCorrection.CORR_NAMES.length]; // extrinsic corrections (needed from properties, before geometryCorrection
public int extra_items = 8; // number of extra items saved with kernels (center offset (partial, full, derivatives)
public ImagePlus eyesisKernelImage = null;
public long startTime;
public long startTime; // start of batch processing
public long startSetTime; // start of set processing
public long startStepTime; // start of step processing
public double [][][] fine_corr = new double [4][2][6]; // per port, per x/y, set of 6 coefficient for fine geometric corrections
TileProcessor tp = null;
......@@ -1247,7 +1251,7 @@ public class QuadCLT {
return;
}
}
System.out.println("Processing "+fileIndices.length+" files finished at "+
System.out.println("processCLTChannelImages(): Processing "+fileIndices.length+" files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
......@@ -1974,7 +1978,7 @@ public class QuadCLT {
}
}
}
System.out.println("Processing "+fileIndices.length+" files finished at "+
System.out.println("processCLTSets(): processing "+fileIndices.length+" files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
......@@ -2610,7 +2614,7 @@ public class QuadCLT {
return;
}
}
System.out.println("Processing "+fileIndices.length+" files finished at "+
System.out.println("processCLTQuads(): processing "+fileIndices.length+" files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
......@@ -3257,6 +3261,7 @@ public class QuadCLT {
infinity_corr, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
updateStatus,
false, // batch_mode
debugLevel);
Runtime.getRuntime().gc();
if (debugLevel >-1) System.out.println("Processing set "+(nSet+1)+" (of "+fileIndices.length+") finished at "+
......@@ -3268,7 +3273,7 @@ public class QuadCLT {
return;
}
}
System.out.println("Processing "+fileIndices.length+" files ("+setNames.size()+" file sets) finished at "+
System.out.println("processCLTQuadCorrs(): processing "+fileIndices.length+" files ("+setNames.size()+" file sets) finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
public void channelGainsEqualize(
......@@ -3503,6 +3508,7 @@ public class QuadCLT {
final boolean infinity_corr, // calculate and apply geometry correction at infinity
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode, //no debug images
final int debugLevel){
boolean advanced=this.correctionsParameters.zcorrect || this.correctionsParameters.equirectangular;
// boolean crop= advanced? true: this.correctionsParameters.crop;
......@@ -3703,7 +3709,7 @@ public class QuadCLT {
}
}
if (clt_parameters.show_overlap) {
if (!batch_mode && clt_parameters.show_overlap) {
sdfa_instance.showArrays(
texture_overlap,
tilesX * clt_parameters.transform_size,
......@@ -3712,7 +3718,7 @@ public class QuadCLT {
name + "-TXTOL-D"+clt_parameters.disparity,
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
}
if (clt_parameters.show_rgba_color) {
if (!batch_mode && clt_parameters.show_rgba_color) {
// for now - use just RGB. Later add oprion for RGBA
double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]};
double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]};
......@@ -3738,7 +3744,7 @@ public class QuadCLT {
// visualize correlation results
if (clt_corr_combo!=null){
if (disparity_map != null){
if (!infinity_corr && clt_parameters.show_map && (debugLevel > -1)){
if (!batch_mode && !infinity_corr && clt_parameters.show_map && (debugLevel > -1)){
sdfa_instance.showArrays(
disparity_map,
tilesX,
......@@ -3756,7 +3762,7 @@ public class QuadCLT {
disparity_map[ImageDtt.DISPARITY_INDEX_CM],
disparity_map[ ImageDtt.DISPARITY_STRENGTH_INDEX]};
String [] titles = {"disp_cm", "strength"};
if (clt_mismatch != null){
if (!batch_mode && (clt_mismatch != null)){
double [][] inf_ds1 = {
disparity_map[ImageDtt.DISPARITY_INDEX_CM],
disparity_map[ ImageDtt.DISPARITY_STRENGTH_INDEX],
......@@ -3772,10 +3778,10 @@ public class QuadCLT {
inf_ds = inf_ds1;
titles = titles1;
}
if (clt_parameters.inf_repeat <1) {
if (clt_parameters.inf_repeat < 1) {
System.out.println("=== Generating image to be saved and then used for correction with 'CLT ext infinity corr'===");
// This image can be saved and re-read with "CLT ext infinity corr" command
if (sdfa_instance != null){
if (!batch_mode && (sdfa_instance != null)){
sdfa_instance.showArrays(
inf_ds,
tilesX,
......@@ -3787,7 +3793,7 @@ public class QuadCLT {
} else { // calculate/apply coefficients
if (debugLevel + (clt_parameters.fine_dbg ? 1:0) > 0){
// still show image, even as it is not needed
if (sdfa_instance != null){
if (!batch_mode && (sdfa_instance != null)) {
sdfa_instance.showArrays(
inf_ds,
tilesX,
......@@ -3839,14 +3845,11 @@ public class QuadCLT {
new_corr,
debugLevel + 2);
}
}
}
if (!infinity_corr && clt_parameters.corr_show && (debugLevel > -1)){
if (!batch_mode && !infinity_corr && clt_parameters.corr_show && (debugLevel > -1)){
double [][] corr_rslt = new double [clt_corr_combo.length][];
String [] titles = new String[clt_corr_combo.length]; // {"combo","sum"};
for (int i = 0; i< titles.length; i++) titles[i] = ImageDtt.TCORR_TITLES[i];
......@@ -3868,7 +3871,7 @@ public class QuadCLT {
titles );
}
if (!infinity_corr && (clt_corr_partial!=null)){
if (!batch_mode && !infinity_corr && (clt_corr_partial!=null)){
if (debugLevel > -1){ // -1
String [] allColorNames = {"red","blue","green","combo"};
String [] titles = new String[clt_corr_partial.length];
......@@ -3918,7 +3921,7 @@ public class QuadCLT {
System.out.println("--tilesX="+tilesX);
System.out.println("--tilesY="+tilesY);
}
if (debugLevel > 0){
if (!batch_mode && (debugLevel > 0)){
double [][] clt = new double [clt_data[iQuad].length*4][];
for (int chn = 0; chn < clt_data[iQuad].length; chn++) {
double [][] clt_set = image_dtt.clt_dbg(
......@@ -3964,7 +3967,7 @@ public class QuadCLT {
"-D"+clt_parameters.disparity, //String suffix, // such as disparity=...
toRGB,
!this.correctionsParameters.jpeg, // boolean bpp16, // 16-bit per channel color mode for result
true, // boolean saveShowIntermediate, // save/show if set globally
!batch_mode, // true, // boolean saveShowIntermediate, // save/show if set globally
false, // boolean saveShowFinal, // save/show result (color image?)
iclt_data,
tilesX * clt_parameters.transform_size,
......@@ -3973,7 +3976,7 @@ public class QuadCLT {
debugLevel );
} // end of generating shifted channel images
if (clt_parameters.gen_chn_img) {
if (!batch_mode && clt_parameters.gen_chn_img) {
// combine to a sliced color image
int [] slice_seq = {0,1,3,2}; //clockwise
int width = imps_RGB[0].getWidth();
......@@ -3996,6 +3999,7 @@ public class QuadCLT {
if (clt_parameters.gen_4_img) {
// Save as individual JPEG images in the model directory
String x3d_path= correctionsParameters.selectX3dDirectory(
name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
true, // smart,
true); //newAllowed, // save
for (int sub_img = 0; sub_img < 4; sub_img++){
......@@ -4003,7 +4007,7 @@ public class QuadCLT {
imps_RGB[sub_img],
x3d_path,
correctionsParameters.png && !clt_parameters.black_back,
clt_parameters.show_textures,
!batch_mode && clt_parameters.show_textures,
correctionsParameters.JPEG_quality); // jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
}
}
......@@ -4573,7 +4577,7 @@ public class QuadCLT {
return;
}
}
System.out.println("Processing "+fileIndices.length+" files finished at "+
System.out.println("cltDisparityScans(): processing "+fileIndices.length+" files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
......@@ -5097,7 +5101,7 @@ public class QuadCLT {
final boolean updateStatus,
final int debugLevel)
{
this.startTime=System.nanoTime();
this.startStepTime=System.nanoTime();
if (tp == null){
System.out.println("showCLTPlanes(): tp is null");
......@@ -5112,10 +5116,11 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
false, // batch_mode
debugLevel);
Runtime.getRuntime().gc();
System.out.println("Processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
System.out.println("showCLTPlanes(): processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
public boolean assignCLTPlanes(
......@@ -5132,22 +5137,23 @@ public class QuadCLT {
System.out.println("showCLTPlanes(): tp.clt_3d_passes is null");
return false;
}
this.startTime=System.nanoTime();
this.startStepTime=System.nanoTime();
boolean ok = tp.assignTilesToSurfaces(
clt_parameters,
geometryCorrection,
threadsMax,
updateStatus,
false, // boolean batch_mode,
debugLevel);
Runtime.getRuntime().gc();
System.out.println("Processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
System.out.println("assignCLTPlanes(): processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return ok;
}
public void out3d(
public void out3d_old(
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
......@@ -5166,6 +5172,7 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
false, // batch_mode
debugLevel);
// CLTPass3d last_scan = tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1); // get last one
......@@ -5452,6 +5459,7 @@ public class QuadCLT {
adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
false, // final boolean batch_mode,
debugLevel); // final int debugLevel)
......@@ -5466,6 +5474,7 @@ public class QuadCLT {
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
false, // final boolean batch_mode,
debugLevel);
}
......@@ -5495,7 +5504,7 @@ public class QuadCLT {
final boolean updateStatus,
final int debugLevel)
{
this.startTime=System.nanoTime();
this.startStepTime=System.nanoTime();
final boolean show_init_refine = clt_parameters.show_init_refine;
//max_expand
......@@ -5915,8 +5924,8 @@ public class QuadCLT {
///// Refining after all added - end
Runtime.getRuntime().gc();
System.out.println("Processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
System.out.println("preExpandCLTQuad3d(): processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true;
}
......@@ -5927,17 +5936,17 @@ public class QuadCLT {
boolean adjust_poly,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
// final int tilesX = tp.getTilesX();
// final int tilesY = tp.getTilesY();
int debugLevelInner = batch_mode ? -5: debugLevel;
boolean update_disp_from_latest = clt_parameters.lym_update_disp ; // true;
int max_tries = clt_parameters.lym_iter; // 25;
double min_sym_update = clt_parameters.lym_change; // 4e-6; // stop iterations if no angle changes more than this
double min_poly_update = clt_parameters.lym_poly_change; // Parameter vector difference to exit from polynomial correction
int bg_scan = 0;
int combo_scan= tp.clt_3d_passes.size()-1;
if (clt_parameters.show_extrinsic && (debugLevel >-1)) {
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) {
tp.showScan(
tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan,
"bg_scan"); //String title)
......@@ -5968,7 +5977,7 @@ public class QuadCLT {
clt_parameters.fds_rel_tilt, // final double max_rel_tilt, // = 0.2; // (pix / disparity) per tile
clt_parameters.tileX, // dbg_x, // final int dbg_x,
clt_parameters.tileX, // dbg_y, // final int dbg_y,
debugLevel); // final int debugLevel)
debugLevelInner); // final int debugLevel)
// prepare re-measurements of background
boolean [] bg_sel = tp.clt_3d_passes.get(bg_scan).getSelected();
boolean [] bg_use = new boolean [bg_sel.length];
......@@ -6019,8 +6028,8 @@ public class QuadCLT {
null, // final double [][] mismatch, // null or double [12][]
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevel - 1);
if (clt_parameters.show_extrinsic && (debugLevel >-1)) {
debugLevelInner - 1);
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) {
tp.showScan(
tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan,
"bg_scan_post"); //String title)
......@@ -6051,7 +6060,7 @@ public class QuadCLT {
clt_parameters.fds_rel_tilt, // final double max_rel_tilt, // = 0.2; // (pix / disparity) per tile
clt_parameters.tileX, // dbg_x, // final int dbg_x,
clt_parameters.tileX, // dbg_y, // final int dbg_y,
debugLevel); // final int debugLevel)
debugLevelInner); // final int debugLevel)
// update selection after filtering
combo_disp = tp.clt_3d_passes.get(combo_scan).getDisparity(0);
......@@ -6074,7 +6083,7 @@ public class QuadCLT {
System.out.println("Updated number of lazy eye tiles = " + num_combo1+" (was "+num_combo+")");
}
if (clt_parameters.show_extrinsic && (debugLevel >-1)) {
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) {
String [] titles = {"bgnd_disp","bgnd_str","combo_disp","combo_str","bg_sel","bg_use","combo_use"};
double [] dbg_bg_sel = new double [bg_sel.length];
double [] dbg_bg_use = new double [bg_sel.length];
......@@ -6113,7 +6122,7 @@ public class QuadCLT {
bg_mismatch, // final double [][] mismatch, // null or double [12][]
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevel - 1);
debugLevelInner - 1);
CLTMeasure( // perform single pass according to prepared tiles operations and disparity
image_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
......@@ -6124,7 +6133,7 @@ public class QuadCLT {
combo_mismatch, // final double [][] mismatch, // null or double [12][]
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevel - 1);
debugLevelInner - 1);
double [][] scans14 = new double [28][];
scans14[14 * 0 + 0] = tp.clt_3d_passes.get(bg_scan).disparity_map[ImageDtt.DISPARITY_INDEX_CM]; // .getDisparity(0);
scans14[14 * 0 + 1] = tp.clt_3d_passes.get(bg_scan).getStrength();
......@@ -6136,7 +6145,7 @@ public class QuadCLT {
}
// (new showDoubleFloatArrays()).showArrays(scans14, tp.getTilesX(), tp.getTilesY(), true, "scans_14"); // , titles);
if (clt_parameters.show_extrinsic && (debugLevel > 1)) {
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel > 1)) {
tp.showScan(
tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan,
"bg_scan_iter"); //String title)
......@@ -6181,13 +6190,13 @@ public class QuadCLT {
target_disparity, // double [][] target_disparity, // null or programmed disparity (1 per each 14 entries of scans_14)
tp.getTilesX(), // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel - 1); // + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
debugLevelInner - 1); // + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
comp_diff = 0.0;
int num_pars = 0;
if (adjust_poly) {
apply_fine_corr(
new_corr,
debugLevel + 2);
debugLevelInner + 2);
for (int n = 0; n < new_corr.length; n++){
for (int d = 0; d < new_corr[n].length; d++){
for (int i = 0; i < new_corr[n][d].length; i++){
......@@ -6239,8 +6248,11 @@ public class QuadCLT {
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
final int debugLevelInner = batch_mode ? -5: debugLevel;
// final int tilesX = tp.getTilesX();
// final int tilesY = tp.getTilesY();
final double trustedCorrelation = tp.getTrustedCorrelation();
......@@ -6313,7 +6325,7 @@ public class QuadCLT {
max_rel_tilt, // final double max_rel_tilt, // = 0.2; // (pix / disparity) per tile
dbg_x, // final int dbg_x,
dbg_y, // final int dbg_y,
debugLevel); // final int debugLevel)
debugLevelInner); // final int debugLevel)
......@@ -6422,7 +6434,7 @@ public class QuadCLT {
dbg_x,
dbg_y, // final int dbg_y,
debugLevel+1); // final int debugLevel)
debugLevelInner+1); // final int debugLevel)
if (last_pass) {
break;
......@@ -6446,7 +6458,7 @@ public class QuadCLT {
show_expand = (clt_parameters.show_expand && (max_expand <= 10));
if (debugLevel > -1) {
if (debugLevelInner > -1) {
tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size()-2), // CLTPass3d scan,
"after_pre_last_combo_pass-"+(tp.clt_3d_passes.size()-2)); //String title)
......@@ -6477,9 +6489,8 @@ public class QuadCLT {
geometryCorrection,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
batch_mode,
debugLevelInner);
// Save tp.clt_3d_passes.size() to roll back without restarting the program
tp.saveCLTPasses();
......@@ -6926,9 +6937,10 @@ public class QuadCLT {
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
this.startTime=System.nanoTime();
this.startStepTime=System.nanoTime();
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
if (this.image_data == null){
......@@ -6952,12 +6964,13 @@ public class QuadCLT {
threadsMax, // maximal number of threads to launch
updateStatus,
0); // final int debugLevel)
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
"after_pass3-"+(next_pass-1)); //String title)
}
String x3d_path= correctionsParameters.selectX3dDirectory( // for x3d and obj
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
true, // smart,
true); //newAllowed, // save
......@@ -7036,7 +7049,7 @@ public class QuadCLT {
bgndIndex,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
batch_mode ? -5: debugLevel);
double [] scan_disparity = new double [tilesX * tilesY];
int indx = 0;
// boolean [] scan_selected = scan.getSelected();
......@@ -7094,7 +7107,8 @@ public class QuadCLT {
false, // final boolean save_corr,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
batch_mode ? -5: debugLevel);
}
// TEMPORARY EXIT
......@@ -7116,7 +7130,7 @@ public class QuadCLT {
scanIndex,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
batch_mode ? -5: debugLevel);
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
......@@ -7159,7 +7173,7 @@ public class QuadCLT {
}
*/
// boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex < 3);
boolean showTri = (debugLevel > -1) && (((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||((scanIndex - next_pass) == 73));
boolean showTri = !batch_mode && (debugLevel > -1) && (((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||((scanIndex - next_pass) == 73));
// boolean showTri = ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||(scanIndex == 49) || (scanIndex == 54);
try {
......@@ -7199,8 +7213,8 @@ public class QuadCLT {
System.out.println("Wavefront material file saved to "+wfOutput.mtl_path);
}
Runtime.getRuntime().gc();
System.out.println("Generating 3d output files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
System.out.println("output3d(): generating 3d output files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true;
......@@ -7475,6 +7489,9 @@ public class QuadCLT {
clt_parameters.black_back, // boolean noalpha,
debugLevel);
String path= correctionsParameters.selectX3dDirectory(
//TODO: Which one to use - name or this.image_name ?
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
// name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
true, // smart,
true); //newAllowed, // save
// only show/save original size if debug or debug_filters)
......@@ -7620,6 +7637,9 @@ public class QuadCLT {
String path= correctionsParameters.selectX3dDirectory(
//TODO: Which one to use - name or this.image_name ?
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
// name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
true, // smart,
true); //newAllowed, // save
// only show/save original size if debug or debug_filters)
......@@ -8001,5 +8021,509 @@ public class QuadCLT {
}
public ImagePlus [] conditionImageSet(
final int nSet, // index of the 4-image set
final EyesisCorrectionParameters.CLTParameters clt_parameters,
final int [][] fileIndices, // =new int [numImagesToProcess][2]; // file index, channel number
final ArrayList<String> setNames, // = new ArrayList<String>();
final ArrayList<ArrayList<Integer>> setFiles, // = new ArrayList<ArrayList<Integer>>();
final double [] referenceExposures, // =eyesisCorrections.calcReferenceExposures(debugLevel); // multiply each image by this and divide by individual (if not NaN)
final double [] scaleExposures, // = new double[channelFiles.length]; //
final boolean [][] saturation_imp, // = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
final boolean batch_mode, // disable any debug images
final int debugLevel)
{
String [] sourceFiles=correctionsParameters.getSourcePaths();
int maxChn = 0;
for (int i = 0; i < setFiles.get(nSet).size(); i++){
int chn = fileIndices[setFiles.get(nSet).get(i)][1];
if (chn > maxChn) maxChn = chn;
}
int [] channelFiles = new int[maxChn+1];
for (int i =0; i < channelFiles.length; i++) channelFiles[i] = -1;
for (int i = 0; i < setFiles.get(nSet).size(); i++){
channelFiles[fileIndices[setFiles.get(nSet).get(i)][1]] = setFiles.get(nSet).get(i);
}
ImagePlus [] imp_srcs = new ImagePlus[channelFiles.length];
/// boolean [][] saturation_imp = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
/// double [] scaleExposures = new double[channelFiles.length]; //
double [][] dbg_dpixels = batch_mode? null : (new double [channelFiles.length][]);
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
int nFile=channelFiles[srcChannel];
imp_srcs[srcChannel]=null;
if (nFile >=0){
if (correctionsParameters.isJP4()){
int subchannel=eyesisCorrections.pixelMapping.getSubChannel(srcChannel);
if (this.correctionsParameters.swapSubchannels01) {
switch (subchannel){
case 0: subchannel=1; break;
case 1: subchannel=0; break;
}
}
if (debugLevel>0) System.out.println("Processing set " + setNames.get(nSet)+" channel "+srcChannel+" - subchannel "+subchannel+" of "+sourceFiles[nFile]);
ImagePlus imp_composite=eyesisCorrections.JP4_INSTANCE.open(
"", // path,
sourceFiles[nFile],
"", //arg - not used in JP46 reader
true, // un-apply camera color gains
null, // new window
false); // do not show
imp_srcs[srcChannel]=eyesisCorrections.JP4_INSTANCE.demuxImage(imp_composite, subchannel);
if (imp_srcs[srcChannel] == null) imp_srcs[srcChannel] = imp_composite; // not a composite image
// do we need to add any properties?
} else {
imp_srcs[srcChannel]=new ImagePlus(sourceFiles[nFile]);
// (new JP46_Reader_camera(false)).decodeProperiesFromInfo(imp_src); // decode existent properties from info
eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info
if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]);
}
scaleExposures[srcChannel] = 1.0;
if (!Double.isNaN(referenceExposures[nFile]) && (imp_srcs[srcChannel].getProperty("EXPOSURE")!=null)){
scaleExposures[srcChannel] = referenceExposures[nFile]/Double.parseDouble((String) imp_srcs[srcChannel].getProperty("EXPOSURE"));
if (debugLevel > -1) {
System.out.println("Will scale intensity (to compensate for exposure) by "+scaleExposures[srcChannel]+
", EXPOSURE = "+imp_srcs[srcChannel].getProperty("EXPOSURE"));
}
}
imp_srcs[srcChannel].setProperty("name", correctionsParameters.getNameFromSourceTiff(sourceFiles[nFile]));
imp_srcs[srcChannel].setProperty("channel", srcChannel); // it may already have channel
imp_srcs[srcChannel].setProperty("path", sourceFiles[nFile]); // it may already have channel
if (this.correctionsParameters.pixelDefects && (eyesisCorrections.defectsXY!=null)&& (eyesisCorrections.defectsXY[srcChannel]!=null)){
// apply pixel correction
int numApplied= eyesisCorrections.correctDefects(
imp_srcs[srcChannel],
srcChannel,
debugLevel);
if ((debugLevel>0) && (numApplied>0)) { // reduce verbosity after verified defect correction works
System.out.println("Corrected "+numApplied+" pixels in "+sourceFiles[nFile]);
}
}
float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
int width = imp_srcs[srcChannel].getWidth();
int height = imp_srcs[srcChannel].getHeight();
if (!batch_mode && (debugLevel > -1)) {
double [] max_pix= {0.0, 0.0, 0.0, 0.0};
// for (int y = 0; y < height-1; y+=2){
for (int y = 0; y < 499; y+=2){
// for (int x = 0; x < width-1; x+=2){
for (int x = width/2; x < width-1; x+=2){
if (pixels[y*width+x ] > max_pix[0]) max_pix[0] = pixels[y*width+x ];
if (pixels[y*width+x+ 1] > max_pix[1]) max_pix[1] = pixels[y*width+x+ 1];
if (pixels[y*width+x+width ] > max_pix[2]) max_pix[2] = pixels[y*width+x+width ];
if (pixels[y*width+x+width+1] > max_pix[3]) max_pix[3] = pixels[y*width+x+width+1];
}
}
System.out.println(String.format("channel %d max_pix[] = %6.2f %6.2f %6.2f %6.2f", srcChannel, max_pix[0], max_pix[1], max_pix[2], max_pix[3]));
dbg_dpixels[srcChannel] = new double [pixels.length];
for (int i = 0; i < pixels.length; i++) dbg_dpixels[srcChannel][i] = pixels[i];
// imp_srcs[srcChannel].show();
}
if (clt_parameters.sat_level > 0.0){
double [] saturations = {
Double.parseDouble((String) imp_srcs[srcChannel].getProperty("saturation_1")),
Double.parseDouble((String) imp_srcs[srcChannel].getProperty("saturation_0")),
Double.parseDouble((String) imp_srcs[srcChannel].getProperty("saturation_3")),
Double.parseDouble((String) imp_srcs[srcChannel].getProperty("saturation_2"))};
saturation_imp[srcChannel] = new boolean[width*height];
System.out.println(String.format("channel %d saturations = %6.2f %6.2f %6.2f %6.2f", srcChannel,
saturations[0],saturations[1],saturations[2],saturations[3]));
double [] scaled_saturations = new double [saturations.length];
for (int i = 0; i < scaled_saturations.length; i++){
scaled_saturations[i] = saturations[i] * clt_parameters.sat_level;
}
for (int y = 0; y < height-1; y+=2){
for (int x = 0; x < width-1; x+=2){
if (pixels[y*width+x ] > scaled_saturations[0]) saturation_imp[srcChannel][y*width+x ] = true;
if (pixels[y*width+x+ 1] > scaled_saturations[1]) saturation_imp[srcChannel][y*width+x +1] = true;
if (pixels[y*width+x+width ] > scaled_saturations[2]) saturation_imp[srcChannel][y*width+x+width ] = true;
if (pixels[y*width+x+width+1] > scaled_saturations[3]) saturation_imp[srcChannel][y*width+x+width+1] = true;
}
}
}
if (this.correctionsParameters.vignetting){
if ((eyesisCorrections.channelVignettingCorrection==null) || (srcChannel<0) || (srcChannel>=eyesisCorrections.channelVignettingCorrection.length) || (eyesisCorrections.channelVignettingCorrection[srcChannel]==null)){
System.out.println("No vignetting data for channel "+srcChannel);
return null;
}
/// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
if (pixels.length!=eyesisCorrections.channelVignettingCorrection[srcChannel].length){
System.out.println("Vignetting data for channel "+srcChannel+" has "+eyesisCorrections.channelVignettingCorrection[srcChannel].length+" pixels, image "+sourceFiles[nFile]+" has "+pixels.length);
return null;
}
// TODO: Move to do it once:
double min_non_zero = 0.0;
for (int i=0;i<pixels.length;i++){
double d = eyesisCorrections.channelVignettingCorrection[srcChannel][i];
if ((d > 0.0) && ((min_non_zero == 0) || (min_non_zero > d))){
min_non_zero = d;
}
}
double max_vign_corr = clt_parameters.vignetting_range*min_non_zero;
System.out.println("Vignetting data: channel="+srcChannel+", min = "+min_non_zero);
for (int i=0;i<pixels.length;i++){
double d = eyesisCorrections.channelVignettingCorrection[srcChannel][i];
if (d > max_vign_corr) d = max_vign_corr;
pixels[i]*=d;
}
// Scale here, combine with vignetting later?
/// int width = imp_srcs[srcChannel].getWidth();
/// int height = imp_srcs[srcChannel].getHeight();
for (int y = 0; y < height-1; y+=2){
for (int x = 0; x < width-1; x+=2){
pixels[y*width+x ] *= clt_parameters.scale_g;
pixels[y*width+x+width+1] *= clt_parameters.scale_g;
pixels[y*width+x +1] *= clt_parameters.scale_r;
pixels[y*width+x+width ] *= clt_parameters.scale_b;
}
}
} else { // assuming GR/BG pattern
System.out.println("Applying fixed color gain correction parameters: Gr="+
clt_parameters.novignetting_r+", Gg="+clt_parameters.novignetting_g+", Gb="+clt_parameters.novignetting_b);
/// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
/// int width = imp_srcs[srcChannel].getWidth();
/// int height = imp_srcs[srcChannel].getHeight();
double kr = clt_parameters.scale_r/clt_parameters.novignetting_r;
double kg = clt_parameters.scale_g/clt_parameters.novignetting_g;
double kb = clt_parameters.scale_b/clt_parameters.novignetting_b;
for (int y = 0; y < height-1; y+=2){
for (int x = 0; x < width-1; x+=2){
pixels[y*width+x ] *= kg;
pixels[y*width+x+width+1] *= kg;
pixels[y*width+x +1] *= kr;
pixels[y*width+x+width ] *= kb;
}
}
}
}
}
// temporary applying scaleExposures[srcChannel] here, setting it to all 1.0
System.out.println("Temporarily applying scaleExposures[] here" );
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
for (int i = 0; i < pixels.length; i++){
pixels[i] *= scaleExposures[srcChannel];
}
scaleExposures[srcChannel] = 1.0;
}
// may need to equalize gains between channels
if (clt_parameters.gain_equalize || clt_parameters.colors_equalize){
channelGainsEqualize(
clt_parameters.gain_equalize,
clt_parameters.colors_equalize,
clt_parameters.nosat_equalize, // boolean nosat_equalize,
channelFiles,
imp_srcs,
saturation_imp, // boolean[][] saturated,
setNames.get(nSet), // just for debug messages == setNames.get(nSet)
debugLevel);
}
if (!batch_mode && (debugLevel > -1) && (saturation_imp != null)){
String [] titles = {"chn0","chn1","chn2","chn3"};
double [][] dbg_satur = new double [saturation_imp.length] [saturation_imp[0].length];
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
for (int i = 0; i < saturation_imp[srcChannel].length; i++){
dbg_satur[srcChannel][i] = saturation_imp[srcChannel][i]? 1.0 : 0.0;
}
}
int width = imp_srcs[0].getWidth();
int height = imp_srcs[0].getHeight();
(new showDoubleFloatArrays()).showArrays(dbg_satur, width, height, true, "Saturated" , titles);
if (debugLevel > -1) { // 0){
double [][] dbg_dpixels_norm = new double [channelFiles.length][];
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
dbg_dpixels_norm[srcChannel] = new double[pixels.length];
for (int i = 0; i < pixels.length; i++){
dbg_dpixels_norm[srcChannel][i] = pixels[i];
}
}
(new showDoubleFloatArrays()).showArrays(dbg_dpixels, width, height, true, "dpixels" , titles);
(new showDoubleFloatArrays()).showArrays(dbg_dpixels_norm, width, height, true, "dpixels_norm" , titles);
double [][] dbg_dpixels_split = new double [4 * dbg_dpixels.length][dbg_dpixels[0].length / 4];
String [] dbg_titles = {"g1_0","r_0","b_0","g2_0","g1_2","r_1","b_1","g2_1","g1_2","r_2","b_2","g2_2","g1_3","r_3","b_3","g2_3"};
for (int srcChn = 0; srcChn < 4; srcChn++) {
for (int y = 0; y < height-1; y+=2){
for (int x = 0; x < width-1; x+=2){
dbg_dpixels_split[ 0 + 4 * srcChn][ y*width/4 +x/2 ] = dbg_dpixels_norm[srcChn][y * width + x ];
dbg_dpixels_split[ 3 + 4 * srcChn][ y*width/4 +x/2 ] = dbg_dpixels_norm[srcChn][y * width + x + width + 1];
dbg_dpixels_split[ 1 + 4 * srcChn][ y*width/4 +x/2 ] = dbg_dpixels_norm[srcChn][y * width + x + 1];
dbg_dpixels_split[ 2 + 4 * srcChn][ y*width/4 +x/2 ] = dbg_dpixels_norm[srcChn][y * width + x + width ];
}
}
}
(new showDoubleFloatArrays()).showArrays(dbg_dpixels_split, width/2, height/2, true, "dpixels_split" , dbg_titles);
}
}
return imp_srcs;
}
public void batchCLT3d(
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
EyesisCorrectionParameters.NonlinParameters nonlinParameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
int convolveFFTSize, // 128 - fft size, kernel size should be size/2
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
this.startTime=System.nanoTime();
String [] sourceFiles=correctionsParameters.getSourcePaths();
boolean [] enabledFiles=new boolean[sourceFiles.length];
for (int i=0;i<enabledFiles.length;i++) enabledFiles[i]=false;
int numFilesToProcess=0;
int numImagesToProcess=0;
for (int nFile=0;nFile<enabledFiles.length;nFile++){
if ((sourceFiles[nFile]!=null) && (sourceFiles[nFile].length()>1)) {
int [] channels={correctionsParameters.getChannelFromSourceTiff(sourceFiles[nFile])};
if (correctionsParameters.isJP4()){
int subCamera= channels[0]- correctionsParameters.firstSubCamera; // to match those in the sensor files
// removeUnusedSensorData should be off!?
channels=this.eyesisCorrections.pixelMapping.channelsForSubCamera(subCamera);
}
if (channels!=null){
for (int i=0;i<channels.length;i++) if (eyesisCorrections.isChannelEnabled(channels[i])){
if (!enabledFiles[nFile]) numFilesToProcess++;
enabledFiles[nFile]=true;
numImagesToProcess++;
}
}
}
}
if (numFilesToProcess==0){
System.out.println("No files to process (of "+sourceFiles.length+")");
return;
} else {
if (debugLevel>0) System.out.println(numFilesToProcess+ " files to process (of "+sourceFiles.length+"), "+numImagesToProcess+" images to process");
}
double [] referenceExposures=eyesisCorrections.calcReferenceExposures(debugLevel); // multiply each image by this and divide by individual (if not NaN)
int [][] fileIndices=new int [numImagesToProcess][2]; // file index, channel number
int index=0;
for (int nFile=0;nFile<enabledFiles.length;nFile++){
if ((sourceFiles[nFile]!=null) && (sourceFiles[nFile].length()>1)) {
int [] channels={correctionsParameters.getChannelFromSourceTiff(sourceFiles[nFile])};
if (correctionsParameters.isJP4()){
int subCamera= channels[0]- correctionsParameters.firstSubCamera; // to match those in the sensor files
channels=eyesisCorrections.pixelMapping.channelsForSubCamera(subCamera);
}
if (channels!=null){
for (int i=0;i<channels.length;i++) if (eyesisCorrections.isChannelEnabled(channels[i])){
fileIndices[index ][0]=nFile;
fileIndices[index++][1]=channels[i];
}
}
}
}
ArrayList<String> setNames = new ArrayList<String>();
ArrayList<ArrayList<Integer>> setFiles = new ArrayList<ArrayList<Integer>>();
for (int iImage=0;iImage<fileIndices.length;iImage++){
int nFile=fileIndices[iImage][0];
String setName = correctionsParameters.getNameFromSourceTiff(sourceFiles[nFile]);
if (!setNames.contains(setName)) {
setNames.add(setName);
setFiles.add(new ArrayList<Integer>());
}
setFiles.get(setNames.indexOf(setName)).add(new Integer(nFile));
}
// Do per 4-image set processing
int nSet = 0;
for (nSet = 0; nSet < setNames.size(); nSet++){
if ((nSet > 0) &&(debugLevel > -2)) {
System.out.println("Processing set "+(nSet+1)+" (of "+fileIndices.length+") finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startSetTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
this.startSetTime = System.nanoTime();
boolean [][] saturation_imp = (clt_parameters.sat_level > 0.0)? new boolean[QUAD][] : null;
double [] scaleExposures = new double[QUAD]; //
ImagePlus [] imp_srcs = conditionImageSet(
nSet, // final int nSet, // index of the 4-image set
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fileIndices, // final int [][] fileIndices, // =new int [numImagesToProcess][2]; // file index, channel number
setNames, // final ArrayList<String> setNames, // = new ArrayList<String>();
setFiles, // final ArrayList<ArrayList<Integer>> setFiles, // = new ArrayList<ArrayList<Integer>>();
referenceExposures, //final double [] referenceExposures, // =eyesisCorrections.calcReferenceExposures(debugLevel); // multiply each image by this and divide by individual (if not NaN)
scaleExposures, // final double [] scaleExposures, // = new double[channelFiles.length]; //
saturation_imp, // final boolean [][] saturation_imp, // = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
true, // final boolean batch_mode, // disable any debug images
debugLevel); // final int debugLevel)
// once per quad here
if (imp_srcs == null) continue;
if (correctionsParameters.clt_batch_4img){
processCLTQuadCorr( // returns ImagePlus, but it already should be saved/shown
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
nonlinParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
convolveFFTSize, // 128 - fft size, kernel size should be size/2
scaleExposures,
false, // apply_corr, // calculate and apply additional fine geometry correction
false, // infinity_corr, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
true, // batch_mode
updateStatus,
debugLevel);
}
if (correctionsParameters.clt_batch_extrinsic) {
if (tp != null) tp.resetCLTPasses();
boolean ok = preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
nonlinParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (ok) {
System.out.println("Adjusting extrinsics");
extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
true, // final boolean batch_mode,
debugLevel); // final int debugLevel)
}
}
if (correctionsParameters.clt_batch_poly) {
if (tp != null) tp.resetCLTPasses();
boolean ok = preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
nonlinParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (ok) {
System.out.println("Adjusting polynomial fine crorection");
extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
true, // final boolean batch_mode,
debugLevel); // final int debugLevel)
}
}
if (correctionsParameters.clt_batch_explore) {
if (tp != null) tp.resetCLTPasses();
boolean ok = preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
nonlinParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (ok) {
System.out.println("Explore 3d space");
expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
clt_parameters,
debayerParameters,
nonlinParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
true, // final boolean batch_mode,
debugLevel);
} else continue;
} else continue; // if (correctionsParameters.clt_batch_explore)
if (correctionsParameters.clt_batch_surf) {
tp.showPlanes(
clt_parameters,
geometryCorrection,
threadsMax,
updateStatus,
true, // batch_mode
debugLevel);
} else continue; // if (correctionsParameters.clt_batch_surf)
if (correctionsParameters.clt_batch_assign) {
boolean ok = tp.assignTilesToSurfaces(
clt_parameters,
geometryCorrection,
threadsMax,
updateStatus,
true, // boolean batch_mode,
debugLevel);
if (!ok) continue;
} else continue; // if (correctionsParameters.clt_batch_assign)
if (correctionsParameters.clt_batch_gen3d) {
boolean ok = 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,
true, // final boolean batch_mode,
debugLevel); // final int debugLevel)
if (!ok) continue;
} else continue; // if (correctionsParameters.clt_batch_gen3d)
Runtime.getRuntime().gc();
// if (debugLevel > -2) System.out.println("Processing set "+(nSet+1)+" (of "+fileIndices.length+") finished at "+
// IJ.d2s(0.000000001*(System.nanoTime()-this.startSetTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (eyesisCorrections.stopRequested.get()>0) {
System.out.println("User requested stop");
System.out.println("Processing "+(nSet + 1)+" file sets (of "+setNames.size()+") finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return;
}
}
if (debugLevel > -2) {
System.out.println("Processing set "+(nSet+1)+" (of "+fileIndices.length+") finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startSetTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
System.out.println("Processing "+fileIndices.length+" files ("+setNames.size()+" file sets) finished in "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
}
......@@ -3514,7 +3514,7 @@ public class TileProcessor {
final int dbg_tile = 49468; // x = 220, y = 152 (pavement line)
final boolean show_scan = show_filter_scan || (debugLevel > 1);
showDoubleFloatArrays sdfa_instance = null;
if ((debugLevel > -1) || show_scan) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
if ((debugLevel > -2) && ((debugLevel > -1) || show_scan)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
if (debugLevel > 0){
System.out.println("FilterScan(,,"+disparity_far+", " +disparity_near+", "+ sure_smth);
}
......@@ -4501,8 +4501,10 @@ public class TileProcessor {
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
final int debugLevelInner = batch_mode ? -5: debugLevel;
trimCLTPasses(); // make possible to run this method multiple times - remove extra passes added by it last time
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
// boolean show_st = clt_parameters.stShow || (debugLevel > 1);
......@@ -4535,7 +4537,7 @@ public class TileProcessor {
boolean show_overlap = false; //true; // clt_parameters.show_overlap
boolean show_rgba_color = false; //true; // clt_parameters.show_rgba_color
if (show_nonoverlap){
if (!batch_mode && show_nonoverlap){
texture_nonoverlap = image_dtt.combineRGBATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
clt_parameters.transform_size,
......@@ -4553,7 +4555,7 @@ public class TileProcessor {
}
if (show_overlap || show_rgba_color){
if (!batch_mode && (show_overlap || show_rgba_color)){
int alpha_index = 3;
texture_overlap = image_dtt.combineRGBATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
......@@ -4583,7 +4585,7 @@ public class TileProcessor {
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
}
}
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
double [][] tiles_tone = scan_prev.getTileRBGA(
12); // int num_layers);
sdfa_instance.showArrays(
......@@ -4604,14 +4606,14 @@ public class TileProcessor {
Double.NaN, // double kR,
Double.NaN, // double kB,
Double.NaN); // double fatZero)
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
ta.showToneDiffWeights3("Raw_");
ta.showToneDiffWeights1("Raw_");
}
ta.blurMixTones(
false, // final boolean use_sqrt,
true); //final boolean weighted) // blur weighted
if (debugLevel >-1) {
if (!batch_mode && (debugLevel >-1)) {
ta.showToneDiffWeights3("Mixed_");
ta.showToneDiffWeights1("Mixed_");
}
......@@ -4637,7 +4639,7 @@ public class TileProcessor {
clt_parameters.tsReset,
dispStrength, // final double [][][] dispStrength,
tileSel, // final boolean [][] tileSel,
debugLevel); // final int debugLevel,
debugLevelInner); // final int debugLevel,
// assign tiles that do not depend on other assigned tiles - single pass
int [][] tile_layers = tileSurface.getTileLayersCopy();
int [][] tile_layers_single_surf = tileSurface.newTileLayers(tileSel); // final boolean [][] tileSel,)
......@@ -4646,7 +4648,7 @@ public class TileProcessor {
int [] stats_single_surf= tileSurface.assignTilesToSingleSurface(
tile_layers_single_surf, //final int [][] tileLayers,
clt_parameters.tsNoEdge , // final boolean noEdge,
0, // -1, // debugLevel, // final int debugLevel)
batch_mode ? -5: 0, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.print("Assign the only surface :");
......@@ -4678,7 +4680,7 @@ public class TileProcessor {
(clt_parameters.tsEnGrow? growMaxDiffNear: null), // final double [] maxDiffNear, // null
clt_parameters.plDispNorm, // final double dispNorm, // disparity normalize (proportionally scale down disparity difference if above
dispStrength, // final double [][][] dispStrength,
debugLevel, // 2, // -1, // debugLevel, // final int debugLevel)
debugLevelInner, // 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.print("growWeakAssigned():");
......@@ -4690,7 +4692,7 @@ public class TileProcessor {
tile_layers_planes, //final int [][] tileLayers,
st.planes_mod, // final TilePlanes.PlaneData[][] planes
clt_parameters.tsNoEdge , // final boolean noEdge,
2, // -1, // debugLevel, // final int debugLevel)
debugLevelInner, // 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.print("assignPlanesTiles():");
......@@ -4732,7 +4734,7 @@ public class TileProcessor {
clt_parameters.tsMinAdvantage, //final double minAdvantage,
clt_parameters.plDispNorm, // final double dispNorm, // disparity normalize (proportionally scale down disparity difference if above
dispStrength, // final double [][][] dispStrength,
0, // -1, // debugLevel, // final int debugLevel)
batch_mode ? -5: 0, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.print("Assign to nearest with single candidate :");
......@@ -4762,7 +4764,7 @@ public class TileProcessor {
clt_parameters.tsMinAdvantage, //final double minAdvantage,
clt_parameters.plDispNorm, // final double dispNorm, // disparity normalize (proportionally scale down disparity difference if above
dispStrength, // final double [][][] dispStrength,
0, // -1, // debugLevel, // final int debugLevel)
batch_mode ? -5: 0, // 0, // -1, final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.print("Assign to best fit surface :");
......@@ -4781,7 +4783,7 @@ public class TileProcessor {
clt_parameters.tsClustSize , // final int minSize, // **
clt_parameters. tsClustWeight, // final double minStrength, // **
dispStrength, // final double [][][] dispStrength,
0, // -1, // debugLevel, // final int debugLevel)
batch_mode ? -5: 0, // 0, // -1, final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
tileSurface.printStats(stats);
......@@ -4799,7 +4801,7 @@ public class TileProcessor {
clt_parameters.tsMaxSurStrength , // final double maxStrength, // **
clt_parameters.tsCountDis, // final boolean includeImpossible, // ** // count prohibited neighbors as assigned
dispStrength, // final double [][][] dispStrength,
0, // -1, // debugLevel, // final int debugLevel)
batch_mode ? -5: 0, // 0, // -1, final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.print("Assign from neighbors :");
......@@ -4821,7 +4823,7 @@ public class TileProcessor {
clt_parameters.tsClustSize , // final int minSize, // **
clt_parameters. tsClustWeight, // final double minStrength, // **
dispStrength, // final double [][][] dispStrength,
0, // -1, // debugLevel, // final int debugLevel)
batch_mode ? -5: 0, // 0, // -1, final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
tileSurface.printStats(stats);
......@@ -4846,7 +4848,7 @@ public class TileProcessor {
}
tileSurface.compareAssignments(
tile_assignments, // final int [][][] tileAssignments)
debugLevel); //
debugLevelInner); //
int [][][] opinions = new int [tile_layers.length][][];
tile_layers = tileSurface.getConsensusAssignment(
......@@ -4855,7 +4857,7 @@ public class TileProcessor {
tile_assignments); // final int [][][] tileAssignments)
int [][] tile_layers_surf = ta.imgToSurf(tile_layers);
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
double [][] dbg_tls = new double [tile_layers_surf.length][];
for (int ml = 0; ml < tile_layers_surf.length; ml++) if (tile_layers_surf[ml] != null){
dbg_tls[ml] = new double [tile_layers_surf[ml].length];
......@@ -4865,7 +4867,7 @@ public class TileProcessor {
}
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf");
}
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
ta.showTileCost("before_",tile_layers_surf);
ta.showTileCosts("before_",tile_layers_surf);
}
......@@ -4878,12 +4880,12 @@ public class TileProcessor {
ta.optimizeAssignment25(
clt_parameters.tsNoEdge , // final boolean noEdge,
tile_layers_surf, // final int [][] tileLayers,
2, // final int debugLevel,
(batch_mode ? -5 : 2), // 2, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
double [][] dbg_tls = new double [tile_layers_surf.length][];
for (int ml = 0; ml < tile_layers_surf.length; ml++) if (tile_layers_surf[ml] != null){
dbg_tls[ml] = new double [tile_layers_surf[ml].length];
......@@ -4893,10 +4895,10 @@ public class TileProcessor {
}
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf");
}
if (debugLevel > -2) {
if (!batch_mode && (debugLevel > -2)) {
ta.showTileCost("after_",tile_layers_surf);
}
if (debugLevel > -1) {
if (!batch_mode && (debugLevel > -1)) {
ta.showTileCosts("after_",tile_layers_surf);
}
ta_stats = ta.statTileCosts(tile_layers_surf);
......@@ -4919,26 +4921,26 @@ public class TileProcessor {
tileSel, // final boolean [][] tileSel,
debugLevel); // final int debugLevel,
if (clt_parameters.tsShow && (debugLevel > -2)){
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -2)){
tileSurface.showAssignment(
"assignments", // String title,
dispStrength); // final double [][][] dispStrength)
}
boolean [][] assigned_sel = tileSurface.extractSelection(
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
int [][] clusters1 = tileSurface.enumerateClusters(
assigned_sel, //final boolean [][] selection,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
int [][] cluster_stats1 = tileSurface.clusterStats(
clusters1, // int [][] clusters,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -4946,7 +4948,7 @@ public class TileProcessor {
cluster_stats1, // int [][] cluster_stats,
-1); //clt_parameters.tsNumClust); // int max_clusters){
if (clt_parameters.tsShow && (debugLevel > -1)){
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -1)){
tileSurface.showClusters(
"clusters_individual", // String title,
cluster_stats1, // int [][] cluster_stats,
......@@ -4957,12 +4959,12 @@ public class TileProcessor {
// Try splitting (currently no initial conflicts):
int [][] clusters1a = tileSurface.spitConflictClusters(
clusters1, // final int [][] clusters,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
int [][] cluster_stats1a = tileSurface.clusterStats(
clusters1a, // int [][] clusters,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -4970,7 +4972,7 @@ public class TileProcessor {
cluster_stats1a, // int [][] cluster_stats,
-1); //clt_parameters.tsNumClust); // int max_clusters){
if (clt_parameters.tsShow && (debugLevel > -1)){
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -1)){
tileSurface.showClusters(
"clusters_individual_fixed", // String title,
cluster_stats1a, // int [][] cluster_stats,
......@@ -4983,19 +4985,19 @@ public class TileProcessor {
boolean [][] grown_sel = tileSurface.growSelection(
2, // int grow,
assigned_sel, // final boolean [][] sel_in,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
int [][] clusters2 = tileSurface.enumerateClusters(
grown_sel, // final boolean [][] selection,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
int [][] cluster_stats2 = tileSurface.clusterStats(
clusters2, // int [][] clusters,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -5003,7 +5005,7 @@ public class TileProcessor {
cluster_stats2, // int [][] cluster_stats,
-1); //clt_parameters.tsNumClust); // int max_clusters){
if (clt_parameters.tsShow && (debugLevel > -1)){
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -1)){
tileSurface.showClusters(
"clusters_merged", // String title,
cluster_stats2, // int [][] cluster_stats,
......@@ -5014,13 +5016,13 @@ public class TileProcessor {
// Just for testing: splitting combined clusters
int [][] clusters2a = tileSurface.spitConflictClusters(
clusters2, // final int [][] clusters,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
int [][] cluster_stats2a = tileSurface.clusterStats(
clusters2a, // int [][] clusters,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -5028,7 +5030,7 @@ public class TileProcessor {
cluster_stats2a, // int [][] cluster_stats,
-1); //clt_parameters.tsNumClust); // int max_clusters){
if (clt_parameters.tsShow && (debugLevel > -1)){
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -1)){
tileSurface.showClusters(
"clusters_merged_split", // String title,
cluster_stats2a, // int [][] cluster_stats,
......@@ -5038,11 +5040,11 @@ public class TileProcessor {
tileSurface.mergeAndGrow( // T ODO: add result
assigned_sel, // final boolean [][] sel_in,
0, // final int debugLevel,
batch_mode ? -5: 0, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
if (clt_parameters.tsShow && (debugLevel > -1)){
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -1)){
int numToShow = clt_parameters.tsNumClust;
int num_surf = tileSurface.getSurfaceDataLength();
if (numToShow > num_surf) numToShow = num_surf;
......@@ -5067,6 +5069,7 @@ public class TileProcessor {
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
trimCLTPasses(); // make possible to run this method multiple time - remove extra passes added by it last time
......@@ -5207,7 +5210,7 @@ public class TileProcessor {
// Trying new class
LinkPlanes lp = new LinkPlanes (clt_parameters, st);
if (clt_parameters.show_planes && (debugLevel > -1)){
if (!batch_mode && clt_parameters.show_planes && (debugLevel > -1)){
showPlaneData(
"initial",
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
......@@ -5552,7 +5555,7 @@ public class TileProcessor {
true, // final boolean weak_connected, // select connected planes even if they are weak/thick
st.getPlanesMod());
if (clt_parameters.show_planes && (debugLevel > -2)){
if (!batch_mode && clt_parameters.show_planes && (debugLevel > -2)){
showPlaneData(
"final",
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
......@@ -5930,17 +5933,19 @@ public class TileProcessor {
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
int debugLevelInner = batch_mode ? -5: debugLevel;
CLTPass3d scan_bg = clt_3d_passes.get(bg_scan_index); //
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
CLTPass3d scan_lm = getLastMeasured(-1);
// boolean [] border_tiles = (scan_lm != null) ? scan_lm.getBorderTiles() : null;
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
if (!batch_mode && (debugLevel > -1)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
//TODO: for next passes - combine all selected for previous passes (all passes with smaller disparity)
boolean show_st = clt_parameters.stShow || (debugLevel > 1);
boolean show_st = !batch_mode && ( clt_parameters.stShow || (debugLevel > 1));
boolean [] these_tiles;
int [] replaced = null; // +1 - hor, +2 - vert
......@@ -5959,7 +5964,7 @@ public class TileProcessor {
clt_parameters.or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement
clt_parameters.or_absHor, // 0.15; // Minimal horizontal absolute scaled offset ortho strength needed for replacement
clt_parameters.or_absVert, // 0.19; // Minimal vertical absolute scaled offset ortho strength needed for replacement
debugLevel);
debugLevelInner);
if (clt_parameters.poles_fix) {
boolean [] selection = new boolean [replaced.length];
......@@ -6017,7 +6022,7 @@ public class TileProcessor {
true, // final boolean zero_gap_strength, // set strength to zero when covering gaps
// final int threadsMax, // maximal number of threads to launch
// final boolean updateStatus,
2); //debugLevel);
batch_mode ? -5: 2); //debugLevel);
} else {
these_tiles= combineHorVertDisparity_old(
scan_prev, // final CLTPass3d scan,
......@@ -6028,7 +6033,7 @@ public class TileProcessor {
this_maybe, // maximal strength to ignore as non-background
sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
clt_parameters,
debugLevel);
debugLevelInner);
scan_prev.combineHorVertStrength(true, false); // strength now max of original and horizontal. Use scale instead of boolean?
}
......@@ -6152,7 +6157,7 @@ public class TileProcessor {
}
//==================
public void thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
public void thirdPassSetup_old( // prepare tile tasks for the second pass based on the previous one(s)
EyesisCorrectionParameters.CLTParameters clt_parameters,
double disparity_far, //
double disparity_near, //
......
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