Commit 270fcbc6 authored by Andrey Filippov's avatar Andrey Filippov

Before adding BLUE_SKY to DSI_MAIN

parent 8ee61ae6
...@@ -3775,24 +3775,22 @@ public class OpticalFlow { ...@@ -3775,24 +3775,22 @@ public class OpticalFlow {
quadCLTs[ref_index].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry quadCLTs[ref_index].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
*/ */
// public static QuadCLT buildRefDSI( // public static QuadCLT buildRefDSI(
public static void buildRefDSI( public static void photoEach(
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
boolean batch_mode,
String set_name,
QuadCLT quadCLT_main, // tiles should be set QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_ref, // tiles should be set QuadCLT quadCLT_ref, // tiles should be set
final int threadsMax, // maximal number of threads to launch final double [][] dsi,
final int photo_num_full, //
final boolean batch_mode,
final int threadsMax, // int threadsMax,
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) { final int debugLevel) {
final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel; // copied from TQ boolean [] blue_sky = quadCLT_ref.getBlueSky();
// boolean photo_en = clt_parameters.photo_en; // false; // perform photogrammetric calibration to equalize pixel values if (debugLevel > -3) {
boolean photo_each = clt_parameters.photo_each; // true; // perform photogrammetric calibration to equalize pixel values System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+
// boolean photo_to_main= clt_parameters.photo_to_main; // maybe it will not be needed, it will apply this calibration to the next scene sequence ", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****");
}
int photo_num_full = clt_parameters.photo_num_full; // 1; // Number of full recalibrations with re-processing of the images
int photo_num_refines = clt_parameters.photo_num_refines; // 3; // Calibrate, remove outliers, recalibrate, ... int photo_num_refines = clt_parameters.photo_num_refines; // 3; // Calibrate, remove outliers, recalibrate, ...
int photo_min_good = clt_parameters.photo_min_good; // 1000; // Minimal number of good pixels for photometric calibration int photo_min_good = clt_parameters.photo_min_good; // 1000; // Minimal number of good pixels for photometric calibration
double photo_min_strength = clt_parameters.photo_min_strength; // 0.0; // maybe add to filter out weak tiles double photo_min_strength = clt_parameters.photo_min_strength; // 0.0; // maybe add to filter out weak tiles
...@@ -3802,7 +3800,156 @@ public class OpticalFlow { ...@@ -3802,7 +3800,156 @@ public class OpticalFlow {
double photo_std_2 = clt_parameters.photo_std_2; // 200.0; // Minimal standard deviation of the filtered values for poly order 2 double photo_std_2 = clt_parameters.photo_std_2; // 200.0; // Minimal standard deviation of the filtered values for poly order 2
int photo_offs_set = clt_parameters.photo_offs_set; // 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value int photo_offs_set = clt_parameters.photo_offs_set; // 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
double photo_offs = clt_parameters.photo_offs; // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance) double photo_offs = clt_parameters.photo_offs; // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
// boolean photo_debug = clt_parameters.photo_debug; // false; // Generate images and text
// preparing same format as after combo, filling in only needed data
double [][] ds_photo = new double[TwoQuadCLT.DSI_LENGTH][];
ds_photo[OpticalFlow.COMBO_DSN_INDX_DISP] = dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA];
ds_photo[OpticalFlow.COMBO_DSN_INDX_DISP_BG_ALL] = dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA];
ds_photo[OpticalFlow.COMBO_DSN_INDX_STRENGTH] = dsi[TwoQuadCLT.DSI_STRENGTH_AUX];
boolean photo_each_debug = !batch_mode; // false; // true; // false;
boolean photo_each_debug2 = !batch_mode; // false; // true; // false;
for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) { // maybe need to correct just offsets?
int poly_order = photo_order;
if ((poly_order > 1) && (nrecalib == 0)) {
poly_order = 1;
}
boolean ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
quadCLT_ref, // final QuadCLT ref_scene, will set photometric calibration to this scene
photo_min_strength, // final double min_strength,
photo_max_diff, // final double max_diff, // 30.0
poly_order, // final int photo_order, // 0 - offset only, 1 - linear, 2 - quadratic
photo_std_1, // final double photo_std_1, // 50.0; // Minimal standard deviation of the filtered values for poly order 1
photo_std_2, // final double photo_std_2, // 200.0; // Minimal standard deviation of the filtered values for poly order 2
photo_offs_set, // final int photo_offs_set,// 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels
ds_photo, // combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
blue_sky, // final boolean[] blue_sky,
threadsMax, // int threadsMax,
photo_each_debug); //final boolean debug)
if (!ok) {
System.out.println("************** Failed calibratePhotometric2, restoring original");
quadCLT_ref.setLwirOffsets(quadCLT_main.getLwirOffsets());
quadCLT_ref.setLwirScales (quadCLT_main.getLwirScales ());
quadCLT_ref.setLwirScales2(quadCLT_main.getLwirScales2());
quadCLT_ref.setPhotometricScene(quadCLT_main.getPhotometricScene());
// Retry linear only
ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
quadCLT_ref, // final QuadCLT ref_scene, will set photometric calibration to this scene
photo_min_strength, // final double min_strength,
photo_max_diff, // final double max_diff, // 30.0
1, // poly_order, // final int photo_order, // 0 - offset only, 1 - linear, 2 - quadratic
photo_std_1, // final double photo_std_1, // 50.0; // Minimal standard deviation of the filtered values for poly order 1
photo_std_2, // final double photo_std_2, // 200.0; // Minimal standard deviation of the filtered values for poly order 2
photo_offs_set, // final int photo_offs_set,// 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels
ds_photo, // combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
blue_sky, // final boolean[] blue_sky,
threadsMax, // int threadsMax,
photo_each_debug); //final boolean debug)
if (!ok) {
System.out.println("Failed even linear photometric on pass "+nrecalib+", abandoning calibration");
break;
}
}
// copy offsets to the current to be saved with other properties. Is it correct/needed?
quadCLT_ref.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1);
quadCLT_ref.setDSI(dsi); // try to avoid saving, will complain on restoring, but keep
// Re-read reference and other scenes using new offsets
quadCLT_ref.setQuadClt(); // should work even when the data is new for the same scene
quadCLT_ref.restoreFromModel(
clt_parameters,
colorProcParameters,
null, // double [] noise_sigma_level,
-1, // noise_variant, // <0 - no-variants, compatible with old code
null, // final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
threadsMax,
debugLevel);
// Re-measure and update (is it needed?)
CLTPass3d scan = new CLTPass3d(quadCLT_ref.tp);
scan.setTileOpDisparity(dsi[TwoQuadCLT.DSI_DISPARITY_AUX]);
quadCLT_ref.setQuadClt(); // just in case ?
quadCLT_ref.CLTMeas( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scan, // final CLTPass3d scan,
false, // final boolean save_textures,
false, // final boolean need_diffs, // calculate diffs even if textures are not needed
0, // final int clust_radius,
true, // final boolean save_corr,
true, // false, // final boolean run_lma, // = true;
0.0, // final double max_chn_diff, // filter correlation results by maximum difference between channels
-1.0, // final double mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel-2); // final int debugLevel);
double [][] aux_new_scan = TileProcessor.getDSLMA(
scan,
false); // boolean force_final);
dsi[TwoQuadCLT.DSI_DISPARITY_AUX] = aux_new_scan[0]; // compare diffs
dsi[TwoQuadCLT.DSI_STRENGTH_AUX] = aux_new_scan[1];
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA] = aux_new_scan[2];
// Re-measure and update from BG spread and average in dsi
CLTPass3d bgscan = new CLTPass3d(quadCLT_ref.tp);
bgscan.setTileOpDisparity(null);
quadCLT_ref.setQuadClt(); // just in case ?
quadCLT_ref.CLTMeas( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
bgscan, // final CLTPass3d scan,
true, // false, // final boolean save_textures,
true, // false, // final boolean need_diffs, // calculate diffs even if textures are not needed
0, // final int clust_radius,
true, // final boolean save_corr, IS IT NEEDED?
false, // final boolean run_lma, // = true;
0.0, // final double max_chn_diff, // filter correlation results by maximum difference between channels
-1.0, // final double mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel-2); // final int debugLevel);
if (photo_each_debug2) {
quadCLT_ref.tp.showScan(bgscan, quadCLT_ref.getImageName()+"-bgscan-"+nrecalib); // nrecalib
quadCLT_ref.tp.showScan(scan, quadCLT_ref.getImageName()+"-scan-"+nrecalib);
}
dsi[TwoQuadCLT.DSI_SPREAD_AUX] = bgscan.getSecondMax(); // //aux_bg_scan[3];
dsi[TwoQuadCLT.DSI_AVGVAL_AUX] = bgscan.getAvgVal(); //aux_bg_scan[4];
quadCLT_ref.setDSI(dsi); // Restore known dsi
// quadCLT_ref.setBlueSky(null); //ref_blue_sky); it is null here
quadCLT_ref.setDSRBG(
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
}
public static void buildRefDSI(
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
boolean batch_mode,
String set_name,
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_ref, // tiles should be set
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) {
final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel; // copied from TQ
boolean photo_each = clt_parameters.photo_each; // true; // perform photogrammetric calibration to equalize pixel values
double sky_highest_min = clt_parameters.imp.sky_highest_min; double sky_highest_min = clt_parameters.imp.sky_highest_min;
double cold_frac = clt_parameters.imp.cold_frac; double cold_frac = clt_parameters.imp.cold_frac;
...@@ -3867,190 +4014,85 @@ public class OpticalFlow { ...@@ -3867,190 +4014,85 @@ public class OpticalFlow {
} else { } else {
dsi[TwoQuadCLT.DSI_STRENGTH_AUX] = aux_last_scan[1]; dsi[TwoQuadCLT.DSI_STRENGTH_AUX] = aux_last_scan[1];
} }
boolean ran_photo_each = false;
// perform photometric here, after first DSI // perform photometric here, after first DSI
if (photo_each && (!quadCLT_ref.isPhotometricThis() || !batch_mode)) { if (photo_each && (!quadCLT_ref.isPhotometricThis() || !batch_mode)) {
if (debugLevel > -3) { // if (debugLevel > -3) {
System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+ // System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+
", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****"); // ", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****");
} // }
photoEach(
// preparing same format as after combo, filling in only needed data clt_parameters, // CLTParameters clt_parameters,
double [][] ds_photo = new double[TwoQuadCLT.DSI_LENGTH][]; colorProcParameters, // ColorProcParameters colorProcParameters,
ds_photo[OpticalFlow.COMBO_DSN_INDX_DISP] = dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA]; quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
ds_photo[OpticalFlow.COMBO_DSN_INDX_DISP_BG_ALL] = dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA]; quadCLT_ref, // QuadCLT quadCLT_ref, // tiles should be set
ds_photo[OpticalFlow.COMBO_DSN_INDX_STRENGTH] = dsi[TwoQuadCLT.DSI_STRENGTH_AUX]; dsi, // final double [][] dsi,
clt_parameters.photo_num_full, // int photo_num_full =
boolean photo_each_debug = !batch_mode; // false; // true; // false; batch_mode, // final boolean batch_mode,
boolean photo_each_debug2 = !batch_mode; // false; // true; // false; threadsMax, // final int threadsMax, // int threadsMax,
updateStatus, // final boolean updateStatus,
for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) { // maybe need to correct just offsets? debugLevel); // final int debugLevel)
int poly_order = photo_order; ran_photo_each = true; // will need to re-run after blue sky detection
if ((poly_order > 1) && (nrecalib == 0)) {
poly_order = 1;
}
boolean ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
quadCLT_ref, // final QuadCLT ref_scene, will set photometric calibration to this scene
photo_min_strength, // final double min_strength,
photo_max_diff, // final double max_diff, // 30.0
poly_order, // final int photo_order, // 0 - offset only, 1 - linear, 2 - quadratic
photo_std_1, // final double photo_std_1, // 50.0; // Minimal standard deviation of the filtered values for poly order 1
photo_std_2, // final double photo_std_2, // 200.0; // Minimal standard deviation of the filtered values for poly order 2
photo_offs_set, // final int photo_offs_set,// 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels
ds_photo, // combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
threadsMax, // int threadsMax,
photo_each_debug); //final boolean debug)
if (!ok) {
System.out.println("************** Failed calibratePhotometric2, restoring original");
quadCLT_ref.setLwirOffsets(quadCLT_main.getLwirOffsets());
quadCLT_ref.setLwirScales (quadCLT_main.getLwirScales ());
quadCLT_ref.setLwirScales2(quadCLT_main.getLwirScales2());
quadCLT_ref.setPhotometricScene(quadCLT_main.getPhotometricScene());
// Retry linear only
ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
quadCLT_ref, // final QuadCLT ref_scene, will set photometric calibration to this scene
photo_min_strength, // final double min_strength,
photo_max_diff, // final double max_diff, // 30.0
1, // poly_order, // final int photo_order, // 0 - offset only, 1 - linear, 2 - quadratic
photo_std_1, // final double photo_std_1, // 50.0; // Minimal standard deviation of the filtered values for poly order 1
photo_std_2, // final double photo_std_2, // 200.0; // Minimal standard deviation of the filtered values for poly order 2
photo_offs_set, // final int photo_offs_set,// 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels
ds_photo, // combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
threadsMax, // int threadsMax,
photo_each_debug); //final boolean debug)
if (!ok) {
System.out.println("Failed even linear photometric on pass "+nrecalib+", abandoning calibration");
break;
}
}
// copy offsets to the current to be saved with other properties. Is it correct/needed?
quadCLT_ref.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1);
quadCLT_ref.setDSI(dsi); // try to avoid saving, will complain on restoring, but keep
// Re-read reference and other scenes using new offsets
quadCLT_ref.setQuadClt(); // should work even when the data is new for the same scene
/*
quadCLT_ref = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel);
*/
quadCLT_ref.restoreFromModel(
clt_parameters,
colorProcParameters,
null, // double [] noise_sigma_level,
-1, // noise_variant, // <0 - no-variants, compatible with old code
null, // final QuadCLTCPU ref_scene, // may be null if scale_fpn <= 0
threadsMax,
debugLevel);
// Re-measure and update (is it needed?)
CLTPass3d scan = new CLTPass3d(quadCLT_ref.tp);
scan.setTileOpDisparity(dsi[TwoQuadCLT.DSI_DISPARITY_AUX]);
quadCLT_ref.setQuadClt(); // just in case ?
quadCLT_ref.CLTMeas( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scan, // final CLTPass3d scan,
false, // final boolean save_textures,
false, // final boolean need_diffs, // calculate diffs even if textures are not needed
0, // final int clust_radius,
true, // final boolean save_corr,
true, // false, // final boolean run_lma, // = true;
0.0, // final double max_chn_diff, // filter correlation results by maximum difference between channels
-1.0, // final double mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel-2); // final int debugLevel);
double [][] aux_new_scan = TileProcessor.getDSLMA(
scan,
false); // boolean force_final);
dsi[TwoQuadCLT.DSI_DISPARITY_AUX] = aux_new_scan[0]; // compare diffs
dsi[TwoQuadCLT.DSI_STRENGTH_AUX] = aux_new_scan[1];
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA] = aux_new_scan[2];
// Re-measure and update from BG spread and average in dsi
CLTPass3d bgscan = new CLTPass3d(quadCLT_ref.tp);
bgscan.setTileOpDisparity(null);
quadCLT_ref.setQuadClt(); // just in case ?
quadCLT_ref.CLTMeas( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
bgscan, // final CLTPass3d scan,
true, // false, // final boolean save_textures,
true, // false, // final boolean need_diffs, // calculate diffs even if textures are not needed
0, // final int clust_radius,
true, // final boolean save_corr, IS IT NEEDED?
false, // final boolean run_lma, // = true;
0.0, // final double max_chn_diff, // filter correlation results by maximum difference between channels
-1.0, // final double mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel-2); // final int debugLevel);
if (photo_each_debug2) {
quadCLT_ref.tp.showScan(bgscan, quadCLT_ref.getImageName()+"-bgscan-"+nrecalib); // nrecalib
quadCLT_ref.tp.showScan(scan, quadCLT_ref.getImageName()+"-scan-"+nrecalib);
}
dsi[TwoQuadCLT.DSI_SPREAD_AUX] = bgscan.getSecondMax(); // //aux_bg_scan[3];
dsi[TwoQuadCLT.DSI_AVGVAL_AUX] = bgscan.getAvgVal(); //aux_bg_scan[4];
quadCLT_ref.setDSI(dsi); // Restore known dsi
quadCLT_ref.setBlueSky(ref_blue_sky);
quadCLT_ref.setDSRBG(
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
} else { } else {
System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLT_ref.getPhotometricScene()); System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLT_ref.getPhotometricScene());
quadCLT_ref.setQuadClt(); // just in case ? quadCLT_ref.setQuadClt(); // just in case ?
} }
quadCLT_ref.setBlueSky (
boolean retry=false; sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this
while (true) { lma_seed,
quadCLT_ref.setBlueSky ( sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this
sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this sky_shrink, // int sky_shrink, // = 4;
lma_seed, sky_expand_extra, // int sky_expand_extra, // = 100; // 1?
sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this sky_bottleneck, //int sky_bottleneck, //
sky_shrink, // int sky_shrink, // = 4; cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence
sky_expand_extra, // int sky_expand_extra, // = 100; // 1? cold_frac, // = 0.005; // this and lower will scale fom by cold_scale
sky_bottleneck, //int sky_bottleneck, // hot_frac, // = 0.9; // this and above will scale fom by 1.0
cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence min_strength, // = 0.08;
cold_frac, // = 0.005; // this and lower will scale fom by cold_scale seed_rows, // = 5; // sky should appear in this top rows
hot_frac, // = 0.9; // this and above will scale fom by 1.0 lowest_sky_row, // = 50;// appears that low - invalid, remove completely
min_strength, // = 0.08; sky_bottom_override, // double sky_temp_override, // really cold average seed - ignore lowest_sky_row filter
seed_rows, // = 5; // sky should appear in this top rows sky_override_shrink, // int shrink_for_temp, // shrink before finding hottest sky
lowest_sky_row, // = 50;// appears that low - invalid, remove completely sky_highest_min, // = 100; // lowest absolute value should not be higher (requires photometric)
sky_bottom_override, // double sky_temp_override, // really cold average seed - ignore lowest_sky_row filter disp_boost_min, // double disp_boost_min, // = 0.5;
sky_override_shrink, // int shrink_for_temp, // shrink before finding hottest sky disp_boost_diff, //double disp_boost_diff, // = 0.35;
sky_highest_min, // = 100; // lowest absolute value should not be higher (requires photometric) disp_boost_neibs, //int disp_boost_neibs, // = 2;
disp_boost_min, // double disp_boost_min, // = 0.5; disp_boost_amount, //double disp_boost_amount, // = 2.0;
disp_boost_diff, //double disp_boost_diff, // = 0.35; dsi[TwoQuadCLT.DSI_STRENGTH_AUX], // double [] strength,
disp_boost_neibs, //int disp_boost_neibs, // = 2; dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread,
disp_boost_amount, //double disp_boost_amount, // = 2.0; dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread,
dsi[TwoQuadCLT.DSI_STRENGTH_AUX], // double [] strength, dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val,
dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread, batch_mode? -1: 1); /// debugLevel); // int debugLevel)
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread, if (ran_photo_each) {
dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val, // quadCLT_ref.setBlueSky(null); // Reset blue sky - is it needed?
batch_mode? -1: 1); /// debugLevel); // int debugLevel) // see if blue sky was detected - rerun photoEach
if (!retry) { boolean [] blue_sky = quadCLT_ref.getBlueSky();
boolean has_blue_sky = false;
for (int i = 0; i < blue_sky.length; i++) if (blue_sky[i]) {
has_blue_sky = true;
break; break;
} }
if (has_blue_sky) {
if (debugLevel > -3) {
System.out.println("Detected non-empty Blue Sky after initial DSI in "+quadCLT_ref.getImageName()+
", re-running photoEach()");
}
photoEach(
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_ref, // QuadCLT quadCLT_ref, // tiles should be set
dsi, // final double [][] dsi,
// just once?
clt_parameters.photo_num_full, // int photo_num_full =
batch_mode, // final boolean batch_mode,
threadsMax, // final int threadsMax, // int threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
}
} }
quadCLT_ref.saveDSIAll ( quadCLT_ref.saveDSIAll (
"-DSI_MAIN", // String suffix, // "-DSI_MAIN" "-DSI_MAIN", // String suffix, // "-DSI_MAIN"
dsi); dsi);
...@@ -4080,10 +4122,14 @@ public class OpticalFlow { ...@@ -4080,10 +4122,14 @@ public class OpticalFlow {
} }
public static void reuseRefDSI( public static void reuseRefDSI(
CLTParameters clt_parameters, CLTParameters clt_parameters,
QuadCLT quadCLT_main, // tiles should be set ColorProcParameters colorProcParameters,
QuadCLT quadCLT_ref, // tiles should be set QuadCLT quadCLT_main, // tiles should be set
final int debugLevel) { QuadCLT quadCLT_ref, // tiles should be set
final boolean batch_mode,
final int threadsMax, // int threadsMax,
final boolean updateStatus,
final int debugLevel) {
boolean photo_each = clt_parameters.photo_each; // true; // perform photogrammetric calibration to equalize pixel values boolean photo_each = clt_parameters.photo_each; // true; // perform photogrammetric calibration to equalize pixel values
boolean photo_to_main= clt_parameters.photo_to_main; // maybe it will not be needed, it will apply this calibration to the next scene sequence boolean photo_to_main= clt_parameters.photo_to_main; // maybe it will not be needed, it will apply this calibration to the next scene sequence
double sky_highest_min = clt_parameters.imp.sky_highest_min; double sky_highest_min = clt_parameters.imp.sky_highest_min;
...@@ -4129,31 +4175,51 @@ public class OpticalFlow { ...@@ -4129,31 +4175,51 @@ public class OpticalFlow {
if (dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null) { if (dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null) {
System.out.println("DSI_MAIN file has old format and does not have spread data, will recalculate."); System.out.println("DSI_MAIN file has old format and does not have spread data, will recalculate.");
} else { } else {
quadCLT_ref.setBlueSky ( boolean [] ref_blue_sky = quadCLT_ref.getBlueSky();
sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this if (ref_blue_sky == null) {
lma_seed, // 2.0; // seed - disparity_lma limit quadCLT_ref.setBlueSky (
sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this
sky_shrink, // int sky_shrink, // = 4; lma_seed, // 2.0; // seed - disparity_lma limit
sky_expand_extra, // int sky_expand_extra, // = 100; // 1? sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this
sky_bottleneck, //int sky_bottleneck, // sky_shrink, // int sky_shrink, // = 4;
cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence sky_expand_extra, // int sky_expand_extra, // = 100; // 1?
cold_frac, // = 0.005; // this and lower will scale fom by cold_scale sky_bottleneck, //int sky_bottleneck, //
hot_frac, // = 0.9; // this and above will scale fom by 1.0 cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence
min_strength, // = 0.08; cold_frac, // = 0.005; // this and lower will scale fom by cold_scale
seed_rows, // = 5; // sky should appear in this top rows hot_frac, // = 0.9; // this and above will scale fom by 1.0
lowest_sky_row, // = 50;// appears that low - invalid, remove completely min_strength, // = 0.08;
sky_bottom_override, // double sky_temp_override, // really cold average seed - ignore lowest_sky_row filter seed_rows, // = 5; // sky should appear in this top rows
sky_override_shrink, // int shrink_for_temp, // shrink before finding hottest sky lowest_sky_row, // = 50;// appears that low - invalid, remove completely
sky_highest_min, // = 100; // lowest absolute value should not be higher (requires photometric) sky_bottom_override, // double sky_temp_override, // really cold average seed - ignore lowest_sky_row filter
disp_boost_min, // double disp_boost_min, // = 0.5; sky_override_shrink, // int shrink_for_temp, // shrink before finding hottest sky
disp_boost_diff, //double disp_boost_diff, // = 0.35; sky_highest_min, // = 100; // lowest absolute value should not be higher (requires photometric)
disp_boost_neibs, //int disp_boost_neibs, // = 2; disp_boost_min, // double disp_boost_min, // = 0.5;
disp_boost_amount, //double disp_boost_amount, // = 2.0; disp_boost_diff, //double disp_boost_diff, // = 0.35;
dsi[TwoQuadCLT.DSI_STRENGTH_AUX], // double [] strength, disp_boost_neibs, //int disp_boost_neibs, // = 2;
dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread, disp_boost_amount, //double disp_boost_amount, // = 2.0;
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], //double [] disp_lma, dsi[TwoQuadCLT.DSI_STRENGTH_AUX], // double [] strength,
dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val, dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread,
debugLevel); // int debugLevel) dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], //double [] disp_lma,
dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val,
debugLevel); // int debugLevel)
if (debugLevel > -3) {
System.out.println("Calculated missing Blue Sky in "+quadCLT_ref.getImageName()+
", re-running photoEach()");
}
photoEach(
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_ref, // QuadCLT quadCLT_ref, // tiles should be set
dsi, // final double [][] dsi,
// just once?
clt_parameters.photo_num_full, // int photo_num_full =
batch_mode, // final boolean batch_mode,
threadsMax, // final int threadsMax, // int threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
}
} }
} }
...@@ -4179,7 +4245,8 @@ public class OpticalFlow { ...@@ -4179,7 +4245,8 @@ public class OpticalFlow {
int photo_offs_set = clt_parameters.photo_offs_set; // 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value int photo_offs_set = clt_parameters.photo_offs_set; // 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
double photo_offs = clt_parameters.photo_offs; // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance) double photo_offs = clt_parameters.photo_offs; // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
boolean photo_debug = clt_parameters.photo_debug; // false; // Generate images and text boolean photo_debug = clt_parameters.photo_debug; // false; // Generate images and text
boolean [] ref_blue_sky = null; // turn off "lma" in the ML output boolean [] ref_blue_sky = quadCLTs[ref_index].getBlueSky(); // null; // turn off "lma" in the ML output
for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) { for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) {
int poly_order = photo_order; int poly_order = photo_order;
if ((poly_order > 1) && (nrecalib == 0)) { if ((poly_order > 1) && (nrecalib == 0)) {
...@@ -4197,7 +4264,8 @@ public class OpticalFlow { ...@@ -4197,7 +4264,8 @@ public class OpticalFlow {
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance) photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2 photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels photo_min_good, // final int min_good, // minimal number of "good" pixels
combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls, combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
ref_blue_sky, // final boolean[] blue_sky,
threadsMax, // int threadsMax, threadsMax, // int threadsMax,
photo_debug); //final boolean debug) photo_debug); //final boolean debug)
// copy offsets to the current to be saved with other properties. Is it correct/needed? // copy offsets to the current to be saved with other properties. Is it correct/needed?
...@@ -4475,8 +4543,12 @@ public class OpticalFlow { ...@@ -4475,8 +4543,12 @@ public class OpticalFlow {
// need to read photometric from reference scene -INTERFRAME.corr-xml, and if it exists - set and propagate to main? // need to read photometric from reference scene -INTERFRAME.corr-xml, and if it exists - set and propagate to main?
reuseRefDSI( reuseRefDSI(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLTs[ref_index], // QuadCLT quadCLT_ref, // tiles should be set quadCLTs[ref_index], // QuadCLT quadCLT_ref, // tiles should be set
batch_mode, // final boolean batch_mode,
threadsMax, // final int threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
} }
......
...@@ -846,7 +846,8 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -846,7 +846,8 @@ public class QuadCLT extends QuadCLTCPU {
final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance) final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
final int num_refines, // 2 final int num_refines, // 2
final int min_good, // minimal number of "good" pixels final int min_good, // minimal number of "good" pixels
final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls, final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
final boolean[] blue_sky,
int threadsMax, int threadsMax,
final boolean debug) final boolean debug)
{ {
...@@ -861,6 +862,11 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -861,6 +862,11 @@ public class QuadCLT extends QuadCLTCPU {
disparity_ref[i] = Double.NaN; disparity_ref[i] = Double.NaN;
} }
} }
if (blue_sky != null) {
for (int i = 0; i < blue_sky.length; i++) if (blue_sky[i]) {
disparity_ref[i] = 0.0;
}
}
ImagePlus img_ref = renderGPUFromDSI( ImagePlus img_ref = renderGPUFromDSI(
-1, // final int sensor_mask, -1, // final int sensor_mask,
......
...@@ -629,7 +629,7 @@ public class TexturedModel { ...@@ -629,7 +629,7 @@ public class TexturedModel {
} }
boolean renormalize = true;// false - use normalizations from previous scenes to keep consistent colors boolean renormalize = true;// false - use normalizations from previous scenes to keep consistent colors
getInterCombinedTexturesNew( // return ImagePlus[] matching tileClusters[], with alpha ImagePlus[] combined_textures = getInterCombinedTexturesNew( // return ImagePlus[] matching tileClusters[], with alpha
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters, colorProcParameters, // ColorProcParameters colorProcParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters, rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
...@@ -642,7 +642,7 @@ public class TexturedModel { ...@@ -642,7 +642,7 @@ public class TexturedModel {
// final int margin, // final int margin,
renormalize, // final boolean renormalize, // false - use normalizations from previous scenes to keep consistent colors renormalize, // final boolean renormalize, // false - use normalizations from previous scenes to keep consistent colors
debugLevel); // final int debug_level) debugLevel); // final int debug_level)
/*
if (debugLevel > -1000) { if (debugLevel > -1000) {
return false; return false;
} }
...@@ -660,7 +660,7 @@ public class TexturedModel { ...@@ -660,7 +660,7 @@ public class TexturedModel {
// final int margin, // final int margin,
renormalize, // final boolean renormalize, // false - use normalizations from previous scenes to keep consistent colors renormalize, // final boolean renormalize, // false - use normalizations from previous scenes to keep consistent colors
debugLevel); // final int debug_level) debugLevel); // final int debug_level)
*/
boolean save_full_textures = true; // false; // true; boolean save_full_textures = true; // false; // true;
EyesisCorrectionParameters.CorrectionParameters correctionsParameters = ref_scene.correctionsParameters; EyesisCorrectionParameters.CorrectionParameters correctionsParameters = ref_scene.correctionsParameters;
String x3d_dir = ref_scene.getX3dDirectory(); String x3d_dir = ref_scene.getX3dDirectory();
...@@ -676,9 +676,9 @@ public class TexturedModel { ...@@ -676,9 +676,9 @@ public class TexturedModel {
} }
} }
// ********************* just for testing ************************************ // ********************* just for testing ************************************
if (debugLevel > -1000) { // if (debugLevel > -1000) {
return false; // return false;
} // }
// Maybe will switch to combined textures (less files) // Maybe will switch to combined textures (less files)
...@@ -2098,49 +2098,6 @@ public class TexturedModel { ...@@ -2098,49 +2098,6 @@ public class TexturedModel {
} }
} }
} }
/*
for (int mode = 0; mode < alpha.length; mode++) {
Arrays.fill(alpha[mode], 1.0);
for (int idir = 0; idir < alpha8.length; idir++) {
if ((mode & (1 << idir)) == 0) {
for (int i = 0; i < alpha8[idir].length; i++) {
alpha[mode][i] *= alpha8[idir][i];
}
}
}
}
for (int mode = 0; mode < alpha.length; mode++) {
Arrays.fill(alpha[mode], 1.0);
for (int idir = 0; idir < alpha8.length; idir++) {
if ((mode & (1 << idir)) == 0) {
for (int i = 0; i < alpha8[idir].length; i++) {
alpha[mode][i] = Math.min(alpha[mode][i],alpha8[idir][i]);
}
}
}
}
for (int imode = 0; imode < alpha.length; imode++) {
int mode = (imode | imode << 8) & 0x1ff;
for (int c = 2; c < 256; c <<=2){
int m = (c << 1) | (c >> 1);
if ((mode & m) != m) {
mode |= c;
}
}
mode &= 0xff;
Arrays.fill(alpha[imode], 1.0);
for (int idir = 0; idir < alpha8.length; idir++) {
if ((mode & (1 << idir)) == 0) {
for (int i = 0; i < alpha8[idir].length; i++) {
alpha[imode][i] *= alpha8[idir][i];
}
}
}
}
*/
for (int imode = 0; imode < alpha.length; imode++) { for (int imode = 0; imode < alpha.length; imode++) {
int mode = (imode | imode << 8) & 0x1ff; int mode = (imode | imode << 8) & 0x1ff;
...@@ -2232,9 +2189,41 @@ public class TexturedModel { ...@@ -2232,9 +2189,41 @@ public class TexturedModel {
} }
return alpha; return alpha;
} }
public static void generateFgAlphas(
final boolean [][] texture_en, // non-transparent texture pixels
final double [][] alphas, // or null will be updated
final int edge, // now should be 2 or 1
final double border_alpha, // alpha along the border
final int width,
final int transform_size){
final int num_slices = texture_en.length;
final int img_size = texture_en[0].length;
final TileNeibs pn = new TileNeibs(width, img_size/width);
final Thread[] threads = ImageDtt.newThreadArray(THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nslice = ai.getAndIncrement(); nslice < texture_en.length; nslice = ai.getAndIncrement()) {
boolean [] texture_edge=pn.getEdgeSelection(
edge, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
texture_en[nslice], // boolean [] tiles,
null); // boolean [] prohibit);
for (int i = 0; i < texture_en[nslice].length; i++) {
if (texture_en[nslice][i]){
alphas[nslice][i] *= texture_edge[i] ? border_alpha : 1.0;
} else {
alphas[nslice][i] = 0.0;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
public static double [][] processTexture( public static double [][][] processTexture(
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final int tilesX, final int tilesX,
final double [][] slice_disparities, final double [][] slice_disparities,
...@@ -2257,6 +2246,9 @@ public class TexturedModel { ...@@ -2257,6 +2246,9 @@ public class TexturedModel {
final int trim_shrink = 2; final int trim_shrink = 2;
final int trim_edge = 5; // trim FG edges - pixels from edge if tile center has no texture (2 for 1pix with diagonal) final int trim_edge = 5; // trim FG edges - pixels from edge if tile center has no texture (2 for 1pix with diagonal)
final int trim_edge_center = 2; // required number of texture pixels in the 2x2 tile center to keep edge final int trim_edge_center = 2; // required number of texture pixels in the 2x2 tile center to keep edge
final int edge_transparent = 2;
final double edge_weight = 0.7;
final int num_slices = sensor_texture.length; final int num_slices = sensor_texture.length;
final int transform_size = clt_parameters.transform_size; final int transform_size = clt_parameters.transform_size;
final int width = tilesX * transform_size; final int width = tilesX * transform_size;
...@@ -2267,7 +2259,7 @@ public class TexturedModel { ...@@ -2267,7 +2259,7 @@ public class TexturedModel {
(combo_texture_in != null) ? (combo_texture_in != null) ?
combo_texture_in : combo_texture_in :
getComboTexture (sensor_texture); getComboTexture (sensor_texture);
double [][][] dbg_out = (dbg_prefix != null) ? new double [5][][] : null; double [][][] dbg_out = (dbg_prefix != null) ? new double [6][][] : null;
boolean [][][] dbg_bool = (dbg_prefix != null) ? new boolean [4][][] : null; boolean [][][] dbg_bool = (dbg_prefix != null) ? new boolean [4][][] : null;
...@@ -2336,6 +2328,9 @@ public class TexturedModel { ...@@ -2336,6 +2328,9 @@ public class TexturedModel {
trim_shrink, // final int shrink, trim_shrink, // final int shrink,
width); // final int width) width); // final int width)
if (dbg_bool != null) dbg_bool[3] = copyTexture(texture_fg_filt); // filter by size if (dbg_bool != null) dbg_bool[3] = copyTexture(texture_fg_filt); // filter by size
// TODO: Create BG generation using FG textures and predicting occlusions
double [][] out_textures = processBgOcclusions( double [][] out_textures = processBgOcclusions(
sensor_texture, // final double [][][] sensor_texture, sensor_texture, // final double [][][] sensor_texture,
gcombo_texture, // final double [][] combo_texture, gcombo_texture, // final double [][] combo_texture,
...@@ -2359,10 +2354,20 @@ public class TexturedModel { ...@@ -2359,10 +2354,20 @@ public class TexturedModel {
out_textures); // final double [][] combo_texture // will be modified - NaN where not selected out_textures); // final double [][] combo_texture // will be modified - NaN where not selected
*/ */
double [][] tile_alpha = generateTileAlphas( double [][] alphas = generateTileAlphas(
fg_has_bg[2], // boolean [][] texture_tiles, fg_has_bg[2], // boolean [][] texture_tiles,
width, // int width, width, // int width,
transform_size); // int transform_size) transform_size); // int transform_size)
if (dbg_out != null) dbg_out[5] = copyTexture(alphas); // alpha after tile borders
generateFgAlphas(
texture_fg_filt, // final boolean [][] texture_en, // non-transparent texture pixels
alphas, // final double [][] alphas, // or null will be updated
edge_transparent, // final int edge, // now should be 2 or 1
edge_weight, // final double border_alpha, // alpha along the border
width, // final int width,
transform_size); // final int transform_size)
if (dbg_prefix != null) { if (dbg_prefix != null) {
...@@ -2372,7 +2377,6 @@ public class TexturedModel { ...@@ -2372,7 +2377,6 @@ public class TexturedModel {
final double [][] dbg_fg_prefiltered = dbgBooleanTexture (dbg_bool[1], -1000, 1000); final double [][] dbg_fg_prefiltered = dbgBooleanTexture (dbg_bool[1], -1000, 1000);
final double [][] dbg_fg_prefiltered_neibs = dbgBooleanTexture (dbg_bool[2], -1000, 1000); final double [][] dbg_fg_prefiltered_neibs = dbgBooleanTexture (dbg_bool[2], -1000, 1000);
// final double [][] dbg_fg_filtered = dbgBooleanTexture (dbg_bool[3], -1000, 1000);
final double [][] tdbg_is_fg = dbgBooleanTexture (fg_has_bg[1], fg_has_bg[0], 0,1,2,3); final double [][] tdbg_is_fg = dbgBooleanTexture (fg_has_bg[1], fg_has_bg[0], 0,1,2,3);
final double [][] gdbg_is_fg = new double [tdbg_is_fg.length][width*height]; final double [][] gdbg_is_fg = new double [tdbg_is_fg.length][width*height];
...@@ -2418,10 +2422,10 @@ public class TexturedModel { ...@@ -2418,10 +2422,10 @@ public class TexturedModel {
gtext_fg_filt[nslice], //dbg_fg_filtered[nslice], gtext_fg_filt[nslice], //dbg_fg_filtered[nslice],
gdbg_is_fg[nslice], gdbg_is_fg[nslice],
gcombo_texture[nslice], gcombo_texture[nslice],
// gtext_fg_filt[nslice], // ??
out_textures [nslice], // dirs_avg, out_textures [nslice], // dirs_avg,
dbg_out_textures[nslice], dbg_out_textures[nslice],
tile_alpha[nslice], dbg_out[5][nslice],
alphas[nslice],
sensor_texture[nslice][ 0], sensor_texture[nslice][ 0],
sensor_texture[nslice][ 1], sensor_texture[nslice][ 1],
sensor_texture[nslice][ 2], sensor_texture[nslice][ 2],
...@@ -2456,10 +2460,10 @@ public class TexturedModel { ...@@ -2456,10 +2460,10 @@ public class TexturedModel {
"TEXTURE_FG_FILTERED", "TEXTURE_FG_FILTERED",
"IS_FG", "IS_FG",
"COMBO_TEXTURE", "COMBO_TEXTURE",
// "FG_FILTERED_TEXTURE",
"OUT_TEXTURE_BG", "OUT_TEXTURE_BG",
"OUT_TEXTURE_FG", "OUT_TEXTURE_FG",
"TILE_ALPHA", "TILE_ALPHA",
"TEXTURE_ALPHA",
"T00", "T00",
"T01", "T01",
"T02", "T02",
...@@ -2490,22 +2494,25 @@ public class TexturedModel { ...@@ -2490,22 +2494,25 @@ public class TexturedModel {
width, width,
height, height,
true, true,
dbg_prefix+"-out_textures-" dbg_prefix+"-out_textures"
);
ShowDoubleFloatArrays.showArrays(
alphas,
width,
height,
true,
dbg_prefix+"-alphas"
); );
} }
double [][] alpha_templates = generateAlphaTemplates(
transform_size, // final int transform_size,
(dbg_prefix != null)); // boolean debug)
return out_textures; // need overall alpha. What about colors? double [][][] textures_alphas = new double [num_slices][][];
for (int nslice = 0; nslice < num_slices; nslice++) {
textures_alphas[nslice] = new double [][] {out_textures[nslice], alphas[nslice]};
}
return textures_alphas; // What about colors?
} }
public static ImagePlus[] getInterCombinedTexturesNew( // return ImagePlus[] matching tileClusters[], with alpha public static ImagePlus[] getInterCombinedTexturesNew( // return ImagePlus[] matching tileClusters[], with alpha
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -2623,9 +2630,6 @@ public class TexturedModel { ...@@ -2623,9 +2630,6 @@ public class TexturedModel {
double [][] dxyzatr_dt = null; double [][] dxyzatr_dt = null;
// should get velocities from HashMap at reference scene from timestamp , not re-calculate. // should get velocities from HashMap at reference scene from timestamp , not re-calculate.
if (mb_en) { // all scenes have the same name/path if (mb_en) { // all scenes have the same name/path
// dxyzatr_dt = OpticalFlow.getVelocities( // looks at previous/next scene poses
// scenes, // QuadCLT [] quadCLTs,
// nscene); // int nscene)
dxyzatr_dt = new double[][] { // for all, including ref dxyzatr_dt = new double[][] { // for all, including ref
scenes[nscene].getErsCorrection().getErsXYZ_dt(), scenes[nscene].getErsCorrection().getErsXYZ_dt(),
scenes[nscene].getErsCorrection().getErsATR_dt()}; scenes[nscene].getErsCorrection().getErsATR_dt()};
...@@ -2697,13 +2701,11 @@ public class TexturedModel { ...@@ -2697,13 +2701,11 @@ public class TexturedModel {
inter_weights[fnslice][tileY][tileX] +=w; inter_weights[fnslice][tileY][tileX] +=w;
if (inter_textures_wd[fnslice][tileY][tileX] == null) { // create if it did not exist if (inter_textures_wd[fnslice][tileY][tileX] == null) { // create if it did not exist
inter_textures_wd[fnslice][tileY][tileX] = new double [slice_texture88[tileY][tileX].length + num_colors][slice_texture88[tileY][tileX][0].length]; inter_textures_wd[fnslice][tileY][tileX] = new double [slice_texture88[tileY][tileX].length + num_colors][slice_texture88[tileY][tileX][0].length];
/// inter_textures_wd2[fnslice][tileY][tileX] = new double [slice_texture88[tileY][tileX].length + num_colors][slice_texture88[tileY][tileX][0].length];
} }
for (int nchn = 0; nchn < slice_texture88[tileY][tileX].length; nchn++) { for (int nchn = 0; nchn < slice_texture88[tileY][tileX].length; nchn++) {
for (int i = 0; i < slice_texture88[tileY][tileX][nchn].length; i++) { for (int i = 0; i < slice_texture88[tileY][tileX][nchn].length; i++) {
double d = slice_texture88[tileY][tileX][nchn][i]; double d = slice_texture88[tileY][tileX][nchn][i];
inter_textures_wd [fnslice][tileY][tileX][nchn][i] += w * d; inter_textures_wd [fnslice][tileY][tileX][nchn][i] += w * d;
/// inter_textures_wd2[fnslice][tileY][tileX][nchn][i] += w * d *d;
} }
} }
} }
...@@ -2714,7 +2716,7 @@ public class TexturedModel { ...@@ -2714,7 +2716,7 @@ public class TexturedModel {
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
} }
if (debug_level > -2) { // -1 if (debug_level > -1) { // -2
if (nscene == ref_index) { if (nscene == ref_index) {
System.out.println("Textures from the reference scene, nslice = " + nslice +((slice_texture88 == null)? " - EMPTY":"")); System.out.println("Textures from the reference scene, nslice = " + nslice +((slice_texture88 == null)? " - EMPTY":""));
} else { } else {
...@@ -2724,7 +2726,7 @@ public class TexturedModel { ...@@ -2724,7 +2726,7 @@ public class TexturedModel {
} // for (int nslice = 0; nslice < num_slices; nslice++) { } // for (int nslice = 0; nslice < num_slices; nslice++) {
} // for (int nscene = 0; nscene < num_scenes; nscene++) { } // for (int nscene = 0; nscene < num_scenes; nscene++) {
// Divide accumulated data by weights // Divide accumulated data by weights
double [][][] faded_textures = new double [num_slices][][]; /// double [][][] faded_textures = new double [num_slices][][];
final double [][] dbg_weights = (debug_level > 0 )?(new double [num_slices][tiles]) : null; final double [][] dbg_weights = (debug_level > 0 )?(new double [num_slices][tiles]) : null;
final double [][] dbg_overlap = (debug_level > 0 )?(new double [num_slices*(num_colors+1)][]) : null; final double [][] dbg_overlap = (debug_level > 0 )?(new double [num_slices*(num_colors+1)][]) : null;
final int width = tilesX * transform_size; final int width = tilesX * transform_size;
...@@ -2743,8 +2745,6 @@ public class TexturedModel { ...@@ -2743,8 +2745,6 @@ public class TexturedModel {
if (dbg_weights != null) { if (dbg_weights != null) {
Arrays.fill(dbg_weights[nslice], Double.NaN); Arrays.fill(dbg_weights[nslice], Double.NaN);
} }
// final Thread[] threads = ImageDtt.newThreadArray(THREADS_MAX);
// final AtomicInteger ai = new AtomicInteger(0);
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
...@@ -2760,21 +2760,16 @@ public class TexturedModel { ...@@ -2760,21 +2760,16 @@ public class TexturedModel {
for (int nchn = 0; nchn < inter_textures_wd[fnslice][tileY][tileX].length - num_colors; nchn++) { for (int nchn = 0; nchn < inter_textures_wd[fnslice][tileY][tileX].length - num_colors; nchn++) {
for (int i = 0; i < inter_textures_wd[fnslice][tileY][tileX][nchn].length; i++) { for (int i = 0; i < inter_textures_wd[fnslice][tileY][tileX][nchn].length; i++) {
double d = inter_textures_wd[fnslice][tileY][tileX][nchn][i] * w; // average double d = inter_textures_wd[fnslice][tileY][tileX][nchn][i] * w; // average
/// double d2= inter_textures_wd2[fnslice][tileY][tileX][nchn][i] * w; // average of squared
inter_textures_wd[fnslice][tileY][tileX][nchn][i] = d; inter_textures_wd[fnslice][tileY][tileX][nchn][i] = d;
/// inter_textures_wd2[fnslice][tileY][tileX][nchn][i] = Math.sqrt(d2- d * d);
} }
} }
for (int ncol = 0; ncol < num_colors; ncol++) { for (int ncol = 0; ncol < num_colors; ncol++) {
int navg = inter_textures_wd[fnslice][tileY][tileX].length - num_colors + ncol; int navg = inter_textures_wd[fnslice][tileY][tileX].length - num_colors + ncol;
for (int i = 0; i < tile_len; i++) { for (int i = 0; i < tile_len; i++) {
inter_textures_wd[fnslice][tileY][tileX][navg][i] = 0; inter_textures_wd[fnslice][tileY][tileX][navg][i] = 0;
/// inter_textures_wd2[fnslice][tileY][tileX][navg][i] = 0;
for (int nsens = 0; nsens < num_sensors; nsens++) { for (int nsens = 0; nsens < num_sensors; nsens++) {
inter_textures_wd[fnslice][tileY][tileX][navg][i] += inter_textures_wd[fnslice][tileY][tileX][navg][i] +=
inter_textures_wd[fnslice][tileY][tileX][1 + (nsens + 1) * num_colors][i]/num_sensors; inter_textures_wd[fnslice][tileY][tileX][1 + (nsens + 1) * num_colors][i]/num_sensors;
/// inter_textures_wd2[fnslice][tileY][tileX][navg][i] +=
/// inter_textures_wd2[fnslice][tileY][tileX][1 + (nsens + 1) * num_colors][i]/num_sensors;
} }
} }
} }
...@@ -2812,19 +2807,17 @@ public class TexturedModel { ...@@ -2812,19 +2807,17 @@ public class TexturedModel {
slice_disparities[nslice] = tileClusters[nslice].getDisparity(); // disparity in the reference view tiles (Double.NaN - invalid) slice_disparities[nslice] = tileClusters[nslice].getDisparity(); // disparity in the reference view tiles (Double.NaN - invalid)
} }
double [][] processed_textures = processTexture( double [][][] faded_textures = processTexture( //[slice]{texture, alpha}
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
tilesX, // final int tilesX, tilesX, // final int tilesX,
slice_disparities, // final double [][] slice_disparities, slice_disparities, // final double [][] slice_disparities,
sensor_textures, // final double [][] sensor_texture, // per-sensor texture value sensor_textures, // final double [][] sensor_texture, // per-sensor texture value
null, // combo_textures, // null, // final double [] combo_texture_in, // average texture value null, // combo_textures, // null, // final double [] combo_texture_in, // average texture value
ref_scene.getImageName()); // final String dbg_prefix); ref_scene.getImageName()); // null); // ref_scene.getImageName()); // final String dbg_prefix);
if (debug_level > -1000) { // if (debug_level > -1000) {
return null; // return null;
} // }
if (debug_level > -1) { if (debug_level > -1) {
double [][] dbg_textures = new double [faded_textures.length * faded_textures[0].length][faded_textures[0][0].length]; double [][] dbg_textures = new double [faded_textures.length * faded_textures[0].length][faded_textures[0][0].length];
...@@ -2849,10 +2842,40 @@ public class TexturedModel { ...@@ -2849,10 +2842,40 @@ public class TexturedModel {
} }
if (debug_level > -100) { for (int nslice = 0; nslice < faded_textures.length; nslice++) {
return null; faded_textures[nslice][0] = TileProcessor.fillNaNs(
faded_textures[nslice][0], // final double [] data,
width, // int width,
16, // final int grow,
0.7, // double diagonal_weight, // relative to ortho
100, // int num_passes,
THREADS_MAX); // final int threadsMax) // maximal number of threads to launch
} }
if (debug_level > -1) {
double [][] dbg_textures = new double [faded_textures.length * faded_textures[0].length][faded_textures[0][0].length];
String [] dbg_titles = new String[dbg_textures.length];
String [] dbg_subtitles = new String [faded_textures[0].length];
for (int i = 0; i < dbg_subtitles.length; i++) {
dbg_subtitles[i] = (i < (dbg_subtitles.length -1)) ? ("Y"+i):"alpha";
}
for (int i = 0; i < dbg_textures.length; i++) {
dbg_textures[i] = faded_textures[i / faded_textures[0].length][i % faded_textures[0].length];
dbg_titles[i] = dbg_subtitles[i % dbg_subtitles.length] + "-" + (i / dbg_subtitles.length);
}
ShowDoubleFloatArrays.showArrays(
dbg_textures,
tilesX * transform_size,
tilesY * transform_size,
true,
ref_scene.getImageName()+"-combined_textures-filled-NaNs",
dbg_titles);
}
// Optionally apply UM (before auto/manual range) // Optionally apply UM (before auto/manual range)
if (tex_um) { if (tex_um) {
......
...@@ -343,170 +343,82 @@ public class LwirWorld { ...@@ -343,170 +343,82 @@ public class LwirWorld {
} }
// perform photometric here, after first DSI // perform photometric here, after first DSI
boolean ran_photo_each = false;
if (photo_each && (!quadCLTs[ref_index].isPhotometricThis() || !batch_mode)) { if (photo_each && (!quadCLTs[ref_index].isPhotometricThis() || !batch_mode)) {
if (debugLevel > -3) { // if (debugLevel > -3) {
System.out.println("**** Running photometric equalization for "+quadCLTs[ref_index].getImageName()+ // System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+
", current was from scene "+quadCLTs[ref_index].getPhotometricScene()+" ****"); // ", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****");
} // }
OpticalFlow.photoEach(
// preparing same format as after combo, filling in only needed data clt_parameters, // CLTParameters clt_parameters,
double [][] ds_photo = new double[TwoQuadCLT.DSI_LENGTH][]; colorProcParameters, // ColorProcParameters colorProcParameters,
ds_photo[OpticalFlow.COMBO_DSN_INDX_DISP] = dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA]; quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
ds_photo[OpticalFlow.COMBO_DSN_INDX_DISP_BG_ALL] = dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA]; quadCLTs[ref_index], // QuadCLT quadCLT_ref, // tiles should be set
ds_photo[OpticalFlow.COMBO_DSN_INDX_STRENGTH] = dsi[TwoQuadCLT.DSI_STRENGTH_AUX]; dsi, // final double [][] dsi,
clt_parameters.photo_num_full, // int photo_num_full =
boolean photo_each_debug = !batch_mode; // false; // true; // false; batch_mode, // final boolean batch_mode,
boolean photo_each_debug2 = !batch_mode; // false; // true; // false; MultiThreading.THREADS_MAX, // threadsMax,
for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) { // maybe need to correct just offsets? updateStatus, // final boolean updateStatus,
int poly_order = photo_order; debugLevel); // final int debugLevel)
if ((poly_order > 1) && (nrecalib == 0)) { ran_photo_each = true; // will need to re-run after blue sky detection
poly_order = 1;
}
boolean ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
quadCLTs[ref_index], // final QuadCLT ref_scene, will set photometric calibration to this scene
photo_min_strength, // final double min_strength,
photo_max_diff, // final double max_diff, // 30.0
poly_order, // final int photo_order, // 0 - offset only, 1 - linear, 2 - quadratic
photo_std_1, // final double photo_std_1, // 50.0; // Minimal standard deviation of the filtered values for poly order 1
photo_std_2, // final double photo_std_2, // 200.0; // Minimal standard deviation of the filtered values for poly order 2
photo_offs_set, // final int photo_offs_set,// 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels
ds_photo, // combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
MultiThreading.THREADS_MAX, // threadsMax,
photo_each_debug); //final boolean debug)
if (!ok) {
System.out.println("************** Failed calibratePhotometric2, restoring original");
quadCLTs[ref_index].setLwirOffsets(quadCLT_main.getLwirOffsets());
quadCLTs[ref_index].setLwirScales (quadCLT_main.getLwirScales ());
quadCLTs[ref_index].setLwirScales2(quadCLT_main.getLwirScales2());
quadCLTs[ref_index].setPhotometricScene(quadCLT_main.getPhotometricScene());
// Retry linear only
QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
quadCLTs[ref_index], // final QuadCLT ref_scene, will set photometric calibration to this scene
photo_min_strength, // final double min_strength,
photo_max_diff, // final double max_diff, // 30.0
1, // poly_order, // final int photo_order, // 0 - offset only, 1 - linear, 2 - quadratic
photo_std_1, // final double photo_std_1, // 50.0; // Minimal standard deviation of the filtered values for poly order 1
photo_std_2, // final double photo_std_2, // 200.0; // Minimal standard deviation of the filtered values for poly order 2
photo_offs_set, // final int photo_offs_set,// 0; // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
photo_offs, // final double photo_offs, // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
photo_num_refines, // final int num_refines, // 2
photo_min_good, // final int min_good, // minimal number of "good" pixels
ds_photo, // combo_dsn_final_filtered, // final double [][] combo_dsn_final, // double [][] combo_dsn_final, // dls,
MultiThreading.THREADS_MAX, // threadsMax,
photo_each_debug); //final boolean debug)
}
// copy offsets to the current to be saved with other properties. Is it correct/needed?
quadCLTs[ref_index].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1);
quadCLTs[ref_index].setDSI(dsi); // try to avoid saving, will complain on restoring, but keep
// Re-read reference and other scenes using new offsets
quadCLTs[ref_index].setQuadClt(); // should work even when the data is new for the same scene
quadCLTs[ref_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_channels[ref_index].set_name,
clt_parameters,
colorProcParameters, //
MultiThreading.THREADS_MAX, // threadsMax,
debugLevel);
// Re-measure and update (is it needed?)
CLTPass3d scan = new CLTPass3d(quadCLTs[ref_index].tp);
scan.setTileOpDisparity(dsi[TwoQuadCLT.DSI_DISPARITY_AUX]);
quadCLTs[ref_index].setQuadClt(); // just in case ?
quadCLTs[ref_index].CLTMeas( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scan, // final CLTPass3d scan,
false, // final boolean save_textures,
false, // final boolean need_diffs, // calculate diffs even if textures are not needed
0, // final int clust_radius,
true, // final boolean save_corr,
true, // false, // final boolean run_lma, // = true;
0.0, // final double max_chn_diff, // filter correlation results by maximum difference between channels
-1.0, // final double mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
MultiThreading.THREADS_MAX, // threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel-2); // final int debugLevel);
double [][] aux_new_scan = TileProcessor.getDSLMA(
scan,
false); // boolean force_final);
dsi[TwoQuadCLT.DSI_DISPARITY_AUX] = aux_new_scan[0]; // compare diffs
dsi[TwoQuadCLT.DSI_STRENGTH_AUX] = aux_new_scan[1];
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA] = aux_new_scan[2];
// Re-measure and update from BG spread and average in dsi
CLTPass3d bgscan = new CLTPass3d(quadCLTs[ref_index].tp);
bgscan.setTileOpDisparity(null);
quadCLTs[ref_index].setQuadClt(); // just in case ?
quadCLTs[ref_index].CLTMeas( // perform single pass according to prepared tiles operations and disparity
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
bgscan, // final CLTPass3d scan,
true, // false, // final boolean save_textures,
true, // false, // final boolean need_diffs, // calculate diffs even if textures are not needed
0, // final int clust_radius,
true, // final boolean save_corr, IS IT NEEDED?
false, // final boolean run_lma, // = true;
0.0, // final double max_chn_diff, // filter correlation results by maximum difference between channels
-1.0, // final double mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
MultiThreading.THREADS_MAX, // threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel-2); // final int debugLevel);
if (photo_each_debug2) {
quadCLTs[ref_index].tp.showScan(bgscan, quadCLTs[ref_index].getImageName()+"-bgscan-"+nrecalib); // nrecalib
quadCLTs[ref_index].tp.showScan(scan, quadCLTs[ref_index].getImageName()+"-scan-"+nrecalib);
}
dsi[TwoQuadCLT.DSI_SPREAD_AUX] = bgscan.getSecondMax(); // //aux_bg_scan[3];
dsi[TwoQuadCLT.DSI_AVGVAL_AUX] = bgscan.getAvgVal(); //aux_bg_scan[4];
quadCLTs[ref_index].setDSI(dsi); // Restore known dsi
quadCLTs[ref_index].setBlueSky(ref_blue_sky);
quadCLTs[ref_index].setDSRBG(
clt_parameters, // CLTParameters clt_parameters,
MultiThreading.THREADS_MAX, // threadsMax,
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
} else { } else {
System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLTs[ref_index].getPhotometricScene()); System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLTs[ref_index].getPhotometricScene());
quadCLTs[ref_index].setQuadClt(); // just in case ? quadCLTs[ref_index].setQuadClt(); // just in case ?
} }
quadCLTs[ref_index].setBlueSky (
boolean retry=false; sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this
while (true) { lma_seed,
quadCLTs[ref_index].setBlueSky ( sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this
sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this sky_shrink, // int sky_shrink, // = 4;
lma_seed, sky_expand_extra, // int sky_expand_extra, // = 100; // 1?
sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this sky_bottleneck, //int sky_bottleneck, //
sky_shrink, // int sky_shrink, // = 4; cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence
sky_expand_extra, // int sky_expand_extra, // = 100; // 1? cold_frac, // = 0.005; // this and lower will scale fom by cold_scale
sky_bottleneck, //int sky_bottleneck, // hot_frac, // = 0.9; // this and above will scale fom by 1.0
cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence min_strength, // = 0.08;
cold_frac, // = 0.005; // this and lower will scale fom by cold_scale seed_rows, // = 5; // sky should appear in this top rows
hot_frac, // = 0.9; // this and above will scale fom by 1.0 lowest_sky_row, // = 50;// appears that low - invalid, remove completely
min_strength, // = 0.08; sky_bottom_override, // double sky_temp_override, // really cold average seed - ignore lowest_sky_row filter
seed_rows, // = 5; // sky should appear in this top rows sky_override_shrink, // int shrink_for_temp, // shrink before finding hottest sky
lowest_sky_row, // = 50;// appears that low - invalid, remove completely sky_highest_min, // = 100; // lowest absolute value should not be higher (requires photometric)
sky_bottom_override, // double sky_temp_override, // really cold average seed - ignore lowest_sky_row filter disp_boost_min, // double disp_boost_min, // = 0.5;
sky_override_shrink, // int shrink_for_temp, // shrink before finding hottest sky disp_boost_diff, //double disp_boost_diff, // = 0.35;
sky_highest_min, // = 100; // lowest absolute value should not be higher (requires photometric) disp_boost_neibs, //int disp_boost_neibs, // = 2;
disp_boost_min, // double disp_boost_min, // = 0.5; disp_boost_amount, //double disp_boost_amount, // = 2.0;
disp_boost_diff, //double disp_boost_diff, // = 0.35; dsi[TwoQuadCLT.DSI_STRENGTH_AUX], // double [] strength,
disp_boost_neibs, //int disp_boost_neibs, // = 2; dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread,
disp_boost_amount, //double disp_boost_amount, // = 2.0; dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread,
dsi[TwoQuadCLT.DSI_STRENGTH_AUX], // double [] strength, dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val,
dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread, batch_mode? -1: 1); /// debugLevel); // int debugLevel)
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread, if (ran_photo_each) {
dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val, quadCLTs[ref_index].setBlueSky(null); // Reset blue sky - is it needed?
batch_mode? -1: 1); /// debugLevel); // int debugLevel) // see if blue sky was detected - rerun photoEach
if (!retry) { boolean [] blue_sky = quadCLTs[ref_index].getBlueSky();
boolean has_blue_sky = false;
for (int i = 0; i < blue_sky.length; i++) if (blue_sky[i]) {
has_blue_sky = true;
break; break;
} }
if (has_blue_sky) {
if (debugLevel > -3) {
System.out.println("Detected non-empty Blue Sky after initial DSI in "+quadCLTs[ref_index].getImageName()+
", re-running photoEach()");
}
OpticalFlow.photoEach(
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLTs[ref_index], // QuadCLT quadCLT_ref, // tiles should be set
dsi, // final double [][] dsi,
// just once?
clt_parameters.photo_num_full, // int photo_num_full =
batch_mode, // final boolean batch_mode,
MultiThreading.THREADS_MAX, // threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
}
} }
quadCLTs[ref_index].saveDSIAll ( quadCLTs[ref_index].saveDSIAll (
"-DSI_MAIN", // String suffix, // "-DSI_MAIN" "-DSI_MAIN", // String suffix, // "-DSI_MAIN"
......
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