Commit b063bc39 authored by Andrey Filippov's avatar Andrey Filippov

implemented disparity-> Z (not distance) conversion and output in the

final Tiff/video
parent f531219b
......@@ -62,7 +62,11 @@ public class CuasMotion {
final static public int TARGET_SCORE = 7;
final static public int TARGET_SEQLEN = 8;
final static public int TARGET_TRAVEL = 9;
final static public int TARGET_NTILE = 10;
final static public int TARGET_DISPARITY = 10;
final static public int TARGET_DISP_DIFF = 11;
final static public int TARGET_DISP_STR = 12;
final static public int TARGET_RANGE = 13;
final static public int TARGET_NTILE = 14;
final static public int TARGET_LENGTH = TARGET_NTILE+1;
final static public int IMPORTANCE_A = 0;
......@@ -3182,6 +3186,13 @@ public class CuasMotion {
targets_data[nTarget][TARGET_SEQLEN] = target[CuasMotionLMA.RSLT_MATCH_LENGTH];
targets_data[nTarget][TARGET_TRAVEL] = target[CuasMotionLMA.RSLT_SEQ_TRAVEL];
targets_data[nTarget][TARGET_DISPARITY] = target[CuasMotionLMA.RSLT_DISPARITY];
targets_data[nTarget][TARGET_DISP_STR] = target[CuasMotionLMA.RSLT_DISP_STR];
targets_data[nTarget][TARGET_DISP_DIFF] = target[CuasMotionLMA.RSLT_DISP_DIFF];
targets_data[nTarget][TARGET_RANGE] = target[CuasMotionLMA.RSLT_RANGE];
int pxl = (int) Math.round(targets_data[nTarget][TARGET_X]) - offs;
int pyt = (int) Math.round(targets_data[nTarget][TARGET_Y]) - offs;
......@@ -3718,6 +3729,10 @@ public class CuasMotion {
final float [][] fpixels,
final double [][][] targets60hz,
final boolean change_color,
final boolean show_disp, // true; // Show disparity (corrected) near target (*** not in clean***)
final boolean show_rng, // true; // Show distance to target (range) in meters
final boolean show_inf, // true; // Show distance greater than max (or negativce) as infinity
final boolean show_inf_gt, // false; // Use ">max" instead of infinity symbol
final boolean show_true_rng,// show true range (from the flight log)
final boolean show_mismatch,
final boolean show_score,
......@@ -3814,11 +3829,18 @@ public class CuasMotion {
final boolean annotate = clt_parameters.imp.cuas_annotate;
final Color text_color = clt_parameters.imp.cuas_text_color;
final Color text_bg_color = clt_parameters.imp.cuas_text_bg;
final Color selected_color = clt_parameters.imp.cuas_selected_color;
final boolean transparent_other = clt_parameters.imp.cuas_transparent;
final boolean transparent_uas = clt_parameters.imp.cuas_transparent_uas;
final String font_name = clt_parameters.imp.cuas_font_name;
final int font_size = clt_parameters.imp.cuas_font_size;
final int font_type = clt_parameters.imp.cuas_font_type;
final int space_before_text = 2;
final double rng_limit = clt_parameters.imp.cuas_rng_limit;
......@@ -3927,7 +3949,7 @@ public class CuasMotion {
final int posY= height + scale * 1; // 513;
final Font font = new Font("Monospaced", Font.PLAIN, scale * 12);
final Font font_target = new Font(font_name, font_type, scale * font_size);
final boolean target_text_transparent = true;
// final boolean target_text_transparent = true;
final int nSlices = fstack_scenes.getSize();
if (annotate_mono) {
ai.set(0);
......@@ -4010,8 +4032,6 @@ public class CuasMotion {
}
}
}
// } else {
// System.out.println("uaslog_rgba == null");
}
double [][] targets = targets60hz[nscene];
......@@ -4021,9 +4041,6 @@ public class CuasMotion {
uas_pXpYDRange, // double [] uas_pXpYD,
known_err); // double max_dist)
for (int ntarget = 0; ntarget < targets.length; ntarget++) {
// if ((ntarget == matching_target) && (dscene == half_step0)) {
// System.out.println("ntarget == matching_target="+ntarget+", nscene="+nscene+", nSeq="+nSeq);
// }
int xc = (int) Math.round(scale * targets[ntarget][TARGET_X]);
int yc = (int) Math.round(scale * targets[ntarget][TARGET_Y]);
int icon_width = (ntarget == matching_target) ? detected_width : undetected_width;
......@@ -4069,29 +4086,48 @@ public class CuasMotion {
String txt = getTargetText(
clt_parameters, // CLTParameters clt_parameters,
targets[ntarget]); // double [] target);
/// int ntile = (int) targets[ntarget][TARGET_NTILE];
if (show_disp) {
double disparity = targets[ntarget][TARGET_DISPARITY];
txt += String.format("\nDISP%4.0f",disparity*1000); // avoid decimal point, show 1000 x disparity
}
double range = targets[ntarget][TARGET_RANGE];
if (show_rng && !Double.isNaN(range) && (range != 0.0)) { // NaN - undefined, 0.0 - undefined
if (show_inf || !Double.isInfinite(range)) {
if (Double.isInfinite(range)) {
if (show_inf_gt) {
txt += String.format("\nRNG>%4.0f",rng_limit);
} else {
txt += "\nRNG \u221E";
}
} else {
txt += String.format("\nRNG %4.0f",range);
}
}
}
// double [][] targets = targets60hz[nscene];
if (show_true_rng && (ntarget == matching_target)) {
// uas_pXpYDRange[3]
txt += String.format("\nTRNG%3.0f",uas_pXpYDRange[3]);
txt += String.format("\nTRNG%4.0f",uas_pXpYDRange[3]);
}
if (show_mismatch) {
txt += String.format("\nErr-%3.1f\nErr-%3.1f",
txt += String.format("\nErr %3.1f\nErr %3.1f",
targets[ntarget][TARGET_MISMATCH_BEFORE],targets[ntarget][TARGET_MISMATCH_AFTER]);
}
if (show_score) {
txt += String.format("\nSEQ-%3.1f\nTRV-%4.1f\n%5.3f",
txt += String.format("\nSEQ %3.1f\nTRV %4.1f\n%5.3f",
targets[ntarget][TARGET_SEQLEN],targets[ntarget][TARGET_TRAVEL], targets[ntarget][TARGET_SCORE]);
}
boolean sel_target = (ntarget == matching_target) && change_color;
ip.setColor(sel_target ? selected_color: text_color);
ip.setFont(font_target);
boolean target_text_transparent = (ntarget == matching_target) ? transparent_uas : transparent_other;
if (target_text_transparent) {
ip.drawString(txt, text_left, text_top); // transparent.
} else {
ip.drawString(txt, text_left, text_top, Color.BLACK); // on black background
ip.drawString(txt, text_left, text_top, text_bg_color); // solid color
}
}
}
......@@ -5628,25 +5664,38 @@ public class CuasMotion {
final double mask_blur = clt_parameters.imp.cuas_mask_blur; // 3;
final boolean mask_round = clt_parameters.imp.cuas_mask_round; // false;
int target_type = clt_parameters.imp.cuas_target_type; // 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
int known_type = clt_parameters.imp.cuas_known_type; // 2; // Target location matching UAS flight log: 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
double known_err = clt_parameters.imp.cuas_known_err; // 20; // Maximal distance between the detected target and UAS log position (in raw image pixels);
int target_type = clt_parameters.imp.cuas_target_type; // 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
int known_type = clt_parameters.imp.cuas_known_type; // 2; // Target location matching UAS flight log: 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
double known_err = clt_parameters.imp.cuas_known_err; // 20; // Maximal distance between the detected target and UAS log position (in raw image pixels);
double input_range = clt_parameters.imp.cuas_input_range; // 5;
boolean scale2x = clt_parameters.imp.cuas_scale2x; // true;
boolean ra_background = clt_parameters.imp.cuas_ra_background; // true;
boolean intermed_low = clt_parameters.imp.cuas_intermed_low; // true;
boolean intermed_high = clt_parameters.imp.cuas_intermed_high; // true;
boolean save_mono = clt_parameters.imp.cuas_save_mono; // true;
boolean save_color = clt_parameters.imp.cuas_save_color; // true;
boolean save_video = clt_parameters.imp.cuas_save_video; // true;
boolean target_debug = clt_parameters.imp.cuas_target_debug; // true;
boolean show_target_score = clt_parameters.imp.cuas_target_score; // false; // show target score and sequence length in the final video
boolean annotate_uas = clt_parameters.imp.cuas_annotate_uas; // false; // show circle around UAS position from the flight log
boolean show_target_color = clt_parameters.imp.cuas_target_color; // false; // show target score and sequence length in the final video
boolean show_disp = clt_parameters.imp.cuas_show_disp; // true; // Show disparity (corrected) near target (*** not in clean***)
boolean show_rng = clt_parameters.imp.cuas_show_rng; // true; // Show distance to target (range) in meters
boolean show_inf = clt_parameters.imp.cuas_show_inf; // true; // Show distance greater than max (or negativce) as infinity
boolean show_inf_gt = clt_parameters.imp.cuas_show_inf_gt; // false; // Use ">max" instead of infinity symbol
double input_range = clt_parameters.imp.cuas_input_range; // 5;
boolean scale2x = clt_parameters.imp.cuas_scale2x; //true;
boolean ra_background = clt_parameters.imp.cuas_ra_background; //true;
boolean intermed_low = clt_parameters.imp.cuas_intermed_low; //true;
boolean intermed_high = clt_parameters.imp.cuas_intermed_high; //true;
boolean save_mono = clt_parameters.imp.cuas_save_mono; //true;
boolean save_color = clt_parameters.imp.cuas_save_color; //true;
boolean save_video = clt_parameters.imp.cuas_save_video; //true;
boolean target_debug = clt_parameters.imp.cuas_target_debug; //true;
boolean show_target_score = clt_parameters.imp.cuas_target_score; // false; // show target score and sequence length ijn the final video
boolean annotate_uas = clt_parameters.imp.cuas_annotate_uas; // false; // show circle around UAS position from the flight log
boolean show_target_color = clt_parameters.imp.cuas_target_color; // false; // show target score and sequence length ijn the final video
boolean show_true_rng = clt_parameters.imp.cuas_show_true_rng; // show true range (from the flight log)
String clean_suffix = "";
if (clean_video) {
if (video_pass) {
......@@ -5656,6 +5705,7 @@ public class CuasMotion {
target_debug = false;
show_target_score = false;
show_target_color = false;
show_disp = false;
clean_suffix = "-CLEAN";
} else {
save_video = false;
......@@ -5774,6 +5824,10 @@ public class CuasMotion {
replaced_targets, // final float [][] fpixels,
targets60hz, // final double [][][] targets60hz,
show_target_color, // final boolean change_color,
show_disp, // final boolean show_disp, // true; // Show disparity (corrected) near target (*** not in clean***)
show_rng, // final boolean show_rng, // true; // Show distance to target (range) in meters
show_inf, // final boolean show_inf, // true; // Show distance greater than max (or negativce) as infinity
show_inf_gt, // final boolean show_inf_gt, // false; // Use ">max" instead of infinity symbol
show_true_rng, // final boolean show_true_rng,// show true range (from the flight log)
target_debug, // final boolean show_mismatch,
show_target_score, // final boolean show_score,
......@@ -10060,11 +10114,12 @@ public class CuasMotion {
double slow_ra = clt_parameters.imp.cuas_slow_ra;
double slow_score = clt_parameters.imp.cuas_slow_score;
boolean generate_output =clt_parameters.imp.cuas_generate; // generate and save targets Tiff and/or video files
boolean clean_video = clt_parameters.imp.cuas_clean_video; //true;// save video without any debug information for targets, output in TIFF files. False - same output for video and TIFFs
/// boolean generate_output =clt_parameters.imp.cuas_generate; // generate and save targets Tiff and/or video files
/// boolean clean_video = clt_parameters.imp.cuas_clean_video; //true;// save video without any debug information for targets, output in TIFF files. False - same output for video and TIFFs
boolean reuse_targets = clt_parameters.imp.cuas_reuse_targets; // true; // read previously calculated non-conflict (one per tile) targets
String reuse_path = clt_parameters.imp.cuas_reuse_path; // ""; // either suffix (all parameters the same) or the full path (contains "/")
double [][][] targets_nonconflict = null;
int seq_length = corr_offset + corr_pairs;
......@@ -10136,6 +10191,7 @@ public class CuasMotion {
}
setTargets(targets_nonconflict);
/*
if (generate_output) {
generateExtractFilterMovingTargets( // move parameters to clt_parameters
false, // final boolean video_pass, // if clt_parameters.cuas_clean_video=true, video_pass=0 - output TIFFS, but no video. If video_pass==1 - only video with no debug
......@@ -10155,6 +10211,7 @@ public class CuasMotion {
System.out.println("Output images/videos with detected targets is disabled by \"Generate and save detected targets\" parameter, skipping it.");
}
*/
return;
}
......
......@@ -87,8 +87,9 @@ public class CuasMotionLMA {
public static final int RSLT_WHEN = 42;
public static final int RSLT_FAIL = 43;
public static final int RSLT_DISPARITY=44;
public static final int RSLT_DISP_STR =45;
public static final int RSLT_RANGE = 46;
public static final int RSLT_DISP_DIFF=45;
public static final int RSLT_DISP_STR =46;
public static final int RSLT_RANGE = 47;
public static final int RSLT_LEN = RSLT_RANGE+1;
......@@ -107,7 +108,7 @@ public class CuasMotionLMA {
"*Q-AMPL","*Q-RMSE","*Q-RMSE/A","*Q-CENTER","*Q-MATCH","*Q-LENGTH","*QTRAVEL","*Q-SCORE",
"Stronger","Slow",
"WHEN", "FAILURE",
"Disparity","Strength","Range"};
"Disparity","Disparity-Diff","Strength","Range"};
public static final int FAIL_NONE = 0;
public static final int FAIL_MOTION = 1; // motion strength/fraction too low
......
......@@ -12,20 +12,24 @@ import com.elphel.imagej.gpu.TpTask;
import com.elphel.imagej.ims.UasLogReader;
import com.elphel.imagej.tileprocessor.Correlation2d;
import com.elphel.imagej.tileprocessor.ErsCorrection;
import com.elphel.imagej.tileprocessor.GeometryCorrection;
import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.ImageDttParameters;
import com.elphel.imagej.tileprocessor.OpticalFlow;
import com.elphel.imagej.tileprocessor.QuadCLT;
import ij.ImagePlus;
import ij.Prefs;
public class CuasRanging {
public static final String TARGET_RANGING_LOGS_SUFFIX = "-TARGET_RANGING.log";
public static final String TARGET_RANGING_LOGS_SUFFIX = "-TARGET_RANGING.log";
public static final String TARGET_RANGING_LOGS_FULL_SUFFIX = "-TARGET_RANGING_FULL.log";
public static final String TARGET_DISPARITIES_SUFFIX = "-TARGET_DISPARITIES";
final QuadCLT center_CLT;
final QuadCLT [] scenes;
final double [][][] img_um;
final CLTParameters clt_parameters;
CuasMotion cuasMotion = null;
public int debugLevel = 0;
......@@ -38,6 +42,7 @@ public class CuasRanging {
this.clt_parameters = clt_parameters;
this.center_CLT = center_CLT;
this.scenes = scenes;
this.img_um = new double [scenes.length][][];
}
public CuasMotion detectTargets(
......@@ -50,7 +55,7 @@ public class CuasRanging {
boolean mono_fixed = clt_parameters.imp.mono_fixed;
double mono_range = clt_parameters.imp.mono_range;
double rng_um_sigma = clt_parameters.imp.cuas_rng_um_sigma;
boolean rng_um_twice = clt_parameters.imp.cuas_rng_um2;
/// boolean rng_um_twice = clt_parameters.imp.cuas_rng_um2;
double rng_radius0 = clt_parameters.imp.cuas_rng_radius0;
double rng_radius = clt_parameters.imp.cuas_rng_radius;
double rng_blur = clt_parameters.imp.cuas_rng_blur;
......@@ -59,9 +64,17 @@ public class CuasRanging {
boolean rng_disp = clt_parameters.imp.cuas_rng_disp;
boolean rng_vfy = clt_parameters.imp.cuas_rng_vfy; // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
boolean reset_disparity = clt_parameters.imp.cuas_reset_disparity;
double cuas_initial_disparity=clt_parameters.imp.cuas_initial_disparity; // 1.0; // Start correlation with this disparity (in addition to infinity) after reset
double cuas_infinity = clt_parameters.imp.cuas_infinity ; // 0.63; // disparity at infinity for targets
boolean smooth_omegas = clt_parameters.imp.cuas_smooth_omegas;
boolean log_ranging = clt_parameters.imp.cuas_log_ranging; // true; // Log ranging iterations
/// int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
boolean reuse_disparity = clt_parameters.imp.cuas_reuse_disparity;
/// double rng_limit = clt_parameters.imp.cuas_rng_limit;
boolean generate_output = clt_parameters.imp.cuas_generate; // generate and save targets Tiff and/or video files
boolean clean_video = clt_parameters.imp.cuas_clean_video; //true;// save video without any debug information for targets, output in TIFF files. False - same output for video and TIFFs
double [][]combo_dsi = center_CLT.comboFromMain();
double [][] dls = {
......@@ -117,27 +130,11 @@ public class CuasRanging {
new String[] {"disp0","lma0", "str0", "disp","str","virt_disp", "virt_str"});
}
// float [] average_pixels = (center_CLT.getCenterAverage() != null) ? ((float []) center_CLT.getCenterAverage().getProcessor().getPixels()):null;
float [] average_pixels = (float []) center_CLT.getCenterAverage().getProcessor().getPixels();
float [][] average_channels = new float [][] {average_pixels}; // for future color images
double [] cuas_atr = OpticalFlow.ZERO3;
/*
boolean extract_center_orientation = false; // clt_parameters.imp.extract_center_orientation; // true; // false; // true;
double [][] center_ATR = null; // {{center_A, center_T, average_R},{radius_A, radius_T}}
if (extract_center_orientation && clt_parameters.imp.lock_position) {
// cuas_atr will be use for rendering combo images, the individual coordinate will be already image-based, not ims-based
center_ATR = CuasCenterLma.getCenterATR(
scenes, // QuadCLT [] quadCLTs,
scenes[ref_index], // QuadCLT ref_scene,ref_index, //int ref_index,
new int [] {earliest_scene, last_index}, // int [] range,
true, // boolean disable_AT_omegas,
debugLevel); // int debugLevel);
cuas_atr = new double [] { center_ATR[0][0], center_ATR[0][1], center_ATR[0][2]};
// Check omegas here !
System.out.println ("Omegas ATR: "+center_ATR[2][0]+", "+center_ATR[2][1]+", "+center_ATR[2][2]);
}
*/
String scenes_suffix = center_CLT.getImageName()+"-CUAS"; // "1747829900_781803-SEQ-FG-MONO-FPN";
ImagePlus imp_targets= OpticalFlow.renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
......@@ -208,66 +205,105 @@ public class CuasRanging {
uasLogReader, // UasLogReader uasLogReader,
debugLevel); // int debugLevel)
cuasMotion.processMovingTargetsMulti(
cuasMotion.processMovingTargetsMulti( // will remove rendering
batch_mode, // final boolean batch_mode,
fpixels, // final float [][] fpixels,
debugLevel); // final int debugLevel) {
double[][][] targets = cuasMotion.getTargets();
/// double [][][] extended_targets = CuasMotion.extendMotionScan(
/// targets, // final double [][][] motion_scan,
/// null, // filter5, // final boolean [][] filtered, // centers, should be non-overlapped
/// cuasMotion.getTilesX(), // final int tilesX)
/// 2, // final int range, // 1 or 2
/// null); // remain); // final int [] remain)
String model_prefix = center_CLT.getImageName()+CuasMotion.getParametersSuffix(clt_parameters,null);
if (rng_disp) {
if (debugLevel > -4) {
System.out.println("detectTargets(): Generating target disparities");
}
String model_prefix = center_CLT.getImageName()+CuasMotion.getParametersSuffix(clt_parameters,null);
if (reset_disparity) {
for (int nseq = 0; nseq < targets.length; nseq++) {
for (int ntile = 0; ntile < targets[nseq].length; ntile++) if (targets[nseq][ntile] != null) {
targets[nseq][ntile][CuasMotionLMA.RSLT_DISPARITY] = 0;
targets[nseq][ntile][CuasMotionLMA.RSLT_DISP_STR] = 0;
}
double [][][] disparity_targets = null;
if (reuse_disparity) {
String disparity_path = model_prefix+TARGET_DISPARITIES_SUFFIX; // may later be directly provided (e.g. select specific version)
if (disparity_path.indexOf(Prefs.getFileSeparator()) < 0) { // now always
String x3d_path = center_CLT.getX3dDirectory();
disparity_path = x3d_path + Prefs.getFileSeparator() + disparity_path+".tiff";
}
disparity_targets = CuasMotion.getTargetsFromHyperAugment(disparity_path);
if (disparity_targets == null) {
System.out.println("processMovingTargetsMulti(): FAILED TO READ TARGET DATA FROM "+disparity_path);
} else {
targets = disparity_targets;
System.out.println("processMovingTargetsMulti(): re-using target data from "+disparity_path);
}
}
if (smooth_omegas) {
if (disparity_targets == null) {
if (debugLevel > -4) {
System.out.println ("Recalculating omegas to better fit target positions in consecutive key frames.");
System.out.println("detectTargets(): Generating target disparities");
}
cuasMotion.recalcOmegas(
targets, // final double [][][] target_single_in,
batch_mode, // boolean batch_mode,
debugLevel); // final int debugLevel){
if (reset_disparity) {
for (int nseq = 0; nseq < targets.length; nseq++) {
for (int ntile = 0; ntile < targets[nseq].length; ntile++) if (targets[nseq][ntile] != null) {
targets[nseq][ntile][CuasMotionLMA.RSLT_DISPARITY] = cuas_initial_disparity + cuas_infinity; // 0;
targets[nseq][ntile][CuasMotionLMA.RSLT_DISP_STR] = 0;
}
}
}
if (smooth_omegas) {
if (debugLevel > -4) {
System.out.println ("Recalculating omegas to better fit target positions in consecutive key frames.");
}
cuasMotion.recalcOmegas(
targets, // final double [][][] target_single_in,
batch_mode, // boolean batch_mode,
debugLevel); // final int debugLevel){
} else {
if (debugLevel > -4) {
System.out.println ("Skipping omegas recalculation omegas.");
} else {
if (debugLevel > -4) {
System.out.println ("Skipping omegas recalculation omegas.");
}
}
// String model_prefix = center_CLT.getImageName()+CuasMotion.getParametersSuffix(clt_parameters,null);
rangeTargets(
targets, //final double [][][] targets, // centers
// rng_combine, // final int rng_combine,
log_ranging, // final boolean log_ranging,
rng_vfy, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
debugLevel); // final int debugLevel)
ImagePlus imp_new_scores = CuasMotion.showTargetSequence(
targets, // double [][][] vector_fields_sequence,
cuasMotion.getSliceTitles(), // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+TARGET_DISPARITIES_SUFFIX, // "-TARGET_DISPARITIES",// String title,
!batch_mode, // boolean show,
cuasMotion.getTilesX()); // int tilesX) {
center_CLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp)
}
}
// calculate range from disparity
getRangeFromDisparity(targets);
// generate results video (move from earlier)
if (generate_output) {
cuasMotion.generateExtractFilterMovingTargets( // move parameters to clt_parameters
false, // final boolean video_pass, // if clt_parameters.cuas_clean_video=true, video_pass=0 - output TIFFS, but no video. If video_pass==1 - only video with no debug
batch_mode, // final boolean batch_mode,
fpixels, // final float [][] fpixels,
targets, // _nonconflict, // final double [][][] vf_sequence, // center tiles (not extended), null /non-null only
debugLevel); // final int debugLevel)
if (clean_video) {
cuasMotion.generateExtractFilterMovingTargets( // move parameters to clt_parameters
true, // final boolean video_pass, // if clt_parameters.cuas_clean_video=true, video_pass=0 - output TIFFS, but no video. If video_pass==1 - only video with no debug
batch_mode, // final boolean batch_mode,
fpixels, // final float [][] fpixels,
targets, // _nonconflict, // final double [][][] vf_sequence, // center tiles (not extended), null /non-null only
debugLevel); // final int debugLevel)
}
} else {
System.out.println("Output images/videos with detected targets is disabled by \"Generate and save detected targets\" parameter, skipping it.");
rangeTargets(
targets, //final double [][][] targets, // centers
// rng_combine, // final int rng_combine,
log_ranging, // final boolean log_ranging,
rng_vfy, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
debugLevel); // final int debugLevel)
ImagePlus imp_new_scores = CuasMotion.showTargetSequence(
targets, // double [][][] vector_fields_sequence,
cuasMotion.getSliceTitles(), // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-TARGET_DISPARITIES",// String title,
!batch_mode, // boolean show,
cuasMotion.getTilesX()); // int tilesX) {
center_CLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp)
}
double [][][] extended_targets = CuasMotion.extendMotionScan(
targets, // final double [][][] motion_scan,
null, // filter5, // final boolean [][] filtered, // centers, should be non-overlapped
cuasMotion.getTilesX(), // final int tilesX)
2, // final int range, // 1 or 2
null); // remain); // final int [] remain)
if (rng_img) {
double [][][] extended_targets = CuasMotion.extendMotionScan(
targets, // final double [][][] motion_scan,
null, // filter5, // final boolean [][] filtered, // centers, should be non-overlapped
cuasMotion.getTilesX(), // final int tilesX)
2, // final int range, // 1 or 2
null); // remain); // final int [] remain)
if (debugLevel > -4) {
System.out.println("detectTargets(): Generating and saving per-sensor target images");
}
......@@ -295,6 +331,52 @@ public class CuasRanging {
return cuasMotion;
}
public void getRangeFromDisparity(
final double [][][] targets){
//clt_parameters.imp.
final double max_disp_diff = clt_parameters.imp.cuas_max_disp_diff; // 0.05; // Maximal disparity difference during last change to consider disparity valid
final double min_disp_str = clt_parameters.imp.cuas_min_disp_str; // 0.4; // Minimal disparity strength to consider disparity valid
final double rng_limit = clt_parameters.imp.cuas_rng_limit; // 5000; // Maximal displayed distance to target
final double cuas_infinity = clt_parameters.imp.cuas_infinity;
final GeometryCorrection gc = center_CLT.getGeometryCorrection();
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < targets.length; nSeq = ai.getAndIncrement()) {
for (int ntile = 0; ntile < targets[nSeq].length; ntile++) if (targets[nSeq][ntile] != null){
if (!Double.isNaN(targets[nSeq][ntile][CuasMotionLMA.RSLT_DISPARITY]) && (targets[nSeq][ntile][CuasMotionLMA.RSLT_DISPARITY] != 0.0)) {
double disparity = targets[nSeq][ntile][CuasMotionLMA.RSLT_DISPARITY] - cuas_infinity; // corrected disparity
double disparity_diff = targets[nSeq][ntile][CuasMotionLMA.RSLT_DISP_DIFF];
double strength = targets[nSeq][ntile][CuasMotionLMA.RSLT_DISP_STR];
if ((disparity_diff > max_disp_diff) || (strength < min_disp_str)) {
targets[nSeq][ntile][CuasMotionLMA.RSLT_RANGE] = Double.NaN;
} else if (disparity <= 0){
targets[nSeq][ntile][CuasMotionLMA.RSLT_RANGE] = Double.POSITIVE_INFINITY;
} else {
double z = gc.getZFromDisparity(disparity); // or should we use sqrt(x^2 + y^2 + z^2)?
if (z > rng_limit) {
targets[nSeq][ntile][CuasMotionLMA.RSLT_RANGE] = Double.POSITIVE_INFINITY;
} else {
targets[nSeq][ntile][CuasMotionLMA.RSLT_RANGE] = Math.abs(z); // was it positive already?
}
}
} else {
targets[nSeq][ntile][CuasMotionLMA.RSLT_RANGE] = Double.NaN;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return;
}
public double [][][] renderKeyFrames(
final double [][][] targets, // centers
final double [][][] targets5x5,
......@@ -343,6 +425,13 @@ public class CuasRanging {
//radius_blur
final int start_scene = frame_center - half_accum_range;
final int num_scenes = 2*half_accum_range + 1;
boolean clean_up = true; // remove unneded data
final double [][][] img_um_seq = getUMSequence(
start_scene, // final int start_scene,
num_scenes, // final int num_scenes,
clean_up, // final boolean clean_up, // remove unneded data
debugLevel); // final int debugLevel)
/*
final double [][][] img_um_seq = QuadCLT.unsharpMaskSourceMono(
scenes, // final QuadCLT[] scenes,
start_scene, // final int start_scene,
......@@ -353,6 +442,7 @@ public class CuasRanging {
um_twice, // final boolean um_twice,
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
*/
double [][][] pXpYD5x5s = cuasMotion.targetPxPyD(
targets5x5[nseq]); // final double [][] targets)
double [][][] pXpYDs = cuasMotion.targetPxPyD(
......@@ -515,12 +605,17 @@ public class CuasRanging {
final boolean log_ranging,
final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
final int debugLevel) {
int show_mode = 2; // 7; // 0; // 4; // 0; //3; +1 - disparity, +2 - corr
int num_seq = cuasMotion.getNumCorrSamples();
int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
int num_seq = cuasMotion.getNumCorrSamples();
int show_mode = clt_parameters.imp.cuas_dbg_show_mode; // 2; // 7; // 0; // 4; // 0; //3; +1 - disparity, +2 - corr
int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
int dbg_rng_seq = clt_parameters.imp.cuas_dbg_rng_seq;
float [][][] accum_2d_corr = null;
int nseq_first = 0;
int nseq_last = num_seq-1;
if (dbg_rng_seq >= 0) {
nseq_first = dbg_rng_seq;
nseq_last = dbg_rng_seq;
}
System.out.println("rangeTargets(): debug/change nseq_first="+nseq_first+", nseq_last="+nseq_last);
// for rng_vfy debugging
final int half_accum_range = cuasMotion.getSeqLength()/2;
......@@ -577,10 +672,14 @@ public class CuasRanging {
sb.append("cuas_min_max_ac = " + clt_parameters.imp.cuas_min_max_ac + "\n"); // 0.175; // 0.14; // LWIR16: 0.01 maximal of a and C coefficients minimum (measures sharpest point/line)
sb.append("cuas_min_min_ac = " + clt_parameters.imp.cuas_min_min_ac + "\n"); // LWIR16: 0.007 minimal of a and C coefficients minimum (measures sharpest point)
sb.append("cuas_reset_disparity = " + clt_parameters.imp.cuas_reset_disparity + "\n"); // reset target disparities from infinity
sb.append("cuas_initial_disparity= "+ clt_parameters.imp.cuas_initial_disparity+ "\n");// Start correlation with this disparity (in addition to infinity) after reset
sb.append("cuas_infinity = " + clt_parameters.imp.cuas_infinity + "\n"); // disparity at infinity for targets
sb.append("cuas_rng_niterate = " + clt_parameters.imp.cuas_rng_niterate + "\n"); // number of disparity iterations
sb.append("cuas_rng_diff = " + clt_parameters.imp.cuas_rng_diff + "\n"); // exit when disparity difference is smaller
sb.append("cuas_max_disp_diff = " + clt_parameters.imp.cuas_max_disp_diff + "\n"); // Maximal disparity difference during last change to consider disparity valid
sb.append("cuas_min_disp_str = " + clt_parameters.imp.cuas_min_disp_str + "\n"); // Minimal disparity strength to consider disparity valid
sb.append("cuas_rng_limit = " + clt_parameters.imp.cuas_rng_limit + "\n"); // Maximal displayed distance to target
sb.append("nseq\tframe_center\tnrefine\ttileX\ttileY\ttile\tdisparity\tdisp_diff\tstrength\tlast_str\tmax_diff\n");
......@@ -683,6 +782,10 @@ public class CuasRanging {
show_corr, // final boolean show_corr,
show_debug_single && (nrefine == 0), // final boolean show_debug_single,
debugLevel); // final int debugLevel)
if (disparity_map == null) {
System.out.println("rangeTargets()): disparity_map==null on nrefine="+nrefine);
break;
}
if (ranging_verify_this != null) {
int half_accum_range = cuasMotion.getSeqLength()/2;
ImagePlus imp_vfy = renderRangingVerify(
......@@ -712,8 +815,10 @@ public class CuasRanging {
}
double max_diff = 0.0;
for (int ntile = 0; ntile < targets[nseq].length; ntile++) if (targets[nseq][ntile] != null) {
double disp_diff = disparity_map[ImageDtt.DISPARITY_INDEX_POLY][ntile];
for (int ntile = 0; ntile < targets[nseq].length; ntile++) if ((targets[nseq][ntile] != null) &&
// (disparity_map != null) &&
(disparity_map[ImageDtt.DISPARITY_INDEX_POLY] != null)) {
double disp_diff = disparity_map[ImageDtt.DISPARITY_INDEX_POLY][ntile]; // null
double str = disparity_map[ImageDtt.DISPARITY_INDEX_POLY+1][ntile];
if (Double.isNaN(disp_diff)) {
if (!use_non_lma) {
......@@ -732,6 +837,7 @@ public class CuasRanging {
}
if ((str > 0) && !((worsen_str * targets[nseq][ntile][CuasMotionLMA.RSLT_DISP_STR]) > str)) {
targets[nseq][ntile][CuasMotionLMA.RSLT_DISPARITY] += disp_diff;
targets[nseq][ntile][CuasMotionLMA.RSLT_DISP_DIFF] = disp_diff;
targets[nseq][ntile][CuasMotionLMA.RSLT_DISP_STR] = str;
} else {
disp_diff = 0;
......@@ -877,57 +983,105 @@ public class CuasRanging {
return imp_vfy;
}
public double [][] refineTargetDisparity( // returns disparity_map
final double [][][] targets, // centers
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
final double [][][] ranging_verify, // Now per group (rng_combine) [2*half_accum_range +1 +1][num_sens+1][] // [num_pix]
final int nseq,
final int nrefine, // number of the refine to select radius (larger first time)
final boolean show_corr,
final boolean show_debug_single,
final int debugLevel) {
public double [][][] getUMSequence(
final int start_scene,
final int num_scenes,
final boolean clean_up, // remove unneded data
final int debugLevel) {
final boolean um_en = clt_parameters.imp.cuas_rng_um;
final boolean um_all = clt_parameters.imp.cuas_rng_um_all;
final double um_sigma = clt_parameters.imp.cuas_rng_um_sigma;
final boolean um_twice = clt_parameters.imp.cuas_rng_um2;
final double um_weight = clt_parameters.imp.cuas_rng_um_weight;
if (clean_up) {
for (int nscene = 0; nscene < start_scene; nscene++) {
this.img_um[nscene] = null;
scenes[nscene].setImageDataAlt(null);
}
for (int nscene = start_scene+num_scenes; nscene < this.img_um.length; nscene++) {
this.img_um[nscene] = null;
scenes[nscene].setImageDataAlt(null);
}
Runtime runtime = Runtime.getRuntime();
runtime.gc();
if (debugLevel > -3) System.out.println("getUMSequence(): Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
}
final double [][][] img_um_seq =
QuadCLT.unsharpMaskSourceMono(
scenes, // final QuadCLT[] scenes,
start_scene, // final int start_scene,
num_scenes, // final int num_scenes,
um_en, // final boolean um_en,
img_um, // final double [][][] img_um, // cache for unsharped images, same length as scenes. May be null
false, // final boolean unsharped, // ==false, not used
false, // final boolean update_source, // ==false, not used if update_source will not generate output, return null
um_sigma, // final double um_sigma,
um_twice, // final boolean um_twice,
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
return img_um_seq;
}
public double [][] refineTargetDisparity( // returns disparity_map
final double [][][] targets, // centers
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
final double [][][] ranging_verify, // Now per group (rng_combine) [2*half_accum_range +1 +1][num_sens+1][] // [num_pix]
final int nseq,
final int nrefine, // number of the refine to select radius (larger first time)
final boolean show_corr,
final boolean show_debug_single,
final int debugLevel) {
// final boolean um_en = clt_parameters.imp.cuas_rng_um;
// final boolean um_all = clt_parameters.imp.cuas_rng_um_all;
final double um_sigma = clt_parameters.imp.cuas_rng_um_sigma;
// final boolean um_twice = clt_parameters.imp.cuas_rng_um2;
// final double um_weight = clt_parameters.imp.cuas_rng_um_weight;
final double rng_fz = clt_parameters.imp.cuas_rng_fz;
final boolean mb_en = clt_parameters.imp.mb_en; // && (fov_tiles==null) && (mode3d > 0);
final double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec
final double mb_max_gain = clt_parameters.imp.mb_max_gain; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(center_CLT.isMonochrome());
final double gpu_sigma_rb_corr = center_CLT.isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(center_CLT.isMonochrome());
final double radius = (nrefine == 0)? clt_parameters.imp.cuas_rng_radius0: clt_parameters.imp.cuas_rng_radius;
final int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
final int frame_center = cuasMotion.getFrameCenter(nseq);
final int half_accum_range = cuasMotion.getSeqLength()/2;
// final boolean unsharped
// final double [] window_full= cuasMotion.getSegmentWindow(
// true, // boolean smooth)
// true); // boolean normalize)
// final double [] window_full= cuasMotion.getSegmentWindow(
// true, // boolean smooth)
// true); // boolean normalize)
//radius_blur
final int start_scene = frame_center - half_accum_range;
final int num_scenes = 2*half_accum_range + 1;
boolean clean_up = true; // remove unneded data
final double [][][] img_um_seq = getUMSequence(
start_scene, // final int start_scene,
num_scenes, // final int num_scenes,
clean_up, // final boolean clean_up, // remove unneded data
debugLevel); // final int debugLevel)
/*
final double [][][] img_um_seq = QuadCLT.unsharpMaskSourceMono( // [num_scenes][num_sens][pixels]
scenes, // final QuadCLT[] scenes,
start_scene, // final int start_scene,
num_scenes, // final int num_scenes,
um_en, // final boolean um_en,
um_all, // final boolean unsharped,
um_sigma, // final double um_sigma,
um_twice, // final boolean um_twice,
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
// double [][][] pXpYD5x5s = cuasMotion.targetPxPyD(
// targets5x5[nseq]); // final double [][] targets)
*/
double [][][] pXpYDs = cuasMotion.targetPxPyD(
targets[nseq]); // final double [][] targets)
......@@ -946,9 +1100,9 @@ public class CuasRanging {
e.printStackTrace();
}
imgdtt_params.updateFromCuas(clt_parameters.imp, num_sens);
boolean show_um = show_debug_single; // (show_corr & 4) != 0; // true; // false; // true;
if (show_um) {
/*
......@@ -962,8 +1116,8 @@ public class CuasRanging {
nseq, // int nseq, // center
title_pXpYDs, // String title,
true); // boolean show)
*/
*/
String [] titles_sensors = new String[img_um_seq[0].length];
String [] titles_scenes = new String[num_scenes];
for (int i = 0; i < titles_sensors.length; i++) {
......@@ -972,7 +1126,7 @@ public class CuasRanging {
for (int i = 0; i < num_scenes; i++) {
titles_scenes[i] = cuasMotion.getSceneTitles()[i+start_scene];
}
ShowDoubleFloatArrays.showArraysHyperstack(
img_um_seq, // double[][][] pixels,
center_CLT.getWidth(), // int width,
......@@ -981,8 +1135,8 @@ public class CuasRanging {
titles_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
true); // show); // boolean show)
}
final int mcorr_sel = ImageDttParameters.corrSelEncode(imgdtt_params,num_sens);
ErsCorrection ers_reference = center_CLT.getErsCorrection();
int num_used_sens = 0;
......@@ -990,38 +1144,38 @@ public class CuasRanging {
int [] channels = new int [num_used_sens];
int nch = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) channels[nch++] = i;
// from OF13477: public static double[][] correlateInterscene(
final int num_pairs = Correlation2d.getNumPairs(num_sens);
final float [][][][] fcorr_td_acc = new float [tilesY][tilesX][][];
final float [][][] accum_weights = new float [tilesY][tilesX][num_pairs];
final boolean show_2d_corr = false;
boolean show_accumulated_correlations = show_2d_corr || debugLevel > -5;
// boolean show_reference_correlations = show_2d_corr || debugLevel > -5;
// final float [][][] fclt_corr = ((accum_2d_corr != null) || show_accumulated_correlations || show_reference_correlations) ?
// boolean show_reference_correlations = show_2d_corr || debugLevel > -5;
// final float [][][] fclt_corr = ((accum_2d_corr != null) || show_accumulated_correlations || show_reference_correlations) ?
final float [][][] fclt_corr = ((accum_2d_corr != null) || show_accumulated_correlations) ?
(new float [tilesX * tilesY][][]) : null;
final boolean use_rms = true; // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023) (from OF11168: boolean use_rms = true; )
final boolean no_map = false;
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
clt_parameters.transform_size,
imgdtt_params, // clt_parameters.img_dtt,
center_CLT.isAux(),
center_CLT.isMonochrome(),
center_CLT.isLwir(),
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
clt_parameters.transform_size,
imgdtt_params, // clt_parameters.img_dtt,
center_CLT.isAux(),
center_CLT.isMonochrome(),
center_CLT.isLwir(),
clt_parameters.getScaleStrength(center_CLT.isAux()),
center_CLT.getGPU());
image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null
final double[][] disparity_map = no_map ? null : new double [image_dtt.getDisparityTitles().length][];
TpTask[][] tp_tasks = null; // will contain last tp_tasks
TpTask[][] tp_tasks_ref = null;
final double [] window_nnorm= cuasMotion.getSegmentWindow( // normalized, sum == 1.0
clt_parameters.imp.cuas_rng_coswnd, // boolean smooth)
false); // boolean normalize) // not normalized, values up to 1.0
final int num_scene_grp = (num_scenes + rng_combine - 1) / rng_combine;
final double [] window_grp = new double [num_scene_grp];
double sw = 0;
......@@ -1030,8 +1184,8 @@ public class CuasRanging {
window_grp[nscene / rng_combine] += w;
sw += w;
}
// final double sum_window = sw;
// final double sum_window = sw;
for (int dseq = -half_accum_range; dseq <= half_accum_range; dseq++) {
final double [][] ref_pXpYD = pXpYDs[dseq + half_accum_range]; // center target
final int nscene = frame_center + dseq;
......@@ -1039,7 +1193,7 @@ public class CuasRanging {
final int iscene_grp = iscene / rng_combine;
final boolean first_in_grp = (iscene % rng_combine) == 0;
final boolean last_in_grp = (((iscene + 1) % rng_combine) == 0) || (dseq == half_accum_range);
final int sm = -1; // merge_all? -1: sensor_mask;
final double [][] dxyzatr_dt = (mb_en ? new double[][] { // for all, including ref
scenes[nscene].getErsCorrection().getErsXYZ_dt(),
......@@ -1057,13 +1211,13 @@ public class CuasRanging {
img_um_seq, // final double [][][] img_um_seq,
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius, // final double radius,
radius, // final double radius,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
tp_tasks = new TpTask[(mb_en && (dxyzatr_dt != null)) ? 2 : 1][];
if (mb_en && (dxyzatr_dt != null)) {
double [][] motion_blur = OpticalFlow.getMotionBlur(
......@@ -1091,11 +1245,11 @@ public class CuasRanging {
null, // double [] disparity_ref,
// only center tiles here!
ref_pXpYD, // 5x5, // double [][] ref_pXpYD, // alternative to disparity_ref when reference is not uniform
// motion blur compensation
// motion blur compensation
mb_tau, // double mb_tau, // 0.008; // time constant, sec
mb_max_gain, // double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
motion_blur, // double [][] mb_vectors, // now [2][ntiles];
scene_xyz, // double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr, // double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], //final QuadCLT scene,
......@@ -1118,7 +1272,7 @@ public class CuasRanging {
null, // double [] disparity_ref,
// only center tiles here!
ref_pXpYD, // 5x5, // double [][] ref_pXpYD, // alternative to disparity_ref when reference is not uniform
// motion blur compensation
// motion blur compensation
0.0, // double mb_tau, // 0.008; // time constant, sec
0.0, // double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
null, // double [][] mb_vectors, // now [2][ntiles];
......@@ -1172,7 +1326,7 @@ public class CuasRanging {
}
// Verify tasks are now updated
OpticalFlow.accumulateCorrelations(
// window_full[iscene] * (2 * half_accum_range + 1), // final double weight, // keep same sum as before
// window_full[iscene] * (2 * half_accum_range + 1), // final double weight, // keep same sum as before
window_grp[iscene_grp], // final double weight, // keep same sum as before
accum_weights, // final int [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
......@@ -1195,7 +1349,7 @@ public class CuasRanging {
for (int i = 0; i < num_scenes; i++) {
titles_scenes[i] = cuasMotion.getSceneTitles()[i+start_scene];
}
ShowDoubleFloatArrays.showArraysHyperstack(
img_um_seq, // double[][][] pixels,
center_CLT.getWidth(), // int width,
......@@ -1203,10 +1357,10 @@ public class CuasRanging {
titles_sensors, // String [] titles, // all slices*frames titles or just slice titles or null
titles_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
true); // show); // boolean show)
}
*/
*/
double [][][] alt_images = new double [2*half_accum_range+1][num_sens][];
double [][][] orig_images = new double [2*half_accum_range+1][num_sens][];
for (int i = 0; i < alt_images.length; i++) {
......@@ -1217,9 +1371,9 @@ public class CuasRanging {
orig_images[i][j] = orig_col_img[j][0];
}
}
String [] titles_alt_scenes = new String[alt_images.length];
String [] titles_sensors = new String[img_um_seq[0].length];
for (int i = 0; i < titles_sensors.length; i++) {
titles_sensors[i] = "SENS-"+i;
......@@ -1227,7 +1381,7 @@ public class CuasRanging {
for (int i = 0; i < titles_alt_scenes.length; i++) {
titles_alt_scenes[i] = cuasMotion.getSceneTitles()[i];
}
ShowDoubleFloatArrays.showArraysHyperstack(
alt_images, // double[][][] pixels,
center_CLT.getWidth(), // int width,
......@@ -1245,11 +1399,11 @@ public class CuasRanging {
titles_alt_scenes, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
true); // show); // boolean show)
}
// Normalize accumulated correlations
OpticalFlow.accumulateCorrelationsAcOnly(
accum_weights, // final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
accum_weights, // final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
double [][][] dcorr_tiles = (fclt_corr != null)? (new double [tp_tasks_ref[0].length][][]):null;
image_dtt.clt_process_tl_correlations( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
imgdtt_params, // clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
......@@ -1257,16 +1411,16 @@ public class CuasRanging {
accum_weights, // float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair] (or null)
null, // dcorr_weight, // double [] dcorr_weight, // alternative to num_acc, compatible with CPU processing (only one non-zero enough)
clt_parameters.gpu_corr_scale, // final double gpu_corr_scale, // 0.75; // reduce GPU-generated correlation values
// clt_parameters.getGpuFatZero(center_CLT.isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0
// clt_parameters.getGpuFatZero(center_CLT.isMonochrome()), // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0
rng_fz, // final double gpu_fat_zero, // clt_parameters.getGpuFatZero(is_mono);absolute == 30.0
image_dtt.transform_size - 1, // final int gpu_corr_rad, // = transform_size - 1 ?
// The tp_tasks data should be decoded from GPU to get coordinates
// The tp_tasks data should be decoded from GPU to get coordinates
tp_tasks_ref[0], // final TpTask [] tp_tasks, // data from the reference frame - will be applied to LMW for the integrated correlations
null, // final double [][] far_fgbg, // null, or [nTile]{disp(fg)-disp(bg), str(fg)-str(bg)} hints for LMA FG/BG split
center_CLT.getErsCorrection().getRXY(false), // final double [][] rXY, // from geometryCorrection
// next both can be nulls
null, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
// combo will be added as extra pair if mcorr_comb_width > 0 and clt_corr_out has a slot for it
// combo will be added as extra pair if mcorr_comb_width > 0 and clt_corr_out has a slot for it
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
......@@ -1275,7 +1429,7 @@ public class CuasRanging {
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
clt_parameters.correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
// define combining of all 2D correlation pairs for CM (LMA does not use them)
// define combining of all 2D correlation pairs for CM (LMA does not use them)
imgdtt_params.mcorr_comb_width, //final int mcorr_comb_width, // combined correlation tile width (set <=0 to skip combined correlations)
imgdtt_params.mcorr_comb_height,//final int mcorr_comb_height, // combined correlation tile full height
imgdtt_params.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)
......@@ -1290,7 +1444,7 @@ public class CuasRanging {
dcorr_tiles, // double [][][] dcorr_tiles,// [tile][sparse, correlation pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
fclt_corr); // float [][][] fclt_corr) // new float [tilesX * tilesY][][] or null
// if (show_accumulated_correlations || (accum_2d_corr != null)){ // -1
// if (show_accumulated_correlations || (accum_2d_corr != null)){ // -1
if (show_corr || (accum_2d_corr != null)){ // -1
float [][] accum_2d_img = ImageDtt.corr_partial_dbg( // not used in lwir
fclt_corr, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
......@@ -1338,7 +1492,6 @@ public class CuasRanging {
final int nseq,
final int dseq,
final int debugLevel) {
// final double radius = clt_parameters.imp.cuas_rng_radius;
final double radius_blur = clt_parameters.imp.cuas_rng_blur;
final double alt_scale = clt_parameters.imp.cuas_rng_scale; // scale alt data to approximately match correlation values
......
......@@ -677,7 +677,7 @@ min_str_neib_fpn 0.35
public double cuas_um_sigma = 10.0; // Apply Unsharp Mask filter sigma when calculating row/column noise
public double cuas_max_abs_rowcol = 50.0; // consider pixels with abs(UM difference) does not exceed this value
public double cuas_outliers_rowcol = 0.001; // scale weight of the outliers with high difference (to prevent undefined values
public boolean cuas_reset_first= true; // false; // Reset average in first scene (for large diffirence in unfinished row/col)
public boolean cuas_reset_first= false; // true; // false; // Reset average in first scene (for large diffirence in unfinished row/col)
public int cuas_invert_margins = 0; // Expand image each side when inverting tasks
public int cuas_invert_iters = 4; // Enhance inversion iterations
public double cuas_invert_tolerance = 0.001; // Finish enhancing when last change was lower than
......@@ -702,7 +702,7 @@ min_str_neib_fpn 0.35
public double cuas_multi_strength = 0.45; // maximal strength to use multi-tile DSI
public double cuas_reliable_str = 0.8; // use for relaible tiles if INTER-INTRA-LMA is available, not just DSI_MAIN
public double cuas_fat_zero = 25.0; // phase correlation fat zero
public double cuas_fat_zero = 50.0; // phase correlation fat zero
public double cuas_cent_radius = 3.0; // centroids center radius
public int cuas_n_recenter = 2; // when cosine window, re-center window these many times
public double cuas_rstr = 0.01; // minimal phase correlation maximums relative to max str
......@@ -736,18 +736,18 @@ min_str_neib_fpn 0.35
public double cuas_sky_threshold = 0.9; // minimal value of the sky mask where target is possible
public double [] cuas_sky_offset = {0.0, 0.0}; // add to coordinates when looking for the mask value
public double cuas_lmax_fraction = 0.6; // Check if local maximum is separated from the surrounding by this fraction of the maximum value
public double cuas_lmax_fraction = 0.55; // Check if local maximum is separated from the surrounding by this fraction of the maximum value
public double cuas_lmax_hack_ridge= 0.45; // Hack for ridges: remove horizontal streaks, where average(abs()) for the line exceeds fraction of abs max 0.32-good, 0.55 - bad
public double cuas_lmax_radius = 3.5; // 4.5; // look inside ((int)cuas_lmax_radius) * 2 + 1 square for the local maximum isolation
public double cuas_lmax_radius = 4.5; // 4.5; // look inside ((int)cuas_lmax_radius) * 2 + 1 square for the local maximum isolation
public boolean cuas_lmax_zero = false; // true; // zero all data outside this radius from the maximum
public double cuas_centered_radius= 3.5; // in centered mode (target placed at [8,8] - zero out data outside peripheral areas, keep 0.5 at the radius
public double cuas_centered_blur = 0.5; // relative transition radius range (for 0.5 the mask inside (1-0.5) radius will be 1.0, outside (1+0.5) radius will be 0
public double cuas_duplicate_tolerance = 2.0; // (pix) Remove weaker maximums closer than this to a stronger one
public double cuas_target_radius = 3.0; // target centroids center radius
public double cuas_target_strength =0.8; // target centroids center radius
public double [][] cuas_target_frac = {{0,0.15},{2.5,0.18},{5,0.3}};
public double cuas_target_radius = 2.0; // target centroids center radius
public double cuas_target_strength =0.2; // target centroids strength
public double [][] cuas_target_frac = {{0,0.04},{2.5,0.1},{5,0.3}};
public boolean cuas_no_border = true; // exclude targets with centers on the 16x16 tile edges
// CUAS Motion LMA parameters
public double cuas_lma_sigma = 2.5;
......@@ -768,25 +768,25 @@ min_str_neib_fpn 0.35
public int cuas_num_iter = 20;
// CUAS Motion LMA filter parameters
public double cuas_lma_rms = 2.5; // 1.5; // Maximal RMS (should always match, regardless if A)
public double cuas_lma_arms = 0.4; // 0.06; // Maximal absolute RMS (should match one of cuas_lma_arms OR cuas_lma_rrms (0.484)
public double cuas_lma_rrms = 0.2; // 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
public double cuas_lma_mina = 0.7; // 1.0; // Minimal A (amplitude) = 1.0 (< 2.0)
public double cuas_lma_rms = 1.5; // 1.5; // Maximal RMS (should always match, regardless if A)
public double cuas_lma_arms = 0.37; // 0.06; // Maximal absolute RMS (should match one of cuas_lma_arms OR cuas_lma_rrms (0.484)
public double cuas_lma_rrms = 0.28; // 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
public double cuas_lma_mina = 0.4; // 1.0; // Minimal A (amplitude) = 1.0 (< 2.0)
public double cuas_lma_pre_mina = 0.5; // scale cuas_lma_mina to filter initial candidates (if there are > one of them)
public int cuas_min_keep = 2; // keep at least this number of candidates before using cuas_lma_pre_mina filter
public double cuas_lma_maxr = 5.0; // Maximal R (radius) =5.0 (> 3.8)
public double cuas_lma_minr1 = 1.0; // Minimal R1 (radius of positive peak)
public double cuas_lma_maxr = 7.0; // Maximal R (radius) =5.0 (> 3.8)
public double cuas_lma_minr1 = 0.75; // Minimal R1 (radius of positive peak)
public double cuas_lma_mink = 0.0; // Minimal K (overshoot) = 0.0 (<0.007)
public double cuas_lma_maxk = 5.0; // Maximal K (overshoot) = 5.0 (>3.8)
public double cuas_lma_a2a = 0.7; // Minimal ratio of the maximal pixel to the amplitude
public double cuas_lma_a2a = 0.5; // Minimal ratio of the maximal pixel to the amplitude
public double cuas_slow_ra = 50.0; // running averaging for slow targets
public double cuas_slow_score = 1.0; // scale scores for slow target mode
public double cuas_score_mv = 0.0; // minimal score for the motion vectors
public double cuas_score_lma = 0.0; // minimal score for the target LMA
public double cuas_score_lma = 1.6; // minimal score for the target LMA
public double cuas_factor_lim = 5.0; // limit each individual score factor
public double cuas_factor_pow = 1.0; // raise score factor to this power before combining
public double [] cuas_score_coeff = {1.0, 0.05, 0.7, 1.5, 2.0, 1.0, 1.0}; //weights of amplitude, RMSE and RMSE/amplitude, center, mismatch, match_length, travel
......@@ -797,22 +797,23 @@ min_str_neib_fpn 0.35
public boolean cuas_isolated = true; // remove targets that do not have neighbors before/after
public int cuas_min_seq = 3; // minimal number of consecutive key frames for the same target
public int cuas_enough_seq = 5; // number of consecutive key frames considered good regardless of individual scores (maybe add minimal travel in pixels)?
public double cuas_seq_travel = 3.0; // minimal diagonal of the bounding box that includes sequence to be considered "cuas_enough_seq". Filtering out atmospheric fluctuations
public int cuas_min_seq_fl = 2; // minimal number of consecutive key frames for the same target that includes first or last key frame
public int cuas_min_seq = 5; // minimal number of consecutive key frames for the same target
public int cuas_enough_seq = 10; // number of consecutive key frames considered good regardless of individual scores (maybe add minimal travel in pixels)?
public double cuas_seq_travel = 2.5; // minimal diagonal of the bounding box that includes sequence to be considered "cuas_enough_seq". Filtering out atmospheric fluctuations
public int cuas_min_seq_fl = 4; // minimal number of consecutive key frames for the same target that includes first or last key frame
// public boolean cuas_remove_2seq = true; // Remove 2-long target sequences consisting of 2 consecutive key frames
// public boolean cuas_remove_2seq_all=true; // Remove 2-long first/last target sequences
public double cuas_max_mismatch = 2.0; // maximal position error between consecutive scene sequences
public double cuas_good_mismatch = 0.4; // maximal position error between consecutive scene sequences that adds to the score
public double cuas_good_mismatch = 1.0; // maximal position error between consecutive scene sequences that adds to the score
public double cuas_slow_fast_mismatch = 1.5; // allow larger mismatch between slow and fast
public double cuas_match_len_pwr = 0.5; // raise matching length to this power for calculating score
public boolean cuas_fail_mismatch = false; // fail high mismatch early
public boolean cuas_ignore_mismatch = false; // calculate mismatch but do not remove
// May be obsolete by now as there is an image mask of the sky.
public boolean cuas_by_horizon = true; // remove targets that are below horizon
public double cuas_horizon = 390.0; // maximal Y - position of the sky
public double cuas_horizon = 380.0; // maximal Y - position of the sky
public double cuas_mask_width = 9;
public double cuas_mask_blur = 3;
......@@ -829,14 +830,14 @@ min_str_neib_fpn 0.35
public boolean cuas_targets = true; // enable targets generation together with the source UM images
public int cuas_iter_show = 1; // Maximal enhancement iteration to show intermediate result (0 - none)
public int cuas_iter_show = 0; // 1; // Maximal enhancement iteration to show intermediate result (0 - none)
public boolean cuas_2d_save_show = true; // save/show 2D correlation
public boolean cuas_intermed_low = true; // save intermediate vector fields and target coordinates from the LMA (80x64 layers)
public boolean cuas_intermed_high = true; // save pixel-resolution accumulated images (640x512)
public boolean cuas_intermed_giga = false;// save huge (gigabyte) intermediate files
public boolean cuas_debug_more = false;// save/show more images
public boolean cuas_debug_more = true;// save/show more images
public boolean cuas_generate = true; // generate and save targets Tiff and/or video files
public boolean cuas_save_mono = true; // save 32-bit monochrome target+backgrounds Tiffs (before optional scaling)
public boolean cuas_save_mono = false; // save 32-bit monochrome target+backgrounds Tiffs (before optional scaling)
public boolean cuas_save_color = true; // save color rendered images (same as videos)
public boolean cuas_save_video = true; // save color rendered images (same as videos)
public boolean cuas_clean_video = true; // save video without any debug information for targets, output in TIFF files. False - same output for video and TIFFs
......@@ -844,10 +845,14 @@ min_str_neib_fpn 0.35
public boolean cuas_annotate = true; // save color rendered images (same as videos)
public boolean cuas_annotate_uas = true; // indicate uas from log if available
public Color cuas_text_color = new Color (0, 255, 255);// 220);
public Color cuas_selected_color = new Color (127, 0, 255);// 220);
public Color cuas_text_color = new Color ( 0, 255, 0);// 220);
public Color cuas_text_bg = new Color (127, 127, 127);// 220);
public Color cuas_selected_color= new Color (127, 0, 255);// 220);
public boolean cuas_transparent = true; // text bg for other targets
public boolean cuas_transparent_uas=false; // text bg for UAS
public String cuas_font_name = "Monospaced";
public int cuas_font_size = 7; // before scaling
public int cuas_font_size = 8; // before scaling
public int cuas_font_type = 1; // 0 - PLAIN, 1 - BOLD, 2 - ITALIC
// AZ/EL calibration
public double cuas_ifov = 0.05; // degree per pixel
......@@ -855,29 +860,33 @@ min_str_neib_fpn 0.35
public int cuas_py0 = 386; // pixel with known elevation
public double cuas_az0 = 201.5; // degrees for cuas_px0;
public double cuas_el0 = 0.0; // degrees for cuas_px0;
public boolean cuas_show_disp = true; // Show disparity (corrected) near target (not in clean)
public boolean cuas_show_rng = true; // Show distance to target (range) in meters
public boolean cuas_show_inf = true; // Show distance greater than max (or negativce) as infinity
public boolean cuas_show_inf_gt = true; // Use ">max" instead of infinity symbol
public boolean cuas_show_true_rng = true; // show true range (from the flight log)
// ranging parameters
public boolean cuas_smooth_omegas = true; // Recalculate omegas from continuing targets positions
public boolean cuas_rng_um = true; // apply UM to images for ranging (assumed true)
public boolean cuas_rng_um_all = false;// Unsharp mask all images (after FPN and Row/Col), unchecked - when needed. Checked faster, but original data is lost.
public double cuas_rng_um_sigma = 2; // unsharp mask sigma for ranging images
public boolean cuas_rng_um2 = false; // apply UM to images twice
public double cuas_rng_um_sigma = 1.5; // unsharp mask sigma for ranging images
public boolean cuas_rng_um2 = true; // apply UM to images twice
public double cuas_rng_um_weight = 1.0; // unsharp mask weight for ranging images
public boolean cuas_rng_coswnd = true; // Use cosine scenes window (false - rectangular)
public int cuas_rng_combine = 8; // combine multiple scenes before intrascene correlation
public double cuas_rng_radius0 = 3.5; // mask out data outside peripheral areas, keep 0.5 at the radius - first iteration
public double cuas_rng_radius = 2.0; // mask out data outside peripheral areas, keep 0.5 at the radius - next iteration
public boolean cuas_rng_coswnd = false; // Use cosine scenes window (false - rectangular)
public int cuas_rng_combine = 2; // combine multiple scenes before intrascene correlation
public double cuas_rng_radius0 = 3.0; // mask out data outside peripheral areas, keep 0.5 at the radius - first iteration
public double cuas_rng_radius = 2.5; // mask out data outside peripheral areas, keep 0.5 at the radius - next iteration
public double cuas_rng_blur = 0.5; // relative transition radius range (for 0.5 the mask inside (1-0.5) radius will be 1.0, outside (1+0.5) radius will be 0
public double cuas_rng_fz = 1000.0; // Fat zero in target ranging mode
public double cuas_rng_scale = 8.0; // Scale alt_data to use same strength as for normal ranging because targets
public double cuas_rng_fz = 30.0; // Fat zero in target ranging mode
public double cuas_rng_scale = 8.0; // Scale alt_data to use same strength as for normal ranging because targets
// will overwrite ImageDttParameters
public boolean cuas_dual_pass = true; // First pass - do not adjust disparity
public boolean cuas_disp_only2 = true; // Disparity only on second pass (keep scales and shape - some CUAS where failing on second pass)
public boolean cuas_disp_only2 = false; // Disparity only on second pass (keep scales and shape - some CUAS where failing on second pass)
public boolean cuas_lma_bypass = false; // Bypass solution tests, OK weak
public int cuas_mcorr_sel = 3; // all pairs and diagonals (as was for non-cuas ranging)
public int cuas_mcorr_sel_lma = 1; // all pairs (will use all selected by cuas_mcorr_sel)
public int cuas_mcorr_sel = 3; // all pairs and diagonals (as was for non-cuas ranging)
public int cuas_mcorr_sel_lma = 3; // all pairs (will use all selected by cuas_mcorr_sel)
public double cuas_max_rel_rms = 1.2; // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
......@@ -887,25 +896,25 @@ min_str_neib_fpn 0.35
public double cuas_min_min_ac = 0.003; // LWIR16: 0.007 minimal of a and C coefficients minimum (measures sharpest point)
public boolean cuas_reset_disparity = true; // reset target disparities from infinity
public double cuas_infinity = 0.68; // disparity at infinity for targets
public double cuas_initial_disparity = 1.0; // Start correlation with this disparity (in addition to infinity) after reset
public double cuas_infinity = 0.63; // disparity at infinity for targets
public boolean cuas_rng_img = true; // Generate/save per-sensor target images
public boolean cuas_rng_img = false; // Generate/save per-sensor target images
public boolean cuas_rng_disp= true; // Generate/save target disparities
public boolean cuas_rng_vfy= false; // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
public int cuas_rng_niterate = 10; // number of disparity iterations
public int cuas_rng_niterate = 6; // number of disparity iterations
public double cuas_rng_diff = 0.002; // exit when disparity difference is smaller
public boolean cuas_debug = true; // save debug images (and show them if not in batch mode)
public boolean cuas_step_debug = true; // save debug images during per-step cuas recalculation (and show them if not in batch mode)
public boolean cuas_save_stats = true; // Save target statistics data to find out which test failed and when (or when tile was found good)
public boolean cuas_debug = false; // save debug images (and show them if not in batch mode)
public int cuas_dbg_rng_seq = -1; // Debug single sequence ranging (-1 - process all)
public int cuas_dbg_show_mode = 0; // Debug show ranging debug images: +1 - disparity, +2 - correlations +4 - debug single run
public boolean cuas_step_debug = false; // save debug images during per-step cuas recalculation (and show them if not in batch mode)
public boolean cuas_save_stats = false; // Save target statistics data to find out which test failed and when (or when tile was found good)
public boolean cuas_target_debug = false; // save debug images during per-step cuas recalculation (and show them if not in batch mode)
public boolean cuas_target_score = true; // show target score and sequence length ijn the final video
public boolean cuas_target_score = true; // show target score and sequence length in the final tiff/video (not in clean video)
public boolean cuas_target_color = true; // annotate known target with different color
public boolean cuas_log_ranging = true; // Log ranging iterations
......@@ -913,11 +922,12 @@ min_str_neib_fpn 0.35
public int cuas_num_orient = 2; // initial value for num_orient
public int cuas_num_accum = 1; // initial value for num_accum
public boolean cuas_reuse_targets = false; // read previously calculated non-conflict (one per tile) targets
public boolean cuas_reuse_targets = true; // read previously calculated non-conflict (one per tile) targets
public String cuas_reuse_path = "-TARGETS_SINGLE-FINAL"; // either suffix (all parameters the same) or the full path (contains "/")
public boolean cuas_reuse_disparity = true; // read previously calculated non-conflict targets data with disparities (recalculate ranges)
public double cuas_max_disp_diff = 0.05; // Maximal disparity difference during last change to consider disparity valid
public double cuas_min_disp_str = 0.4; // Minimal disparity strength to consider disparity valid
public double cuas_rng_limit = 5000; // maximal displayed distance to target
// TODO: move next parameters elsewhere - they are not the motion blur ones.
......@@ -2563,6 +2573,7 @@ min_str_neib_fpn 0.35
"Save pixel-resolution huge files, such as hyperstack comparison.");
gd.addCheckbox ("Save/show additional images", this.cuas_debug_more,
"Save/show more images.");
gd.addCheckbox ("Generate and save detected targets", this.cuas_generate,
"Generate and save targets Tiff and/or video files (all images and videos).");
......@@ -2585,10 +2596,20 @@ min_str_neib_fpn 0.35
String scolor = String.format("%08x", getLongColor(this.cuas_text_color));
gd.addStringField ("Target annotations color",scolor, 8, "Any invalid hex number disables annotation");
}
{
String scolor = String.format("%08x", getLongColor(this.cuas_text_bg));
gd.addStringField ("Target annotations background color",scolor, 8, "Any invalid hex number disables annotation");
}
{
String scolor = String.format("%08x", getLongColor(this.cuas_selected_color));
gd.addStringField ("Selected target annotations color",scolor, 8, "Any invalid hex number disables annotation");
}
gd.addCheckbox ("Transparent text background (other)", this.cuas_transparent,
"Annotate other targets over image (unchecked - over solid color).");
gd.addCheckbox ("Transparent text background (UAS)", this.cuas_transparent_uas,
"Annotate UAS over image (unchecked - over solid color).");
gd.addStringField ("Font name", this.cuas_font_name, 20,
"Font name, currently \"Monospaced\".");
gd.addNumericField("Font size", this.cuas_font_size, 0,3,"pnt",
......@@ -2605,6 +2626,14 @@ min_str_neib_fpn 0.35
"Azimuth corresponding to the known pixel X.");
gd.addNumericField("Known pixel azimuth", this.cuas_el0, 5,8,"degree",
"Elevation corresponding to the known pixel Y.");
gd.addCheckbox ("Show target disparity", this.cuas_show_disp,
"Show disparity before infinity correction (not in clean mode).");
gd.addCheckbox ("Show target distance (meters)", this.cuas_show_rng,
"Show range true from the UAS log.");
gd.addCheckbox ("Show infinity distance to target", this.cuas_show_inf,
"Show when distance is above limit (unchecked - skip the line).");
gd.addCheckbox ("Show infinity as >range_limit", this.cuas_show_inf_gt,
"Show infinity as >range_limit, unchecked - as infinity symbol.");
gd.addCheckbox ("Show true range", this.cuas_show_true_rng,
"Show range true from the UAS log.");
......@@ -2663,7 +2692,9 @@ min_str_neib_fpn 0.35
"Minimal value of min (A,C) coefficients to keep the tile (measures sharpest point correlation maximum)");
gd.addCheckbox ("Reset target disparity", this.cuas_reset_disparity,
"Reset target disparity, start from infinity.");
gd.addNumericField("Disparity at infinity for ranging", this.cuas_infinity, 6, 8, "",
gd.addNumericField("Initial disparity relative to infinity", this.cuas_initial_disparity, 6, 8, "pix",
" Start correlation with this disparity (in addition to infinity) after reset.");
gd.addNumericField("Disparity at infinity for ranging", this.cuas_infinity, 6, 8, "pix",
"Disparity correction in target ranging mode.");
......@@ -2682,6 +2713,11 @@ min_str_neib_fpn 0.35
gd.addMessage("=== Debug ===");
gd.addCheckbox ("Save/show debug images", this.cuas_debug,
"Save CUAS-related debug images and show them in non-batch mode.");
gd.addNumericField("Debug ranging scene (-1 - process all)", this.cuas_dbg_rng_seq, 0,3,"",
"Debug single sequence ranging (-1 - process all).");
gd.addNumericField("Debug show mode", this.cuas_dbg_show_mode, 0,3,"",
"Debug show ranging debug images: +1 - disparity, +2 - correlations +4 - debug single run.");
gd.addCheckbox ("Save/show debug images for each tuning step",this.cuas_step_debug,
"Save CUAS-related debug images during per-step cuas recalculation and show them in non-batch mode.");
gd.addCheckbox ("Save target statistics", this.cuas_save_stats,
......@@ -2702,10 +2738,18 @@ min_str_neib_fpn 0.35
gd.addNumericField("Value to overwrote num_accum", this.cuas_num_accum, 0,3,"",
"Overwrite value (when Overwrite... is checked).");
gd.addCheckbox ("Reuse previosly calculated targets", this.cuas_reuse_targets,
gd.addCheckbox ("Reuse previosly calculated targets", this.cuas_reuse_targets,
"Read previously calculated non-conflict (one per tile) targets.");
gd.addStringField("Calculated targets suffix/path", this.cuas_reuse_path, 120,
"Either suffix (if all the parameters the same) or the full path (contains \"/\").");
gd.addCheckbox ("Reuse previosly calculated disparities", this.cuas_reuse_disparity,
"Read previously calculated non-conflict (one per tile) targets with disparities (recalculate ranges).");
gd.addNumericField("Maximal disparity difference", this.cuas_max_disp_diff, 6,8,"pix",
"Maximal disparity difference during last change to consider disparity valid.");
gd.addNumericField("Minimal target disparity strength", this.cuas_min_disp_str, 6,8,"",
"Minimal disparity strength to consider disparity valid.");
gd.addNumericField("Maximal displayed distance", this.cuas_rng_limit, 6,8,"m",
"Maximal displayed distance to target.");
gd.addTab("LMA sequence","Interscene LMA sequence control");
gd.addMessage("Parameters for control of the LMA pose adjustment sequence");
......@@ -3785,7 +3829,17 @@ min_str_neib_fpn 0.35
lcolor = Long.parseLong(scolor,16);
this.cuas_text_color = setLongColor(lcolor);
} catch(NumberFormatException e){
this.cuas_text_color = setLongColor(0xCCFF00);
this.cuas_text_color = setLongColor(0x00FF00);
}
}
{
String scolor = gd.getNextString();
long lcolor = -1;
try {
lcolor = Long.parseLong(scolor,16);
this.cuas_text_bg = setLongColor(lcolor);
} catch(NumberFormatException e){
this.cuas_text_bg = setLongColor(0x777777);
}
}
{
......@@ -3798,6 +3852,8 @@ min_str_neib_fpn 0.35
this.cuas_selected_color = setLongColor(0xFF0088);
}
}
this.cuas_transparent = gd.getNextBoolean();
this.cuas_transparent_uas = gd.getNextBoolean();
this.cuas_font_name = gd.getNextString();
this.cuas_font_size = (int) gd.getNextNumber();
this.cuas_font_type = (int) gd.getNextNumber();
......@@ -3806,6 +3862,10 @@ min_str_neib_fpn 0.35
this.cuas_py0 = (int) gd.getNextNumber();
this.cuas_az0 = gd.getNextNumber();
this.cuas_el0 = gd.getNextNumber();
this.cuas_show_disp = gd.getNextBoolean();
this.cuas_show_rng = gd.getNextBoolean();
this.cuas_show_inf = gd.getNextBoolean();
this.cuas_show_inf_gt = gd.getNextBoolean();
this.cuas_show_true_rng = gd.getNextBoolean();
this.cuas_smooth_omegas = gd.getNextBoolean();
......@@ -3835,6 +3895,7 @@ min_str_neib_fpn 0.35
this.cuas_min_max_ac = gd.getNextNumber();
this.cuas_min_min_ac = gd.getNextNumber();
this.cuas_reset_disparity = gd.getNextBoolean();
this.cuas_initial_disparity = gd.getNextNumber();
this.cuas_infinity = gd.getNextNumber();
this.cuas_rng_img = gd.getNextBoolean();
......@@ -3842,8 +3903,10 @@ min_str_neib_fpn 0.35
this.cuas_rng_vfy = gd.getNextBoolean();
this.cuas_rng_niterate = (int) gd.getNextNumber();
this.cuas_rng_diff = gd.getNextNumber();
this.cuas_debug = gd.getNextBoolean();
this.cuas_dbg_rng_seq = (int) gd.getNextNumber();
this.cuas_dbg_show_mode = (int) gd.getNextNumber();
this.cuas_step_debug = gd.getNextBoolean();
this.cuas_save_stats = gd.getNextBoolean();
this.cuas_target_debug = gd.getNextBoolean();
......@@ -3857,6 +3920,10 @@ min_str_neib_fpn 0.35
this.cuas_reuse_targets = gd.getNextBoolean();
this.cuas_reuse_path = gd.getNextString();
this.cuas_reuse_disparity = gd.getNextBoolean();
this.cuas_max_disp_diff = gd.getNextNumber();
this.cuas_min_disp_str = gd.getNextNumber();
this.cuas_rng_limit = gd.getNextNumber();
this.mb_gain_index_pose = (int) gd.getNextNumber();
this.mb_gain_index_depth =(int) gd.getNextNumber();
......@@ -4160,6 +4227,7 @@ min_str_neib_fpn 0.35
synth_add_offs = gd.getNextBoolean();// boolean
if (this.weight_zero_neibs > 1.0) this.weight_zero_neibs = 1.0;
return;
}
public void setProperties(String prefix,Properties properties){
......@@ -4855,13 +4923,20 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_annotate", this.cuas_annotate+""); // boolean
properties.setProperty(prefix+"cuas_annotate_uas", this.cuas_annotate_uas+""); // boolean
{
long lcolor_annotate = (cuas_text_color == null) ? 0xCCFF00 : getLongColor(this.cuas_text_color);
long lcolor_annotate = (cuas_text_color == null) ? 0x00FF00 : getLongColor(this.cuas_text_color);
properties.setProperty(prefix+"cuas_text_color", lcolor_annotate+"");
}
{
long lcolor_annotate = (cuas_text_bg == null) ? 0x777777 : getLongColor(this.cuas_text_bg);
properties.setProperty(prefix+"cuas_text_bg", lcolor_annotate+"");
}
{
long lcolor_annotate = (cuas_selected_color == null) ? 0xFF0088 : getLongColor(this.cuas_selected_color);
properties.setProperty(prefix+"cuas_selected_color", lcolor_annotate+"");
}
properties.setProperty(prefix+"cuas_transparent", this.cuas_transparent+""); // boolean
properties.setProperty(prefix+"cuas_transparent_uas", this.cuas_transparent_uas+""); // boolean
properties.setProperty(prefix+"cuas_font_name", this.cuas_font_name+""); // String
properties.setProperty(prefix+"cuas_font_size", this.cuas_font_size+""); // int
properties.setProperty(prefix+"cuas_font_type", this.cuas_font_type+""); // int
......@@ -4870,6 +4945,10 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_py0", this.cuas_py0+""); // int
properties.setProperty(prefix+"cuas_az0", this.cuas_az0+""); // double
properties.setProperty(prefix+"cuas_el0", this.cuas_el0+""); // double
properties.setProperty(prefix+"cuas_show_disp", this.cuas_show_disp+""); // boolean
properties.setProperty(prefix+"cuas_show_rng", this.cuas_show_rng+""); // boolean
properties.setProperty(prefix+"cuas_show_inf", this.cuas_show_inf+""); // boolean
properties.setProperty(prefix+"cuas_show_inf_gt", this.cuas_show_inf_gt+""); // boolean
properties.setProperty(prefix+"cuas_show_true_rng", this.cuas_show_true_rng+""); // boolean
properties.setProperty(prefix+"cuas_smooth_omegas", this.cuas_smooth_omegas+""); // boolean
......@@ -4900,6 +4979,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_min_max_ac", this.cuas_min_max_ac+""); // double
properties.setProperty(prefix+"cuas_min_min_ac", this.cuas_min_min_ac+""); // double
properties.setProperty(prefix+"cuas_reset_disparity", this.cuas_reset_disparity+"");// boolean
properties.setProperty(prefix+"cuas_initial_disparity",this.cuas_initial_disparity+"");// double
properties.setProperty(prefix+"cuas_infinity", this.cuas_infinity+""); // double
properties.setProperty(prefix+"cuas_rng_img", this.cuas_rng_img+""); // boolean
......@@ -4909,6 +4989,9 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_rng_diff", this.cuas_rng_diff+""); // double
properties.setProperty(prefix+"cuas_debug", this.cuas_debug+""); // boolean
properties.setProperty(prefix+"cuas_dbg_rng_seq", this.cuas_dbg_rng_seq+""); // int
properties.setProperty(prefix+"cuas_dbg_show_mode", this.cuas_dbg_show_mode+""); // int
properties.setProperty(prefix+"cuas_step_debug", this.cuas_step_debug+""); // boolean
properties.setProperty(prefix+"cuas_save_stats", this.cuas_save_stats+""); // boolean
properties.setProperty(prefix+"cuas_target_debug", this.cuas_target_debug+""); // boolean
......@@ -4923,6 +5006,11 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_reuse_targets", this.cuas_reuse_targets+""); // boolean
properties.setProperty(prefix+"cuas_reuse_path", this.cuas_reuse_path+""); // String
properties.setProperty(prefix+"cuas_reuse_disparity", this.cuas_reuse_disparity+"");// boolean
properties.setProperty(prefix+"cuas_max_disp_diff", this.cuas_max_disp_diff+""); // double
properties.setProperty(prefix+"cuas_min_disp_str", this.cuas_min_disp_str+""); // double
properties.setProperty(prefix+"cuas_rng_limit", this.cuas_rng_limit+""); // double
properties.setProperty(prefix+"mb_gain_index_pose", this.mb_gain_index_pose+""); // int
properties.setProperty(prefix+"mb_gain_index_depth", this.mb_gain_index_depth+""); // int
......@@ -5895,14 +5983,21 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_annotate_uas")!=null) this.cuas_annotate_uas=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_annotate_uas"));
if (properties.getProperty(prefix+"cuas_text_color")!=null) {
long lcolor_annotate = Long.parseLong(properties.getProperty(prefix+"cuas_text_color"));
if (lcolor_annotate < 0) this.cuas_text_color = setLongColor(0xCCFF00);
if (lcolor_annotate < 0) this.cuas_text_color = setLongColor(0x00FF00);
else this.cuas_text_color = setLongColor(lcolor_annotate);
}
if (properties.getProperty(prefix+"cuas_text_bg")!=null) {
long lcolor_annotate = Long.parseLong(properties.getProperty(prefix+"cuas_text_bg"));
if (lcolor_annotate < 0) this.cuas_text_bg = setLongColor(0x777777);
else this.cuas_text_bg = setLongColor(lcolor_annotate);
}
if (properties.getProperty(prefix+"cuas_selected_color")!=null) {
long lcolor_annotate = Long.parseLong(properties.getProperty(prefix+"cuas_selected_color"));
if (lcolor_annotate < 0) this.cuas_selected_color = setLongColor(0xFF0088);
else this.cuas_selected_color = setLongColor(lcolor_annotate);
}
if (properties.getProperty(prefix+"cuas_transparent")!=null) this.cuas_transparent=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_transparent"));
if (properties.getProperty(prefix+"cuas_transparent_uas")!=null) this.cuas_transparent_uas=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_transparent_uas"));
if (properties.getProperty(prefix+"cuas_font_name")!= null) cuas_font_name=(String) properties.getProperty(prefix+"cuas_font_name");
if (properties.getProperty(prefix+"cuas_font_size")!=null) this.cuas_font_size=Integer.parseInt(properties.getProperty(prefix+"cuas_font_size"));
if (properties.getProperty(prefix+"cuas_font_type")!=null) this.cuas_font_type=Integer.parseInt(properties.getProperty(prefix+"cuas_font_type"));
......@@ -5911,6 +6006,10 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_py0")!=null) this.cuas_py0=Integer.parseInt(properties.getProperty(prefix+"cuas_py0"));
if (properties.getProperty(prefix+"cuas_az0")!=null) this.cuas_az0=Double.parseDouble(properties.getProperty(prefix+"cuas_az0"));
if (properties.getProperty(prefix+"cuas_el0")!=null) this.cuas_el0=Double.parseDouble(properties.getProperty(prefix+"cuas_el0"));
if (properties.getProperty(prefix+"cuas_show_disp")!=null) this.cuas_show_disp=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_show_disp"));
if (properties.getProperty(prefix+"cuas_show_rng")!=null) this.cuas_show_rng=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_show_rng"));
if (properties.getProperty(prefix+"cuas_show_inf")!=null) this.cuas_show_inf=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_show_inf"));
if (properties.getProperty(prefix+"cuas_show_inf_gt")!=null) this.cuas_show_inf_gt=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_show_inf_gt"));
if (properties.getProperty(prefix+"cuas_show_true_rng")!=null) this.cuas_show_true_rng=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_show_true_rng"));
if (properties.getProperty(prefix+"cuas_smooth_omegas")!=null) this.cuas_smooth_omegas=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_smooth_omegas"));
......@@ -5941,6 +6040,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_min_max_ac")!=null) this.cuas_min_max_ac=Double.parseDouble(properties.getProperty(prefix+"cuas_min_max_ac"));
if (properties.getProperty(prefix+"cuas_min_min_ac")!=null) this.cuas_min_min_ac=Double.parseDouble(properties.getProperty(prefix+"cuas_min_min_ac"));
if (properties.getProperty(prefix+"cuas_reset_disparity")!=null) this.cuas_reset_disparity=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_reset_disparity"));
if (properties.getProperty(prefix+"cuas_initial_disparity")!=null)this.cuas_initial_disparity=Double.parseDouble(properties.getProperty(prefix+"cuas_initial_disparity"));
if (properties.getProperty(prefix+"cuas_infinity")!=null) this.cuas_infinity=Double.parseDouble(properties.getProperty(prefix+"cuas_infinity"));
if (properties.getProperty(prefix+"cuas_rng_img")!=null) this.cuas_rng_img=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_rng_img"));
......@@ -5950,6 +6050,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_rng_diff")!=null) this.cuas_rng_diff=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_diff"));
if (properties.getProperty(prefix+"cuas_debug")!=null) this.cuas_debug=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_debug"));
if (properties.getProperty(prefix+"cuas_dbg_rng_seq")!=null) this.cuas_dbg_rng_seq=Integer.parseInt(properties.getProperty(prefix+"cuas_dbg_rng_seq"));
if (properties.getProperty(prefix+"cuas_dbg_show_mode")!=null) this.cuas_dbg_show_mode=Integer.parseInt(properties.getProperty(prefix+"cuas_dbg_show_mode"));
if (properties.getProperty(prefix+"cuas_step_debug")!=null) this.cuas_step_debug=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_step_debug"));
if (properties.getProperty(prefix+"cuas_save_stats")!=null) this.cuas_save_stats=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_save_stats"));
if (properties.getProperty(prefix+"cuas_target_debug")!=null) this.cuas_target_debug=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_target_debug"));
......@@ -5964,6 +6066,11 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_reuse_targets")!=null) this.cuas_reuse_targets=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_reuse_targets"));
if (properties.getProperty(prefix+"cuas_reuse_path")!=null) this.cuas_reuse_path=(String) properties.getProperty(prefix+"cuas_reuse_path");
if (properties.getProperty(prefix+"cuas_reuse_disparity")!=null) this.cuas_reuse_disparity=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_reuse_disparity"));
if (properties.getProperty(prefix+"cuas_max_disp_diff")!=null) this.cuas_max_disp_diff=Double.parseDouble(properties.getProperty(prefix+"cuas_max_disp_diff"));
if (properties.getProperty(prefix+"cuas_min_disp_str")!=null) this.cuas_min_disp_str=Double.parseDouble(properties.getProperty(prefix+"cuas_min_disp_str"));
if (properties.getProperty(prefix+"cuas_rng_limit")!=null) this.cuas_rng_limit=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_limit"));
if (properties.getProperty(prefix+"mb_gain_index_pose")!=null) this.mb_gain_index_pose=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_pose"));
if (properties.getProperty(prefix+"mb_ers_index")!=null) this.mb_ers_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_index"));
if (properties.getProperty(prefix+"mb_ers_y_index")!=null) this.mb_ers_y_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_y_index"));
......@@ -6935,8 +7042,11 @@ min_str_neib_fpn 0.35
imp.cuas_annotate = this.cuas_annotate;
imp.cuas_annotate_uas = this.cuas_annotate_uas;
imp.cuas_text_color= this.cuas_text_color;
imp.cuas_text_bg= this.cuas_text_bg;
imp.cuas_selected_color= this.cuas_selected_color;
imp.cuas_transparent = this.cuas_transparent;
imp.cuas_transparent_uas = this.cuas_transparent_uas;
imp.cuas_font_name = this.cuas_font_name;
imp.cuas_font_size = this.cuas_font_size;
imp.cuas_font_type = this.cuas_font_type;
......@@ -6945,6 +7055,10 @@ min_str_neib_fpn 0.35
imp.cuas_py0 = this.cuas_py0;
imp.cuas_az0 = this.cuas_az0;
imp.cuas_el0 = this.cuas_el0;
imp.cuas_show_disp = this.cuas_show_disp;
imp.cuas_show_rng = this.cuas_show_rng;
imp.cuas_show_inf = this.cuas_show_inf;
imp.cuas_show_inf_gt = this.cuas_show_inf_gt;
imp.cuas_show_true_rng = this.cuas_show_true_rng;
imp.cuas_smooth_omegas = this.cuas_smooth_omegas;
......@@ -6974,6 +7088,7 @@ min_str_neib_fpn 0.35
imp.cuas_min_max_ac = this.cuas_min_max_ac;
imp.cuas_min_min_ac = this.cuas_min_min_ac;
imp.cuas_reset_disparity = this.cuas_reset_disparity;
imp.cuas_initial_disparity= this.cuas_initial_disparity;
imp.cuas_infinity = this.cuas_infinity;
imp.cuas_rng_img = this.cuas_rng_img;
......@@ -6984,6 +7099,8 @@ min_str_neib_fpn 0.35
imp.cuas_rng_diff = this.cuas_rng_diff;
imp.cuas_debug = this.cuas_debug;
imp.cuas_dbg_rng_seq = this.cuas_dbg_rng_seq;
imp.cuas_dbg_show_mode = this.cuas_dbg_show_mode;
imp.cuas_step_debug = this.cuas_step_debug;
imp.cuas_save_stats = this.cuas_save_stats;
imp.cuas_target_debug = this.cuas_target_debug;
......@@ -6997,6 +7114,10 @@ min_str_neib_fpn 0.35
imp.cuas_reuse_targets = this.cuas_reuse_targets;
imp.cuas_reuse_path= this.cuas_reuse_path;
imp.cuas_reuse_disparity = this.cuas_reuse_disparity;
imp.cuas_max_disp_diff = this.cuas_max_disp_diff;
imp.cuas_min_disp_str = this.cuas_min_disp_str;
imp.cuas_rng_limit = this.cuas_rng_limit;
imp.mb_gain_index_pose = this.mb_gain_index_pose;
imp.mb_gain_index_depth = this.mb_gain_index_depth;
......
......@@ -6164,10 +6164,10 @@ if (debugLevel < -100) {
}
}
return um_mono;
}
}
public static double [][][][] unsharpMaskSource(
@Deprecated
public static double [][][][] unsharpMaskSource_old(
final QuadCLT[] scenes,
final int start_scene,
final int num_scenes,
......@@ -6266,6 +6266,195 @@ if (debugLevel < -100) {
return images_um;
}
public static double [][][][] unsharpMaskSource(
final QuadCLT[] scenes,
final int start_scene,
final int num_scenes,
final boolean um_en,
final boolean unsharped,
final boolean update_source, // if update_source will not generate output, return null
final double um_sigma,
final boolean um_twice,
final double um_weight,
final int debugLevel){
final int num_sens = scenes[start_scene].getNumSensors();
int [] whc = scenes[start_scene].getWHC(false);
final int width = whc[0];
final int height = whc[1];
final int num_col = whc[2];
final double [][][][] images_um = update_source? null : new double [num_scenes][num_sens][num_col][];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] img_buf = new double [width * height];
double [] img_buf2 = um_twice ? (new double [width * height]) : null;
for (int iScene = ai.getAndIncrement(); iScene < num_scenes; iScene = ai.getAndIncrement()) {
double [][][] image_um = unsharpMaskSource(
scenes[iScene + start_scene], // final QuadCLT scene,
um_en, // final boolean um_en,
unsharped, // final boolean unsharped,
update_source, // final boolean update_source, // if update_source will not generate output, return null
um_sigma, // final double um_sigma,
img_buf, // final double [] img_buf, // = new double [width * height];
img_buf2, // final double [] img_buf2, // = um_twice ? (new double [width * height]) : null;
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
if (images_um != null) {
images_um[iScene] = image_um;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return images_um;
}
public static double [][][] unsharpMaskSourceMono(
final QuadCLT[] scenes,
final int start_scene,
final int num_scenes,
final boolean um_en,
final double [][][] img_um, // cache for unsharped images, same length as scenes. May be null
final boolean unsharped, // ==false, not used
final boolean update_source, // ==false, not used if update_source will not generate output, return null
final double um_sigma,
final boolean um_twice,
final double um_weight,
final int debugLevel){
final int num_sens = scenes[start_scene].getNumSensors();
int [] whc = scenes[start_scene].getWHC(false);
final int width = whc[0];
final int height = whc[1];
final int num_col = whc[2];
final double [][][] images_um = new double [num_scenes][num_sens][];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] img_buf = new double [width * height];
double [] img_buf2 = um_twice ? (new double [width * height]) : null;
for (int iScene = ai.getAndIncrement(); iScene < num_scenes; iScene = ai.getAndIncrement()) {
int nscene = iScene + start_scene;
if ((img_um == null) || (img_um[nscene] == null)) {
double [][][] image_um_col = unsharpMaskSource( // [sensor][color][pixel]
scenes[iScene + start_scene], // final QuadCLT scene,
um_en, // final boolean um_en,
unsharped, // unsharped, // final boolean unsharped,
update_source, // update_source, // final boolean update_source, // if update_source will not generate output, return null
um_sigma, // final double um_sigma,
img_buf, // final double [] img_buf, // = new double [width * height];
img_buf2, // final double [] img_buf2, // = um_twice ? (new double [width * height]) : null;
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
for (int nsens = 0; nsens < num_sens; nsens++) {
images_um[iScene][nsens] = image_um_col[nsens][0];
}
if (img_um != null) { // save to cache
img_um[nscene] = images_um[iScene];
}
} else if (img_um != null) { // get from cache
images_um[iScene] = img_um[nscene]; // img_um[nscene] is not null here
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return images_um;
}
public static double [][][] unsharpMaskSource( // [sensor][color][pixel]
final QuadCLT scene,
final boolean um_en,
final boolean unsharped,
final boolean update_source, // if update_source will not generate output, return null
final double um_sigma,
final double [] img_buf, // = new double [width * height];
final double [] img_buf2, // = um_twice ? (new double [width * height]) : null;
final double um_weight,
final int debugLevel){
final int num_sens = scene.getNumSensors();
int [] whc = scene.getWHC(false);
final int width = whc[0];
final int height = whc[1];
final int num_col = whc[2];
final double [][][] images_um = update_source? null : new double [num_sens][num_col][];
final int num_sens_col = num_sens*num_col;
DoubleGaussianBlur gb = new DoubleGaussianBlur();
for (int nsens_col = 0; nsens_col < num_sens_col; nsens_col++) {
int nsens = nsens_col / num_col;
int ncol = nsens_col % num_col;
double [] img_src = scene.getOrigImageData()[nsens][ncol];
if (!unsharped && um_en) {
System.arraycopy(img_src, 0, img_buf, 0, img_buf.length);
gb.blurDouble(
img_buf, //
width,
height,
um_sigma, // double sigmaX,
um_sigma, // double sigmaY,
0.01); // double accuracy)
if (um_weight != 1.0) {
for (int i = 0; i < img_buf.length; i++) {
img_buf[i] *= um_weight;
}
}
if (img_buf2 != null) {
for (int i = 0; i < img_buf.length; i++) {
img_buf2[i] = img_src[i] - img_buf[i];
}
System.arraycopy(img_buf2, 0, img_buf, 0, img_buf.length);
gb.blurDouble(
img_buf2, //
width,
height,
um_sigma, // double sigmaX,
um_sigma, // double sigmaY,
0.01); // double accuracy)
if (um_weight != 1.0) {
for (int i = 0; i < img_buf.length; i++) {
img_buf2[i] *= um_weight;
}
}
for (int i = 0; i < img_buf.length; i++) {
img_buf[i] -= img_buf2[i];
}
if (update_source) {
for (int i = 0; i < img_buf.length; i++) {
img_src[i] = img_buf[i];
}
} else {
images_um[nsens][ncol] = img_buf.clone();
}
} else {
if (update_source) {
for (int i = 0; i < img_buf.length; i++) {
img_src[i] -= img_buf[i];
}
} else {
for (int i = 0; i < img_buf.length; i++) {
img_buf[i] = img_src[i] - img_buf[i];
}
images_um[nsens][ncol] = img_buf.clone();
}
}
} else { // just copy
images_um[nsens][ncol] = img_src.clone();
}
}
return images_um;
}
}
......@@ -5068,6 +5068,15 @@ __device__ void convertCorrectTile(
clt_src += DTT_SIZE1;
clt_dst += DTT_SIZE;
}
// A hack to accumulate with positive scale
} else if (tscale > 10.0f) { // > 10 - scale by (tscale-10) and add
float tscale1 = tscale - 10.0f;
for (int j = 0; j < DTT_SIZE * 4; j++){ // all 4 components, 8 rows
// shared memory tiles use DTT_SIZE1
*clt_dst += *clt_src * tscale1;
clt_src += DTT_SIZE1;
clt_dst += DTT_SIZE;
}
} else if (tscale > 0) { // positive - scale and set. For motion blur positive should be first
#pragma unroll
for (int j = 0; j < DTT_SIZE * 4; j++){ // all 4 components, 8 rows
......
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