Commit dafb1ad3 authored by Andrey Filippov's avatar Andrey Filippov

Cleaning up, preparing to the batch run

parent 7b15b76c
...@@ -2549,7 +2549,7 @@ public class EyesisCorrectionParameters { ...@@ -2549,7 +2549,7 @@ public class EyesisCorrectionParameters {
// select qualified (by 'name' - quad timestamp) x3d subdirectory // select qualified (by 'name' - quad timestamp) x3d subdirectory
public String selectX3dDirectory(String name, String version, boolean smart, boolean newAllowed) { public String selectX3dDirectory(String name, String version, boolean smart, boolean newAllowed) { // no trailing "/"
String dir= CalibrationFileManagement.selectDirectory( String dir= CalibrationFileManagement.selectDirectory(
smart, smart,
newAllowed, // save newAllowed, // save
......
...@@ -5,11 +5,16 @@ import java.awt.Font; ...@@ -5,11 +5,16 @@ import java.awt.Font;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.net.URISyntaxException;
import java.net.URL;
import com.elphel.imagej.cameras.CLTParameters; import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
...@@ -49,6 +54,17 @@ public class CuasMotion { ...@@ -49,6 +54,17 @@ public class CuasMotion {
final static public int TARGET_VY = 3; final static public int TARGET_VY = 3;
final static public int TARGET_STRENGTH = 4; final static public int TARGET_STRENGTH = 4;
final static public int TARGET_LENGTH = TARGET_STRENGTH+1; final static public int TARGET_LENGTH = TARGET_STRENGTH+1;
public static String RESOURCE_GRAPICS_DIR ="graphics";
public static String ICON_TARGET_1X = "TDbox_dashed21x21_bold.png";
public static String ICON_TARGET_2X = "TDbox_dashed43x43_2px.png";
public static String [][] TARGET_ICONS = {
{"TDbox_dashed21x21_bold.png","TDbox_dashed43x43_2px.png"}, // unknown
{"TDbox21x21.png", "TDbox43x43_2px.png"}, // selected
{"Circle21x21.png", "Circle43x43_2px.png"}, // friend
{"diamond21x17.png", "diamond43x35_2px.png"} // foe
};
private final GPUTileProcessor gpuTileProcessor; private final GPUTileProcessor gpuTileProcessor;
private CLTParameters clt_parameters=null; private CLTParameters clt_parameters=null;
...@@ -114,7 +130,7 @@ public class CuasMotion { ...@@ -114,7 +130,7 @@ public class CuasMotion {
int debugLevel) { int debugLevel) {
int framecent = 180; int framecent = 180;
int corr_offset = clt_parameters.imp.cuas_corr_offset; int corr_offset = clt_parameters.imp.cuas_corr_offset;
int corr_pairs = clt_parameters.imp.cuas_corr_pairs; int corr_pairs = clt_parameters.imp.cuas_corr_pairs;
double cuas_fat_zero = clt_parameters.imp.cuas_fat_zero; double cuas_fat_zero = clt_parameters.imp.cuas_fat_zero;
double cuas_cent_radius = clt_parameters.imp.cuas_cent_radius; double cuas_cent_radius = clt_parameters.imp.cuas_cent_radius;
int cuas_n_recenter = clt_parameters.imp.cuas_n_recenter; int cuas_n_recenter = clt_parameters.imp.cuas_n_recenter;
...@@ -246,6 +262,12 @@ public class CuasMotion { ...@@ -246,6 +262,12 @@ public class CuasMotion {
CLTParameters clt_parameters, CLTParameters clt_parameters,
QuadCLT parentCLT, QuadCLT parentCLT,
int debugLevel) { int debugLevel) {
String image_name = imp_sel.getTitle().substring(0,17);
parentCLT.setImageName(image_name);
String x3d_path = parentCLT.getX3dDirectory();
System.out.println ("Model directory = "+x3d_path);
int corr_offset = clt_parameters.imp.cuas_corr_offset; int corr_offset = clt_parameters.imp.cuas_corr_offset;
int corr_pairs = clt_parameters.imp.cuas_corr_pairs; int corr_pairs = clt_parameters.imp.cuas_corr_pairs;
double fat_zero = clt_parameters.imp.cuas_fat_zero; double fat_zero = clt_parameters.imp.cuas_fat_zero;
...@@ -287,6 +309,26 @@ public class CuasMotion { ...@@ -287,6 +309,26 @@ public class CuasMotion {
double lma_mink = clt_parameters.imp.cuas_lma_mink; // = 0.0; // Minimal K (overshoot) <0.007 double lma_mink = clt_parameters.imp.cuas_lma_mink; // = 0.0; // Minimal K (overshoot) <0.007
double lma_maxk = clt_parameters.imp.cuas_lma_maxk; // = 5.0; // Minimal K (overshoot) > 3.8 double lma_maxk = clt_parameters.imp.cuas_lma_maxk; // = 5.0; // Minimal K (overshoot) > 3.8
double mask_width = clt_parameters.imp.cuas_mask_width; // 9;
double mask_blur = clt_parameters.imp.cuas_mask_blur; // 3;
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
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;
for (int i = 0; i < target_frac.length; i++) { for (int i = 0; i < target_frac.length; i++) {
if (clt_parameters.imp.cuas_target_frac[i].length >= 2) { if (clt_parameters.imp.cuas_target_frac[i].length >= 2) {
target_frac[i][0] = clt_parameters.imp.cuas_target_frac[i][0]; target_frac[i][0] = clt_parameters.imp.cuas_target_frac[i][0];
...@@ -372,6 +414,37 @@ public class CuasMotion { ...@@ -372,6 +414,37 @@ public class CuasMotion {
"Maximal ratio of the overshoot radius to the first 0 radius (typical 3.0)."); "Maximal ratio of the overshoot radius to the first 0 radius (typical 3.0).");
gd.addNumericField("Mask diameter", mask_width, 5,8,"pix",
"Taget mask to replace static background with moving target.");
gd.addNumericField("Mask transition width", mask_blur, 5,8,"pix",
"Transition between opaque and transparent mask.");
gd.addCheckbox ("Mask round", mask_round,
"Use round mask. Unchesked - use sharp square mask without any transition.");
gd.addNumericField("Targets icon type", target_type, 0,3,"",
"0 - unknown (dashed square), 1 - known (square), 2 - friend (circle), 3 - foe (diamond).");
gd.addNumericField("Image range", input_range, 5,8,"10mK",
"Dispaly pixel values range (1.0 ~= 10 mK).");
gd.addCheckbox ("Scale images twice", scale2x,
"Scale imges to 1280x1024 for higher annotation quality.");
gd.addCheckbox ("Smooth background with runnong average", ra_background,
"Apply running average to the background of the moving targets (false - use high-noise no-averaged images.");
gd.addMessage("=== Saving intermediate and final images and video ===");
gd.addCheckbox ("Save tile-resolution intermediate images", intermed_low,
"Save intermediate vector fields and target coordinates from the LMA (80x64 layers).");
gd.addCheckbox ("Save pixel-resolution intermediate images",intermed_high,
"Save pixel-resolution accumulated images (640x512).");
gd.addCheckbox ("Save monochrome targets+background", save_mono,
"Save 32-bit monochrome targets+background Tiffs (before optional scaling).");
gd.addCheckbox ("Save color targets+background", save_color,
"Save color rendered images (same as videos), optionally scaled.");
gd.addCheckbox ("Save videos", save_video,
"Save video with moving targets.");
gd.addStringField("Data directory", data_dir,100,"Intermediate results directory (to bypass first stages during debugging)."); gd.addStringField("Data directory", data_dir,100,"Intermediate results directory (to bypass first stages during debugging).");
gd.addCheckbox ("Save_params", save_params, "Save edited parameters"); gd.addCheckbox ("Save_params", save_params, "Save edited parameters");
...@@ -400,7 +473,7 @@ public class CuasMotion { ...@@ -400,7 +473,7 @@ public class CuasMotion {
target_radius = gd.getNextNumber(); target_radius = gd.getNextNumber();
target_strength = gd.getNextNumber(); target_strength = gd.getNextNumber();
target_frac = IntersceneMatchParameters.stringToDouble2d(gd.getNextString()); target_frac = IntersceneMatchParameters.stringToDouble2d(gd.getNextString());
no_border = gd.getNextBoolean(); no_border = gd.getNextBoolean();
lma_sigma = gd.getNextNumber(); lma_sigma = gd.getNextNumber();
lma_r0 = gd.getNextNumber(); lma_r0 = gd.getNextNumber();
lma_ovrsht = gd.getNextNumber(); lma_ovrsht = gd.getNextNumber();
...@@ -422,6 +495,22 @@ public class CuasMotion { ...@@ -422,6 +495,22 @@ public class CuasMotion {
lma_maxr = gd.getNextNumber(); lma_maxr = gd.getNextNumber();
lma_mink = gd.getNextNumber(); lma_mink = gd.getNextNumber();
lma_maxk = gd.getNextNumber(); lma_maxk = gd.getNextNumber();
mask_width = gd.getNextNumber();
mask_blur = gd.getNextNumber();
mask_round = gd.getNextBoolean();
target_type= (int) gd.getNextNumber();
input_range = gd.getNextNumber();
scale2x = gd.getNextBoolean();
ra_background = gd.getNextBoolean();
intermed_low = gd.getNextBoolean();
intermed_high = gd.getNextBoolean();
save_mono = gd.getNextBoolean();
save_color = gd.getNextBoolean();
save_video = gd.getNextBoolean();
data_dir = gd.getNextString(); data_dir = gd.getNextString();
save_params = gd.getNextBoolean(); save_params = gd.getNextBoolean();
...@@ -474,6 +563,20 @@ public class CuasMotion { ...@@ -474,6 +563,20 @@ public class CuasMotion {
clt_parameters.imp.cuas_lma_maxr = lma_maxr; clt_parameters.imp.cuas_lma_maxr = lma_maxr;
clt_parameters.imp.cuas_lma_mink = lma_mink; clt_parameters.imp.cuas_lma_mink = lma_mink;
clt_parameters.imp.cuas_lma_maxk = lma_maxk; clt_parameters.imp.cuas_lma_maxk = lma_maxk;
clt_parameters.imp.cuas_mask_width = mask_width;
clt_parameters.imp.cuas_mask_blur = mask_blur;
clt_parameters.imp.cuas_mask_round = mask_round;
clt_parameters.imp.cuas_target_type = target_type;
clt_parameters.imp.cuas_input_range = input_range;
clt_parameters.imp.cuas_scale2x = scale2x;
clt_parameters.imp.cuas_ra_background =ra_background;
clt_parameters.imp.cuas_intermed_low = intermed_low;
clt_parameters.imp.cuas_intermed_high =intermed_high;
clt_parameters.imp.cuas_save_mono = save_mono;
clt_parameters.imp.cuas_save_color = save_color;
clt_parameters.imp.cuas_save_video = save_video;
} }
int start_frame = 0; int start_frame = 0;
...@@ -527,6 +630,24 @@ public class CuasMotion { ...@@ -527,6 +630,24 @@ public class CuasMotion {
System.out.println("lma_maxr= "+lma_maxr); System.out.println("lma_maxr= "+lma_maxr);
System.out.println("lma_mink= "+lma_mink); System.out.println("lma_mink= "+lma_mink);
System.out.println("lma_maxk= "+lma_maxk); System.out.println("lma_maxk= "+lma_maxk);
System.out.println("mask_width= "+mask_width);
System.out.println("mask_blur= "+mask_blur);
System.out.println("mask_round= "+mask_round);
System.out.println("target_type= "+target_type);
System.out.println("input_range= "+input_range);
System.out.println("scale2x= "+scale2x);
System.out.println("ra_background= "+ra_background);
System.out.println("intermed_low= "+intermed_low);
System.out.println("intermed_high= "+intermed_high);
System.out.println("save_mono= "+save_mono);
System.out.println("save_color= "+save_color);
System.out.println("save_video= "+save_video);
System.out.println("ra_background= "+ra_background);
System.out.println("intermed_low= "+intermed_low);
System.out.println("intermed_high= "+intermed_high);
System.out.println("save_mono= "+save_mono);
System.out.println("save_color= "+save_color);
System.out.println("save_video= "+save_video);
} }
float [][] fpixels = new float[num_scenes][]; float [][] fpixels = new float[num_scenes][];
String [] scene_titles = new String [num_scenes]; String [] scene_titles = new String [num_scenes];
...@@ -551,7 +672,6 @@ public class CuasMotion { ...@@ -551,7 +672,6 @@ public class CuasMotion {
String imp_name = imp_sel.getTitle(); String imp_name = imp_sel.getTitle();
imp_name = trimSuffix(imp_name,".tif"); imp_name = trimSuffix(imp_name,".tif");
imp_name = trimSuffix(imp_name,".tiff"); imp_name = trimSuffix(imp_name,".tiff");
// String [] vf_top_titles = {"vX","vY","strength","fraction","speed", "confidence"};
String title_cor2d = imp_name+"-corr2d"+suffix_param; // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs, String title_cor2d = imp_name+"-corr2d"+suffix_param; // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
String title_vf_all = imp_name+"-vector_field_all"+suffix_param; // String title_vf_all = imp_name+"-vector_field_all"+suffix_param; //
String title_vf = imp_name+"-vector_field"+suffix_param; // String title_vf = imp_name+"-vector_field"+suffix_param; //
...@@ -568,7 +688,7 @@ public class CuasMotion { ...@@ -568,7 +688,7 @@ public class CuasMotion {
final int frame0 = start_frame + seq_length/2; final int frame0 = start_frame + seq_length/2;
final int half_accum_range = corr_pairs/2; final int half_accum_range = corr_pairs/2;
final boolean smooth_accum = true; // final boolean smooth_accum = true;
double [][][] corr2d = null; // to read it if bypassing calculations double [][][] corr2d = null; // to read it if bypassing calculations
double [][][] motion_scan = null; double [][][] motion_scan = null;
...@@ -582,7 +702,7 @@ public class CuasMotion { ...@@ -582,7 +702,7 @@ public class CuasMotion {
String vf_path = data_dir + "/" + title_vf+".tiff"; String vf_path = data_dir + "/" + title_vf+".tiff";
// motion_scan_filtered = getVectorFieldHyper(vf_filtered_path); // String path) // motion_scan_filtered = getVectorFieldHyper(vf_filtered_path); // String path)
if (test_lma) { if (test_lma) {
String path_vf = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/25_r1.5/I-1747803449_165687-vector_field_good-offs20-pairs50-rstr0.01-fz300.0-cr3.0-mr1-ms0.0-sp0.0-sb1.0-tr2.0-ts0.8-tf0.0,0.12:2.5,0.15:5.0,0.25.tiff"; String path_vf = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/25_r1.5/I-1747803449_165687-vector_field_good-offs20-pairs50-rstr0.01-fz300.0-cr3.0-mr1-ms0.0-sp0.0-sb1.0-tr2.0-ts0.8-tf0.0,0.12:2.5,0.15:5.0,0.25.tiff";
String path_acc = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/25_r1.5/I-1747803449_165687-accumulated-offs20-pairs50-rstr0.01-fz300.0-cr3.0-mr1-ms0.0-sp0.0-sb1.0-tr2.0-ts0.8-tf0.0,0.12:2.5,0.15:5.0,0.25-n20.tiff"; String path_acc = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/25_r1.5/I-1747803449_165687-accumulated-offs20-pairs50-rstr0.01-fz300.0-cr3.0-mr1-ms0.0-sp0.0-sb1.0-tr2.0-ts0.8-tf0.0,0.12:2.5,0.15:5.0,0.25-n20.tiff";
double [][][] vf_sequence = getVectorFieldHyper(path_vf); // String path) double [][][] vf_sequence = getVectorFieldHyper(path_vf); // String path)
if (vf_sequence == null) { if (vf_sequence == null) {
...@@ -600,6 +720,21 @@ public class CuasMotion { ...@@ -600,6 +720,21 @@ public class CuasMotion {
0, // int num_slices, // (0 - all) 0, // int num_slices, // (0 - all)
wh); // int [] wh) wh); // int [] wh)
boolean batch_mode = true;
generateExtractFilterMovingTargets( // move parameters to clt_parameters
clt_parameters, // CLTParameters clt_parameters,
batch_mode, // final boolean batch_mode,
parentCLT, // QuadCLT parentCLT, //
fpixels, // final float [][] fpixels,
accum, // final float [][] accum, //
vf_sequence, // final double [][][] vf_sequence, //
frame0, //final int frame0, // for vector_field[0] // source scene corresponding to the first sequence
cuasMotion, // final CuasMotion cuasMotion,
scene_titles, // String [] scene_titles, // recreate slice_titles from scene titles?
slice_titles, // String [] slice_titles,
debugLevel); // final int debugLevel)
/*
double [][][][] coord_data2 = getAccumulatedCoordinates( double [][][][] coord_data2 = getAccumulatedCoordinates(
vf_sequence, // final double [][][] vector_fields, // centers vf_sequence, // final double [][][] vector_fields, // centers
accum, // final double [][] accum_data, // should be around 0, no low-freq accum, // final double [][] accum_data, // should be around 0, no low-freq
...@@ -653,7 +788,8 @@ public class CuasMotion { ...@@ -653,7 +788,8 @@ public class CuasMotion {
title_targets_filt+"-VF-TEST-FILTERED", // String title_targets_filt, title_targets_filt+"-VF-TEST-FILTERED", // String title_targets_filt,
targets_remain, // int [] targets_remain, targets_remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX) cuasMotion.tilesX, // int tilesX)
true); // show_vector_field); // boolean show) true, // show_vector_field); // boolean show)
null); // do not save //QuadCLT parentCLT)
int remained_total = printRemain(targets_remain, "Total good targets", true); int remained_total = printRemain(targets_remain, "Total good targets", true);
double [][][] coord_data_filtered_lma = filterAndShowTargetsLMA( double [][][] coord_data_filtered_lma = filterAndShowTargetsLMA(
...@@ -669,7 +805,8 @@ public class CuasMotion { ...@@ -669,7 +805,8 @@ public class CuasMotion {
title_targets_filt+"-LMA-TEST-FILTERED", // String title_targets_filt, title_targets_filt+"-LMA-TEST-FILTERED", // String title_targets_filt,
targets_remain, // int [] targets_remain, targets_remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX) cuasMotion.tilesX, // int tilesX)
true); // show_vector_field); // boolean show) true, // show_vector_field); // boolean show)
null); // do not save //QuadCLT parentCLT)
remained_total = printRemain(targets_remain, "coord_data_filtered_lma: Total new targets LMA", true); remained_total = printRemain(targets_remain, "coord_data_filtered_lma: Total new targets LMA", true);
// remove tiles that did not pass old vf filter // remove tiles that did not pass old vf filter
...@@ -706,7 +843,7 @@ public class CuasMotion { ...@@ -706,7 +843,7 @@ public class CuasMotion {
frame0, // final int frame0, // for vector_field[0] frame0, // final int frame0, // for vector_field[0]
corr_step, // final int frame_step, corr_step, // final int frame_step,
half_accum_range, // final int half_range, half_accum_range, // final int half_range,
smooth_accum, // final boolean smooth, smooth, // final boolean smooth,
corr_offset, // final int corr_offset, // interframe distance for correlation corr_offset, // final int corr_offset, // interframe distance for correlation
true); // final boolean batch_mode) { true); // final boolean batch_mode) {
// zero-fill undefined tiles // zero-fill undefined tiles
...@@ -719,12 +856,9 @@ public class CuasMotion { ...@@ -719,12 +856,9 @@ public class CuasMotion {
title_accumulated+"-TARGETS5x5", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs, title_accumulated+"-TARGETS5x5", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
slice_titles); // titles_accum); slice_titles); // titles_accum);
double mask_width = 9;
double mask_blur = 3;
boolean round = false;
double velocity_scale = 1.0/corr_offset; double velocity_scale = 1.0/corr_offset;
double [][][] targets60hz = new double [fpixels.length][][]; double [][][] targets60hz = new double [fpixels.length][][];
boolean ra_background = true; // boolean ra_background = true;
float [][] background = fpixels; float [][] background = fpixels;
if (ra_background) { if (ra_background) {
background = runningAverage( background = runningAverage(
...@@ -737,7 +871,7 @@ public class CuasMotion { ...@@ -737,7 +871,7 @@ public class CuasMotion {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
mask_width, // final double mask_width, mask_width, // final double mask_width,
mask_blur, // final double mask_blur, mask_blur, // final double mask_blur,
round, // final boolean round, mask_round, // final boolean round,
fpixels_accumulated5x5, // final float [][] target_keyframes, fpixels_accumulated5x5, // final float [][] target_keyframes,
extended_vf_sequence, // final double [][][] vector_field, extended_vf_sequence, // final double [][][] vector_field,
targets_lma_combo, // final double [][][] target_positions, targets_lma_combo, // final double [][][] target_positions,
...@@ -756,16 +890,15 @@ public class CuasMotion { ...@@ -756,16 +890,15 @@ public class CuasMotion {
true, true,
title_accumulated+"-REPLACED-TARGETS", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs, title_accumulated+"-REPLACED-TARGETS", // "-corr2d"+"-"+frame0+"-"+frame1+"-"+corr_pairs,
scene_titles); // titles_accum); scene_titles); // titles_accum);
double input_range = 5; // String diamond_path_1x = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond21x17.png";
boolean scale2x = true;
String diamond_path_1x = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond21x17.png";
// String diamond_path_2x = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond43x35_2px.png"; // String diamond_path_2x = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/diamond43x35_2px.png";
String diamond_path_2x = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/TDbox_dashed43x43_2px.png"; // String diamond_path_2x = "/media/elphel/NVME/lwir16-proc/eagle_mountain/graphics/TDbox_dashed43x43_2px.png";
String diamond_path = scale2x? diamond_path_2x : diamond_path_1x; // String diamond_path = scale2x? diamond_path_2x : diamond_path_1x;
ImagePlus imp_color = convertToRgbAnnotateTargets( ImagePlus imp_color = convertToRgbAnnotateTargets(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
input_range, // final double input_range, // 5 input_range, // final double input_range, // 5
scale2x, // boolean scale2x, scale2x, // boolean scale2x,
target_type, // final int target_type, // = 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
replaced_targets, // final float [][] fpixels, replaced_targets, // final float [][] fpixels,
targets60hz, // final double [][][] targets60hz, targets60hz, // final double [][][] targets60hz,
frame0, // final int frame0, frame0, // final int frame0,
...@@ -773,39 +906,26 @@ public class CuasMotion { ...@@ -773,39 +906,26 @@ public class CuasMotion {
cuasMotion.gpu_max_width, // final int width, cuasMotion.gpu_max_width, // final int width,
title_accumulated+"-COLOR", // String title, title_accumulated+"-COLOR", // String title,
scene_titles, // String [] titles, scene_titles, // String [] titles,
diamond_path, // //String diamond_path, null, // diamond_path, // //String diamond_path, null - use resources
debugLevel); // final int debugLevel) { debugLevel); // final int debugLevel) {
// save tiff in model directory
if (imp_color != null) { if (imp_color != null) {
// temporary, will use model directory // temporary, will use model directory
String save_directory = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/video/"; String save_directory = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/video/";
String video_path_tmp = save_directory + imp_name+"-TARGETS"; String video_path_tmp = save_directory + imp_name+"-TARGETS";
String video_path = saveAsVideo( String video_path = saveAsVideo(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
video_path_tmp, // String file_path, parentCLT, // QuadCLT scene, // if not null - use it's model directory
null, // video_path_tmp, // String file_path,
imp_color, // ImagePlus imp_color, imp_color, // ImagePlus imp_color,
debugLevel); // int debugLevel) { debugLevel); // int debugLevel) {
imp_color.show(); imp_color.show();
} }
*/
continue; continue;
} }
motion_scan = getVectorFieldHyper(vf_path); // title_vf); // String path) motion_scan = getVectorFieldHyper(vf_path); // title_vf); // String path)
/*
if (motion_scan_filtered != null) {
extended_scan = extendMotionScan(
motion_scan_filtered, // final double [][][] motion_scan,
filter5, // final boolean [][] filtered, // centers, should be non-overlapped
cuasMotion.tilesX, // final int tilesX)
1, // final int range, // 1 or 2
remain); // final int [] remain)
}
*/
// extended_scan = getVectorFieldHyper(vf_extended_path); // String path) // extended_scan = getVectorFieldHyper(vf_extended_path); // String path)
// if (extended_scan == null) { // if (extended_scan == null) {
boolean show_vector_field = false; //true; boolean show_vector_field = false; //true;
...@@ -984,7 +1104,7 @@ public class CuasMotion { ...@@ -984,7 +1104,7 @@ public class CuasMotion {
frame0, // final int frame0, // for vector_field[0] frame0, // final int frame0, // for vector_field[0]
corr_step, // final int frame_step, corr_step, // final int frame_step,
half_accum_range, // final int half_range, half_accum_range, // final int half_range,
smooth_accum, // final boolean smooth, smooth, // final boolean smooth,
corr_offset, // final int corr_offset, // interframe distance for correlation corr_offset, // final int corr_offset, // interframe distance for correlation
true); // final boolean batch_mode) { true); // final boolean batch_mode) {
// show just fpixels_accumulated // show just fpixels_accumulated
...@@ -1072,7 +1192,9 @@ public class CuasMotion { ...@@ -1072,7 +1192,9 @@ public class CuasMotion {
title_targets_filt+"-n"+niter, // String title_targets_filt, title_targets_filt+"-n"+niter, // String title_targets_filt,
targets_remain, // int [] targets_remain, targets_remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX) cuasMotion.tilesX, // int tilesX)
show_vector_field); // boolean show) show_vector_field, // boolean show)
null); // do not save //QuadCLT parentCLT)
remained_total = printRemain(targets_remain, "coord_data_filtered: Total new targets", true); remained_total = printRemain(targets_remain, "coord_data_filtered: Total new targets", true);
if (remained_total == 0) { if (remained_total == 0) {
break; break;
...@@ -1090,7 +1212,9 @@ public class CuasMotion { ...@@ -1090,7 +1212,9 @@ public class CuasMotion {
title_targets_filt+"-n"+niter, // String title_targets_filt, title_targets_filt+"-n"+niter, // String title_targets_filt,
targets_remain, // int [] targets_remain, targets_remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX) cuasMotion.tilesX, // int tilesX)
show_vector_field); // boolean show) show_vector_field, // boolean show)
null); // do not save //QuadCLT parentCLT)
remained_total = printRemain(targets_remain, "coord_data_filtered: Total new targets", true); remained_total = printRemain(targets_remain, "coord_data_filtered: Total new targets", true);
...@@ -1216,7 +1340,7 @@ public class CuasMotion { ...@@ -1216,7 +1340,7 @@ public class CuasMotion {
frame0, // final int frame0, // for vector_field[0] frame0, // final int frame0, // for vector_field[0]
corr_step, // final int frame_step, corr_step, // final int frame_step,
half_accum_range, // final int half_range, half_accum_range, // final int half_range,
smooth_accum, // final boolean smooth, smooth, // final boolean smooth,
corr_offset, // final int corr_offset, // interframe distance for correlation corr_offset, // final int corr_offset, // interframe distance for correlation
true); // final boolean batch_mode) { true); // final boolean batch_mode) {
if (show_full_images) { if (show_full_images) {
...@@ -1302,7 +1426,9 @@ public class CuasMotion { ...@@ -1302,7 +1426,9 @@ public class CuasMotion {
title_targets_filt+"-n"+niter, // String title_targets_filt, title_targets_filt+"-n"+niter, // String title_targets_filt,
targets_remain, // int [] targets_remain, targets_remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX) cuasMotion.tilesX, // int tilesX)
show_vector_field); // boolean show) show_vector_field, // boolean show)
null); // do not save //QuadCLT parentCLT)
int remained_total = printRemain(targets_remain, "Total good targets", true); int remained_total = printRemain(targets_remain, "Total good targets", true);
double [][][] coord_data_filtered_lma = filterAndShowTargetsLMA( double [][][] coord_data_filtered_lma = filterAndShowTargetsLMA(
...@@ -1318,7 +1444,9 @@ public class CuasMotion { ...@@ -1318,7 +1444,9 @@ public class CuasMotion {
title_targets_filt+"-n"+niter, // String title_targets_filt, title_targets_filt+"-n"+niter, // String title_targets_filt,
targets_remain, // int [] targets_remain, targets_remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX) cuasMotion.tilesX, // int tilesX)
show_vector_field); // boolean show) show_vector_field, // boolean show)
null); // do not save //QuadCLT parentCLT)
remained_total = printRemain(targets_remain, "coord_data_filtered: Total new targets LMA", true); remained_total = printRemain(targets_remain, "coord_data_filtered: Total new targets LMA", true);
...@@ -1435,7 +1563,10 @@ public class CuasMotion { ...@@ -1435,7 +1563,10 @@ public class CuasMotion {
String title_targets_filt, String title_targets_filt,
int [] targets_remain, int [] targets_remain,
int tilesX, int tilesX,
boolean show) { boolean show,
QuadCLT parentCLT) {
boolean save = (parentCLT != null);
boolean [][] good_targets = filterTargets( boolean [][] good_targets = filterTargets(
coord_data, // final double [][][] target_coords, coord_data, // final double [][][] target_coords,
target_strength, // final double target_strength, target_strength, // final double target_strength,
...@@ -1445,9 +1576,8 @@ public class CuasMotion { ...@@ -1445,9 +1576,8 @@ public class CuasMotion {
double [][][] coord_data_filtered = applyFilter( double [][][] coord_data_filtered = applyFilter(
coord_data, // double [][][] motion_scan, coord_data, // double [][][] motion_scan,
good_targets); // boolean [][] filter5) good_targets); // boolean [][] filter5)
if (show) { if (show || save) {
///ImagePlus imp = ImagePlus imp = showVectorFieldsSequence(
showVectorFieldsSequence(
coord_data_filtered, // double [][][] vector_fields_sequence, coord_data_filtered, // double [][][] vector_fields_sequence,
0.0, // double speed_min, 0.0, // double speed_min,
0.0, // double speed_pref, 0.0, // double speed_pref,
...@@ -1455,8 +1585,11 @@ public class CuasMotion { ...@@ -1455,8 +1585,11 @@ public class CuasMotion {
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
title_targets_filt, // String title, title_targets_filt, // String title,
false, // boolean nan_effective_strength, false, // boolean nan_effective_strength,
true, // boolean show, show, // boolean show,
tilesX); // int tilesX) { tilesX); // int tilesX) {
if (save) {
parentCLT.saveImagePlusInModelDirectory(imp); // ImagePlus imp)
}
} }
return coord_data_filtered; // manually restart with different parameters return coord_data_filtered; // manually restart with different parameters
} }
...@@ -1474,7 +1607,9 @@ public class CuasMotion { ...@@ -1474,7 +1607,9 @@ public class CuasMotion {
String title_targets_filt, String title_targets_filt,
int [] targets_remain, int [] targets_remain,
int tilesX, int tilesX,
boolean show) { boolean show,
QuadCLT parentCLT) {
boolean save = (parentCLT != null);
double lma_minxy = 0.8; double lma_minxy = 0.8;
boolean [][] good_targets = filterTargetsLMA( boolean [][] good_targets = filterTargetsLMA(
coord_data, // final double [][][] target_coords, coord_data, // final double [][][] target_coords,
...@@ -1491,14 +1626,16 @@ public class CuasMotion { ...@@ -1491,14 +1626,16 @@ public class CuasMotion {
double [][][] coord_data_filtered = applyFilter( double [][][] coord_data_filtered = applyFilter(
coord_data, // double [][][] motion_scan, coord_data, // double [][][] motion_scan,
good_targets); // boolean [][] filter5) good_targets); // boolean [][] filter5)
if (show) { if (save || show) {
///ImagePlus imp = ImagePlus imp = showVectorFieldsSequenceLMA(
showVectorFieldsSequenceLMA(
coord_data_filtered, // double [][][] target_scene_sequence, coord_data_filtered, // double [][][] target_scene_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
title_targets_filt, // String title, title_targets_filt, // String title,
true, // boolean show, show, // boolean show,
tilesX); // int tilesX) { tilesX); // int tilesX) {
if (save) {
parentCLT.saveImagePlusInModelDirectory(imp); // ImagePlus imp)
}
} }
return coord_data_filtered; // manually restart with different parameters return coord_data_filtered; // manually restart with different parameters
} }
...@@ -2936,6 +3073,7 @@ public class CuasMotion { ...@@ -2936,6 +3073,7 @@ public class CuasMotion {
CLTParameters clt_parameters, CLTParameters clt_parameters,
final double input_range, // 5 final double input_range, // 5
final boolean scale2x, final boolean scale2x,
final int target_type, // = 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
final float [][] fpixels, final float [][] fpixels,
final double [][][] targets60hz, final double [][][] targets60hz,
final int frame0, final int frame0,
...@@ -2945,6 +3083,18 @@ public class CuasMotion { ...@@ -2945,6 +3083,18 @@ public class CuasMotion {
String [] titles, String [] titles,
String diamond_path, String diamond_path,
final int debugLevel) { final int debugLevel) {
if (diamond_path == null) {
String resource_name = TARGET_ICONS[target_type][scale2x? 1 : 0];
URL resourceUrl = CuasMotion.class.getClassLoader().getResource("graphics/"+resource_name);
Path resourcePath = null;
try {
resourcePath = Paths.get(resourceUrl.toURI());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
diamond_path = resourcePath.toString();
}
final int scale = scale2x? 2 : 1; final int scale = scale2x? 2 : 1;
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX); final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
...@@ -3152,13 +3302,14 @@ public class CuasMotion { ...@@ -3152,13 +3302,14 @@ public class CuasMotion {
}; };
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
imp.show(); // imp.show();
return imp; return imp;
} }
public static String saveAsVideo( public static String saveAsVideo(
CLTParameters clt_parameters, CLTParameters clt_parameters,
String file_path, QuadCLT scene, // if not null - use it's model directory
String file_path, // if not null, use it regardless of scene
ImagePlus imp_color, ImagePlus imp_color,
int debugLevel) { int debugLevel) {
double video_fps = clt_parameters.imp.video_fps; double video_fps = clt_parameters.imp.video_fps;
...@@ -3172,18 +3323,35 @@ public class CuasMotion { ...@@ -3172,18 +3323,35 @@ public class CuasMotion {
boolean dry_run = false; boolean dry_run = false;
String avi_path = null; String avi_path = null;
try {
avi_path=QuadCLT.saveAVI( if (file_path != null) {
file_path, // String file_path, // forces avi, removes .tif, tiff, and .avi try {
dry_run, // !generate_mapped, // boolean dry_run, avi_path=QuadCLT.saveAVI(
mode_avi, // int avi_mode, file_path, // String file_path, // forces avi, removes .tif, tiff, and .avi
avi_JPEG_quality, // int avi_JPEG_quality, dry_run, // !generate_mapped, // boolean dry_run,
video_fps, // double fps, mode_avi, // int avi_mode,
imp_color); // imp_scenes_pair[nstereo]); // ImagePlus imp) avi_JPEG_quality, // int avi_JPEG_quality,
} catch (IOException e) { video_fps, // double fps,
// TODO Auto-generated catch block imp_color); // imp_scenes_pair[nstereo]); // ImagePlus imp)
e.printStackTrace(); } catch (IOException e) {
return null; // TODO Auto-generated catch block
e.printStackTrace();
return null;
}
} else {
try {
avi_path=scene.saveAVIInModelDirectory(
dry_run, // !generate_mapped, // boolean dry_run,
null, // String suffix, // null - use title from the imp
mode_avi, // int avi_mode,
avi_JPEG_quality, // int avi_JPEG_quality,
video_fps, // double fps,
imp_color); // imp_scenes_pair[nstereo]); // ImagePlus imp)
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
} }
if (avi_path == null) { if (avi_path == null) {
return null; return null;
...@@ -3231,6 +3399,315 @@ public class CuasMotion { ...@@ -3231,6 +3399,315 @@ public class CuasMotion {
return webm_path; return webm_path;
} }
public static void generateExtractFilterMovingTargets( // move parameters to clt_parameters
CLTParameters clt_parameters,
final boolean batch_mode,
QuadCLT parentCLT, //
final float [][] fpixels,
final float [][] accum, //
final double [][][] vf_sequence, //
final int frame0, // for vector_field[0] // source scene corresponding to the first sequence
final CuasMotion cuasMotion,
String [] scene_titles, // recreate slice_titles from scene titles?
String [] slice_titles,
final int debugLevel) {
// String x3d_path = parentCLT.getX3dDirectory();
String model_prefix = parentCLT.getImageName();
boolean show_vector_field = true;
boolean show_full_images = true;
show_vector_field &= !batch_mode;
show_full_images &= !batch_mode;
// final String model_dir =
final int corr_offset = clt_parameters.imp.cuas_corr_offset;
final int corr_pairs = clt_parameters.imp.cuas_corr_pairs;
final boolean half_step = clt_parameters.imp.cuas_half_step; // true;
final boolean smooth = clt_parameters.imp.cuas_smooth; // true;
final int corr_step = half_step ? (corr_offset/2) : corr_offset;
final int half_accum_range = corr_pairs/2;
final double target_radius = clt_parameters.imp.cuas_target_radius;
final int n_recenter = clt_parameters.imp.cuas_n_recenter;
final boolean no_border= clt_parameters.imp.cuas_no_border; // true;
final double mask_width = clt_parameters.imp.cuas_mask_width; // 9;
final double mask_blur = clt_parameters.imp.cuas_mask_blur; // 3;
final boolean mask_round = clt_parameters.imp.cuas_mask_round; // false;
final double target_strength = clt_parameters.imp.cuas_target_strength;
final double [][] target_frac = new double [clt_parameters.imp.cuas_target_frac.length][2];
// Moving target LMA
double lma_sigma = clt_parameters.imp.cuas_lma_sigma; // = 3.0;
double lma_r0 = clt_parameters.imp.cuas_lma_r0; // = 3.0; //maximum with with overshoot
double lma_ovrsht = clt_parameters.imp.cuas_lma_ovrsht; // = 2.0;
// CUAS Motion LMA parameters
boolean lma_fit_xy= clt_parameters.imp.cuas_lma_fit_xy; // true;
boolean lma_fit_a= clt_parameters.imp.cuas_lma_fit_a; // true;
boolean lma_fit_c= clt_parameters.imp.cuas_lma_fit_c; // true;
boolean lma_fit_r= clt_parameters.imp.cuas_lma_fit_r; // true;
boolean lma_fit_k= clt_parameters.imp.cuas_lma_fit_k; // true;
double lambda = clt_parameters.imp.cuas_lambda; // = 0.1;
double lambda_good = clt_parameters.imp.cuas_lambda_good; // = 0.5;
double lambda_bad = clt_parameters.imp.cuas_lambda_bad; // = 8;
double lambda_max = clt_parameters.imp.cuas_lambda_max; // = 100;
double rms_diff = clt_parameters.imp.cuas_rms_diff; // = 0.001; // relative RMS improvement
int num_iter = clt_parameters.imp.cuas_num_iter; // = 20;
// CUAS Motion LMA filter parameters
double lma_rms = clt_parameters.imp.cuas_lma_rms; // = 1.5; // Maximal RMS, regardless of amplitude
double lma_arms = clt_parameters.imp.cuas_lma_arms; // = 0.06; // Maximal absolute RMS, sufficient for any amplitude
double lma_rrms = clt_parameters.imp.cuas_lma_rrms; // = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
double lma_mina = clt_parameters.imp.cuas_lma_mina; // = 1.0; // Minimal A (amplitude)
double lma_maxr = clt_parameters.imp.cuas_lma_maxr; // = 5.0; // Maximal radius (>3.8)
double lma_mink = clt_parameters.imp.cuas_lma_mink; // = 0.0; // Minimal K (overshoot) <0.007
double lma_maxk = clt_parameters.imp.cuas_lma_maxk; // = 5.0; // Minimal K (overshoot) > 3.8
int target_type = clt_parameters.imp.cuas_target_type; //0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
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;
double [][][][] coord_data2 = getAccumulatedCoordinates(
vf_sequence, // final double [][][] vector_fields, // centers
accum, // final double [][] accum_data, // should be around 0, no low-freq
target_radius, // final double centroid_radius,
n_recenter, // final int n_recenter, // re-center window around new maximum. 0 -no refines (single-pass)
cuasMotion.tilesX, // final int tilesX){
no_border, // final boolean no_border,
// Moving target LMA
lma_sigma, // final double lma_sigma,
lma_r0, // final double lma_r0,
lma_ovrsht, // final double lma_ovrsht,
// CUAS Motion LMA parameters
lma_fit_xy, // final boolean lma_fit_xy,
lma_fit_a, // final boolean lma_fit_a,
lma_fit_c, // final boolean lma_fit_c,
lma_fit_r, // final boolean lma_fit_r,
lma_fit_k, // final boolean lma_fit_k,
lambda, // final double lambda,
lambda_good, // final double lambda_good,
lambda_bad, // final double lambda_bad,
lambda_max, // final double lambda_max,
rms_diff, // final double rms_diff,
num_iter, // final int num_iter,
debugLevel); // final int debugLevel);
double [][][] coord_data = coord_data2[0];
double [][][] coord_lma = coord_data2[1];
if (show_vector_field || intermed_low) {
ImagePlus imp_vf = showVectorFieldsSequence(
coord_data, // double [][][] vector_fields_sequence,
0.0, // double speed_min,
0.0, // double speed_pref,
1.0, // double speed_boost,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-VF-UNFILTERED", // String title,
false, // boolean nan_effective_strength,
show_vector_field, // boolean show,
cuasMotion.tilesX); // int tilesX) {
if (intermed_low) {
parentCLT.saveImagePlusInModelDirectory(imp_vf);
}
ImagePlus imp_lma = showVectorFieldsSequenceLMA(
coord_lma, // double [][][] target_scene_sequence, // rename
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-LMA-UNFILTERED", // String title,
show_vector_field, // boolean show,
cuasMotion.tilesX); // int tilesX) {
if (intermed_low) {
parentCLT.saveImagePlusInModelDirectory(imp_lma);
}
}
int [] remain = new int [coord_data.length];
double [][][] coord_data_filtered = filterAndShowTargets(
coord_data, // double [][][] coord_data,
target_strength, // double target_strength,
target_frac, // double [][] target_frac,
slice_titles, // String [] slice_titles, //
model_prefix+"-VF-FILTERED", // String title_targets_filt,
remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX)
show_vector_field, // boolean show)
intermed_low?parentCLT:null); // parentCLT to save in model directory, null - do not save
if (debugLevel > -4) printRemain(remain, "Total good targets", true);
double [][][] coord_data_filtered_lma = filterAndShowTargetsLMA(
coord_lma,// double [][][] coord_data,
lma_rms, // double lma_rms, // = 1.5; // Maximal RMS (should always match, regardless if A)
lma_arms, // double lma_arms, // = 0.03; // Maximal absolutre RMS
lma_rrms, // double lma_rrms, // = 0.03; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
lma_mina, // double lma_mina, // = 1.0; // Minimal A (amplitude)
lma_maxr, // double lma_maxr, // = 5.0; // Minimal K (overshoot) = 3.0
lma_mink, // double lma_mink, // = 1.0; // Minimal K (overshoot) = 1.0
lma_maxk, // double lma_maxk, // = 1.0; // Minimal K (overshoot) = 3.0
slice_titles, // String [] slice_titles, //
model_prefix+"-LMA-FILTERED", // String title_targets_filt,
remain, // int [] targets_remain,
cuasMotion.tilesX, // int tilesX)
show_vector_field, // show_vector_field); // boolean show)
intermed_low?parentCLT:null); // parentCLT to save in model directory, null - do not save
if (debugLevel > -4) printRemain(remain, "coord_data_filtered_lma: Total new targets LMA", true);
// remove tiles that did not pass old vf filter
double [][][] targets_lma_combo = filterMotionScans( // should keep LMA coordinates
coord_data_filtered_lma, // double [][][] scan0,
coord_data_filtered, // double [][][] scan1)
remain);
// create vector field sequence by masking after the last filter
double [][][] targets_vf_combo = filterMotionScans( // should keep LMA coordinates
vf_sequence, // double [][][] scan0,
targets_lma_combo, // double [][][] scan1)
remain);
if (debugLevel > -4) printRemain(remain, "targets_lma_combo", true);
ImagePlus imp_filtered_combo= showVectorFieldsSequenceLMA(
targets_lma_combo, // double [][][] target_scene_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-FILTERED-COMBO", // String title,
show_vector_field, // boolean show,
cuasMotion.tilesX); // int tilesX) {
if (intermed_low) {
parentCLT.saveImagePlusInModelDirectory(imp_filtered_combo); // ImagePlus imp)
}
// create larger, 5x5 vector field for accumulation
double [][][] extended_vf_sequence = extendMotionScan(
targets_vf_combo, // final double [][][] motion_scan,
null, // filter5, // final boolean [][] filtered, // centers, should be non-overlapped
cuasMotion.tilesX, // final int tilesX)
2, // final int range, // 1 or 2
remain); // final int [] remain)
ImagePlus imp_extended = showVectorFieldsSequence(
extended_vf_sequence, // double [][][] vector_fields_sequence,
0.0, // double speed_min,
0.0, // double speed_pref,
1.0, // double speed_boost,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-EXTENDED", // String title,
false, // boolean nan_effective_strength,
show_vector_field, // boolean show,
cuasMotion.tilesX); // int tilesX) {
if (intermed_low) {
parentCLT.saveImagePlusInModelDirectory(imp_extended);
}
float [][] fpixels_accumulated5x5 = cuasMotion.shiftAndRenderAccumulate(
clt_parameters, // CLTParameters clt_parameters,
true, // final boolean fill_zeros,
fpixels, // final float [][] fpixels,
extended_vf_sequence, // final double [][][] vector_field,
frame0, // final int frame0, // for vector_field[0]
corr_step, // final int frame_step,
half_accum_range, // final int half_range,
smooth, // final boolean smooth,
corr_offset, // final int corr_offset, // interframe distance for correlation
true); // final boolean batch_mode) {
// zero-fill undefined tiles
ImagePlus imp_accumulated5x5 = ShowDoubleFloatArrays.makeArrays(
fpixels_accumulated5x5, // float[][] pixels,
cuasMotion.gpu_max_width, // int width,
cuasMotion.gpu_max_height, // int height,
model_prefix+"-TARGETS5x5", //String title,
slice_titles); //String [] titles)
if (show_full_images) {
imp_accumulated5x5.show();
}
if (intermed_high) {
parentCLT.saveImagePlusInModelDirectory(imp_accumulated5x5); // ImagePlus imp)
}
double velocity_scale = 1.0/corr_offset;
double [][][] targets60hz = new double [fpixels.length][][];
float [][] background = fpixels;
String ra_bg_suffix=(ra_background? "-RABG":"");
if (ra_background) {
background = runningAverage(
fpixels, // final float [][] fpixels,
corr_pairs, // final int ra_length,
cuasMotion.gpu_max_width); // final int width)
}
float [][] replaced_targets = cuasMotion.shiftAndRenderTargets(
clt_parameters, // CLTParameters clt_parameters,
mask_width, // final double mask_width,
mask_blur, // final double mask_blur,
mask_round, // final boolean round,
fpixels_accumulated5x5, // final float [][] target_keyframes,
extended_vf_sequence, // final double [][][] vector_field,
targets_lma_combo, // final double [][][] target_positions,
background, // final float [][] background, // background image
frame0, // final int frame0,
corr_step, // final int frame_step,
velocity_scale, // final double velocity_scale, // 1.0/(disparity in frames)
targets60hz, // final double [][][] targets60hz,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel)
ImagePlus imp_replaced_targets = ShowDoubleFloatArrays.makeArrays(
replaced_targets, // float[][] pixels,
cuasMotion.gpu_max_width, // int width,
cuasMotion.gpu_max_height, // int height,
model_prefix+"-REPLACED-TARGETS"+(ra_background? "-RABG":""), //String title,
scene_titles); //String [] titles)
if (show_full_images) {
imp_replaced_targets.show();
}
if (save_mono) {
parentCLT.saveImagePlusInModelDirectory(imp_replaced_targets); // ImagePlus imp)
}
ImagePlus imp_color = convertToRgbAnnotateTargets(
clt_parameters, // CLTParameters clt_parameters,
input_range, // final double input_range, // 5
scale2x, // boolean scale2x,
target_type, // final int target_type, // = 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
replaced_targets, // final float [][] fpixels,
targets60hz, // final double [][][] targets60hz,
frame0, // final int frame0,
corr_step, // final int frame_step,
cuasMotion.gpu_max_width, // final int width,
model_prefix+"-RGB"+ra_bg_suffix, // String title,
scene_titles, // String [] titles,
null, // diamond_path, // //String diamond_path, null - use resources
debugLevel); // final int debugLevel) {
// save tiff in model directory
if (imp_color != null) {
if (show_full_images) {
imp_color.show();
}
if (save_color) {
parentCLT.saveImagePlusInModelDirectory(imp_color); // ImagePlus imp)
}
// temporary, will use model directory
//// String save_directory = "/media/elphel/NVME/lwir16-proc/eagle_mountain/linked/movement/selected/video/";
//// String video_path_tmp = save_directory + model_prefix+"-TARGETS";
if (save_video) {
// String video_path =
saveAsVideo( // will take name from the image title
clt_parameters, // CLTParameters clt_parameters,
parentCLT, // QuadCLT scene, // if not null - use it's model directory
null, // video_path_tmp, // String file_path,
imp_color, // ImagePlus imp_color,
debugLevel); // int debugLevel) {
}
}
}
} }
...@@ -743,6 +743,21 @@ min_str_neib_fpn 0.35 ...@@ -743,6 +743,21 @@ min_str_neib_fpn 0.35
public double cuas_lma_mink = 0.0; // Minimal K (overshoot) = 0.0 (<0.007) 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_maxk = 5.0; // Maximal K (overshoot) = 5.0 (>3.8)
public double cuas_mask_width = 9;
public double cuas_mask_blur = 3;
public boolean cuas_mask_round = false;
public int cuas_target_type = 0; // 0 - unknown, 1 - known, 2 - friend, 3 - foe
public double cuas_input_range = 5;
public boolean cuas_scale2x = true;
public boolean cuas_ra_background = true; // apply running average to the background of the moving targets (false - use high-noise no-averaged images
// which files to save in the model directory:
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_save_mono = true; // 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_debug = false; // save debug images (and show them if not in batch mode) public boolean cuas_debug = false; // save debug images (and show them if not in batch mode)
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_step_debug = false; // save debug images during per-step cuas recalculation (and show them if not in batch mode)
...@@ -2237,6 +2252,38 @@ min_str_neib_fpn 0.35 ...@@ -2237,6 +2252,38 @@ min_str_neib_fpn 0.35
"Minimal ratio of the overshoot radius to the first 0 radius (typical 1.0)."); "Minimal ratio of the overshoot radius to the first 0 radius (typical 1.0).");
gd.addNumericField("Maximal overshoot ratio", this.cuas_lma_maxk, 5,8,"", gd.addNumericField("Maximal overshoot ratio", this.cuas_lma_maxk, 5,8,"",
"Maximal ratio of the overshoot radius to the first 0 radius (typical 3.0)."); "Maximal ratio of the overshoot radius to the first 0 radius (typical 3.0).");
gd.addMessage("=== Targets video generation (see also Vidoe/Stereo tab) ===");
gd.addNumericField("Mask diameter", this.cuas_mask_width, 5,8,"pix",
"Taget mask to replace static background with moving target.");
gd.addNumericField("Mask transition width", this.cuas_mask_blur, 5,8,"pix",
"Transition between opaque and transparent mask.");
gd.addCheckbox ("Mask round", this.cuas_mask_round,
"Use round mask. Unchesked - use sharp square mask without any transition.");
gd.addNumericField("Targets icon type", this.cuas_target_type, 0,3,"",
"0 - unknown (dashed square), 1 - known (square), 2 - friend (circle), 3 - foe (diamond).");
gd.addNumericField("Image range", this.cuas_input_range, 5,8,"10mK",
"Dispaly pixel values range (1.0 ~= 10 mK).");
gd.addCheckbox ("Scale images twice", this.cuas_scale2x,
"Scale imges to 1280x1024 for higher annotation quality.");
gd.addCheckbox ("Smooth background with runnong average", this.cuas_ra_background,
"Apply running average to the background of the moving targets (false - use high-noise no-averaged images.");
gd.addMessage("=== Saving intermediate and final images and video ===");
gd.addCheckbox ("Save tile-resolution intermediate images", this.cuas_intermed_low,
"Save intermediate vector fields and target coordinates from the LMA (80x64 layers).");
gd.addCheckbox ("Save pixel-resolution intermediate images",this.cuas_intermed_high,
"Save pixel-resolution accumulated images (640x512).");
gd.addCheckbox ("Save monochrome targets+background", this.cuas_save_mono,
"Save 32-bit monochrome targets+background Tiffs (before optional scaling).");
gd.addCheckbox ("Save color targets+background", this.cuas_save_color,
"Save color rendered images (same as videos), optionally scaled.");
gd.addCheckbox ("Save videos", this.cuas_save_video,
"Save video with moving targets.");
gd.addMessage("=== Debug ==="); gd.addMessage("=== Debug ===");
gd.addCheckbox ("Save/show debug images", this.cuas_debug, gd.addCheckbox ("Save/show debug images", this.cuas_debug,
...@@ -3227,6 +3274,20 @@ min_str_neib_fpn 0.35 ...@@ -3227,6 +3274,20 @@ min_str_neib_fpn 0.35
this.cuas_lma_mink = gd.getNextNumber(); this.cuas_lma_mink = gd.getNextNumber();
this.cuas_lma_maxk = gd.getNextNumber(); this.cuas_lma_maxk = gd.getNextNumber();
this.cuas_mask_width = gd.getNextNumber();
this.cuas_mask_blur = gd.getNextNumber();
this.cuas_mask_round = gd.getNextBoolean();
this.cuas_target_type= (int) gd.getNextNumber();
this.cuas_input_range = gd.getNextNumber();
this.cuas_scale2x = gd.getNextBoolean();
this.cuas_ra_background = gd.getNextBoolean();
this.cuas_intermed_low = gd.getNextBoolean();
this.cuas_intermed_high = gd.getNextBoolean();
this.cuas_save_mono = gd.getNextBoolean();
this.cuas_save_color = gd.getNextBoolean();
this.cuas_save_video = gd.getNextBoolean();
this.cuas_debug = gd.getNextBoolean(); this.cuas_debug = gd.getNextBoolean();
this.cuas_step_debug = gd.getNextBoolean(); this.cuas_step_debug = gd.getNextBoolean();
...@@ -4143,6 +4204,20 @@ min_str_neib_fpn 0.35 ...@@ -4143,6 +4204,20 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_lma_mink", this.cuas_lma_mink+""); // double properties.setProperty(prefix+"cuas_lma_mink", this.cuas_lma_mink+""); // double
properties.setProperty(prefix+"cuas_lma_maxk", this.cuas_lma_maxk+""); // double properties.setProperty(prefix+"cuas_lma_maxk", this.cuas_lma_maxk+""); // double
properties.setProperty(prefix+"cuas_mask_width", this.cuas_mask_width+""); // double
properties.setProperty(prefix+"cuas_mask_blur", this.cuas_mask_blur+""); // double
properties.setProperty(prefix+"cuas_mask_round", this.cuas_mask_round+""); // boolean
properties.setProperty(prefix+"cuas_target_type", this.cuas_target_type+""); // int
properties.setProperty(prefix+"cuas_input_range", this.cuas_input_range+""); // double
properties.setProperty(prefix+"cuas_scale2x", this.cuas_scale2x+""); // boolean
properties.setProperty(prefix+"cuas_ra_background", this.cuas_ra_background+""); // boolean
properties.setProperty(prefix+"cuas_intermed_low", this.cuas_intermed_low+""); // boolean
properties.setProperty(prefix+"cuas_intermed_high", this.cuas_intermed_high+""); // boolean
properties.setProperty(prefix+"cuas_save_mono", this.cuas_save_mono+""); // boolean
properties.setProperty(prefix+"cuas_save_color", this.cuas_save_color+""); // boolean
properties.setProperty(prefix+"cuas_save_video", this.cuas_save_video+""); // boolean
properties.setProperty(prefix+"cuas_debug", this.cuas_debug+""); // boolean properties.setProperty(prefix+"cuas_debug", this.cuas_debug+""); // boolean
properties.setProperty(prefix+"cuas_step_debug", this.cuas_step_debug+""); // boolean properties.setProperty(prefix+"cuas_step_debug", this.cuas_step_debug+""); // boolean
...@@ -5031,6 +5106,20 @@ min_str_neib_fpn 0.35 ...@@ -5031,6 +5106,20 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_lma_maxr")!=null) this.cuas_lma_maxr=Double.parseDouble(properties.getProperty(prefix+"cuas_lma_maxr")); if (properties.getProperty(prefix+"cuas_lma_maxr")!=null) this.cuas_lma_maxr=Double.parseDouble(properties.getProperty(prefix+"cuas_lma_maxr"));
if (properties.getProperty(prefix+"cuas_lma_mink")!=null) this.cuas_lma_mink=Double.parseDouble(properties.getProperty(prefix+"cuas_lma_mink")); if (properties.getProperty(prefix+"cuas_lma_mink")!=null) this.cuas_lma_mink=Double.parseDouble(properties.getProperty(prefix+"cuas_lma_mink"));
if (properties.getProperty(prefix+"cuas_lma_maxk")!=null) this.cuas_lma_maxk=Double.parseDouble(properties.getProperty(prefix+"cuas_lma_maxk")); if (properties.getProperty(prefix+"cuas_lma_maxk")!=null) this.cuas_lma_maxk=Double.parseDouble(properties.getProperty(prefix+"cuas_lma_maxk"));
if (properties.getProperty(prefix+"cuas_mask_width")!=null) this.cuas_mask_width=Double.parseDouble(properties.getProperty(prefix+"cuas_mask_width"));
if (properties.getProperty(prefix+"cuas_mask_blur")!=null) this.cuas_mask_blur=Double.parseDouble(properties.getProperty(prefix+"cuas_mask_blur"));
if (properties.getProperty(prefix+"cuas_mask_round")!=null) this.cuas_mask_round=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_mask_round"));
if (properties.getProperty(prefix+"cuas_target_type")!=null) this.cuas_target_type=Integer.parseInt(properties.getProperty(prefix+"cuas_target_type"));
if (properties.getProperty(prefix+"cuas_input_range")!=null) this.cuas_input_range=Double.parseDouble(properties.getProperty(prefix+"cuas_input_range"));
if (properties.getProperty(prefix+"cuas_scale2x")!=null) this.cuas_scale2x=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_scale2x"));
if (properties.getProperty(prefix+"cuas_ra_background")!=null) this.cuas_ra_background=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_ra_background"));
if (properties.getProperty(prefix+"cuas_intermed_low")!=null) this.cuas_intermed_low=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_intermed_low"));
if (properties.getProperty(prefix+"cuas_intermed_high")!=null) this.cuas_intermed_high=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_intermed_high"));
if (properties.getProperty(prefix+"cuas_save_mono")!=null) this.cuas_save_mono=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_save_mono"));
if (properties.getProperty(prefix+"cuas_save_color")!=null) this.cuas_save_color=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_save_color"));
if (properties.getProperty(prefix+"cuas_save_video")!=null) this.cuas_save_video=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_save_video"));
if (properties.getProperty(prefix+"cuas_debug")!=null) this.cuas_debug=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_debug")); if (properties.getProperty(prefix+"cuas_debug")!=null) this.cuas_debug=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_debug"));
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_step_debug")!=null) this.cuas_step_debug=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_step_debug"));
...@@ -5920,6 +6009,20 @@ min_str_neib_fpn 0.35 ...@@ -5920,6 +6009,20 @@ min_str_neib_fpn 0.35
imp.cuas_lma_mink = this.cuas_lma_mink; imp.cuas_lma_mink = this.cuas_lma_mink;
imp.cuas_lma_maxk = this.cuas_lma_maxk; imp.cuas_lma_maxk = this.cuas_lma_maxk;
imp.cuas_mask_width = this.cuas_mask_width;
imp.cuas_mask_blur = this.cuas_mask_blur;
imp.cuas_mask_round = this.cuas_mask_round;
imp.cuas_target_type= this.cuas_target_type;
imp.cuas_input_range = this.cuas_input_range;
imp.cuas_scale2x = this.cuas_scale2x;
imp.cuas_ra_background = this.cuas_ra_background;
imp.cuas_intermed_low = this.cuas_intermed_low;
imp.cuas_intermed_high = this.cuas_intermed_high;
imp.cuas_save_mono = this.cuas_save_mono;
imp.cuas_save_color = this.cuas_save_color;
imp.cuas_save_video = this.cuas_save_video;
imp.cuas_debug = this.cuas_debug; imp.cuas_debug = this.cuas_debug;
imp.cuas_step_debug = this.cuas_step_debug; imp.cuas_step_debug = this.cuas_step_debug;
......
...@@ -5847,6 +5847,13 @@ public class QuadCLTCPU { ...@@ -5847,6 +5847,13 @@ public class QuadCLTCPU {
} }
public String saveImagePlusInModelDirectory( // use title as filename
ImagePlus imp) {
return saveImagePlusInModelDirectory(
null, // String suffix, // null - use title from the imp
imp); // ImagePlus imp)
}
public String saveImagePlusInModelDirectory( public String saveImagePlusInModelDirectory(
String suffix, // null - use title from the imp String suffix, // null - use title from the imp
ImagePlus imp) ImagePlus imp)
......
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