...
 
Commits (151)
......@@ -37,7 +37,7 @@
<dependency>
<groupId>org.jcuda</groupId>
<artifactId>jcuda</artifactId>
<version>0.9.2</version>
<version>10.1.0</version>
</dependency>
<!--
As of 2018/09/11 TF for GPU on Maven supports CUDA 9.0 (vs latest 9.2)
......@@ -92,11 +92,46 @@
<artifactId>loci_tools</artifactId>
<version>6.1.0</version>
</dependency>
<!--
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.11.0</version>
<type>java-source</type>
</dependency> -->
<!-- https://mvnrepository.com/artifact/com.drewnoakes/metadata-extractor -->
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.ehcache/ehcache-core -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-numbers-quaternion -->
<!--
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-numbers-quaternion</artifactId>
<version>1.0-beta1</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,6 @@ package com.elphel.imagej.calibration;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import javax.swing.JFileChooser;
......@@ -204,49 +203,4 @@ public class CalibrationFileManagement {
}
}
}
/* ======================================================================== */
public static class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String prefix=""; // case sensitive
public MultipleExtensionsFileFilter (String prefix, String [] patterns,String description) {
this.prefix= prefix;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns,String description) {
this.description=description;
this.patterns=patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public boolean accept (File dir, String name) { // directory - don't care here, only name
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (int i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
}
}
package com.elphel.imagej.calibration;
import java.io.File;
// select directory that contains matching MultipleExtensionsFileFilter in specified min/max quantities
//https://stackoverflow.com/questions/22302199/java-filefilter-to-select-certain-directories
// public static class DirectoryContentsFilter extends FileFilter implements FilenameFilter {
public class DirectoryChoser extends javax.swing.JFileChooser {
private static final long serialVersionUID = 390855361964415146L;
protected MultipleExtensionsFileFilter multipleExtensionsFileFilter;
protected int min_files;
protected int max_files;
protected String description;
public DirectoryChoser (
MultipleExtensionsFileFilter multipleExtensionsFileFilter,
int min_files,
int max_files,
String description) // may be null;
{
this.multipleExtensionsFileFilter= multipleExtensionsFileFilter;
this.min_files = min_files;
this.max_files = max_files;
this.description = description;
}
@Override
public boolean isDirectorySelectionEnabled() {
// setOpenButtonState(this, false);
File file = getSelectedFile();
// File [] files = getSelectedFiles();
if(file == null){
// setOpenButtonState(this, true);
return true; // false;
}
// setOpenButtonState(this, false);
if (!file.isDirectory()) return false;
/*
// Can not make it work correctly with multiple selection, giving up for now
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) {
return false;
}
*/
setOpenButtonState(this, true);
return true;
}
private void setOpenButtonState(java.awt.Container c, boolean flag) {
int len = c.getComponentCount();
for (int i = 0; i < len; i++) {
java.awt.Component comp = c.getComponent(i);
if (comp instanceof javax.swing.JButton) {
javax.swing.JButton b = (javax.swing.JButton)comp;
if ( b != null && b.getText() != null && b.getText().equals("Select") ) {
b.setEnabled(flag);
}
} else if (comp instanceof java.awt.Container) {
setOpenButtonState((java.awt.Container) comp, flag);
}
}
}
/*
@Override
public boolean accept (File file) {
if (!file.isDirectory()) return false;
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) return false;
return true;
}
@Override
public boolean accept (File dir, String name) {
// No name filter, need to resolve
// Path dir_path = dir.toPath();
File target = Paths.get(dir.toString(),name).toFile();
return accept(target);
}
@Override
public String getDescription() { // if description is null - generate it
if (description == null) {
description = "Directories containing";
if (min_files > 0) description +=" not less than "+min_files;
if (max_files > 0) description +=" not more than "+max_files;
description += " "+multipleExtensionsFileFilter.description;
}
return description;
}
*/
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -176,8 +176,8 @@ import ij.gui.GenericDialog;
defaultPaths[0]="";
}
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files");
MultipleExtensionsFileFilter sourceFilter =
new MultipleExtensionsFileFilter("",extensions,"Source files");
String [] sourceFiles=null;
if (allFiles){
File dir= new File (this.sourceDirectory);
......@@ -193,7 +193,7 @@ import ij.gui.GenericDialog;
sourceFiles = new String[fileList.length];
for (int i=0;i<sourceFiles.length;i++) sourceFiles[i]=fileList[i].getPath();
} else {
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files");
new MultipleExtensionsFileFilter("",extensions,"Source files");
sourceFiles=CalibrationFileManagement.selectFiles(false,
"Select Source files, saved as TIFF",
"Select",
......
......@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools;
......@@ -5037,7 +5036,7 @@ public boolean LevenbergMarquardt(
boolean smart, // do not open dialog if default matches
String defaultPath){ // x,y,r
String [] extensions={".history-xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.history-xml files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.history-xml files");
String pathname=CalibrationFileManagement.selectFile(
smart,
false,
......@@ -9589,7 +9588,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
path= CalibrationFileManagement.selectFile(true, // save
"Save Field LMA Strategy selection", // title
"Select Field LMA Strategy file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns,
new MultipleExtensionsFileFilter(patterns,
"Strategy files (*.fstg-xml)"), // filter
directory); // may be ""
} else path+=patterns[0];
......@@ -9628,7 +9627,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
path= CalibrationFileManagement.selectFile(false, // save
"Field LMA Strategy selection", // title
"Select Field LMA Strategy file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns,
new MultipleExtensionsFileFilter(patterns,
"Strategy files (*.fstg-xml)"), // filter
directory); // may be ""
} else {
......
......@@ -29,6 +29,8 @@ package com.elphel.imagej.calibration;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.calibration.hardware.CamerasInterface;
import com.elphel.imagej.calibration.hardware.GoniometerMotors;
import com.elphel.imagej.cameras.EyesisCameraParameters;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools;
......@@ -50,7 +52,7 @@ horizontal axis:
private ShowDoubleFloatArrays sdfaInstance = new ShowDoubleFloatArrays(); // just
// for
// debugging
public CalibrationHardwareInterface.CamerasInterface cameras = null;
public CamerasInterface cameras = null;
public LwirReader lwirReader = null;
// public CalibrationHardwareInterface.LaserPointers lasers = null;
// public static CalibrationHardwareInterface.FocusingMotors motorsS=null;
......@@ -67,7 +69,7 @@ horizontal axis:
public MatchSimulatedPattern[] matchSimulatedPatterns = null; // =new
// MatchSimulatedPattern();
public MatchSimulatedPattern.LaserPointer laserPointers = null;
public LaserPointer laserPointers = null;
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters=null;
public SimulationPattern.SimulParameters simulParametersDefault=null;
public Goniometer.GoniometerParameters goniometerParameters = null;
......@@ -78,11 +80,11 @@ horizontal axis:
public double bottomRollersClearance=36.0; // angular clearance between the two bottom rollers
public Goniometer(CalibrationHardwareInterface.CamerasInterface cameras,
public Goniometer(CamerasInterface cameras,
MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
EyesisCameraParameters eyesisCameraParameters,
MatchSimulatedPattern.LaserPointer laserPointers,
LaserPointer laserPointers,
SimulationPattern.SimulParameters simulParametersDefault,
Goniometer.GoniometerParameters goniometerParameters,
DistortionProcessConfiguration distortionProcessConfiguration
......@@ -104,7 +106,7 @@ horizontal axis:
MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
EyesisCameraParameters eyesisCameraParameters,
MatchSimulatedPattern.LaserPointer laserPointers,
LaserPointer laserPointers,
SimulationPattern.SimulParameters simulParametersDefault,
Goniometer.GoniometerParameters goniometerParameters,
DistortionProcessConfiguration distortionProcessConfiguration
......@@ -754,15 +756,10 @@ horizontal axis:
public double[] estimateOrientation(
ImagePlus[] images, // last acquire images with number of pointers
// detected>0
// MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
// LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
// Goniometer.GoniometerParameters goniometerParameters,
// MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
// MatchSimulatedPattern.LaserPointer laserPointer, // null OK
// SimulationPattern.SimulParameters simulParametersDefault,
DistortionCalibrationData distortionCalibrationData,
PatternParameters patternParameters, // should not be null
Distortions lensDistortions, // should not be null
LaserPointer laserPointers, // as a back up measure
boolean equalizeGreens,
int threadsMax,
boolean updateStatus,
......@@ -774,7 +771,7 @@ horizontal axis:
throw new IllegalArgumentException(msg);
}
// remove unneeded, copied from updateFocusGrid()
// remove unneeded, copied from updateFocusGrid() Now it is not needed?
SimulationPattern.SimulParameters simulParameters = modifySimulParameters();
MatchSimulatedPattern.DistortionParameters distortionParameters = modifyDistortionParameters();
......@@ -815,8 +812,7 @@ horizontal axis:
// used alternatively if keeping it
this.matchSimulatedPatterns[numSensor].invalidateFlatFieldForGrid(); // Reset Flat Filed calibration - different image.
this.matchSimulatedPatterns[numSensor].invalidateFocusMask();
if (matchSimulatedPatterns[numSensor].getPointersXY(images[numSensor],
this.laserPointers.laserUVMap.length) == null) { // no pointers in this image
if (MatchSimulatedPattern.getPointersXYUV(images[numSensor],this.laserPointers) == null) { // no pointers in this image
String msg = "No laser pointers detected for "+ images[numSensor].getTitle()+ " - they are needed for absolute grid positioning";
if (debug_level > 0) System.out.println("Warning: " + msg);
IJ.showMessage("Warning", msg);
......@@ -933,8 +929,9 @@ horizontal axis:
* //PatternParameters patternParameters, eyesisCameraParameters
* //EyesisCameraParameters eyesisCameraParameters );
*/
distortionCalibrationData.setImages(imp_calibrated, // ImagePlus [] images, // imagesin the memory
patternParameters); // PatternParameters patternParameters);
distortionCalibrationData.setImages(imp_calibrated, // ImagePlus [] images, // images in the memory
patternParameters, // PatternParameters patternParameters);
laserPointers);
distortionCalibrationData.initImageSet(eyesisCameraParameters);
// Set initial azimuth and elevation
......@@ -992,7 +989,9 @@ horizontal axis:
// TODO: Set initial values for the goniometer angles from the sensor
// (channel) number, average them if there are several in the list
lensDistortions.LevenbergMarquardt(false); // skip dialog
lensDistortions.LevenbergMarquardt(
false, // skip dialog
false); // new: dry_run use it here?
if (debug_level > 0)
System.out.println("Finished LMA at "
+ IJ.d2s(0.000000001 * (System.nanoTime() - startTime), 3));
......@@ -1008,6 +1007,10 @@ horizontal axis:
};
return result;
}
public static class GoniometerParameters {
public String gridGeometryFile="";
public String initialCalibrationFile="";
......@@ -1075,7 +1078,7 @@ horizontal axis:
5682.48889 per degree
*/
// motors rotate positive - look down, positive - CCW
CalibrationHardwareInterface.GoniometerMotors goniometerMotors=null;
GoniometerMotors goniometerMotors=null;
// public double stepsPerDegreeTilt=-5682.48889; // minus that positive steps make negative elevation
// public double stepsPerDegreeAxial=-36.0; // minus that positive steps make rotate CCW when looking from Eyesis top
// public double scanStepTilt=20.0; // degrees (equal steps not larger than
......@@ -1098,11 +1101,11 @@ horizontal axis:
public GoniometerParameters(CalibrationHardwareInterface.GoniometerMotors goniometerMotors){
public GoniometerParameters(GoniometerMotors goniometerMotors){
this.goniometerMotors=goniometerMotors;
}
public GoniometerParameters(
CalibrationHardwareInterface.GoniometerMotors goniometerMotors,
GoniometerMotors goniometerMotors,
String gridGeometryFile,
String initialCalibrationFile, // not needed
String strategyFile,
......
This diff is collapsed.
......@@ -45,7 +45,7 @@ public class LensAdjustment {
MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
MatchSimulatedPattern.LaserPointer laserPointer, // null OK
LaserPointer laserPointer, // null OK
SimulationPattern.SimulParameters simulParametersDefault,
boolean maskNonPSF, // mask out areas not needed for focusing PSF measurements
boolean equalizeGreens,
......
package com.elphel.imagej.calibration;
import java.io.File;
import java.io.FilenameFilter;
import javax.swing.filechooser.FileFilter;
/* ======================================================================== */
public class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String [] prefixes= {""}; // case sensitive
// prefix/prefixeas can not be null - ambiguity
public MultipleExtensionsFileFilter (String prefix, String [] patterns,String description) {
this.prefixes= new String[1];
this.prefixes[0] = prefix;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] prefixes, String [] patterns,String description) {
this.prefixes= prefixes;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns,String description) {
this.description=description;
this.patterns=patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!testPrefix(name)) return false;
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public boolean accept (File dir, String name) { // directory - don't care here, only name
if (!testPrefix(name)) return false;
for (int i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
private boolean testPrefix(String name) {
if ((prefixes == null) || (prefixes[0] == null)) return true;
for (String s : prefixes) {
if ((s == null) || name.startsWith(s)) {
return true;
}
}
return false; // prefix mismatch;
}
}
\ No newline at end of file
......@@ -38,7 +38,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.SwingUtilities;
import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
......@@ -85,7 +84,7 @@ public class PixelMapping {
String [] extensions={".calib-tiff"};
String [] defaultPaths=((defaultPath==null) || defaultPath.equals(""))?null:(new String[1]);
if (defaultPaths!=null) defaultPaths[0]=defaultPath;
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
String [] calibFiles=CalibrationFileManagement.selectFiles(false,
"Select camera sub-modules calibration files",
"Select",
......@@ -109,15 +108,27 @@ public class PixelMapping {
}
}
public PixelMapping (String [] calibFiles, int debugLevel){
public PixelMapping (
String [] calibFiles,
int first_channel, // 0 - old way
int num_channels, // 0 - any
boolean update_channel, // false (replace file channel with effective channel (subtract first_channel)
int debugLevel){
this.debugLevel=debugLevel;
if (calibFiles==null) calibFiles=new String[0];
this.sensors=new SensorData[this.maxSensors];
this.sensors=new SensorData[(num_channels > 0)? num_channels: this.maxSensors];
for (int i=0;i<this.sensors.length;i++) this.sensors[i]=null;
int maxChannel=0;
for (int i=0;i<calibFiles.length;i++){
SensorData sensorData=new SensorData (calibFiles[i],this.debugLevel);
int channel=sensorData.getChannel();
int channel=sensorData.getChannel(); // from Properties
if ((channel < first_channel) || ((num_channels > 0) && (channel >= (first_channel + num_channels)))) {
continue; // wrong channels
}
channel -= first_channel;
if (update_channel) {
sensorData.setChannel(channel);
}
this.sensors[channel]=sensorData;
if (channel>maxChannel) maxChannel=channel;
}
......@@ -142,43 +153,79 @@ public class PixelMapping {
// System.out.println("getSubChannel("+channel+") => "+this.sensors[channel].getSubChannel());
return this.sensors[channel].getSubChannel();
}
public int getSubChannelSilent(int channel ){
if ((channel<0) || (channel>=this.sensors.length)) {
return -1;
}
// System.out.println("getSubChannel("+channel+") => "+this.sensors[channel].getSubChannel());
return this.sensors[channel].getSubChannel();
}
public int getSubCamera(int channel ){
if ((channel<0) || (channel>=this.sensors.length)) return -1;
return this.sensors[channel].getSubCamera();
}
/*
public int getSensorPort(int channel ){
if ((channel<0) || (channel>=this.sensors.length)) return -1;
return this.sensors[channel].getSensorPort();
}
*/
// Enumerated calibration file
public boolean isChannelAvailable(int channel){
return (this.sensors != null) && (channel>=0) && (channel<this.sensors.length) && (this.sensors[channel]!=null);
}
public boolean isChannelAvailable(int [] channels){
if (channels == null) return false;
for (int c:channels) {
if (isChannelAvailable(c)) return true;
}
return false;
}
// Updating for nc393. subCamera here is 0..9 for Eyesis4pi393 - 0-based index of the file, so it combines physical camera (separate IP)
// as stored in "subcamera" field of the calibration file and "sensor_port". sensor_port may start from non-0, so we need to count all combinations
//removeUnusedSensorData xshould be off!
//removeUnusedSensorData should be off!
public boolean subcamerasUsed() {
for (int i=0;i<this.sensors.length;i++) if ((this.sensors[i]!=null) && (this.sensors[i].subcamera >= 0)) {
return true;
}
return false;
}
// if subcameras are not used (-1), as in Quads, return {channel index} or null if alien file
public int [] getSensorWH(int chn) {
if ((sensors == null) || (chn < 0) || (chn >= sensors.length)) {
return null;
}
return sensors[chn].getSensorWH();
}
public int [] channelsForSubCamera(int subCamera){
if (subCamera < 0) {
return null;
}
if (this.sensors == null) return null;
if (this.debugLevel>1) {
System.out.print("channelsForSubCamera("+subCamera+"),this.sensors.length="+this.sensors.length+": ");
// } else if (this.debugLevel > -2) {
// System.out.print(".");
}
// ArrayList<ArrayList<ArrayList<Integer>>> camera_IPs = new ArrayList<ArrayList<ArrayList<Integer>>>();
if (!subcamerasUsed()) {
for (int i=0;i<this.sensors.length;i++) if ((this.sensors[i]!=null) && (this.sensors[i].channel == subCamera)) {
int [] rslt = {i};
return rslt;
}
return null;
}
// Eyesis version
ArrayList<Point> cam_port = new ArrayList<Point>();
for (int i=0;i<this.sensors.length;i++) if (this.sensors[i]!=null) {
Point cp = new Point(this.sensors[i].subcamera, this.sensors[i].sensor_port);
if (!cam_port.contains(cp)){
cam_port.add(cp);
}
// System.out.println("this.sensors["+i+"]!=null, this.sensors[i].subcamera="+this.sensors[i].subcamera+", this.sensors[i].sensor_port="+this.sensors[i].sensor_port);
}
Point [] cam_port_arr = cam_port.toArray(new Point[0]);
Arrays.sort(cam_port_arr, new Comparator<Point>() {
......@@ -199,7 +246,6 @@ public class PixelMapping {
} else if (this.debugLevel > -2) {
System.out.print(".");
}
if (this.sensors == null) return null;
int numChannels=0;
for (int i=0;i<this.sensors.length;i++) if (this.sensors[i]!=null) {
if (new Point(this.sensors[i].subcamera, this.sensors[i].sensor_port).equals(cam_port_arr[subCamera])) numChannels++;
......@@ -220,21 +266,16 @@ public class PixelMapping {
public float [] getBayerFlatFieldFloat(
int channel,
// int width,
// int height,
int [][] bayer){ //{{1,0},{2,1}} GR/BG
int [][] bayer, //{{1,0},{2,1}} GR/BG
double range) { // max/min
if ((this.sensors == null) || (channel<0) && (channel>=this.sensors.length))return null;
// width = this.sensors[channel]
return this.sensors[channel].getBayerFlatFieldFloat(
// width,
// height,
bayer);
bayer,
range);
}
public double [] getBayerFlatField(
int channel,
// int width,
// int height,
int [][] bayer){ //{{1,0},{2,1}} GR/BG
if ((this.sensors == null) || (channel<0) && (channel>=this.sensors.length))return null;
return this.sensors[channel].getBayerFlatField(
......@@ -292,7 +333,7 @@ public class PixelMapping {
String [] extensions={".eqr-tiff", ".eqrect-tiff"};
String [] defaultPaths=((defaultPath==null) || defaultPath.equals(""))?null:(new String[1]);
if (defaultPaths!=null) defaultPaths[0]=defaultPath;
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"equirectangular map "+extensions[0]+" files");
MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"equirectangular map "+extensions[0]+" files");
String [] eqrectFiles=CalibrationFileManagement.selectFiles(false,
"Select equirectangular calibration files",
"Select",
......@@ -15935,16 +15976,19 @@ public class PixelMapping {
return corrScale;
}
public float [] getBayerFlatFieldFloat(
int [][] bayer){ //{{1,0},{2,1}} GR/BG
int [][] bayer, //{{1,0},{2,1}} GR/BG
double range) {
return _getBayerFlatFieldFloat(
this.pixelCorrectionWidth, // width,
this.pixelCorrectionHeight, // int height,
bayer);
bayer,
range);
}
private float [] _getBayerFlatFieldFloat(
int width,
int height,
int [][] bayer){ //{{1,0},{2,1}} GR/BG
int [][] bayer, //{{1,0},{2,1}} GR/BG
double range) {
float [] corrScale = new float [width*height];
for (int y=0;y<height;y++) for (int x=0;x<width;x++){
......@@ -15954,11 +15998,6 @@ public class PixelMapping {
x, //double px,
y //double py)
);
/* double d=interpolateCorrectionVector(
true, // boolean rgbOnly,
x, //double px,
y //double py)
)[iBayer];*/
if (iBayer>=v.length){
System.out.println("getBayerFlatField(): v.length="+v.length+" x="+x+" y="+y+" iBayer="+iBayer);
}
......@@ -15966,6 +16005,24 @@ public class PixelMapping {
if (d!=0.0) d=1.0/d;
corrScale[y*width+x]= (float) d;
}
if (range > 0.0) {
double [] mins = {Double.NaN,Double.NaN,Double.NaN,Double.NaN};
int indx = 0;
for (int y=0;y<height;y++) for (int x=0;x<width;x++){
int iBayer= 2*(y&1) +(x&1);
double d = corrScale[indx++];
if (! ( d >= mins[iBayer])) mins[iBayer] = d;
}
for (int i = 0; i < mins.length; i++) {
mins[i] *= range;
}
indx = 0;
for (int y=0;y<height;y++) for (int x=0;x<width;x++){
int iBayer= 2*(y&1) +(x&1);
if ( corrScale[indx] >= mins[iBayer]) corrScale[indx] = (float) mins[iBayer];
indx++;
}
}
return corrScale;
}
public int [][] getDefectsXY(){
......@@ -16221,6 +16278,7 @@ public class PixelMapping {
}
public SensorData (){} // just to get parameter names
public void setChannel(int chn){this.channel = chn;}
public int getChannel(){return this.channel;}
public int getSubChannel(){return this.subchannel;}
public int getSubCamera(){return this.subcamera;}
......
......@@ -626,7 +626,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
float [][] simArray=new float [2][];
simArray[0]=(new SimulationPattern(simulParameters)).combineWithCanvas(0.0, k*width, k*height, scaledWoi,simArray0[0]);
simArray[1]=(new SimulationPattern(simulParameters)).combineWithCanvas(0.0, k*width, k*height, scaledWoi,simArray0[1]);
if (globalDebugLevel>1) SDFA_INSTANCE.showArrays(simArray,width*k,height*k,true, "full-simulation");
if (globalDebugLevel>0) SDFA_INSTANCE.showArrays(simArray,width*k,height*k,true, "full-simulation");
return simArray;
}
......@@ -1009,14 +1009,32 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
y0);
}
public double [] extractSimulMono ( // TODO: can use twice smaller barray
double [] localbArray,
SimulParameters simulParameters,
int outSubdiv, // subdivide output pixels - now 4
int size, // number of Bayer cells in width of the square selection (half number of pixels)
double x0, // selection center, X (in pixels)
double y0) {
return extractSimulMono ( // TODO: can use twice smaller barray
localbArray,
false, // boolean invert,
simulParameters,
outSubdiv, // subdivide output pixels - now 4
size, // number of Bayer cells in width of the square selection (half number of pixels)
x0, // selection center, X (in pixels)
y0);
}
public double [] extractSimulMono ( // TODO: can use twice smaller barray
double [] localbArray,
boolean invert,
SimulParameters simulParameters,
int outSubdiv, // subdivide output pixels - now 4
int size, // number of Bayer cells in width of the square selection (half number of pixels)
double x0, // selection center, X (in pixels)
double y0) {
double pattern_sign = invert? -1.0 : 1.0;
int sampleWidth=(int) (Math.sqrt(simulParameters.fill)*simulParameters.subdiv);
int sampleN=sampleWidth*sampleWidth;
if (sampleWidth<1) sampleWidth=1;
......@@ -1043,7 +1061,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
return null;
}
}
simul_pixels[iy*size+ix]= (s-sampleAverage)/sampleAverage;
simul_pixels[iy*size+ix]= pattern_sign * (s - sampleAverage) / sampleAverage;
}
}
if (this.debugLevel>2) {
......@@ -1069,6 +1087,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
return rslt;
}
// colorComp == -1 = mono, positive, colorComp == -2 - mono, negative
public double[] extractBayerSim (
float [][] spixels, // [0] - regular pixels, [1] - shifted by 1/2 diagonally, for checker greens
int full_width,
......@@ -1105,21 +1124,28 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
result[index]=spixels[(ixi+iyi) & 1][iy*full_width+ix];
}
} else { // components 0..3
int ser;
double pattern_sign = (colorComp == -2)? -1.0: 1.0;
if (colorComp < 0) {
ser = 1; // offset by 1/2 pix? should it be so? // FIXME: verify and fix if needed - compare to extractSimulMono()
} else {
ser = 0;
r.x+=(bayerPeriod/2)*(colorComp &1);
r.y+=(bayerPeriod/2)*((colorComp>>1) &1);
}
if (debugLevel>2) System.out.println(">>> r.width="+r.width+
" r.height="+r.height+
" r.x="+r.x+
" r.y="+r.y+
" colorComp="+colorComp);
for (index=0;index<result.length;index++){
int iy=r.y+(index / r.width);
int ix=r.x+(index % r.width);
if (iy<0) iy=0;
else if (iy>=full_height) iy=full_height-1;
if (ix<0) ix=0;
else if (ix>=full_width) iy=full_width-1;
result[index]=spixels[0][iy*full_width+ix];
int iy = r.y + (index / r.width);
int ix = r.x + (index % r.width);
if (iy < 0) iy = 0;
else if (iy >= full_height) iy = full_height - 1;
if (ix < 0) ix = 0;
else if (ix >= full_width) iy = full_width - 1;
result[index] = pattern_sign * spixels[ser][iy * full_width + ix];
}
}
return result;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.