Commit 96a9bb0d authored by Andrey Filippov's avatar Andrey Filippov

Row/col correction

parent 86e73701
...@@ -251,6 +251,7 @@ public class Cuas { ...@@ -251,6 +251,7 @@ public class Cuas {
double [][] ref_combo_dsi, // DSI data for the reference scene (or null to read it from file) double [][] ref_combo_dsi, // DSI data for the reference scene (or null to read it from file)
boolean condition_dsi, boolean condition_dsi,
int sensor_mask, // -1 - all; int sensor_mask, // -1 - all;
boolean new_average,
int debugLevel) { int debugLevel) {
//TODO: verify it still works with new reference_scene //TODO: verify it still works with new reference_scene
boolean batch_run = clt_parameters.batch_run; boolean batch_run = clt_parameters.batch_run;
...@@ -422,21 +423,24 @@ public class Cuas { ...@@ -422,21 +423,24 @@ public class Cuas {
int tilesX = center_CLT.getTilesX(); int tilesX = center_CLT.getTilesX();
int tilesY = center_CLT.getTilesY(); int tilesY = center_CLT.getTilesY();
double dts = center_CLT.getTimeStamp(); double dts = center_CLT.getTimeStamp();
CuasData cuasData = null;
// here we need cumulative parent data // here we need cumulative parent data
CuasData cuasData = CuasData.getCuasData( // may result in null ! if (!new_average) {
true, // boolean try_cumul, // and save as such if only old style existed cuasData = CuasData.getCuasData( // may result in null !
cumulative_parent_dir_path, // String full_path, // ends with /vxx true, // boolean try_cumul, // and save as such if only old style existed
num_colors, // int num_colors, // only used if restored from tiff, ignored for .cuas cumulative_parent_dir_path, // String full_path, // ends with /vxx
tilesX, // int width, // only used if restored from tiff, ignored for .cuas num_colors, // int num_colors, // only used if restored from tiff, ignored for .cuas
dts, // double dts, // time stamp as double, only used if restored from tiff, ignored for .cuas tilesX, // int width, // only used if restored from tiff, ignored for .cuas
debugLevel); // int debugLevel) dts, // double dts, // time stamp as double, only used if restored from tiff, ignored for .cuas
if (debugLevel > -3) { debugLevel); // int debugLevel)
if (cuasData != null) { if (debugLevel > -3) {
System.out.println("createCenterClt(): read cumulative parent data from "+cumulative_parent_dir_path); if (cuasData != null) {
} else { System.out.println("createCenterClt(): read cumulative parent data from "+cumulative_parent_dir_path);
System.out.println("createCenterClt(): FAILED to read cumulative parent data from "+cumulative_parent_dir_path); } else {
} System.out.println("createCenterClt(): FAILED to read cumulative parent data from "+cumulative_parent_dir_path);
} }
}
}
CuasData newCuasData = getTDComboSceneSequence( CuasData newCuasData = getTDComboSceneSequence(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
......
...@@ -2880,7 +2880,6 @@ public class ImageDttCPU { ...@@ -2880,7 +2880,6 @@ public class ImageDttCPU {
} }
// TODO: use correction after disparity applied (to work for large disparity values) // TODO: use correction after disparity applied (to work for large disparity values)
if (fine_corr != null){ if (fine_corr != null){
for (int ip = 0; ip < centersXY.length; ip++){ for (int ip = 0; ip < centersXY.length; ip++){
double [] tXY = geometryCorrection.getRelativeCoords(centersXY[ip]); double [] tXY = geometryCorrection.getRelativeCoords(centersXY[ip]);
for (int d = 0; d <2; d++) { for (int d = 0; d <2; d++) {
...@@ -2909,9 +2908,6 @@ public class ImageDttCPU { ...@@ -2909,9 +2908,6 @@ public class ImageDttCPU {
for (int i = 0; i < numSensors; i++) { for (int i = 0; i < numSensors; i++) {
clt_data[i][ncol][tileY][tileX] = new double [4][]; clt_data[i][ncol][tileY][tileX] = new double [4][];
// if ((i==9) && (tileY>=18) && (tileY<=20) && (tileX >= 23) && (tileX <= 29)) {
// System.out.println("sensor="+i+", tileY="+tileY+", tileX="+tileX);
// }
// Extract image tiles and kernels, correct aberrations, return (ut do not apply) fractional shifts // Extract image tiles and kernels, correct aberrations, return (ut do not apply) fractional shifts
fract_shiftsXY[i] = extract_correct_tile( // return a pair of residual offsets fract_shiftsXY[i] = extract_correct_tile( // return a pair of residual offsets
image_data[i], image_data[i],
......
...@@ -666,9 +666,14 @@ min_str_neib_fpn 0.35 ...@@ -666,9 +666,14 @@ min_str_neib_fpn 0.35
public boolean cuas_step = true; // recalculate template image after each fitting step public boolean cuas_step = true; // recalculate template image after each fitting step
public boolean cuas_subtract_fpn= true; // Subtract FPN public boolean cuas_subtract_fpn= true; // Subtract FPN
public boolean cuas_calc_fpn = false; // Recalculate+save FPN unconditionally, if false - try to read saved one public boolean cuas_calc_fpn = false; // Recalculate+save FPN unconditionally, if false - try to read saved one first
public double cuas_rot_period = 175.0; // rotation period of te gimbal mount (in scenes) public double cuas_rot_period = 175.0; // rotation period of te gimbal mount (in scenes)
public boolean cuas_subtract_rowcol= true; // Subtract row/column noise
public boolean cuas_calc_rowcol= true; // Recalculate+save row/column noise, if false - try to read saved one first
public double cuas_um_sigma = 20.0; // Apply Unsharp Mask filter sigma when calculating row/column noise
public double cuas_max_abs_rowcol = 100.0; // consider pixels with abs(UM difference) does not exceed this value
public double cuas_outliers_rowcol = 0.001; // scale weight of the outliers with high difference (to prevent undefined values
public boolean cuas_reset_first= false; // Reset average in first scene (for large diffirence in unfinished row/col)
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)
...@@ -2000,12 +2005,27 @@ min_str_neib_fpn 0.35 ...@@ -2000,12 +2005,27 @@ min_str_neib_fpn 0.35
"Filter tile CLT variants that keep fraction of the total weight."); "Filter tile CLT variants that keep fraction of the total weight.");
gd.addCheckbox ("Recalculate after each tuning step", this.cuas_step, gd.addCheckbox ("Recalculate after each tuning step", this.cuas_step,
"Recalciulate correlation pattern after each position/orientation and disparity adjustment step."); "Recalciulate correlation pattern after each position/orientation and disparity adjustment step.");
gd.addMessage("=== Subtract FPN ===");
gd.addCheckbox ("Subtract FPN", this.cuas_subtract_fpn, gd.addCheckbox ("Subtract FPN", this.cuas_subtract_fpn,
"Subtract FPN from the channel images."); "Subtract FPN from the channel images.");
gd.addCheckbox ("(Re)calculate FPN", this.cuas_calc_fpn, gd.addCheckbox ("(Re)calculate FPN", this.cuas_calc_fpn,
"Recalculate+save FPN unconditionally, if false - try to read saved one."); "Recalculate+save FPN unconditionally, if false - try to read saved one.");
gd.addNumericField("Rotation period", this.cuas_rot_period, 5,7,"scene periods", gd.addNumericField("Rotation period", this.cuas_rot_period, 5,7,"scene periods",
"Used for averaging FPN for integer number of rotation periods. TODO: calculate from the actual rotation."); "Used for averaging FPN for integer number of rotation periods. TODO: calculate from the actual rotation.");
gd.addMessage("=== Row/column noise (on top of the FPN) ===");
gd.addCheckbox ("Subtract row/column noise", this.cuas_subtract_rowcol,
"Subtract per-scene row/column noise (on top of the per scene sequence FPN).");
gd.addCheckbox ("(Re)calculate row/column noise", this.cuas_calc_rowcol,
"Recalculate per-scene row column noise even if it exists. If false, try to read first.");
gd.addNumericField("Row/column unsharp mask filter", this.cuas_um_sigma, 5,7,"pix",
"Apply Unsharp mask filter to the difference between individual scenes and per-sequence FPN before calculating row/column noise.");
gd.addNumericField("Row/column maximal difference", this.cuas_max_abs_rowcol, 5,7,"counts",
"Consider pixels were abs(UM difference) does not exceed this value during row/column noise calcualtion.");
gd.addNumericField("Row/column scale outliers", this.cuas_outliers_rowcol, 5,7,"x",
"Scale weight of the outliers with high difference than above (to prevent undefined values).");
gd.addCheckbox ("Reset average on first sequence", this.cuas_reset_first,
"Reset average in first scene (for large diffirence in unfinished row/col.");
gd.addMessage("=== Debug ==="); gd.addMessage("=== Debug ===");
gd.addCheckbox ("Save/show debug images", this.cuas_debug, gd.addCheckbox ("Save/show debug images", this.cuas_debug,
"Save CUAS-related debug images and show them in non-batch mode."); "Save CUAS-related debug images and show them in non-batch mode.");
...@@ -2912,6 +2932,13 @@ min_str_neib_fpn 0.35 ...@@ -2912,6 +2932,13 @@ min_str_neib_fpn 0.35
this.cuas_calc_fpn = gd.getNextBoolean(); this.cuas_calc_fpn = gd.getNextBoolean();
this.cuas_rot_period = gd.getNextNumber(); this.cuas_rot_period = gd.getNextNumber();
this.cuas_subtract_rowcol = gd.getNextBoolean();
this.cuas_calc_rowcol = gd.getNextBoolean();
this.cuas_um_sigma = gd.getNextNumber();
this.cuas_max_abs_rowcol = gd.getNextNumber();
this.cuas_outliers_rowcol = gd.getNextNumber();
this.cuas_reset_first = gd.getNextBoolean();
this.cuas_debug = gd.getNextBoolean(); this.cuas_debug = gd.getNextBoolean();
this.cuas_step_debug = gd.getNextBoolean(); this.cuas_step_debug = gd.getNextBoolean();
...@@ -3745,6 +3772,12 @@ min_str_neib_fpn 0.35 ...@@ -3745,6 +3772,12 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_calc_fpn", this.cuas_calc_fpn+""); // boolean properties.setProperty(prefix+"cuas_calc_fpn", this.cuas_calc_fpn+""); // boolean
properties.setProperty(prefix+"cuas_rot_period", this.cuas_rot_period+""); // double properties.setProperty(prefix+"cuas_rot_period", this.cuas_rot_period+""); // double
properties.setProperty(prefix+"cuas_subtract_rowcol", this.cuas_subtract_rowcol+"");// boolean
properties.setProperty(prefix+"cuas_calc_rowcol", this.cuas_calc_rowcol+""); // boolean
properties.setProperty(prefix+"cuas_um_sigma", this.cuas_um_sigma+""); // double
properties.setProperty(prefix+"cuas_max_abs_rowcol", this.cuas_max_abs_rowcol+""); // double
properties.setProperty(prefix+"cuas_outliers_rowcol", this.cuas_outliers_rowcol+"");// double
properties.setProperty(prefix+"cuas_reset_first", this.cuas_reset_first+""); // 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
...@@ -4552,6 +4585,13 @@ min_str_neib_fpn 0.35 ...@@ -4552,6 +4585,13 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_calc_fpn")!=null) this.cuas_calc_fpn=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_calc_fpn")); if (properties.getProperty(prefix+"cuas_calc_fpn")!=null) this.cuas_calc_fpn=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_calc_fpn"));
if (properties.getProperty(prefix+"cuas_rot_period")!=null) this.cuas_rot_period=Double.parseDouble(properties.getProperty(prefix+"cuas_rot_period")); if (properties.getProperty(prefix+"cuas_rot_period")!=null) this.cuas_rot_period=Double.parseDouble(properties.getProperty(prefix+"cuas_rot_period"));
if (properties.getProperty(prefix+"cuas_subtract_rowcol")!=null) this.cuas_subtract_rowcol=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_subtract_rowcol"));
if (properties.getProperty(prefix+"cuas_calc_rowcol")!=null) this.cuas_calc_rowcol=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_calc_rowcol"));
if (properties.getProperty(prefix+"cuas_um_sigma")!=null) this.cuas_um_sigma=Double.parseDouble(properties.getProperty(prefix+"cuas_um_sigma"));
if (properties.getProperty(prefix+"cuas_max_abs_rowcol")!=null) this.cuas_max_abs_rowcol=Double.parseDouble(properties.getProperty(prefix+"cuas_max_abs_rowcol"));
if (properties.getProperty(prefix+"cuas_outliers_rowcol")!=null) this.cuas_outliers_rowcol=Double.parseDouble(properties.getProperty(prefix+"cuas_outliers_rowcol"));
if (properties.getProperty(prefix+"cuas_reset_first")!=null) this.cuas_reset_first=Boolean.parseBoolean(properties.getProperty(prefix+"cuas_reset_first"));
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"));
...@@ -5360,6 +5400,13 @@ min_str_neib_fpn 0.35 ...@@ -5360,6 +5400,13 @@ min_str_neib_fpn 0.35
imp.cuas_calc_fpn = this.cuas_calc_fpn; imp.cuas_calc_fpn = this.cuas_calc_fpn;
imp.cuas_rot_period = this.cuas_rot_period; imp.cuas_rot_period = this.cuas_rot_period;
imp.cuas_subtract_rowcol = this.cuas_subtract_rowcol;
imp.cuas_calc_rowcol = this.cuas_calc_rowcol;
imp.cuas_um_sigma = this.cuas_um_sigma;
imp.cuas_max_abs_rowcol = this.cuas_max_abs_rowcol;
imp.cuas_outliers_rowcol = this.cuas_outliers_rowcol;
imp.cuas_reset_first = this.cuas_reset_first;
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;
......
...@@ -4843,12 +4843,20 @@ public class OpticalFlow { ...@@ -4843,12 +4843,20 @@ public class OpticalFlow {
double min_ref_frac= clt_parameters.imp.min_ref_frac; double min_ref_frac= clt_parameters.imp.min_ref_frac;
boolean cuas_subtract_fpn = clt_parameters.imp.cuas_subtract_fpn; boolean cuas_subtract_fpn = clt_parameters.imp.cuas_subtract_fpn;
boolean cuas_calc_fpn = clt_parameters.imp.cuas_calc_fpn; boolean cuas_calc_fpn = clt_parameters.imp.cuas_calc_fpn;
double cuas_rot_period = clt_parameters.imp.cuas_rot_period; double cuas_rot_period = clt_parameters.imp.cuas_rot_period;
boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
boolean cuas_step_debug = clt_parameters.imp.cuas_step_debug;
boolean cuas_subtract_rowcol=clt_parameters.imp.cuas_subtract_rowcol;// Subtract row/column noise
boolean cuas_calc_rowcol= clt_parameters.imp.cuas_calc_rowcol; // Recalculate+save row/column noise, if false - try to read saved one first
double cuas_um_sigma = clt_parameters.imp.cuas_um_sigma; // Apply Unsharp Mask filter sigma when calculating row/column noise
double cuas_max_abs_rowcol= clt_parameters.imp.cuas_max_abs_rowcol; // consider pixels with abs(UM difference) does not exceed this value
double cuas_outliers_rowcol=clt_parameters.imp.cuas_outliers_rowcol;// scale weight of the outliers with high difference (to prevent undefined values
boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
boolean cuas_step_debug = clt_parameters.imp.cuas_step_debug;
boolean cuas_reset_first=clt_parameters.imp.cuas_reset_first && first_in_series;
double [] ref_blue_sky = null; // turn off "lma" in the ML output double [] ref_blue_sky = null; // turn off "lma" in the ML output
if (reuse_video) { // disable all other options if (reuse_video) { // disable all other options
...@@ -5163,8 +5171,9 @@ public class OpticalFlow { ...@@ -5163,8 +5171,9 @@ public class OpticalFlow {
} // while (blue_sky == null) } // while (blue_sky == null)
if ((center_CLT != null) && center_CLT.hasCenterClt()) { if ((center_CLT != null) && center_CLT.hasCenterClt()) {
int fpn_width = center_CLT.getTilesX() * center_CLT.getTileSize(); // see if center_CLT can be used int fpn_width = center_CLT.getTilesX() * center_CLT.getTileSize(); // see if center_CLT can be used
double [][][] fpn = null;
boolean show_fpn = cuas_debug && !clt_parameters.batch_run; //
if (cuas_subtract_fpn) { if (cuas_subtract_fpn) {
boolean show_fpn = cuas_debug && !clt_parameters.batch_run; //
boolean changed = quadCLT_main.isPhotometricUpdatedAndReset(); boolean changed = quadCLT_main.isPhotometricUpdatedAndReset();
if (changed) { if (changed) {
System.out.println ("00.re-spawning with updated photogrammetric calibration of reference scene."); System.out.println ("00.re-spawning with updated photogrammetric calibration of reference scene.");
...@@ -5184,8 +5193,7 @@ public class OpticalFlow { ...@@ -5184,8 +5193,7 @@ public class OpticalFlow {
debugLevel-2); debugLevel-2);
} }
} }
fpn = center_CLT.getCorrectionFPN().readImageFPN ( -1); // int sens_mask);
double [][][] fpn = center_CLT.getCorrectionFPN().readImageFPN ( -1); // int sens_mask);
if ((fpn == null) || cuas_calc_fpn) { if ((fpn == null) || cuas_calc_fpn) {
if (debugLevel >-3) { if (debugLevel >-3) {
System.out.println("Calculating FPN."); System.out.println("Calculating FPN.");
...@@ -5199,17 +5207,18 @@ public class OpticalFlow { ...@@ -5199,17 +5207,18 @@ public class OpticalFlow {
rot_range, // final int [] range, // required rot_range, // final int [] range, // required
-1, // final int sensor_mask, -1, // final int sensor_mask,
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
int dbg_sens = 12;
int dbg_sens = -12; // disable testing
if (cuas_debug && (dbg_sens >= 0)) { if (cuas_debug && (dbg_sens >= 0)) {
double um_sigma_fpn = 10.0;
center_CLT.getCorrectionFPN().debugFPN( center_CLT.getCorrectionFPN().debugFPN(
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
fpn, // double [][][] fpn, fpn, // double [][][] fpn,
rot_range, // int [] range, rot_range, // int [] range,
dbg_sens, // int nsens, dbg_sens, // int nsens,
um_sigma_fpn, // double um_sigma = 10.0; cuas_um_sigma, // double um_sigma = 10.0;
show_fpn); // boolean show) { cuas_max_abs_rowcol, // double max_abs, // = 100.0;
cuas_outliers_rowcol,// double weight_outlier, // = 0.001;
show_fpn); // boolean show) {
} }
} else { } else {
...@@ -5226,6 +5235,7 @@ public class OpticalFlow { ...@@ -5226,6 +5235,7 @@ public class OpticalFlow {
center_CLT.getCorrectionFPN().setApplyFPN( center_CLT.getCorrectionFPN().setApplyFPN(
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
fpn);// double [][][] fpn) fpn);// double [][][] fpn)
} else { } else {
if (debugLevel >-3) { if (debugLevel >-3) {
System.out.println("Skipping FPN."); System.out.println("Skipping FPN.");
...@@ -5235,6 +5245,46 @@ public class OpticalFlow { ...@@ -5235,6 +5245,46 @@ public class OpticalFlow {
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
null);// double [][][] fpn) null);// double [][][] fpn)
} }
if (cuas_subtract_rowcol) {
/// read/calculate Row/Column noise correction
boolean is_new = false;
double [][][][] row_col = null;
if (!cuas_calc_rowcol) {
if (debugLevel >-3) {
System.out.println("Reading row/column noise per-scene data.");
}
row_col = center_CLT.getCorrectionFPN().readImageRowCol();
}
if (row_col == null) {
if (debugLevel >-3) {
System.out.println("Calculating row/column noise per-scene data.");
}
row_col= CorrectionFPN.calculateRowCol(
quadCLTs, // final QuadCLT [] quadCLTs,
fpn, // final double [][][] fpn, // if null - already applied
fpn_width, // final int width,
cuas_um_sigma, // final double um_sigma,
cuas_max_abs_rowcol, // final double max_abs, // = 100.0;
cuas_outliers_rowcol); // final double weight_outlier // = 0.001;)
is_new = (row_col != null);
}
center_CLT.getCorrectionFPN().saveShowRowCol(
row_col[0], // final double [][][] rows, // [scene][sensor][width]
row_col[1], // final double [][][] cols, // [scene][sensor][height]
is_new, //final boolean save,
show_fpn); // final boolean show)
// TODO: apply to all scenes here ! *************************************
CorrectionFPN.setApplyRowCol(
quadCLTs, // final QuadCLT [] scenes,
row_col[0], //final double [][][] rows,
row_col[1]); // final double [][][] cols )
} else { // reset row/col correction
CorrectionFPN.setApplyRowCol(
quadCLTs, // final QuadCLT [] scenes,
null, //final double [][][] rows,
null); // final double [][][] cols )
}
} }
...@@ -5422,7 +5472,7 @@ public class OpticalFlow { ...@@ -5422,7 +5472,7 @@ public class OpticalFlow {
} else {// if (build_orientations) { } else {// if (build_orientations) {
if (center_CLT != null) { if (center_CLT != null) {
if (!reuse_video) { // reuse_video only uses reference scene if (!reuse_video) { // reuse_video only uses reference scene
boolean changed = quadCLTs[ref_index].isPhotometricUpdatedAndReset(); boolean changed = false; // quadCLTs[ref_index].isPhotometricUpdatedAndReset(); //*** It should use quadCLT_main.isPhotometricUpdatedAndReset()
if (changed) { if (changed) {
System.out.println ("0.re-spawning with updated photogrammetric calibration of reference scene."); System.out.println ("0.re-spawning with updated photogrammetric calibration of reference scene.");
} else { } else {
...@@ -5970,6 +6020,8 @@ public class OpticalFlow { ...@@ -5970,6 +6020,8 @@ public class OpticalFlow {
/* /*
QuadCLT center_CLT = QuadCLT.restoreCenterClt(quadCLTs[ref_index]); // QuadCLT ref_clt); QuadCLT center_CLT = QuadCLT.restoreCenterClt(quadCLTs[ref_index]); // QuadCLT ref_clt);
*/ */
// if (cuas_reset_first)
boolean dbg_created=false; boolean dbg_created=false;
int sensor_mask_clt = -1; // all int sensor_mask_clt = -1; // all
if (center_CLT == null) { if (center_CLT == null) {
...@@ -5985,6 +6037,7 @@ public class OpticalFlow { ...@@ -5985,6 +6037,7 @@ public class OpticalFlow {
combo_dsn_final, // double [][] ref_dsi, // DSI data for the reference scene (or null to read it from file) combo_dsn_final, // double [][] ref_dsi, // DSI data for the reference scene (or null to read it from file)
condition_dsi, // boolean condition_dsi, condition_dsi, // boolean condition_dsi,
sensor_mask_clt, // int sensor_mask, // -1 - all; sensor_mask_clt, // int sensor_mask, // -1 - all;
true, // boolean // new_average,
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
if (cuas_centers != null) { if (cuas_centers != null) {
cuas_centers[1] = center_CLT.getImagePath(); cuas_centers[1] = center_CLT.getImagePath();
...@@ -6002,14 +6055,15 @@ public class OpticalFlow { ...@@ -6002,14 +6055,15 @@ public class OpticalFlow {
combo_dsn_final =center_CLT.restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky combo_dsn_final =center_CLT.restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky
} }
center_CLT = Cuas.createCenterClt( // assuming cuas_rotation is true center_CLT = Cuas.createCenterClt( // assuming cuas_rotation is true
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
center_CLT, // QuadCLT ref_scene, // where combo_dsi is center_CLT, // QuadCLT ref_scene, // where combo_dsi is
null, // int [] range, // or null null, // int [] range, // or null
combo_dsn_final, // double [][] ref_dsi, // DSI data for the reference scene (or null to read it from file) combo_dsn_final, // double [][] ref_dsi, // DSI data for the reference scene (or null to read it from file)
condition_dsi, // boolean condition_dsi, condition_dsi, // boolean condition_dsi,
sensor_mask_clt, // int sensor_mask, // -1 - all; sensor_mask_clt, // int sensor_mask, // -1 - all;
debugLevel); // int debugLevel) cuas_reset_first, // boolean // new_average,
debugLevel); // int debugLevel)
if (cuas_centers != null) { if (cuas_centers != null) {
cuas_centers[1] = center_CLT.getImagePath(); cuas_centers[1] = center_CLT.getImagePath();
} }
......
...@@ -136,9 +136,10 @@ public class QuadCLTCPU { ...@@ -136,9 +136,10 @@ public class QuadCLTCPU {
public static final int THREADS_MAX = 100; public static final int THREADS_MAX = 100;
public static final double [] ZERO3 = {0.0,0.0,0.0}; public static final double [] ZERO3 = {0.0,0.0,0.0};
public static final String CENTER_DIR_SUFFIX = "-CENTER"; public static final String CENTER_DIR_SUFFIX = "-CENTER";
public static final String CENTER_CLT_SUFFIX = "-CLT"; public static final String CENTER_CLT_SUFFIX = "-CLT";
public static final String CENTER_FPN_SUFFIX = "-FPN"; public static final String CENTER_FPN_SUFFIX = "-FPN";
public static final String CENTER_ROWCOL_SUFFIX = "-ROWCOL";
// public GPUTileProcessor.GpuQuad gpuQuad = null; // public GPUTileProcessor.GpuQuad gpuQuad = null;
...@@ -174,6 +175,10 @@ public class QuadCLTCPU { ...@@ -174,6 +175,10 @@ public class QuadCLTCPU {
public double [][][] image_fpn_applied = null; // [channel][color][pixel] // when applying different instance, the old will be unapplied public double [][][] image_fpn_applied = null; // [channel][color][pixel] // when applying different instance, the old will be unapplied
public double [][] image_row_avg = null; //[nsens][width] integrated by columns, lwir-only (single-color) public double [][] image_row_avg = null; //[nsens][width] integrated by columns, lwir-only (single-color)
public double [][] image_col_avg = null; //[nsens][height] integrated by rows, lwir-only (single-color) public double [][] image_col_avg = null; //[nsens][height] integrated by rows, lwir-only (single-color)
public double [][] image_row_avg_applied = null; //[nsens][width] integrated by columns, lwir-only (single-color)
public double [][] image_col_avg_applied = null; //[nsens][height] integrated by rows, lwir-only (single-color)
boolean new_image_data = false; boolean new_image_data = false;
boolean [][] saturation_imp = null; // (near) saturated pixels or null boolean [][] saturation_imp = null; // (near) saturated pixels or null
boolean is_aux = false; boolean is_aux = false;
...@@ -6301,6 +6306,15 @@ public class QuadCLTCPU { ...@@ -6301,6 +6306,15 @@ public class QuadCLTCPU {
if ((imp == null) || (imp.getTitle() == null) || (imp.getTitle().equals(""))) { if ((imp == null) || (imp.getTitle() == null) || (imp.getTitle().equals(""))) {
return null; return null;
} }
return readFloatArray(
imp, // ImagePlus imp,
num_slices, //int num_slices, // (0 - all)
wh); // int [] wh)
/*
ImageStack imageStack = imp.getStack(); ImageStack imageStack = imp.getStack();
int nChn=imageStack.getSize(); int nChn=imageStack.getSize();
if ((num_slices > 0) && (num_slices < nChn)) { if ((num_slices > 0) && (num_slices < nChn)) {
...@@ -6315,8 +6329,77 @@ public class QuadCLTCPU { ...@@ -6315,8 +6329,77 @@ public class QuadCLTCPU {
wh[1] = imp.getHeight(); wh[1] = imp.getHeight();
} }
return result; return result;
*/
} }
public static double [][] readDoubleArray(
ImagePlus imp,
int num_slices, // (0 - all)
int [] wh) {
float [][] fdata = readFloatArray(
imp, // ImagePlus imp,
num_slices, // int num_slices, // (0 - all)
wh); // int [] wh)
if (fdata == null) {
return null;
}
double [][] result = new double [fdata.length][];
for (int n = 0; n < fdata.length; n++) if (fdata[n]!=null) {
result[n] = new double [fdata[n].length];
for (int i = 0; i < fdata[n].length; i++) {
result[n][i] = fdata[n][i];
}
}
return result;
}
public static float [][] readFloatArray(
ImagePlus imp,
int num_slices, // (0 - all)
int [] wh) {
if ((imp == null) || (imp.getTitle() == null) || (imp.getTitle().equals(""))) {
return null;
}
ImageStack imageStack = imp.getStack();
int nChn=imageStack.getSize();
if ((num_slices > 0) && (num_slices < nChn)) {
nChn = num_slices;
}
float [][] result = new float [nChn][];
for (int n = 0; n < nChn; n++) {
result[n] = (float[]) imageStack.getPixels(n + 1);
}
if (wh != null) {
wh[0] = imp.getWidth();
wh[1] = imp.getHeight();
}
return result;
}
public ImagePlus readImagePlusFromModelDirectory(
String suffix)
{
// String x3d_path = getX3dDirectory();
String x3d_path = readX3dDirectory(correctionsParameters.getModelName(image_name));
String file_name = image_name + suffix;
String file_path = x3d_path + Prefs.getFileSeparator() + file_name + ".tiff";
ImagePlus imp = null;
try {
imp = new ImagePlus(file_path);
} catch (Exception e) {
System.out.println ("Failed to open "+file_path+", maybe will generate it");
}
if ((imp == null) || (imp.getTitle() == null) || (imp.getTitle().equals(""))) {
return null;
}
return imp;
}
/* /*
public float [][] readFloatArrayFromThisModelDirectory( public float [][] readFloatArrayFromThisModelDirectory(
...@@ -6487,10 +6570,7 @@ public class QuadCLTCPU { ...@@ -6487,10 +6570,7 @@ public class QuadCLTCPU {
return image_data; return image_data;
} }
public double [][][] getImageFpnApplied(){
return image_fpn_applied;
}
public void setImageData(double [][][] data) { public void setImageData(double [][][] data) {
image_data = data; image_data = data;
new_image_data = true; new_image_data = true;
...@@ -9920,6 +10000,52 @@ public class QuadCLTCPU { ...@@ -9920,6 +10000,52 @@ public class QuadCLTCPU {
this.image_fpn = fpn; this.image_fpn = fpn;
} }
public void resetRowCol() {
setRowCol(null,null);
}
public void setRowCol(
double [][] row,
double [][] col) {
image_row_avg = row;
image_col_avg = col;
}
public double [][] getRowCorr(){
return image_row_avg;
}
public double [][] getColCorr(){
return image_col_avg;
}
public double [][] getRowApplied(){
return image_row_avg_applied;
}
public double [][] getColApplied(){
return image_col_avg_applied;
}
public void setRowColApplied(
double [][] row,
double [][] col) {
image_row_avg_applied = row;
image_col_avg_applied = col;
}
public boolean rowColDiffers(
double [][] row,
double [][] col) {
return (image_row_avg_applied != row) || (image_col_avg_applied != col);
}
public boolean rowColDiffers() {
return rowColDiffers(
image_row_avg, // double [][] row,
image_col_avg); // double [][] col)
}
public void processCLTQuadCorrs( // not used in lwir public void processCLTQuadCorrs( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -10005,6 +10131,12 @@ public class QuadCLTCPU { ...@@ -10005,6 +10131,12 @@ public class QuadCLTCPU {
public void applyFPN() { public void applyFPN() {
getCorrectionFPN().applyFPN(this.image_fpn); getCorrectionFPN().applyFPN(this.image_fpn);
} }
public void applyRowCol() {
CorrectionFPN.applyRowCol(
(QuadCLT) this, //final QuadCLT scene,
getRowCorr(), // final double [][] row,
getColCorr()); // final double [][] col )
}
public void processCLTQuadCorrsTestERS( public void processCLTQuadCorrsTestERS(
......
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