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

Tested basic DSI generation for LWIR

parent 9a970304
......@@ -161,6 +161,7 @@ public class EyesisCorrectionParameters {
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_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_all = true; // Save all parameters with the model
......@@ -302,6 +303,7 @@ public class EyesisCorrectionParameters {
cp.clt_batch_dsi= this.clt_batch_dsi;
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_all= this.clt_batch_save_all;
......@@ -482,6 +484,7 @@ public class EyesisCorrectionParameters {
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_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_all", this.clt_batch_save_all+"");
......@@ -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_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_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all"));
......@@ -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,
"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");
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,
"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,
......@@ -1103,6 +1111,7 @@ public class EyesisCorrectionParameters {
this.clt_batch_dbg1= gd.getNextBoolean(); // 29
this.clt_batch_dsi= 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_all= gd.getNextBoolean();
if (clt_parameters != null) {
......@@ -1291,6 +1300,10 @@ public class EyesisCorrectionParameters {
extensions[0] = sourceSuffix;
prefixes[0] = sourcePrefix;
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(
setFilter,
......@@ -1320,15 +1333,26 @@ public class EyesisCorrectionParameters {
for (int nFile=0;nFile<files.length;nFile++) {
// String [] setChnFiles = files[nFile].list(setFilter);
File [] setChnFiles = files[nFile].listFiles(setFilter);
File [] setMainChnFiles = files[nFile].listFiles(setFilterMain);
File [] setAuxChnFiles = files[nFile].listFiles(setFilterAux);
int num_match = setChnFiles.length;
if ( (num_match == num_chn_files) || // all files for main and aux
(num_match == num_chn_main) || // only main camera files
(num_match == num_chn_aux)) // only aux camera files
{ // only use sets of exact number of files
if (num_match == num_chn_files) {
// || // all files for main and aux
// (setMainChnFiles.length == num_chn_main) || // has all needed main camera files
// (setAuxChnFiles.length == num_chn_aux)) // has all needed camera files
// { // only use sets of exact number of files
setDirList.add(files[nFile]);
for (File f: setChnFiles) {
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()];
......
......@@ -269,7 +269,7 @@ public class PolynomialApproximation {
this.debugLevel);
}
public double [][] quadraticApproximation(
public double [][] quadraticApproximation( // no use
double [][][] data,
boolean forceLinear, // use linear approximation
int debugLevel
......@@ -312,8 +312,8 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel);
}
public double [][] quadraticApproximation(
/*
public double [][] quadraticApproximation( // no use
double [][][] data,
boolean forceLinear, // use linear approximation
double thresholdLin, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
......@@ -328,7 +328,7 @@ public class PolynomialApproximation {
1.0E-15, // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this.debugLevel);
}
*/
public double [][] quadraticApproximation(
double [][][] data,
boolean forceLinear, // use linear approximation
......@@ -442,7 +442,11 @@ 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;
int i,j,n=0;
......@@ -465,7 +469,7 @@ public class PolynomialApproximation {
SZ02[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;
if (w>0) {
n++;
......@@ -585,7 +589,7 @@ public class PolynomialApproximation {
}
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
public double normMatix(double [][] a) {
double d,norm=1.0;
......
......@@ -65,6 +65,7 @@ public class CLTPass3d{
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 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_measured = false;
public String texture = null; // relative (to x3d) path
......@@ -96,6 +97,13 @@ public class CLTPass3d{
}
}
public int getClustRadius() {
return clust_radius;
}
public void setClustRadius (int clust_radius) {
this.clust_radius = clust_radius;
}
public TileProcessor getTileProcessor()
{
......@@ -606,32 +614,38 @@ public class CLTPass3d{
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
public void conditionDisparity()
{
/*
conditionDisparity(disparity_index);
}
public void conditionDisparity(int disparity_index) // only called from above
{
*/
int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY();
double corr_magic_scale = tileProcessor.getMagicScale();
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_hor = 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_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 j = 0; j < 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];
has_lma[indx] = true;
} else {
calc_disparity[indx] = disparity_map[disparity_index][indx]/corr_magic_scale + this.disparity[i][j];
}
......@@ -654,10 +668,11 @@ public class CLTPass3d{
int tilesX = tileProcessor.getTilesX();
int tilesY = tileProcessor.getTilesY();
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];
if (lma_disparity != null) {
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;
......
......@@ -2439,7 +2439,7 @@ public class ExtrinsicAdjustment {
this.last_ymfx); // modifies this.last_ymfx (weights and subtracts fx)
this.initial_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(1);
showDerivatives(2);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3235,26 +3235,46 @@ public class QuadCLT extends QuadCLTCPU {
}
// Resore to CLTMeasureCorr when done testing
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_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 boolean updateStatus,
final int debugLevel)
{
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
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures,
clust_radius, // final int clust_radius,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
}
// 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);
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
......@@ -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 [][] 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(
getNumSensors(),
clt_parameters.transform_size,
......@@ -3305,8 +3312,7 @@ public class QuadCLT extends QuadCLTCPU {
ImageDtt.BITS_ALL_DISPARITIES |
ImageDtt.BITS_ALL_DIFFS | // needs max_diff?
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
......@@ -3336,7 +3342,7 @@ public class QuadCLT extends QuadCLTCPU {
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.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
......@@ -3366,6 +3372,66 @@ public class QuadCLT extends QuadCLTCPU {
threadsMax,
debugLevel);
} else {
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
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.texture_tiles = null;
scan.setTextureSelection(tex_sel);
......@@ -4123,6 +4189,7 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -4972,7 +5039,7 @@ public class QuadCLT extends QuadCLTCPU {
}
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(
scan, // CLTPass3d scan,
"LY-combo_scan-"+scan+"_post"); //String title)
......
......@@ -48,6 +48,8 @@ import java.util.Properties;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.checkerframework.checker.units.qual.m;
import com.elphel.imagej.calibration.PixelMapping;
import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.cameras.ColorProcParameters;
......@@ -442,6 +444,30 @@ public class QuadCLTCPU {
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
public void saveDSIGTAux(
......@@ -3750,7 +3776,9 @@ public class QuadCLTCPU {
int getTotalFiles(SetChannels [] sc) { // USED in lwir
int nf = 0;
if (sc != null) {
for (int i = 0; i < sc.length; i++) nf+=sc[i].fileNumber().length;
}
return nf;
}
......@@ -4747,12 +4775,7 @@ public class QuadCLTCPU {
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)
......@@ -7675,6 +7698,7 @@ public class QuadCLTCPU {
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
clt_parameters,
0, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
clt_parameters.stUseRefine, // use supertiles
bg_pass, /// does it have .selected
// disparity range - differences from
......@@ -7707,6 +7731,7 @@ public class QuadCLTCPU {
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass,
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,
clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance,
......@@ -7742,11 +7767,11 @@ public class QuadCLTCPU {
clt_parameters,
refine_pass,
false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (debugLevel > -3){
System.out.println("CLTMeasure("+refine_pass+")-*");
}
......@@ -7791,6 +7816,7 @@ public class QuadCLTCPU {
clt_parameters,
tp.clt_3d_passes.size() -1, // new, refine_pass+1, - just added from macro - VERIFY
true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
......@@ -7800,7 +7826,6 @@ public class QuadCLTCPU {
if (show_init_refine) tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1), // CLTPass3d scan,
"after_measure_macro-"+tp.clt_3d_passes.size());
}
/// Refining after all added
......@@ -7814,6 +7839,7 @@ public class QuadCLTCPU {
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
clt_parameters,
0, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
clt_parameters.stUseRefine, // use supertiles
bg_pass,
// disparity range - differences from
......@@ -7845,6 +7871,7 @@ public class QuadCLTCPU {
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass,
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,
clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance,
......@@ -7862,6 +7889,7 @@ public class QuadCLTCPU {
clt_parameters,
refine_pass,
true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
......@@ -7890,12 +7918,27 @@ public class QuadCLTCPU {
false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true, // final boolean copyDebug)
debugLevel);
for (int nexpand = 0; nexpand < 20; nexpand++) {
tp.clt_3d_passes.add(combo_pass);
}
/*
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
......@@ -7907,18 +7950,190 @@ public class QuadCLTCPU {
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,
"expamded-"+nexpand+"-added-"+num_added);
"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_compositeScan-"+tp.clt_3d_passes.size());
"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());
*/
tp.clt_3d_passes.add(combo_pass);
// 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,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure,
-0.5, // 0.0, // clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters.grow_disp_max, // final double disp_near,
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(
combo_multi[clust_radius-1], // CLTPass3d scan,
"combo_multi-"+clust_radius+"-pass"+nnn);
tp.clt_3d_passes.add(combo_multi[clust_radius-1] );
combo_pass = combo_multi[clust_radius-1];
// combine tasks from (original) combo_pass and combo_pass_multi (use its combo_disparity, but saved getLMA from original combo_pass ?
// when done, grow to fill gaps from 3x3 first (by 1 step) and from 5x5 - second?(by 2 steps), ...
}
}
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
Runtime.getRuntime().gc();
......@@ -7927,6 +8142,12 @@ public class QuadCLTCPU {
return true;
}
ArrayList <CLTPass3d> prepareDisparityScan( // USED in lwir
double scan_start,
double scan_step,
......@@ -8065,6 +8286,7 @@ public class QuadCLTCPU {
clt_parameters,
combo_scan,
false, // final boolean save_textures,
0, // final int clust_radius,
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner - 1);
......@@ -8119,7 +8341,7 @@ public class QuadCLTCPU {
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"};
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];
......@@ -8215,6 +8437,9 @@ public class QuadCLTCPU {
data[slice][i] = pixels[i];
}
}
boolean [] bg_sel = new boolean [width*height];
boolean [] bg_use = new boolean [width*height];
boolean [] combo_use = new boolean [width*height];
......@@ -8616,15 +8841,17 @@ public class QuadCLTCPU {
combo_scan,
false, // final boolean save_textures,
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
false, // updateStatus,
debugLevelInner - 1);
/**/
// Why twice?
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
combo_scan,
false, // final boolean save_textures,
0, // clust_radius,
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner - 1);
......@@ -8916,6 +9143,7 @@ public class QuadCLTCPU {
clt_parameters,
combo_scan + 1 + nm,
false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
......@@ -8996,6 +9224,7 @@ public class QuadCLTCPU {
clt_parameters,
last_scan,
false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
......@@ -9033,6 +9262,7 @@ public class QuadCLTCPU {
clt_parameters,
last_scan2,
false, // true, // final boolean save_textures,
0, // final int clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
......@@ -9775,6 +10005,7 @@ public class QuadCLTCPU {
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
clt_parameters,
0, // int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
stUseRefine, // use supertiles
bg_index, // bg_scan bg_pass,
// disparity range - differences from
......@@ -9968,6 +10199,7 @@ public class QuadCLTCPU {
passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass,
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,
clt_parameters.grow_disp_max, // final double grow_disp_max,
clt_parameters.gr_unique_tol, // final double unique_tolerance,
......@@ -10004,6 +10236,7 @@ public class QuadCLTCPU {
clt_parameters,
refine_pass,
false, // final boolean save_textures,
0, // final int clust_radius,
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevel - 1);
......@@ -11087,63 +11320,6 @@ public class QuadCLTCPU {
clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor,
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
......@@ -11165,12 +11341,7 @@ public class QuadCLTCPU {
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)
......@@ -11208,7 +11379,6 @@ public class QuadCLTCPU {
debugLevel);
}
scan_rslt.disparity = disparity_array;
scan_rslt.tile_op = tile_op;
scan_rslt.disparity_map = disparity_map;
......@@ -11231,35 +11401,37 @@ public class QuadCLTCPU {
scanIndex,
true, // save_textures,
false, // save_corr,
0, // clust_radius,
threadsMax, // maximal number of threads to launch
updateStatus,
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,
final int scanIndex,
final boolean save_textures,
final boolean save_corr,
// final int clust_radius,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
return CLTMeasure( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures,
save_corr, // final boolean save_corr,
// null, // final double [][] mismatch, // null or double [12][]
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
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 boolean updateStatus,
final int debugLevel)
......@@ -11269,7 +11441,7 @@ public class QuadCLTCPU {
scanIndex, // final int scanIndex,
save_textures, // final boolean save_textures,
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
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -11280,11 +11452,12 @@ public class QuadCLTCPU {
final int scanIndex,
final boolean save_textures,
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 boolean updateStatus,
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 int dbg_x = -295-debugLevel;
final int dbg_y = -160-debugLevel;
......@@ -11329,9 +11502,8 @@ public class QuadCLTCPU {
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 [][] shiftXY = new double [getNumSensors()][2];
......@@ -11371,7 +11543,7 @@ public class QuadCLTCPU {
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?
clt_parameters.img_dtt.getMcorrAll (getNumSensors()), // boolean sel_all,
clt_parameters.img_dtt.getMcorrDia (getNumSensors()), // boolean sel_dia,
......@@ -11379,8 +11551,9 @@ public class QuadCLTCPU {
clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib,
clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor,
clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert);
if (USE_PRE_2021) {
image_dtt.clt_aberrations_quad_corr(
if (clust_radius > 0) {
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
......@@ -11388,12 +11561,13 @@ public class QuadCLTCPU {
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, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
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
// 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,
......@@ -11401,22 +11575,7 @@ public class QuadCLTCPU {
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.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,
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)
......@@ -11424,18 +11583,84 @@ public class QuadCLTCPU {
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
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
// (clt_parameters.dbg_mode & 256) != 0, // transpose 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
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
// 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 { // clust_radius
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
......@@ -11458,14 +11683,7 @@ public class QuadCLTCPU {
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.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)
......@@ -11481,7 +11699,7 @@ public class QuadCLTCPU {
clt_parameters.clt_window,
shiftXY, //
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.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)
......@@ -11499,11 +11717,12 @@ public class QuadCLTCPU {
threadsMax,
debugLevel);
}
scan.disparity_map = disparity_map;
scan.texture_tiles = texture_tiles;
scan.is_measured = true; // but no disparity map/textures
scan.is_combo = false;
scan.has_lma = null;
scan.getLMA(); // recalculate
scan.resetProcessed();
return scan;
}
......@@ -11602,61 +11821,6 @@ public class QuadCLTCPU {
clt_parameters.img_dtt.getMcorrNeib (getNumSensors()), // boolean sel_neib,
clt_parameters.img_dtt.getMcorrHor (getNumSensors()), // boolean sel_hor,
clt_parameters.img_dtt.getMcorrVert (getNumSensors())); // boolean sel_vert);
if (USE_PRE_2021) {
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, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
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
// 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)
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
......@@ -11679,12 +11843,7 @@ public class QuadCLTCPU {
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)
......@@ -11717,7 +11876,6 @@ public class QuadCLTCPU {
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax,
debugLevel);
}
scan.disparity_map = disparity_map;
scan.texture_tiles = texture_tiles;
scan.is_measured = true;
......@@ -11843,7 +12001,7 @@ public class QuadCLTCPU {
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
if (debugLevel > -5){
if (debugLevel > -3) { // -5){
tp.showScan(
scan, // CLTPass3d scan,
"LY-combo_scan-"+scan+"_post"); //String title)
......@@ -12852,6 +13010,7 @@ public class QuadCLTCPU {
clt_parameters,
scanIndex,
false, // final boolean save_textures,
0, // final int clust_radius,
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner -1); // - 1); // -5-1
......
......@@ -1062,16 +1062,18 @@ public class TileProcessor {
double strength;
double adiff;
boolean has_lma;
int clust_radius;
DSD (int indx){ // only index
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.disparity = disparity;
this.strength = strength;
this.adiff = adiff;
this.has_lma = has_lma;
this.clust_radius = clust_radius;
}
}
......@@ -1088,10 +1090,13 @@ public class TileProcessor {
// if there is at least one with lma - remove all without lma measurements
boolean some_lma = false;
int best_clust_radius = 1000000;
for (DSD dsd : src_list) {
some_lma |= dsd.has_lma;
if (some_lma) {
break;
if (dsd.has_lma) {
if (!some_lma || (dsd.clust_radius < best_clust_radius)) {
best_clust_radius = dsd.clust_radius;
}
some_lma = true;
}
}
......@@ -1099,7 +1104,7 @@ public class TileProcessor {
int best_indx = 0;
for (int i = 1; i < list_in.size(); 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) {
best_indx = i;
}
......@@ -1110,7 +1115,7 @@ public class TileProcessor {
ArrayList<DSD> list_remain = new ArrayList<DSD>();
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) {
list_remain.add(dsd);
}
......@@ -1273,6 +1278,7 @@ public class TileProcessor {
double strongest_weak_hor = 0.0;
double strongest_weak_vert = 0.0;
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;
if (nt == dbg_tile) {
......@@ -1292,6 +1298,7 @@ public class TileProcessor {
(pass.disparity[ty][tx] > combo_pass0.max_tried_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;
double [] mdisp_lma_arr = pass.disparity_map[ImageDtt.DISPARITY_INDEX_POLY];
boolean m_lma = (mdisp_lma_arr != null) && !Double.isNaN(mdisp_lma_arr[nt]);
......@@ -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
continue;
}
boolean first_lma = !use_lma && m_lma;
use_lma = m_lma;
boolean first_lma = m_lma && (!use_lma || (clust_radius < best_lma));
if (first_lma) {
use_lma = true;
// best_lma = clust_radius;
}
double mdisp = m_lma?
mdisp_lma_arr[nt] : pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM][nt];
double corr_magic = m_lma ? corr_magic_scale_lma : corr_magic_scale;
......@@ -1325,11 +1335,11 @@ public class TileProcessor {
// if ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) {
if ((disp >= disp_far) && (disp <= disp_near) && !Double.isNaN(adiff)){
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;
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 {
if ((last && (strength > 0.0)) || (!no_weak && (strength > strongest_weak))){
strongest_weak = strength; // definitely not LMA
......@@ -1348,7 +1358,7 @@ public class TileProcessor {
adiff_best_hor = adiff_hor;
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 {
if ((last && (strength_hor > 0.0)) || (!no_weak && (strength_hor > strongest_weak_hor))){
strongest_weak_hor = strength_hor;
......@@ -1366,7 +1376,7 @@ public class TileProcessor {
adiff_best_vert = adiff_vert;
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 {
if ((last && (strength_vert > 0.0)) || (!no_weak && (strength_vert > strongest_weak_vert))){
strongest_weak_vert = strength_vert;
......@@ -1539,6 +1549,7 @@ ImageDtt.startAndJoin(threads);
final ArrayList <CLTPass3d> passes,
final int firstPass,
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_rrange, // same, relative to disparity
final double disp_arange, // look for a fit within range from the neighbor
......@@ -1603,6 +1614,7 @@ ImageDtt.startAndJoin(threads);
if (num_neibs >= min_defined) {
//min_defined
double avg_lma = swd/sw;
sw /= num_neibs;
// Now find "best fit": smallest residual within range
double drange = Math.max(disp_arange, disp_rrange * avg_lma);
int best_index = -1;
......@@ -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.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,6 +1675,118 @@ ImageDtt.startAndJoin(threads);
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);
final ArrayList <CLTPass3d> passes,
final int firstPass,
final int lastPassPlus1,
final int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
final CLTPass3d new_scan,
final double grow_disp_max,
final double unique_tolerance,
......@@ -2354,7 +2483,7 @@ ImageDtt.startAndJoin(threads);
total ++;
for (int ipass = firstPass; ipass <lastPassPlus1; 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
if ( Double.isNaN(pass.disparity[ty][tx]) ||
(Math.abs(new_scan.disparity[ty][tx] - pass.disparity[ty][tx]) < unique_tolerance) ||
......@@ -2625,6 +2754,7 @@ ImageDtt.startAndJoin(threads);
passes, // clt_3d_passes, // final ArrayList <CLTPass3d> passes,
firstPass, // final int firstPass,
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,
grow_disp_max, // final double grow_disp_max,
unique_tolerance, // final double unique_tolerance,
......@@ -3370,6 +3500,18 @@ ImageDtt.startAndJoin(threads);
}
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
public double [][] getShowScan(
......@@ -5569,9 +5711,65 @@ ImageDtt.startAndJoin(threads);
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)
CLTParameters clt_parameters,
int clust_radius, // 0 - initial single-tile, 1 - 1x1 (same), 2 - 3x3, 3 5x5
boolean use_supertiles, // false (2018)
int bg_scan_index, // 0
double disparity_far, // 0.3
......
......@@ -62,19 +62,23 @@ import ij.io.FileSaver;
public class TwoQuadCLT {
public static int DSI_DISPARITY_MAIN = 0;
public static int DSI_DISPARITY_AUX = 1;
public static int DSI_DISPARITY_RIG = 2;
public static int DSI_DISPARITY_X3D = 3;
public static int DSI_STRENGTH_MAIN = 4;
public static int DSI_STRENGTH_AUX = 5;
public static int DSI_STRENGTH_RIG = 6;
public static int DSI_DISPARITY_MAIN_LMA = 1;
public static int DSI_DISPARITY_AUX = 2;
public static int DSI_DISPARITY_AUX_LMA = 3;
public static int DSI_DISPARITY_RIG = 4;
public static int DSI_DISPARITY_X3D = 5;
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_MAIN_SUFFIX = "-DSI_MAIN";
public static String [] DSI_SLICES =
{ "disparity_main",
"disparity_lma_main",
"disparity_aux",
"disparity_lma_aux",
"disparity_rig",
"disparity_x3d",
"strength_main",
......@@ -3160,8 +3164,14 @@ if (debugLevel > -100) return true; // temporarily !
// String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths();
String set_name = quadCLT_main.image_name;
if (set_name == null ) {
set_name = quadCLT_aux.image_name;
}
if (set_name == null ) {
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;
}
......@@ -3169,18 +3179,19 @@ if (debugLevel > -100) return true; // temporarily !
QuadCLT.SetChannels [] set_channels_aux = quadCLT_aux.setChannels(set_name,debugLevel);
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) {
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) {
path_list.add(sourceFiles_main[fn]);
}
}
if (set_channels_main !=null) {
quadCLT_main.writeKml(debugLevel ); // also generated with x3d model
}
String jp4_copy_path= quadCLT_main.correctionsParameters.selectX3dDirectory(
set_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
......@@ -3193,7 +3204,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Created "+dir);
}
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);
try {
Files.copy(
......@@ -9099,38 +9110,51 @@ if (debugLevel > -100) return true; // temporarily !
// Reset dsi data (only 2 slices will be used)
this.dsi = new double [DSI_SLICES.length][];
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;
this.startTime=System.nanoTime();
String [] sourceFiles=quadCLT_main.correctionsParameters.getSourcePaths();
QuadCLT.SetChannels [] set_channels_main = quadCLT_main.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+")");
return;
}
double [] referenceExposures_main = null;
double [] referenceExposures_aux = null;
if (!colorProcParameters.lwir_islwir) referenceExposures_main = quadCLT_main.eyesisCorrections.calcReferenceExposures(debugLevel);
if (!colorProcParameters_aux.lwir_islwir) referenceExposures_aux = quadCLT_aux.eyesisCorrections.calcReferenceExposures(debugLevel);
for (int nSet = 0; nSet < set_channels_main.length; nSet++){
if (!colorProcParameters.lwir_islwir && !(set_channels_main == null)) {
referenceExposures_main = quadCLT_main.eyesisCorrections.calcReferenceExposures(debugLevel);
}
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
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");
}
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()+"'");
}
*/
int [] channelFiles_main = set_channels_main[nSet].fileNumber();
int [] channelFiles_aux = set_channels_aux[nSet].fileNumber();
boolean [][] saturation_imp_main = (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;
double [] scaleExposures_main = new double[channelFiles_main.length];
double [] scaleExposures_aux = new double[channelFiles_aux.length];
int [] channelFiles_main = (set_channels_main==null)? null: set_channels_main[nSet].fileNumber();
int [] channelFiles_aux = (set_channels_aux ==null)? null: set_channels_aux[nSet].fileNumber();
boolean [][] saturation_imp_main = ((channelFiles_main != null) && (clt_parameters.sat_level > 0.0))? new boolean[channelFiles_main.length][] : null;
boolean [][] saturation_imp_aux = ((channelFiles_aux != null) && (clt_parameters.sat_level > 0.0))? new boolean[channelFiles_aux.length][] : null;
double [] scaleExposures_main = (channelFiles_main != null) ? (new double[channelFiles_main.length]) : null;
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);
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,
colorProcParameters, // ColorProcParameters colorProcParameters, //
sourceFiles, // String [] sourceFiles,
......@@ -9140,7 +9164,8 @@ if (debugLevel > -100) return true; // temporarily !
scaleExposures_main, //output // double [] scaleExposures
saturation_imp_main, //output // boolean [][] saturation_imp,
threadsMax, // int threadsMax,
debugLevelInner); // int debugLevel);
debugLevelInner);
}// int debugLevel);
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
......@@ -9150,7 +9175,8 @@ if (debugLevel > -100) return true; // temporarily !
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)?
quadCLT_main.correctionsParameters.rig_batch_adjust_aux : quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt;
double [][] main_ds = null;
if (set_channels_main != null) {
for (int num_adjust_main = 0; num_adjust_main < adjust_main; num_adjust_main++) {
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
", pass "+(num_adjust_main+1)+" of "+adjust_main);
......@@ -9158,7 +9184,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
", pass "+(num_adjust_main+1)+" of "+adjust_main);
}
//Generates background image in model tree - should be done later, after adjustment (It is overwritten later, so OK)
//Generates background image in model tree - should be done later, after adjustment (It is overwritten later, so OK)
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
......@@ -9205,7 +9231,7 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
// clear memory for main
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
if (!ok) break;
}
......@@ -9231,9 +9257,9 @@ if (debugLevel > -100) return true; // temporarily !
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 ?
// 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
......@@ -9425,7 +9451,7 @@ if (debugLevel > -100) return true; // temporarily !
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)
// null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
}
......@@ -9438,15 +9464,15 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel);
}
/// continue; // skipping to the next file
/// 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}
main_ds = new double[][] {dsi[DSI_DISPARITY_MAIN], dsi[DSI_STRENGTH_MAIN]}; // {null, null}
}
if ((adjust_aux == 0) &&
!quadCLT_main.correctionsParameters.clt_batch_4img_aux &&
!quadCLT_main.correctionsParameters.clt_batch_dsi_aux &&
......@@ -9456,7 +9482,7 @@ if (debugLevel > -100) return true; // temporarily !
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
main_ds, // double [][] ds,
quadCLT_main.getGeometryCorrection(), // GeometryCorrection geometryCorrection_main,
......@@ -9476,7 +9502,9 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel); // int debug_level
}
ImagePlus [] imp_srcs_aux = quadCLT_aux.conditionImageSet(
ImagePlus [] imp_srcs_aux = null;
if (set_channels_aux != null) {
imp_srcs_aux = quadCLT_aux.conditionImageSet(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
colorProcParameters_aux, // ColorProcParameters colorProcParameters, //
sourceFiles, // String [] sourceFiles,
......@@ -9499,7 +9527,7 @@ if (debugLevel > -100) return true; // temporarily !
if (dbg_path.length()==0) {
dbg_path = null;
}
// dbg_path = "/home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif";
// 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"
......@@ -9550,7 +9578,7 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel + 2); // final int debugLevel)
if (!ok) break;
}
// clear memory for AUX
// clear memory for AUX
quadCLT_aux.tp.resetCLTPasses();
}
// Generate 4 AUX camera images and thumbnail
......@@ -9587,6 +9615,7 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
if (quadCLT_main.correctionsParameters.clt_batch_dsi_aux_full) {
if (updateStatus) IJ.showStatus("Expanding DSI for the aux camera image set "+quadCLT_main.image_name+" (for DSI export)");
quadCLT_aux.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters,
......@@ -9597,21 +9626,38 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
double [][] aux_last_scan = quadCLT_aux.tp.getShowDS(
}
// 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];
// dsi[DSI_DISPARITY_AUX] = aux_last_scan[0]; // incompatible dimensions
// dsi[DSI_STRENGTH_AUX] = aux_last_scan[1]; // incompatible dimensions
// 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];
quadCLT_main.saveDSIGTAux( // GT from main and AUX DS
quadCLT_aux.saveDSIGTAux( // GT from main and AUX DS
quadCLT_aux,
dsi_aux_from_main);
}
quadCLT_aux.tp.resetCLTPasses();
}
//
}
// TODO: Add new ML generation here
if (quadCLT_main.correctionsParameters.clt_batch_genMl) { // rig.ml_generate) { //clt_batch_genMl
outputMLDataLwir(
......@@ -9654,7 +9700,11 @@ if (debugLevel > -100) return true; // temporarily !
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()+")");
}
......@@ -10088,7 +10138,11 @@ if (debugLevel > -100) return true; // temporarily !
{
// update properties from potentially modified parameters (others should be updated
if (path == null) {
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())) {
......
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