Commit 9c63f90b authored by Andrey Filippov's avatar Andrey Filippov

Merge branch 'lwir-distort' of git.elphel.com:Elphel/imagej-elphel into lwir-distort

parents 7f44490f 3b485572
......@@ -96,6 +96,7 @@ import ij.text.TextWindow;
return (eyesisCameraParameters==null)?0:eyesisCameraParameters.getNumStations();
}
public double getPixelSize(int station, int channel) {
return this.eyesisCameraParameters.eyesisSubCameras[station][channel].getPixelSize();
}
......
......@@ -1248,10 +1248,16 @@ public class EyesisAberrations {
if (debugLevel>0) System.out.println("Processing file #"+(imgNum+1)+ " ( of "+files.length+") :"+files[imgNum][0]);
ImagePlus imp=new ImagePlus(files[imgNum][0]); // read source file
JP4_INSTANCE.decodeProperiesFromInfo(imp);
boolean is_lwir = lwirReaderParameters.is_LWIR(imp);
int fft_size = is_lwir ? distortionParameters.FFTSize_lwir : distortionParameters.FFTSize;
int fft_overlap = is_lwir ? distortionParameters.FFTOverlap_lwir : distortionParameters.FFTOverlap;
imp.setProperty("MONOCHROME",""+is_lwir);
// boolean is_lwir = lwirReaderParameters.is_LWIR(imp);
int sensor_type = LwirReaderParameters.sensorType(imp);
// int fft_size = is_lwir ? distortionParameters.FFTSize_lwir : distortionParameters.FFTSize;
// int fft_overlap = is_lwir ? distortionParameters.FFTOverlap_lwir : distortionParameters.FFTOverlap;
int fft_size = distortionParameters.getFFTSize(sensor_type);
int fft_overlap = distortionParameters.getFFTOverlap(sensor_type);
imp.setProperty("MONOCHROME",""+(sensor_type == 1));
// pad image to full sensor size
int numGridImage=fileIndices[imgNum];
int chn = distortions.fittingStrategy.distortionCalibrationData.gIP[numGridImage].getChannel();
......@@ -1261,7 +1267,8 @@ public class EyesisAberrations {
sensor_width_height, // eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate);
// TODO: Add vignetting correction ?
MatchSimulatedPattern matchSimulatedPattern= new MatchSimulatedPattern(distortionParameters.FFTSize);
// MatchSimulatedPattern matchSimulatedPattern= new MatchSimulatedPattern(distortionParameters.FFTSize);
MatchSimulatedPattern matchSimulatedPattern= new MatchSimulatedPattern(distortionParameters.getFFTSize(sensor_type));
boolean [] correlationSizesUsed=null;
float [][] simArray= null;
......@@ -1348,7 +1355,7 @@ public class EyesisAberrations {
fft_size, // FFT_SIZE, // int fft_size,
colorComponents, //COMPONENTS, // ColorComponents colorComponents,
PSF_subpixel, //PSF_SUBPIXEL, // int PSF_subpixel,
(is_lwir?otfFilterParameters_lwir:otfFilterParameters),
((sensor_type == 1) ?otfFilterParameters_lwir:otfFilterParameters),
// otfFilterParameters, // OTF_FILTER, // OTFFilterParameters otfFilterParameters,
psfParameters, //PSF_PARS, // final PSFParameters psfParameters
psfParameters.minDefinedArea , //PSF_PARS.minDefinedArea, // final double minDefinedArea,
......
......@@ -632,6 +632,9 @@ horizontal axis:
int nImg=indices[index];
int subCam= distortionCalibrationData.getImageChannel(images[nImg]);
int sensor_type = eyesisCameraParameters.getSensorType(subCam);
// int stationNumber= distortionCalibrationData.getImageStation(numGridImage), // station number
double timeStamp= distortionCalibrationData.getImageTimestamp(images[nImg]);
......@@ -673,7 +676,9 @@ horizontal axis:
if (this.debugLevel>1) lensDistortions.showHintGrid(hintGrid);
MatchSimulatedPattern matchSimulatedPattern = new MatchSimulatedPattern(this.distortionParametersDefault.FFTSize); // new instance, all reset
/// MatchSimulatedPattern matchSimulatedPattern = new MatchSimulatedPattern(this.distortionParametersDefault.FFTSize); // new instance, all reset
MatchSimulatedPattern matchSimulatedPattern = new MatchSimulatedPattern(distortionParametersDefault.getFFTSize(sensor_type)); // new instance, all reset
//sensort_type
// next 2 lines are not needed for the new instance, but can be
// used alternatively if keeping it
matchSimulatedPattern.invalidateFlatFieldForGrid(); // Reset Flat Filed calibration - different image.
......@@ -690,7 +695,7 @@ horizontal axis:
", initial number of pointers was "+numPointers);
}
//matchSimulatedPatterns[numSensor].getChannel(images[numSensor])+" ");
MatchSimulatedPattern.DistortionParameters distortionParameters = modifyDistortionParameters();
MatchSimulatedPattern.DistortionParameters distortionParameters = modifyDistortionParameters(sensor_type);
SimulationPattern.SimulParameters simulParameters = modifySimulParameters();
boolean noMessageBoxes=true;
......@@ -729,34 +734,13 @@ horizontal axis:
}
/*
* private showDoubleFloatArrays SDFA_INSTANCE= new showDoubleFloatArrays(); // just for debugging?
this.SDFA_INSTANCE.showArrays(gridXYZCorr, getGridWidth(), getGridHeight(), true, "Grid corrections", titles);
*
gd.addChoice( // ArrayIndexOutOfBoundsException: 21
this.distortionCalibrationData.getParameterName(parIndex)+
" ("+sValue+" "+
this.distortionCalibrationData.getParameterUnits(parIndex)+")"+
(this.distortionCalibrationData.isSubcameraParameter(parIndex)?(" s"+subCam):"com "),
this.definedModes, this.definedModes[this.parameterMode[numSeries][i]]);
*
* this.parameterMode[numSeries][i]=gd.getNextChoiceIndex();
PatternParameters patternParameters, // should not be null
boolean equalizeGreens,
int threadsMax,
boolean updateStatus,
int debug_level) {// debug level used inside loops
*
*
*/
public MatchSimulatedPattern.DistortionParameters modifyDistortionParameters(){
public MatchSimulatedPattern.DistortionParameters modifyDistortionParameters(int sensor_type){
MatchSimulatedPattern.DistortionParameters distortionParameters = this.distortionParametersDefault.clone();
distortionParameters.refineInPlace = false;
distortionParameters.correlationMaxOffset = this.goniometerParameters.maxCorr;
distortionParameters.correlationSize = this.goniometerParameters.correlationSize;
// distortionParameters.correlationSize = this.goniometerParameters.correlationSize;
distortionParameters.setCorrelationSize(this.goniometerParameters.correlationSize, sensor_type);
distortionParameters.correlationGaussWidth = this.goniometerParameters.correlationGaussWidth;
distortionParameters.refineCorrelations = false;
distortionParameters.fastCorrelationOnFirstPass = true;
......@@ -767,7 +751,8 @@ horizontal axis:
distortionParameters.flatFieldExpand = this.goniometerParameters.flatFieldExpand;
distortionParameters.numberExtrapolated = 1; // measuring distortions -
distortionParameters.correlationMinInitialContrast=this.goniometerParameters.correlationMinInitialContrast;
distortionParameters.minimalPatternCluster=this.goniometerParameters.minimalPatternCluster;
// distortionParameters.minimalPatternCluster=this.goniometerParameters.minimalPatternCluster;
distortionParameters.setMinimalPatternCluster(this.goniometerParameters.minimalPatternCluster, sensor_type);
distortionParameters.scaleMinimalInitialContrast=this.goniometerParameters.scaleMinimalInitialContrast;
distortionParameters.searchOverlap=this.goniometerParameters.searchOverlap;
return distortionParameters;
......@@ -781,7 +766,7 @@ horizontal axis:
return simulParameters;
}
public double[] estimateOrientation(
public double[] estimateOrientation( // FIXME: Does not use LWIR parameters, assumes EO!
ImagePlus[] images, // last acquire images with number of pointers
// detected>0
DistortionCalibrationData distortionCalibrationData,
......@@ -792,6 +777,7 @@ horizontal axis:
int threadsMax,
boolean updateStatus,
int debug_level) {// debug level used inside loops
int sensor_type = 0; // EO
long startTime = System.nanoTime();
if (lensDistortions == null) {
String msg = "lensDistortions is not initialized";
......@@ -801,7 +787,7 @@ horizontal axis:
// remove unneeded, copied from updateFocusGrid() Now it is not needed?
SimulationPattern.SimulParameters simulParameters = modifySimulParameters();
MatchSimulatedPattern.DistortionParameters distortionParameters = modifyDistortionParameters();
MatchSimulatedPattern.DistortionParameters distortionParameters = modifyDistortionParameters(sensor_type);
int numImages = 0;
for (int i = 0; i < images.length; i++)
......@@ -834,8 +820,8 @@ horizontal axis:
for (int numSensor = 0; numSensor < images.length; numSensor++)
if (images[numSensor] != null) {
// reset matchSimulatedPattern, so it will start from scratch
this.matchSimulatedPatterns[numSensor] = new MatchSimulatedPattern(
this.distortionParametersDefault.FFTSize); // new instance, all reset
// this.matchSimulatedPatterns[numSensor] = new MatchSimulatedPattern( this.distortionParametersDefault.FFTSize); // new instance, all reset
this.matchSimulatedPatterns[numSensor] = new MatchSimulatedPattern(distortionParametersDefault.getFFTSize(sensor_type)); // new instance, all reset
// next 2 lines are not needed for the new instance, but can be
// used alternatively if keeping it
this.matchSimulatedPatterns[numSensor].invalidateFlatFieldForGrid(); // Reset Flat Filed calibration - different image.
......
......@@ -63,8 +63,9 @@ public class LensAdjustment {
distortionParameters.refineInPlace=false;
distortionParameters.correlationMaxOffset=focusMeasurementParameters.maxCorr;
distortionParameters.correlationSize=focusMeasurementParameters.correlationSize;
int sensor_type = 0; // EO
// distortionParameters.correlationSize=focusMeasurementParameters.correlationSize;
distortionParameters.setCorrelationSize(focusMeasurementParameters.correlationSize,sensor_type);
distortionParameters.correlationGaussWidth=focusMeasurementParameters.correlationGaussWidth;
distortionParameters.refineCorrelations=false;
distortionParameters.fastCorrelationOnFirstPass=true;
......
......@@ -1407,6 +1407,10 @@ import ij.gui.GenericDialog;
return eyesisSubCameras[0][ncam].isLWIR();
}
public int getSensorType(int ncam) {
return eyesisSubCameras[0][ncam].isLWIR()? 1 : 0;
}
/**
* Setting default camera geometry parameters for LWIR16 prototype system
* @return false if number of cameras is not 20
......
......@@ -44,6 +44,7 @@ public class LwirReaderParameters {
public final static int [] FFC_GROUPS= {1,2,4};
public static final String [] SENSOR_TYPES = {"EO","LWIR"};
public static final String SENSOR_TYPE = "SENSOR_TYPE";
protected static int MAX_LWIR_WIDTH = 1024; //
private boolean parameters_updated = false;
protected String camera_name = "Talon"; // "LWIR16";
......@@ -73,7 +74,6 @@ public class LwirReaderParameters {
protected double eo_gain_rg = 0.7705; // 1.116; halogen/fluorescent
protected double eo_gain_bg = 2.401; // 1.476;
protected boolean [] selected_channels = {true, true, true, true, true, true, true, true};
protected int max_lwir_width = 1024; //
/*
protected double [] eo_exp_corr = {1.0, 1.0, 1.0, 1.0};
protected double [] eo_gcorr_rbgb = {
......@@ -145,11 +145,11 @@ public class LwirReaderParameters {
return 20;
}
public boolean is_LWIR(int width) {
return width <= max_lwir_width;
public static boolean is_LWIR(int width) {
return width <= MAX_LWIR_WIDTH;
}
public boolean is_LWIR(ImagePlus imp){
public static boolean is_LWIR(ImagePlus imp){
// See if image has LwirReaderParameters.SENSOR_TYPE property, then use is_LWIR(String property_value),
// if not - use old width property
if (imp.getProperty("WOI_WIDTH")==null) {
......@@ -160,6 +160,16 @@ public class LwirReaderParameters {
}
return is_LWIR(imp.getWidth());
}
public static int sensorType(ImagePlus imp) {
if (imp.getProperty("WOI_WIDTH")==null) {
EyesisTiff.decodeProperiesFromInfo(imp);
}
if (imp.getProperty(SENSOR_TYPE)!=null) {
return (is_LWIR((String) imp.getProperty(SENSOR_TYPE)))? 1:0;
}
return is_LWIR(imp.getWidth())? 1 : 0;
}
public int getDebugLevel() {
return this.debug_level;
......
......@@ -51,6 +51,22 @@ public class ImagejJp4TiffMulti {
final boolean scale,
final String std) throws IOException, FormatException // std - include non-elphel properties with prefix std
{
return getMultiImages(
urls,
imps,
0.0, // final double timeout_sec,
scale,
std);
}
public ImagePlus [] getMultiImages(
final String [] urls,
final ImagePlus [] imps,
final double timeout_sec,
final boolean scale,
final String std) throws IOException, FormatException // std - include non-elphel properties with prefix std
{
// final ImagePlus [] imps = new ImagePlus [urls.length];
LOGGER.error("Please ignore 'File has length 0 and may be corrupt' - caused by bioformat reading memory file");
final Thread[] threads = newThreadArray(MAX_THREADS);
......
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