Commit c500f3ad authored by Andrey Filippov's avatar Andrey Filippov

added per-set infinity offset

parent 5764ddb9
...@@ -30,7 +30,11 @@ import ij.Prefs; ...@@ -30,7 +30,11 @@ import ij.Prefs;
import ij.gui.GenericDialog; import ij.gui.GenericDialog;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
public class EyesisCorrectionParameters { public class EyesisCorrectionParameters {
...@@ -602,6 +606,8 @@ public class EyesisCorrectionParameters { ...@@ -602,6 +606,8 @@ public class EyesisCorrectionParameters {
return true; return true;
} }
// TODO: extract timestamnp from JP4 or, at least combine movie timestamp+frame into a single filename string // TODO: extract timestamnp from JP4 or, at least combine movie timestamp+frame into a single filename string
public String [] getSourcePaths(){ public String [] getSourcePaths(){
String [] empty={}; String [] empty={};
...@@ -2720,6 +2726,10 @@ public class EyesisCorrectionParameters { ...@@ -2720,6 +2726,10 @@ public class EyesisCorrectionParameters {
public boolean show_planes = false; // show planes public boolean show_planes = false; // show planes
public double [] vertical_xyz = {0.0,1.0,0.0}; // real world up unit vector in camera CS (x - right, y - up, z - to camera}; public double [] vertical_xyz = {0.0,1.0,0.0}; // real world up unit vector in camera CS (x - right, y - up, z - to camera};
public HashMap<String,Double> z_corr_map = new HashMap<String,Double>();
public static String Z_CORR_PREFIX = "z_corr.";
public CLTParameters(){} public CLTParameters(){}
public void setProperties(String prefix,Properties properties){ public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"transform_size", this.transform_size+""); properties.setProperty(prefix+"transform_size", this.transform_size+"");
...@@ -3324,7 +3334,13 @@ public class EyesisCorrectionParameters { ...@@ -3324,7 +3334,13 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"vertical_xyz.x", this.vertical_xyz[0]+""); properties.setProperty(prefix+"vertical_xyz.x", this.vertical_xyz[0]+"");
properties.setProperty(prefix+"vertical_xyz.y", this.vertical_xyz[1]+""); properties.setProperty(prefix+"vertical_xyz.y", this.vertical_xyz[1]+"");
properties.setProperty(prefix+"vertical_xyz.z", this.vertical_xyz[2]+""); properties.setProperty(prefix+"vertical_xyz.z", this.vertical_xyz[2]+"");
}
if (z_corr_map != null) {
for (HashMap.Entry<String,Double> entry : z_corr_map.entrySet()){
properties.setProperty(prefix+Z_CORR_PREFIX+entry.getKey(), entry.getValue().toString());
}
}
}
public void getProperties(String prefix,Properties properties){ public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"transform_size")!=null) this.transform_size=Integer.parseInt(properties.getProperty(prefix+"transform_size")); if (properties.getProperty(prefix+"transform_size")!=null) this.transform_size=Integer.parseInt(properties.getProperty(prefix+"transform_size"));
if (properties.getProperty(prefix+"clt_window")!=null) this.clt_window=Integer.parseInt(properties.getProperty(prefix+"clt_window")); if (properties.getProperty(prefix+"clt_window")!=null) this.clt_window=Integer.parseInt(properties.getProperty(prefix+"clt_window"));
...@@ -3929,6 +3945,14 @@ public class EyesisCorrectionParameters { ...@@ -3929,6 +3945,14 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"vertical_xyz.y")!=null) this.vertical_xyz[1]=Double.parseDouble(properties.getProperty(prefix+"vertical_xyz.y")); if (properties.getProperty(prefix+"vertical_xyz.y")!=null) this.vertical_xyz[1]=Double.parseDouble(properties.getProperty(prefix+"vertical_xyz.y"));
if (properties.getProperty(prefix+"vertical_xyz.z")!=null) this.vertical_xyz[2]=Double.parseDouble(properties.getProperty(prefix+"vertical_xyz.z")); if (properties.getProperty(prefix+"vertical_xyz.z")!=null) this.vertical_xyz[2]=Double.parseDouble(properties.getProperty(prefix+"vertical_xyz.z"));
Set<String> ss = properties.stringPropertyNames();
String full_prefix = prefix+Z_CORR_PREFIX;
int li = full_prefix.length();
for (String s:ss){
if (s.indexOf(full_prefix) == 0){
z_corr_map.put(s.substring(li), Double.parseDouble(properties.getProperty(s)));
}
}
} }
public boolean showDialog() { public boolean showDialog() {
...@@ -5353,6 +5377,43 @@ public class EyesisCorrectionParameters { ...@@ -5353,6 +5377,43 @@ public class EyesisCorrectionParameters {
return true; return true;
} }
public boolean modifyZCorr (String title) {
if (z_corr_map == null){
z_corr_map = new HashMap<String,Double>();
}
GenericDialog gd = new GenericDialog(title);
if (z_corr_map.size() > 0) {
gd.addMessage("Edit infinity disparity correction (in 1/m), set >= 1.0 to remove for the following");
for (HashMap.Entry<String,Double> entry : z_corr_map.entrySet()){
gd.addNumericField(entry.getKey(), entry.getValue(), 8);
}
}
gd.addMessage("Add new infinity correction");
gd.addStringField ("Timestamp string (seconds_microseconds):", "", 40);
gd.addNumericField("Infinity correction (in 1/m)", 0, 8);
gd.addCheckbox ("Clear list", false);
WindowTools.addScrollBars(gd);
gd.showDialog();
if (gd.wasCanceled()) return false;
HashMap<String,Double> new_map = new HashMap<String,Double>();
for (HashMap.Entry<String,Double> entry : z_corr_map.entrySet()){
double d = gd.getNextNumber();
if (d < 1.0) {
new_map.put(entry.getKey(),d);
}
}
String new_ts = gd.getNextString();
double d = gd.getNextNumber();
if (gd.getNextBoolean()){
z_corr_map = new HashMap<String,Double>();
} else {
z_corr_map = new_map;
}
if(new_ts.length() > 0){
z_corr_map.put(new_ts, d);
}
return true;
}
} }
public static class DCTParameters { public static class DCTParameters {
......
...@@ -543,6 +543,7 @@ private Panel panel1, ...@@ -543,6 +543,7 @@ private Panel panel1,
panelClt3 = new Panel(); panelClt3 = new Panel();
panelClt3.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap panelClt3.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Setup CLT parameters", panelClt3, color_configure); addButton("Setup CLT parameters", panelClt3, color_configure);
addButton("Infinity offset", panelClt3, color_configure);
addButton("Setup CLT Batch parameters", panelClt3, color_configure); addButton("Setup CLT Batch parameters", panelClt3, color_configure);
addButton("CLT batch process", panelClt3, color_process); addButton("CLT batch process", panelClt3, color_process);
add(panelClt3); add(panelClt3);
...@@ -3678,6 +3679,12 @@ private Panel panel1, ...@@ -3678,6 +3679,12 @@ private Panel panel1,
} else if (label.equals("Setup CLT parameters")) { } else if (label.equals("Setup CLT parameters")) {
CLT_PARAMETERS.showDialog(); CLT_PARAMETERS.showDialog();
return; return;
/* ======================================================================== */
} else if (label.equals("Infinity offset")) {
while (true) {
if (!CLT_PARAMETERS.modifyZCorr("Modify infinity per image set disparity corrections")) break;
}
return;
/* ======================================================================== */ /* ======================================================================== */
// public ImagePlus DBG_IMP = null; // public ImagePlus DBG_IMP = null;
} else if (label.equals("Select CLT image")) { } else if (label.equals("Select CLT image")) {
......
...@@ -1053,7 +1053,7 @@ public class ImageDtt { ...@@ -1053,7 +1053,7 @@ public class ImageDtt {
final int corr_size = transform_size * 2 -1; final int corr_size = transform_size * 2 -1;
final int [][] transpose_indices = new int [corr_size*(corr_size-1)/2][2]; final int [][] transpose_indices = new int [corr_size*(corr_size-1)/2][2];
int indx = 0; int indx = 0;
if ((globalDebugLevel > -1) && (disparity_corr != 0.0)){ if ((globalDebugLevel > -10) && (disparity_corr != 0.0)){
System.out.println(String.format("Using manual infinity disparity correction of %8.5f pixels",disparity_corr)); System.out.println(String.format("Using manual infinity disparity correction of %8.5f pixels",disparity_corr));
} }
for (int i =0; i < corr_size-1; i++){ for (int i =0; i < corr_size-1; i++){
......
...@@ -3606,8 +3606,12 @@ public class QuadCLT { ...@@ -3606,8 +3606,12 @@ public class QuadCLT {
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}}; {clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
shiftXY = shiftXY0; shiftXY = shiftXY0;
} }
// final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction);
final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction); double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(name)){
z_correction +=clt_parameters.z_corr_map.get(name);
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr( double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
...@@ -4672,8 +4676,13 @@ public class QuadCLT { ...@@ -4672,8 +4676,13 @@ public class QuadCLT {
shiftXY = shiftXY0; shiftXY = shiftXY0;
} }
final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction); // final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction);
double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){
z_correction +=clt_parameters.z_corr_map.get(image_name);
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
...@@ -6272,7 +6281,7 @@ public class QuadCLT { ...@@ -6272,7 +6281,7 @@ public class QuadCLT {
final boolean batch_mode, final boolean batch_mode,
final int debugLevel) final int debugLevel)
{ {
final int debugLevelInner = batch_mode ? -5: debugLevel; final int debugLevelInner = batch_mode ? -3: debugLevel;
// final int tilesX = tp.getTilesX(); // final int tilesX = tp.getTilesX();
// final int tilesY = tp.getTilesY(); // final int tilesY = tp.getTilesY();
...@@ -6440,7 +6449,7 @@ public class QuadCLT { ...@@ -6440,7 +6449,7 @@ public class QuadCLT {
dbg_x, dbg_x,
dbg_y, // final int dbg_y, dbg_y, // final int dbg_y,
debugLevelInner+1); // final int debugLevel) debugLevelInner + 2); // final int debugLevel)
if (last_pass) { if (last_pass) {
break; break;
...@@ -7728,12 +7737,13 @@ public class QuadCLT { ...@@ -7728,12 +7737,13 @@ public class QuadCLT {
//linearStackToColor //linearStackToColor
public CLTPass3d CLTBackgroundMeas( // measure background public CLTPass3d CLTBackgroundMeas( // measure background
final double [][][] image_data, // first index - number of image in a quad // final String image_name,
final boolean [][] saturation_imp, // (near) saturated pixels or null final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) final int debugLevel)
{ {
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY(); final int tilesY = tp.getTilesY();
...@@ -7764,7 +7774,13 @@ public class QuadCLT { ...@@ -7764,7 +7774,13 @@ public class QuadCLT {
double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][]; double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(); ImageDtt image_dtt = new ImageDtt();
final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction); // final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction);
double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){
z_correction +=clt_parameters.z_corr_map.get(image_name);
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
...@@ -7922,6 +7938,7 @@ public class QuadCLT { ...@@ -7922,6 +7938,7 @@ public class QuadCLT {
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity
// final String image_name,
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null final boolean [][] saturation_imp, // (near) saturated pixels or null
final EyesisCorrectionParameters.CLTParameters clt_parameters, final EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -7970,7 +7987,13 @@ public class QuadCLT { ...@@ -7970,7 +7987,13 @@ public class QuadCLT {
double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][]; double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(); ImageDtt image_dtt = new ImageDtt();
final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction); // final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction);
double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){
z_correction +=clt_parameters.z_corr_map.get(image_name);
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
image_dtt.clt_aberrations_quad_corr( image_dtt.clt_aberrations_quad_corr(
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles 1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes tile_op, // per-tile operation bit codes
......
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