Commit cbe46a22 authored by Andrey Filippov's avatar Andrey Filippov

ranging following target

parent 7364fa88
......@@ -4925,7 +4925,7 @@ public class CuasMotion {
/// "-NL"+lmax_flt_neglim+"-FH"+lmax_flt_hsigma+"-FL"+lmax_flt_lsigma+"-FS"+lmax_flt_scale+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma+
"-FZ"+clt_parameters.imp.cuas_rng_fz+
"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-M"+clt_parameters.imp.cuas_mcorr_sel+"-"+clt_parameters.imp.cuas_mcorr_sel_lma;
if (center_targ) {
......@@ -4976,7 +4976,7 @@ public class CuasMotion {
"-MS"+min_score_lma+"-ML"+min_seq+"-SL"+enough_seq+"-MT"+seq_travel+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma+
"-FZ"+clt_parameters.imp.cuas_rng_fz+
"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-M"+clt_parameters.imp.cuas_mcorr_sel+"-"+clt_parameters.imp.cuas_mcorr_sel_lma;
......
package com.elphel.imagej.cuas;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -34,7 +35,9 @@ public class CuasRanging {
final double [][][] img_um;
final CLTParameters clt_parameters;
CuasMotion cuasMotion = null;
public int debugLevel = 0;
double [][][] ranging_verify = null; // just for debugging, length - total number of scenes (some will be null)
double [] ranging_verify_weight = null; // accumulated scene weight (divide ranging_verify pixels)
public int debugLevel = 0;
public CuasRanging (
CLTParameters clt_parameters,
......@@ -527,7 +530,7 @@ public class CuasRanging {
scene_atr, // final double [] scene_atr,
radius0, // final double radius,
nseq, // final int nseq,
half_accum_range, // final int first_offs,
-half_accum_range,// final int first_offs,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
......@@ -645,7 +648,7 @@ public class CuasRanging {
/// final int num_sens = center_CLT.getNumSensors();
/// final int num_scenes = 2*half_accum_range+1;
/// final int num_scene_grp = (num_scenes + (rng_combine - 1)) / rng_combine;
final double [][][] ranging_verify = null; // (rng_vfy) ? (new double [num_scene_grp + 1][num_sens + 1][]) : null;
/// final double [][][] ranging_verify = null; // (rng_vfy) ? (new double [num_scene_grp + 1][num_sens + 1][]) : null;
if (log_ranging) {
String log_head = getRangingLogParameters();
......@@ -658,14 +661,16 @@ public class CuasRanging {
System.out.println ("rangeSingleTargets(): Processing target_id from "+target_id0+" to "+target_id1+" (inclusive)"); // for debugging
for (int target_id = target_id0; target_id <= target_id1; target_id++) {
boolean rng_vfy_this = (target_id == target_id0) && rng_vfy; // only for the first target in range
double [] target_stats = rangeSingleTarget( // return {disparity, strength, last disparity difference}
targets, // final double [][][] targets, // centers
linked_targets, // final int [][][] linked_targets,
target_id, // final int target_id, // target number, starting with 1
log_ranging, // final boolean log_ranging,
accum_2d_corr, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
show_mode, // final int show_mode, //+1 - disparity, +2 - correlations +4 - debug single run
ranging_verify, // final double [][][] ranging_verify,
show_mode, // final int show_mode, //+1 - disparity, +2 - correlations +4 - debug single run
// ranging_verify, // final double [][][] ranging_verify,
rng_vfy_this, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data) NOT implemented
debugLevel) ; // final int debugLevel) ;
target_glob_stats[target_id-1] = target_stats;
}
......@@ -751,7 +756,8 @@ public class CuasRanging {
sb.append("cuas_rng_radius0 = " + clt_parameters.imp.cuas_rng_radius0 + "\n"); // mask out data outside peripheral areas, keep 0.5 at the radius - first iteration
sb.append("cuas_rng_radius = " + clt_parameters.imp.cuas_rng_radius + "\n"); // mask out data outside peripheral areas, keep 0.5 at the radius - next iteration
sb.append("cuas_rng_blur = " + clt_parameters.imp.cuas_rng_blur + "\n"); // 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
sb.append("cuas_rng_fz = " + clt_parameters.imp.cuas_rng_fz + "\n"); // Fat zero in target ranging mode
sb.append("cuas_rng_fz0 = " + clt_parameters.imp.cuas_rng_fz0 + "\n"); // Fat zero in target ranging mode (first iteration)
sb.append("cuas_rng_fz = " + clt_parameters.imp.cuas_rng_fz + "\n"); // Fat zero in target ranging mode (next iterations)
sb.append("cuas_rng_scale = " + clt_parameters.imp.cuas_rng_scale + "\n"); // Scale alt_data to use same strength as for normal ranging because targets
sb.append("cuas_lma_bypass = " + clt_parameters.imp.cuas_lma_bypass + "\n"); // Bypass solution tests, OK weak
sb.append("cuas_mcorr_sel = " + clt_parameters.imp.cuas_mcorr_sel + "\n"); // all pairs and diagonals (as was for non-cuas ranging)
......@@ -784,7 +790,7 @@ public class CuasRanging {
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
// final int nseq,
final int show_mode, //+1 - disparity, +2 - correlations +4 - debug single run
final double [][][] ranging_verify,
final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data) NOT implemented
final int debugLevel) {
final int end_mode = clt_parameters.imp.cuas_glob_ends; // 1; // 0 - same as internal, 1 - cosine extended ends, 2 - rectangular extended ends // make a parameter
final boolean first_last_extra = (end_mode > 0);
......@@ -816,7 +822,7 @@ public class CuasRanging {
double cuas_infinity = clt_parameters.imp.cuas_infinity ; // 0.63; // disparity at infinity for targets
final int tilesX = center_CLT.getTilesX();
final int tilesY = center_CLT.getTilesY();
// final int tilesY = center_CLT.getTilesY();
// final int frame_center = cuasMotion.getFrameCenter(nseq); // for debug only
final boolean use_non_lma = false;
......@@ -842,6 +848,7 @@ public class CuasRanging {
int ref_tileX = ref_tile % tilesX;
int ref_tileY = ref_tile / tilesX;
for (int nrefine = 0; nrefine < rng_niterate; nrefine++) {
boolean rng_vfy_this = rng_vfy && (nrefine == refine_vfy);
double [][] disparity_map = refineSingleTargetDisparity(
targets, // final double [][][] targets, // centers
accum_2d_corr, //final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
......@@ -852,7 +859,17 @@ public class CuasRanging {
first_last_extra, // final boolean first_last_extra,
smooth_ends, // final boolean smooth_ends,
show_corr, // final boolean show_corr,
debugLevel); // final int debugLevel)
rng_vfy_this, // final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
debugLevel); // final int debugLevel)
// render this.ranging_verify here, regardless of the disparity_map
if (rng_vfy_this) {
ImagePlus imp_vfy = renderRangingVerifySingle(
target_id, // final int target_id,
nrefine, // final int nrefine,
false); // final boolean show)
center_CLT.saveImagePlusInModelDirectory(imp_vfy);
}
if (disparity_map == null) {
System.out.println("rangeTargets()): disparity_map==null on nrefine="+nrefine);
break;
......@@ -1043,7 +1060,7 @@ public class CuasRanging {
tilesX,
tilesY,
true,
center_CLT.getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz+
center_CLT.getImageName()+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-accumulated_disparity_map_R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (cuasMotion.getFrameCenter(nseq))+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
......@@ -1221,7 +1238,7 @@ public class CuasRanging {
ImagePlus imp_vfy = ShowDoubleFloatArrays.showArraysHyperstack(
ranging_verify, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz+
center_CLT.getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-F"+ (nscene0 + half_accum_range)+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
......@@ -1231,6 +1248,109 @@ public class CuasRanging {
show); // boolean show)
return imp_vfy;
}
public ImagePlus renderRangingVerifySingle(
final int target_id,
final int nrefine,
final boolean show) {
if (ranging_verify == null) {
return null;
}
String [] scene_titles = cuasMotion.getSceneTitles();
final int num_scenes = scene_titles.length;
ArrayList<Integer> indices_list = new ArrayList<Integer>();
for (int i = 0; i < num_scenes; i++) if (this.ranging_verify[i] != null) {
indices_list.add(i);
}
final int[] indices = indices_list.stream().mapToInt(Integer::intValue).toArray();
final int num_used_scenes = indices.length;
String [] titles_scenes = new String [num_used_scenes + 1];
final double [][][] ranging_verify = new double [indices.length + 1][][];
final double [] ranging_verify_weight = new double [indices.length + 1];
int sw = 0;
for (int i = 0; i < indices.length; i++) {
ranging_verify[i] = this.ranging_verify[indices[i]];
ranging_verify_weight[i] = this.ranging_verify_weight[indices[i]];
sw += ranging_verify_weight[i];
titles_scenes[i] = scene_titles[indices[i]];
}
titles_scenes[num_used_scenes]="COMBO";
final int num_sens = ranging_verify[0].length-1;
ranging_verify[num_used_scenes] = new double [num_sens+1][]; // ranging_verify[0][0].length];
ranging_verify_weight[num_used_scenes] = sw;
String [] titles_sensors = new String [num_sens+1];
for (int i = 0; i < (titles_sensors.length-1); i++) {
titles_sensors[i] = "SENS_"+i;
}
titles_sensors[titles_sensors.length-1]="ALL";
/// final int half_accum_range = cuasMotion.getSeqLength()/2;
/// final int num_scenes = 2*half_accum_range+1;
int rng_combine = clt_parameters.imp.cuas_rng_combine; // // combine multiple scenes before intrascene correlation
/// final int num_scene_grp = (num_scenes + (rng_combine - 1)) / rng_combine; //==ranging_verify.length - 1;
/// final int num_scenes = ranging_verify.length-1;
final int num_pix = ranging_verify[0][0].length;
/// final int half_accum_range = (num_scenes-1)/2;
// calculate averages: per scene (all sensors)
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 iScene = ai.getAndIncrement(); iScene < num_used_scenes; iScene = ai.getAndIncrement()) {
ranging_verify[iScene][num_sens] = new double [num_pix];
for (int npix = 0; npix < num_pix; npix++) {
double d = 0;
for (int nsens = 0; nsens < num_sens; nsens++) {
d += ranging_verify[iScene][nsens][npix];
}
ranging_verify[iScene][num_sens][npix] = d/num_sens;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ai.set(0);
// calculate averages: per sensors (including "all")
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSens = ai.getAndIncrement(); nSens < (num_sens+1); nSens = ai.getAndIncrement()) {
ranging_verify[num_used_scenes][nSens] = new double [num_pix];
for (int npix = 0; npix < num_pix; npix++) {
double d = 0;
for (int iscene = 0; iscene < num_used_scenes; iscene++) {
d += ranging_verify[iscene][nSens][npix]; // sum before normalizing
ranging_verify[iscene][nSens][npix] /= ranging_verify_weight[iscene]; // normalize each group image
}
ranging_verify[num_used_scenes][nSens][npix] = d / ranging_verify_weight[num_used_scenes];
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ImagePlus imp_vfy = ShowDoubleFloatArrays.showArraysHyperstack(
ranging_verify, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-RANGING_VERIFY-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz0+":"+clt_parameters.imp.cuas_rng_fz+
"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma +
"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
"-ID"+ target_id+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
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
show); // boolean show)
return imp_vfy;
}
public double [][][] getUMSequence(
final int start_scene,
......@@ -1244,13 +1364,13 @@ public class CuasRanging {
final double um_weight = clt_parameters.imp.cuas_rng_um_weight;
if (clean_up) {
for (int nscene = 0; nscene < start_scene; nscene++) {
if (erase_source) { // keep cache if source images are deleted
if (!erase_source) { // keep cache if source images are deleted
this.img_um[nscene] = null;
}
scenes[nscene].setImageDataAlt(null);
}
for (int nscene = start_scene+num_scenes; nscene < this.img_um.length; nscene++) {
if (erase_source) { // keep cache if source images are deleted
if (!erase_source) { // keep cache if source images are deleted
this.img_um[nscene] = null;
}
scenes[nscene].setImageDataAlt(null);
......@@ -1300,12 +1420,15 @@ public class CuasRanging {
final boolean first_last_extra,
final boolean smooth_ends,
final boolean show_corr,
final boolean rng_vfy, // Generate/save ranging verification images (per-sensor and combined rendering from the same data)
final int debugLevel){
final boolean show_sensors_vfy = true; // generate (unmasked) sensor images when rng_vfy is true;
final boolean show_alt_vfy = true; // generate (unmasked) sensor images when rng_vfy is true;
// final boolean show_corr = true;
// final boolean first_last_extra = true; // use longer sequences for the first/last keyframe
// final int num_tiles = targets[0].length;
// final double um_sigma = clt_parameters.imp.cuas_rng_um_sigma; // only for file names
final double rng_fz = clt_parameters.imp.cuas_rng_fz;
final double rng_fz = (nrefine == 0)?clt_parameters.imp.cuas_rng_fz0 : 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
......@@ -1315,17 +1438,23 @@ public class CuasRanging {
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 half_accum_range = cuasMotion.getSeqLength()/2;
boolean clean_up = true; // remove unneded data
boolean clean_up = true; // remove unneeded data
boolean erase_source = true; // check everything works
final int frame_center0 = cuasMotion.getFrameCenter(first_seq);
final int frame_step = cuasMotion.getCorrInc(); // 20
final int hframe_step = frame_step/2;
final int start_scene = frame_center0 - (first_last_extra ? half_accum_range: hframe_step);
final int num_seq = target_tiles.length;
final int num_scenes = first_last_extra ? ((num_seq -1) * frame_step + 2* half_accum_range + 1) : (num_seq * frame_step);
// final int num_scenes = first_last_extra ? ((num_seq -1) * frame_step + 2* half_accum_range + 1) : (num_seq * frame_step);
final int num_scenes = ((num_seq-1) * frame_step) + 2 * (first_last_extra ? half_accum_range : (frame_step/ 2)) + 1;
final double [] window_nnorm = new double [num_scenes];
Arrays.fill(window_nnorm, 1.0);
if (rng_vfy) { // create for each scene, unused will be nulls
ranging_verify = new double [cuasMotion.getSceneTitles().length + 1][][];
ranging_verify_weight = new double [ranging_verify.length];
}
if (first_last_extra ) {
final double [] window1= cuasMotion.getSegmentWindow( // normalized, sum == 1.0
smooth_ends, // boolean smooth)
......@@ -1348,6 +1477,35 @@ public class CuasRanging {
clean_up, // final boolean clean_up, // remove unneded data
erase_source, // final boolean erase_source, // erase source images (will not clean up this.img_um)
debugLevel); // final int debugLevel)
if (rng_vfy && show_sensors_vfy) {
String [] titles_sensors = new String[img_um_seq[0].length];
for (int i = 0; i < titles_sensors.length; i++) titles_sensors[i] = "SENS-"+i;
String [] titles_scenes = new String[img_um_seq.length];
for (int i = 0; i < titles_scenes.length; i++) {
titles_scenes[i] = cuasMotion.getSceneTitles()[start_scene+i];
}
boolean show = false; // true;
ImagePlus imp_sensors_um =ShowDoubleFloatArrays.showArraysHyperstack(
img_um_seq, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-SENSOR_FULL_IMAGES"+
//"-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz+
//"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma
//"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
//"-ID"+ target_id+":"+nrefine+
//"-M"+clt_parameters.imp.cuas_mcorr_sel+
//"-"+clt_parameters.imp.cuas_mcorr_sel_lma
,
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
show); // boolean show)
center_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_sensors_um); // imp_scenes); // ImagePlus imp)
}
/*
double [][][] pXpYDs = cuasMotion.targetPxPyD(
targets[nseq]); // final double [][] targets)
......@@ -1411,8 +1569,21 @@ public class CuasRanging {
for (int rnseq = 0; rnseq < num_seq; rnseq++) { // relative sequence number, starting from 0
int nseq = first_seq + rnseq; // absolute sequence number
int frame_center = cuasMotion.getFrameCenter(nseq);
int first_offs = ((rnseq==0) && first_last_extra)? -half_accum_range : -hframe_step;
int last_offs = ((rnseq==(num_seq - 1)) && first_last_extra)? half_accum_range : (frame_step - hframe_step);
// int first_offs = ((rnseq==0) && first_last_extra)? -half_accum_range : -hframe_step;
// int last_offs = ((rnseq==(num_seq - 1)) && first_last_extra)? half_accum_range : (frame_step - hframe_step);
int first_offs = -hframe_step;
if ((rnseq==0) && first_last_extra) {
first_offs = -half_accum_range;
}
int last_offs = frame_step - hframe_step - 1; // -1 for inclusive
if (rnseq==(num_seq - 1)) {
if (first_last_extra) {
last_offs = half_accum_range;
} else {
last_offs = frame_step - hframe_step; // 1 longer
}
}
// int rscene0 = frame_center + first_offs; // negative offset
// int rscene1 = frame_center + last_offs; // positive offset
int ntile = target_tiles[rnseq];
......@@ -1450,6 +1621,7 @@ public class CuasRanging {
System.out.println("renderKeyFrame() BUG1");
continue;
}
int seq_offs = first_offs - rnseq * frame_step; // start of he img_um_seq[] relative to the center of he interval
prepareAltImages(
image_dtt, // final ImageDtt image_dtt,
ref_pXpYD, // final double [][] ref_pXpYD,
......@@ -1457,7 +1629,7 @@ public class CuasRanging {
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius, // final double radius,
first_offs, // final int first_offs,
seq_offs, // first_offs, // final int first_offs,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
......@@ -1536,17 +1708,23 @@ public class CuasRanging {
}
// correlate only after the last in group, others - just accumulate in TD
if (last_in_grp) {
/*
if (ranging_verify != null) { // [2*half_accum_range +1 +1][num_sens+1][] // [num_pix])
if (rng_vfy) { // this should not be in a thread
if (ranging_verify == null) { // save to this.ranging_verify sparce array
ranging_verify = new double [cuasMotion.getSceneTitles().length + 1][][];
ranging_verify_weight = new double [ranging_verify.length];
}
if (ranging_verify[nscene] == null) {
ranging_verify[nscene]= new double [num_sens+1][];
}
double [][] scene_render = center_CLT.renderDoubleFromTDMono ( // [sensor][pixel]
-1, // int sensor_mask,
null, // int [] wh, // may be null, or {width, height}
false); // boolean use_reference
for (int nsens = 0; nsens < scene_render.length; nsens++) {
ranging_verify[iscene_grp][nsens] = scene_render[nsens];
ranging_verify[nscene][nsens] = scene_render[nsens];
}
ranging_verify_weight[nscene] = wgrp;
}
*/
float [][][][] fcorr_td = new float[tilesY][tilesX][][];
image_dtt.quadCorrTD(
......@@ -1675,6 +1853,71 @@ public class CuasRanging {
titles); // image_dtt.getCorrelation2d().getCorrTitles()); //CORR_TITLES);
}
}
if (rng_vfy && show_alt_vfy) {
String [] titles_sensors = new String[img_um_seq[0].length];
for (int i = 0; i < titles_sensors.length; i++) titles_sensors[i] = "SENS-"+i;
String [] titles_scenes = new String[img_um_seq.length];
for (int i = 0; i < titles_scenes.length; i++) {
titles_scenes[i] = cuasMotion.getSceneTitles()[start_scene+i];
}
boolean show = false; // true;
double [][][] alt_images = new double [titles_scenes.length][][];
for (int i = 0; i < alt_images.length; i++) {
double [][][] alt_sens_col = scenes[start_scene+i].getAltImageData();
alt_images[i] = new double[alt_sens_col.length][];
for (int j = 0; j < alt_sens_col.length; j++) {
alt_images[i][j] = alt_sens_col[j][0];
}
}
//img_um_seq
ImagePlus imp_alt =ShowDoubleFloatArrays.showArraysHyperstack(
alt_images, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-SENSOR_ALT_IMAGES"+
//"-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz+
//"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma
//"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
//"-ID"+ target_id+":"+nrefine+
//"-M"+clt_parameters.imp.cuas_mcorr_sel+
//"-"+clt_parameters.imp.cuas_mcorr_sel_lma
,
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
show); // boolean show)
center_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_alt); // imp_scenes); // ImagePlus imp)
}
/*
if (rng_vfy && show_sensors_vfy) { // verify img_um_seq did not change - yes, same as before
String [] titles_sensors = new String[img_um_seq[0].length];
for (int i = 0; i < titles_sensors.length; i++) titles_sensors[i] = "SENS-"+i;
String [] titles_scenes = new String[img_um_seq.length];
for (int i = 0; i < titles_scenes.length; i++) {
titles_scenes[i] = cuasMotion.getSceneTitles()[start_scene+i];
}
boolean show = false; // true;
ImagePlus imp_sensors_um =ShowDoubleFloatArrays.showArraysHyperstack(
img_um_seq, // double[][][] pixels,
center_CLT.getWidth(), // int width,
center_CLT.getImageName()+"-SENSOR_FULL_IMAGES2"+
//"-R"+"-FZ"+clt_parameters.imp.cuas_rng_fz+
//"-CB"+clt_parameters.imp.cuas_rng_combine+(clt_parameters.imp.cuas_rng_coswnd?"-WC":"-WR")+
"-UM"+(clt_parameters.imp.cuas_rng_um2?"D":"") +clt_parameters.imp.cuas_rng_um_sigma
//"-R"+clt_parameters.imp.cuas_rng_radius0+":"+clt_parameters.imp.cuas_rng_radius+
//"-ID"+ target_id+":"+nrefine+
//"-M"+clt_parameters.imp.cuas_mcorr_sel+
//"-"+clt_parameters.imp.cuas_mcorr_sel_lma
,
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
show); // boolean show)
center_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_sensors_um); // imp_scenes); // ImagePlus imp)
}
*/
return disparity_map; // disparity_map
}
......@@ -1690,7 +1933,7 @@ public class CuasRanging {
final int debugLevel) {
final double um_sigma = clt_parameters.imp.cuas_rng_um_sigma;
final double rng_fz = clt_parameters.imp.cuas_rng_fz;
final double rng_fz = (nrefine == 0)?clt_parameters.imp.cuas_rng_fz0 : 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
......@@ -1836,7 +2079,7 @@ public class CuasRanging {
scene_xyz, // final double [] scene_xyz,
scene_atr, // final double [] scene_atr,
radius, // final double radius,
half_accum_range, // final int first_offs,
-half_accum_range,// final int first_offs,
nseq, // final int nseq,
dseq, // final int dseq,
debugLevel); // final int debugLevel)
......@@ -2113,7 +2356,7 @@ public class CuasRanging {
final double [] scene_xyz,
final double [] scene_atr,
final double radius,
final int first_offs,
final int first_offs, // not used
final int nseq, // absolute sequence number (to calculate center frame
final int dseq,
final int debugLevel) {
......@@ -2124,12 +2367,12 @@ public class CuasRanging {
final int tileSize = center_CLT.getTileSize();
final int width = tilesX * tileSize;
final int frame_center = cuasMotion.getFrameCenter(nseq);
final int half_accum_range = cuasMotion.getSeqLength()/2;
// final int half_accum_range = cuasMotion.getSeqLength()/2;
ErsCorrection ers_reference = center_CLT.getErsCorrection();
final int num_sens = center_CLT.getNumSensors();
final int nscene = frame_center + dseq;
final int iscene = half_accum_range + dseq;
final int iscene = dseq - first_offs; // starts from 0
final String ts = scenes[nscene].getImageName();
final double [] scene_ers_xyz_dt = ers_reference.getSceneErsXYZ_dt(ts);
......@@ -2158,11 +2401,11 @@ public class CuasRanging {
width, // final int width,
debugLevel); // final int debugLevel);
for (int nsens = 0; nsens < num_sens; nsens++) {
img_sens_col[nsens][0] = masked[nsens];
img_sens_col[nsens][0] = masked[nsens]; // .clone();
}
} else {
for (int nsens = 0; nsens < num_sens; nsens++) {
img_sens_col[nsens][0] = img_um_seq[iscene][nsens]; // Index 80 out of bounds for length 71
img_sens_col[nsens][0] = img_um_seq[iscene][nsens]; //.clone(); // Index 80 out of bounds for length 71
}
}
scenes[nscene].setImageDataAlt(img_sens_col);
......
......@@ -879,6 +879,7 @@ min_str_neib_fpn 0.35
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_fz0 = 300.0; // Fat zero in target ranging mode, first iteration (first 2?)
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
......@@ -2666,8 +2667,10 @@ min_str_neib_fpn 0.35
"Mask out data outside peripheral areas, keep 0.5 at the radius .");
gd.addNumericField("Mask blur fraction for ranging", this.cuas_rng_blur, 5,8,"",
"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.");
gd.addNumericField("Fat zero", this.cuas_rng_fz, 5,8,"",
"Fat zero for target ranging.");
gd.addNumericField("Fat zero (first iteration)", this.cuas_rng_fz0, 5,8,"",
"Fat zero for target ranging (larger, use for the initial fitting).");
gd.addNumericField("Fat zero (next iterations)", this.cuas_rng_fz, 5,8,"",
"Fat zero for target ranging (smaller, use for the next LMA iterations).");
gd.addNumericField("Scale alt image data", this.cuas_rng_scale, 5,8,"x",
"Scale alt_data to use same strength as for normal ranging because targets are smaller than tile.");
......@@ -3890,6 +3893,7 @@ min_str_neib_fpn 0.35
this.cuas_rng_radius0 = gd.getNextNumber();
this.cuas_rng_radius = gd.getNextNumber();
this.cuas_rng_blur = gd.getNextNumber();
this.cuas_rng_fz0= gd.getNextNumber();
this.cuas_rng_fz = gd.getNextNumber();
this.cuas_rng_scale = gd.getNextNumber();
......@@ -4977,6 +4981,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_rng_radius0", this.cuas_rng_radius0+""); // double
properties.setProperty(prefix+"cuas_rng_radius", this.cuas_rng_radius+""); // double
properties.setProperty(prefix+"cuas_rng_blur", this.cuas_rng_blur+""); // double
properties.setProperty(prefix+"cuas_rng_fz0", this.cuas_rng_fz0+""); // double
properties.setProperty(prefix+"cuas_rng_fz", this.cuas_rng_fz+""); // double
properties.setProperty(prefix+"cuas_rng_scale", this.cuas_rng_scale+""); // double
......@@ -6041,6 +6046,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_rng_radius0")!=null) this.cuas_rng_radius0=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_radius0"));
if (properties.getProperty(prefix+"cuas_rng_radius")!=null) this.cuas_rng_radius=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_radius"));
if (properties.getProperty(prefix+"cuas_rng_blur")!=null) this.cuas_rng_blur=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_blur"));
if (properties.getProperty(prefix+"cuas_rng_fz0")!=null) this.cuas_rng_fz0=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_fz0"));
if (properties.getProperty(prefix+"cuas_rng_fz")!=null) this.cuas_rng_fz=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_fz"));
if (properties.getProperty(prefix+"cuas_rng_scale")!=null) this.cuas_rng_scale=Double.parseDouble(properties.getProperty(prefix+"cuas_rng_scale"));
......@@ -7092,6 +7098,7 @@ min_str_neib_fpn 0.35
imp.cuas_rng_radius0 = this.cuas_rng_radius0;
imp.cuas_rng_radius = this.cuas_rng_radius;
imp.cuas_rng_blur = this.cuas_rng_blur;
imp.cuas_rng_fz0 = this.cuas_rng_fz0;
imp.cuas_rng_fz = this.cuas_rng_fz;
imp.cuas_rng_scale = this.cuas_rng_scale;
......
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