Commit 3a62a4a1 authored by Andrey Filippov's avatar Andrey Filippov

Calculating DSI stats over multiple images

parent 848f691d
......@@ -104,7 +104,8 @@ private Panel panel1,
panelClt1,
panelClt2,
panelClt3,
panelClt4
panelClt4,
panelClt5
;
JP46_Reader_camera JP4_INSTANCE=null;
......@@ -396,13 +397,14 @@ private Panel panel1,
Color color_configure= new Color(200, 200,160);
Color color_process= new Color(180, 180, 240);
Color color_conf_process= new Color(180, 240, 240);
Color color_restore= new Color(180, 240, 180);
Color color_restore= new Color(160, 240, 160);
Color color_stop= new Color(255, 160, 160);
Color color_report= new Color(180, 220, 180);
instance = this;
addKeyListener(IJ.getInstance());
int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?5:0);
int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?6:0);
setLayout(new GridLayout(menuRows, 1));
panel6 = new Panel();
......@@ -544,7 +546,7 @@ private Panel panel1,
addButton("CLT reset fine corr", panelClt2, color_stop);
addButton("CLT reset extrinsic corr", panelClt2, color_stop);
addButton("CLT show geometry", panelClt2, color_configure);
addButton("CLT show fine corr", panelClt2, color_configure);
addButton("CLT show fine corr", panelClt2, color_report);
addButton("CLT apply fine corr", panelClt2, color_process);
addButton("CLT test fine corr", panelClt2, color_process);
addButton("CLT process fine corr", panelClt2, color_conf_process);
......@@ -568,8 +570,8 @@ private Panel panel1,
addButton("Setup CLT Batch parameters", panelClt3, color_configure);
addButton("CLT batch process", panelClt3, color_process);
addButton("CM Test", panelClt3, color_stop);
addButton("Show scan", panelClt3, color_configure);
addButton("Show all scans", panelClt3, color_configure);
addButton("Show scan", panelClt3, color_report);
addButton("Show all scans", panelClt3, color_report);
addButton("Periodic", panelClt3, color_configure);
add(panelClt3);
}
......@@ -585,8 +587,8 @@ private Panel panel1,
// addButton("CLT 2*4 images - 3", panelClt4, color_conf_process);
addButton("Rig offset", panelClt4, color_configure);
addButton("Save offset", panelClt4, color_process);
addButton("SHOW extrinsics", panelClt4, color_configure);
addButton("LIST extrinsics", panelClt4, color_configure);
addButton("SHOW extrinsics", panelClt4, color_report);
// addButton("LIST extrinsics", panelClt4, color_configure);
addButton("RIG DSI", panelClt4, color_conf_process);
addButton("MAIN extrinsics", panelClt4, color_process);
addButton("AUX extrinsics", panelClt4, color_process);
......@@ -599,17 +601,24 @@ private Panel panel1,
// /"Reset GT"
addButton("Reset GT", panelClt4, color_stop);
addButton("Ground truth", panelClt4, color_conf_process);
addButton("Show biscan", panelClt4, color_configure);
addButton("Show biscan", panelClt4, color_report);
addButton("Poles GT", panelClt4, color_process);
addButton("ML export", panelClt4, color_conf_process);
addButton("JP4 copy", panelClt4, color_conf_process);
addButton("DSI show", panelClt4, color_process);
addButton("DSI show", panelClt4, color_report);
addButton("Rig batch", panelClt4, color_process);
add(panelClt4);
}
if (DCT_MODE) {
panelClt5 = new Panel();
panelClt5.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("LIST extrinsics", panelClt5, color_report);
addButton("DSI histogram", panelClt5, color_report);
add(panelClt5);
}
pack();
GUI.center(this);
......@@ -4583,6 +4592,10 @@ private Panel panel1,
} else if (label.equals("LIST extrinsics")) {
listExtrinsics();
return;
/* ======================================================================== */
} else if (label.equals("DSI histogram")) {
dsiHistogram();
return;
/* ======================================================================== */
} else if (label.equals("Reset GT")) {
......@@ -5597,11 +5610,22 @@ private Panel panel1,
if (dir!=null) {
System.out.println("top directory = "+dir);
}
//listExtrinsics(String dir, String mask)
// if (TWO_QUAD_CLT == null) {
// return false;
// }
return TwoQuadCLT.listExtrinsics(dir); // , mask);
// return TwoQuadCLT.listExtrinsics(dir); // , mask);
return MLStats.listExtrinsics(dir); // , mask);
//(new MLStats).
}
public boolean dsiHistogram() {
String dir= CalibrationFileManagement.selectDirectory(
false, // true, // smart,
false, // newAllowed, // save
"Model directories to scan", // title
"Select", // button
null, // filter
CORRECTION_PARAMETERS.x3dDirectory); //this.sourceDirectory);
if (dir!=null) {
System.out.println("top directory = "+dir);
}
return MLStats.dsiHistogram(dir); // , mask);
}
public boolean showDSI() {
......
/**
** MLStats - Generate reports over multiple scenes
**
** Copyright (C) 2018 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** MLStats.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import java.util.Properties;
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.gui.GenericDialog;
import ij.text.TextWindow;
public class MLStats {
// TwoQuadCLT twoQuadCLT;
// public MLStats(TwoQuadCLT twoQuadCLT) {
// this.twoQuadCLT = twoQuadCLT;
// }
public static boolean dsiHistogram(String dir) {
Path path= Paths.get(dir);
int disparity_bins = 400;
int strength_bins = 100;
double disparity_min_drop = -0.1;
double disparity_min_clip = -0.1;
double disparity_max_drop = 100.0; //
double disparity_max_clip = 100.0; //
double strength_min_drop = 0.1;
double strength_min_clip = 0.1;
double strength_max_drop = 1.0; //
double strength_max_clip = 0.9; //
String mask = ".*-DSI_COMBO\\.tiff";
GenericDialog gd = new GenericDialog("Select file mask and histogram parameters");
gd.addStringField ("Combined DSI file mask: ", mask, 40);
gd.addNumericField("Number of disparity bins", disparity_bins, 0);
gd.addNumericField("Number of strength bins", strength_bins, 0);
gd.addNumericField("Drop tiles with disparities below", disparity_min_drop, 3);
gd.addNumericField("Clip low disparities with", disparity_min_clip, 3);
gd.addNumericField("Drop tiles with disparities above", disparity_max_drop, 3);
gd.addNumericField("Clip high disparities with", disparity_max_clip, 3);
gd.addNumericField("Drop tiles with strength below", strength_min_drop, 3);
gd.addNumericField("Clip low strength with", strength_min_clip, 3);
gd.addNumericField("Drop tiles with strength above", strength_max_drop, 3);
gd.addNumericField("Clip high strength with", strength_max_clip, 3);
gd.showDialog ();
if (gd.wasCanceled()) return false;
mask = gd.getNextString();
disparity_bins = (int) gd.getNextNumber();
strength_bins = (int) gd.getNextNumber();
disparity_min_drop = gd.getNextNumber();
disparity_min_clip = gd.getNextNumber();
disparity_max_drop = gd.getNextNumber();
disparity_max_clip = gd.getNextNumber();
strength_min_drop = gd.getNextNumber();
strength_min_clip = gd.getNextNumber();
strength_max_drop = gd.getNextNumber();
strength_max_clip = gd.getNextNumber();
// get list of all files:
System.out.println("File mask = "+mask);
final List<Path> files=new ArrayList<>();
final String fMask = mask;
try {
Files.walkFileTree(path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>(){
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if(!attrs.isDirectory()){
if (file.toString().matches(fMask)) {
files.add(file);
}
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
e.printStackTrace();
}
int [][] hist = new int [disparity_bins][strength_bins];
int [] slices = {TwoQuadCLT.DSI_DISPARITY_RIG,TwoQuadCLT.DSI_STRENGTH_RIG};
double disparity_step = (disparity_max_clip - disparity_min_clip) / disparity_bins;
double strength_step = (strength_max_clip - strength_min_clip) / strength_bins;
double disparity_offs = disparity_min_clip - disparity_step/2; // last and first bin that include clip will be 0.5 width
double strength_offs = strength_min_clip - strength_step/2; // last and first bin that include clip will be 0.5 width
int tnut = 0;
for (Path p:files) {
// System.out.println(p.getFileName());
// System.out.println(p.normalize().toString());
ImagePlus imp_dsi=new ImagePlus(p.normalize().toString());
ImageStack dsi_stack= imp_dsi.getStack();
// if (debugLevel>0){
// System.out.println(" kernel_clt_stack.getWidth() = "+dsi_stack.getWidth()+
// " kernel_clt_stack.getHeight() = "+dsi_stack.getHeight());
// }
float [][] dsi_float = new float [slices.length][];
int nLayers = dsi_stack.getSize();
for (int nl = 0; nl < nLayers; nl++){
for (int i = 0; i < slices.length; i++) {
if (TwoQuadCLT.DSI_SLICES[slices[i]].equals(dsi_stack.getSliceLabel(nl + 1))) {
dsi_float[i]= (float[]) dsi_stack.getPixels(nl + 1);
break;
}
}
}
int nut = 0;
for (int nTile = 0; nTile < dsi_float[0].length; nTile++) if (!Float.isNaN( dsi_float[0][nTile])){
double d = dsi_float[0][nTile];
double s = dsi_float[1][nTile];
if (
(d >= disparity_min_drop) &&
(d <= disparity_max_drop) &&
(s >= strength_min_drop) &&
(s <= strength_max_drop)) {
if (d < disparity_min_clip) d = disparity_min_clip;
if (d > disparity_max_clip) d = disparity_max_clip;
if (s < strength_min_clip) s = strength_min_clip;
if (s > strength_max_clip) s = strength_max_clip;
int dbin = (int) ((d - disparity_offs)/disparity_step);
if (dbin >= disparity_bins) dbin = disparity_bins - 1;
int sbin = (int) ((s - strength_offs)/strength_step);
if (sbin >= strength_bins) sbin = strength_bins - 1;
// int [][] hist = new int [disparity_bins][strength_bins];
hist[dbin][sbin]++;
nut++;
}
}
System.out.println(p.getFileName()+": "+nut+" useful tiles counted");
tnut += nut;
}
System.out.println("Total number of useful tiles: "+tnut);
double [] hist_double = new double [disparity_bins*strength_bins];
for (int nTile = 0; nTile < hist_double.length; nTile++) {
int dbin = nTile % disparity_bins;
int sbin = nTile / disparity_bins;
hist_double[nTile] = hist[dbin][sbin];
}
(new showDoubleFloatArrays()).showArrays(
hist_double,
disparity_bins,
strength_bins,
"DSI_histogram");
return true;
}
public static boolean listExtrinsics(String dir) // , String mask)
{
Path path= Paths.get(dir);
boolean inPixels = true;
boolean inMrad = false;
boolean showATR = true;
boolean showZooms = true;
boolean showSym = true;
boolean showRigATR = true;
boolean showRigZoom = true;
boolean showRigAngle = true;
boolean showRigBaseline = false;
String mask = ".*EXTRINSICS\\.corr-xml";
GenericDialog gd = new GenericDialog("Select file mask and output format");
gd.addStringField ("Extrinsics (or general configuration) file mask: ", mask, 40);
gd.addCheckbox("Show results in pixels (false in angular units)",inPixels);
gd.addCheckbox("Show results in mrad (false in arcseconds)", inMrad);
gd.addCheckbox("Show azimuths, tilts, rolls", showATR);
gd.addCheckbox("Show zooms", showZooms);
gd.addCheckbox("Show symmetric angles", showSym);
gd.addCheckbox("Show rig azimuth, tilt, roll", showRigATR);
gd.addCheckbox("Show rig zoom", showRigZoom);
gd.addCheckbox("Show rig angle", showRigAngle);
gd.addCheckbox("Show rig baseline", showRigBaseline);
gd.showDialog ();
if (gd.wasCanceled()) return false;
mask = gd.getNextString();
inPixels = gd.getNextBoolean();
inMrad = gd.getNextBoolean();
showATR = gd.getNextBoolean();
showZooms = gd.getNextBoolean();
showSym = gd.getNextBoolean();
showRigATR = gd.getNextBoolean();
showRigZoom = gd.getNextBoolean();
showRigAngle = gd.getNextBoolean();
showRigBaseline = gd.getNextBoolean();
String units = inPixels ? "pix":(inMrad?"mil":"\"");
String zunits = inPixels ? "pix":(inMrad?"mil":"\"");
double scale = inPixels ? 1.0 : (inMrad?1000.0:(180.0/Math.PI*60*60)); //leave pixels as is, convert radians to arc-sec
String fmt = "\t"+(inPixels ? "%8.4f":(inMrad?"%8.4f":"%8.2f"));
String fmt_angle = "\t%8.3f";
String fmt_len = "\t%8.3f";
int num_sym = showZooms? GeometryCorrection.CorrVector.LENGTH:GeometryCorrection.CorrVector.ZOOM_INDEX;
class ModVerString{
String model;
String version;
String txt;
ModVerString (String model, String version, String txt){
this.model = model;
this.version = version;
this.txt = txt;
}
@Override
public String toString() {
return model+"\t"+version+txt;
}
}
ArrayList<ModVerString> line_list = new ArrayList<ModVerString>();
String title = "Extrinsic_parameters_variations_in_"+(inPixels ? "pixels":(inMrad?"mrad":"arcseconds"));
String header="#\tModel\tVersion";
int num_col = 0;
if (showATR) {
header+=String.format("\taz m0 (%s)\taz m1 (%s)\taz m2 (%s)\taz m3 (%s)"+
"\ttl m0 (%s)\ttl m1 (%s) \ttl m2 (%s)\ttl m3 (%s)"+
"\trl m0 (%s)\trl m1 (%s) \trl m2 (%s)\trl m3 (%s)",
units,units,units,units,units,units,units,units,units,units,units,units);
num_col+=12;
}
if (showZooms) {
header+=String.format("\tzm m0 (%s)\tzm m1 (%s)\tzm m2 (%s)\tzm m3 (%s)", zunits, zunits, zunits, zunits);
num_col+=4;
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
header+=String.format("\tsym%02d-m", i);
}
num_col+=num_sym;
}
if (showATR) {
header+=String.format("\taz a0 (%s)\taz a1 (%s)\taz a2 (%s)\taz a3 (%s)"+
"\ttl a0 (%s)\ttl a1 (%s) \ttl a2 (%s)\ttl a3 (%s)"+
"\trl a0 (%s)\trl a1 (%s) \trl a2 (%s)\trl a3 (%s)",
units,units,units,units,units,units,units,units,units,units,units,units);
num_col+=12;
}
if (showZooms) {
header+=String.format("\tzm a0 (%s)\tzm a1 (%s)\tzm a2 (%s)\tzm a3 (%s)", zunits, zunits, zunits, zunits);
num_col+=4;
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
header+=String.format("\tsym%02d-a", i);
}
num_col+=num_sym;
}
if (showRigATR) {
header+=String.format("\trig azmth (%s)\trig tilt(%s)\trig roll (%s)", units, units, units);
num_col+=3;
}
if (showRigZoom) {
header+=String.format("\trig zoom (%s)", zunits);
num_col+=1;
}
//
if (showRigAngle) {
header+="\trig angle (°)";
num_col+=1;
}
if (showRigBaseline) {
header+="\trig baseline (mm)";
num_col+=1;
}
System.out.println("File mask = "+mask);
final List<Path> files=new ArrayList<>();
final String fMask = mask;
try {
Files.walkFileTree(path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>(){
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if(!attrs.isDirectory()){
if (file.toString().matches(fMask)) {
files.add(file);
}
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
e.printStackTrace();
}
int indx=1;
double [][] stats = new double [num_col][2];
String [] fmts = new String[num_col];
for (Path p:files) {
int count = p.getNameCount();
if (count >=3) {
String model = p.getName(count-3).toString();
String version = p.getName(count-2).toString();
String name = p.getName(count-1).toString();
System.out.println(indx+": model:"+model+", version:"+version+", name: "+name);
Properties properties = loadProperties(
p.toString(), // String path,
null); // Properties properties)
QuadCLT qcm = new QuadCLT(
QuadCLT.PREFIX, // String prefix,
properties, // Properties properties,
null, // EyesisCorrections eyesisCorrections,
null // EyesisCorrectionParameters.CorrectionParameters correctionsParameters
);
QuadCLT qca = new QuadCLT(
QuadCLT.PREFIX_AUX, // String prefix,
properties, // Properties properties,
null, // EyesisCorrections eyesisCorrections,
null // EyesisCorrectionParameters.CorrectionParameters correctionsParameters
);
System.out.println(indx+": model:"+model+", version:"+version+", name: "+name);
GeometryCorrection.CorrVector cvm = qcm.geometryCorrection.getCorrVector();
GeometryCorrection.CorrVector cva = qca.geometryCorrection.getCorrVector();
// double [] vect_main = qcm.geometryCorrection.getCorrVector().toArray();
StringBuffer sb = new StringBuffer();
int ncol = 0;
// sb.append(indx+"\t"+model+"\t"+version);
if (showATR) { // main camera
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.AZIMUTH_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // azimuths
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.TILT_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // tilts
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ROLL_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // rolls
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
}
if (showZooms) { // main camera
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cvm.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ZOOM_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // zooms
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
double v = scale * cvm.getExtrinsicSymParameterValue(i, inPixels);
sb.append(String.format(fmt,v)); // sym parameters
fmts [ncol] = fmt;
stats[ncol ][0]+=v;
stats[ncol++][1]+=v*v;
}
}
if (showATR) { // aux camera
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.AZIMUTH_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // azimuths
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.TILT_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // tilts
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ROLL_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // rolls
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
}
if (showZooms) { // aux camera
double [] v = new double[4];
for (int i = 0; i <4; i++) {
if (i < 3) {
v[i] = scale * cva.getExtrinsicParameterValue(i+GeometryCorrection.CorrVector.ZOOM_INDEX, inPixels);
v[3] -= v[i];
}
sb.append(String.format(fmt,v[i])); // zooms
fmts [ncol] = fmt;
stats[ncol ][0]+=v[i];
stats[ncol++][1]+=v[i]*v[i];
}
}
if (showSym) {
for (int i = 0; i < num_sym; i++) {
double v = scale * cva.getExtrinsicSymParameterValue(i, inPixels);
sb.append(String.format(fmt,v)); // sym parameters
fmts [ncol] = fmt;
stats[ncol ][0]+=v;
stats[ncol++][1]+=v*v;
}
}
if (showRigATR) {
int [] indices = {
GeometryCorrection.RigOffset.AUX_AZIMUTH_INDEX,
GeometryCorrection.RigOffset.AUX_TILT_INDEX,
GeometryCorrection.RigOffset.AUX_ROLL_INDEX};
for (int i = 0; i < indices.length; i++) {
double v = scale * qca.geometryCorrection.getRigOffsetParameter(indices[i], inPixels);
sb.append(String.format(fmt,v)); // tig atz parameters
fmts [ncol] = fmt;
stats[ncol ][0]+=v;
stats[ncol++][1]+=v*v;
}
}
if (showRigZoom) {
double v = scale * qca.geometryCorrection.getRigOffsetParameter(GeometryCorrection.RigOffset.AUX_ZOOM_INDEX, inPixels);
sb.append(String.format(fmt,v)); // tig atz parameters
fmts [ncol] = fmt;
stats[ncol ][0]+=v;
stats[ncol++][1]+=v*v;
}
if (showRigAngle) {
// sb.append(String.format(fmt_angle, 180/Math.PI * qca.geometryCorrection.getRigOffsetParameter(GeometryCorrection.RigOffset.AUX_ANGLE_INDEX, false)));
double v = 180/Math.PI * qca.geometryCorrection.getRigOffsetParameter(GeometryCorrection.RigOffset.AUX_ANGLE_INDEX, inPixels);
sb.append(String.format(fmt_angle,v)); // tig atz parameters
fmts [ncol] = fmt_angle;
stats[ncol ][0]+=v;
stats[ncol++][1]+=v*v;
}
if (showRigBaseline) {
// sb.append(String.format(fmt_len, qca.geometryCorrection.getRigOffsetParameter(GeometryCorrection.RigOffset.AUX_BASELINE_INDEX, false)));
double v = qca.geometryCorrection.getRigOffsetParameter(GeometryCorrection.RigOffset.AUX_ANGLE_INDEX, inPixels);
sb.append(String.format(fmt_len,v)); // tig atz parameters
fmts [ncol] = fmt_len;
stats[ncol ][0]+=v;
stats[ncol++][1]+=v*v;
}
sb.append("\n");
line_list.add( new ModVerString(model,version,sb.toString()));
indx++;
}
}
Collections.sort(line_list, new Comparator<ModVerString>() {
@Override
public int compare(ModVerString lhs, ModVerString rhs) {
// -1 - less than, 1 - greater than, 0 - equal, not inverted for ascending disparity
int rslt = lhs.model.compareTo(rhs.model);
if (rslt == 0) rslt = lhs.version.compareTo(rhs.version);
return rslt;
}
});
StringBuffer sb_avg = new StringBuffer();
StringBuffer sb_rms = new StringBuffer();
sb_avg.append("--\tAverage\t");
sb_rms.append("--\tStandard deviation\t");
int nrows = indx -1;
if (indx > 1) {
for (int ncol = 0; ncol < num_col; ncol++) {
stats[ncol][0] /= nrows;
stats[ncol][1] /= nrows;
stats[ncol][1] = Math.sqrt(stats[ncol][1] - stats[ncol][0]*stats[ncol][0]);
if (Double.isNaN(stats[ncol][1])) { // small negative by rounding error?
stats[ncol][1] = 0.0;
}
sb_avg.append(String.format(fmts[ncol],stats[ncol][0]));
sb_rms.append(String.format(fmts[ncol],stats[ncol][1]));
}
}
// ~1280
// int a = GeometryCorrection.RigOffset.VECTOR_LENGTH;
StringBuffer sb = new StringBuffer();
indx = 1;
for (ModVerString mvs:line_list) {
sb.append((indx++)+"\t"+mvs.toString());
}
sb.append(sb_avg.toString()+"\n");
sb.append(sb_rms.toString()+"\n");
new TextWindow (title, header, sb.toString(), 1200,800);
return true;
}
public static Properties loadProperties(
String path,
Properties properties){
if (properties == null) {
properties = new Properties();
}
InputStream is;
try {
is = new FileInputStream(path);
} catch (FileNotFoundException e) {
IJ.showMessage("Error","Failed to open configuration file: "+path);
return null;
}
try {
properties.loadFromXML(is);
} catch (IOException e) {
IJ.showMessage("Error","Failed to read XML configuration file: "+path);
return null;
}
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return properties;
// getAllProperties(properties);
// if (DEBUG_LEVEL>0) System.out.println("Configuration parameters are restored from "+path);
}
}
......@@ -21,34 +21,20 @@
**
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import java.util.Properties;
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.Prefs;
import ij.gui.GenericDialog;
import ij.io.FileSaver;
import ij.text.TextWindow;
public class TwoQuadCLT {
public static int DSI_DISPARITY_MAIN = 0;
......@@ -6350,6 +6336,7 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Configuration parameters are saved to "+path);
}
}
/*
public static boolean listExtrinsics(String dir) // , String mask)
{
Path path= Paths.get(dir);
......@@ -6756,5 +6743,5 @@ if (debugLevel > -100) return true; // temporarily !
// getAllProperties(properties);
// if (DEBUG_LEVEL>0) System.out.println("Configuration parameters are restored from "+path);
}
*/
}
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