Commit 737075f8 authored by Andrey Filippov's avatar Andrey Filippov

added source image padding to match WOI in properties, making kernel

generation with large-cell calibration pattern
parent 9d5dd318
...@@ -5949,6 +5949,16 @@ if (MORE_BUTTONS) { ...@@ -5949,6 +5949,16 @@ if (MORE_BUTTONS) {
IJ.showMessage("LENS_DISTORTION.fittingStrategy is not set"); IJ.showMessage("LENS_DISTORTION.fittingStrategy is not set");
return; return;
} }
DistortionCalibrationData dcd = LENS_DISTORTIONS.getDistortionCalibrationData();
if (dcd == null) {
dcd = DISTORTION_CALIBRATION_DATA;
}
if (dcd == null) {
System.out.println("dcd is null");
return;
}
GenericDialog gd=new GenericDialog ("Parameters of the filter by predicted grid"); GenericDialog gd=new GenericDialog ("Parameters of the filter by predicted grid");
gd.addNumericField("Mismatch tolerance of match between the predicted and acquired grid", 0.5, 1,4,"fraction of grid half-period"); gd.addNumericField("Mismatch tolerance of match between the predicted and acquired grid", 0.5, 1,4,"fraction of grid half-period");
gd.addCheckbox ("Calibrate by translation (false - orientation only)", true); gd.addCheckbox ("Calibrate by translation (false - orientation only)", true);
...@@ -5957,6 +5967,8 @@ if (MORE_BUTTONS) { ...@@ -5957,6 +5967,8 @@ if (MORE_BUTTONS) {
gd.addCheckbox ("Process images with estimated orientation and no matched laser pointers", false); gd.addCheckbox ("Process images with estimated orientation and no matched laser pointers", false);
gd.addCheckbox ("Use image sets data if available (false - use camera data)", true); gd.addCheckbox ("Use image sets data if available (false - use camera data)", true);
gd.addNumericField("Process only one specified image (<0 - all)", -1, 0); gd.addNumericField("Process only one specified image (<0 - all)", -1, 0);
gd.addNumericField("Start image set", 0, 0);
gd.addNumericField("End image set", dcd.getNumSets()-1, 0);
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return; if (gd.wasCanceled()) return;
...@@ -5967,6 +5979,8 @@ if (MORE_BUTTONS) { ...@@ -5967,6 +5979,8 @@ if (MORE_BUTTONS) {
boolean processBlind= gd.getNextBoolean(); boolean processBlind= gd.getNextBoolean();
boolean useSetsData= gd.getNextBoolean(); boolean useSetsData= gd.getNextBoolean();
int imageNumber= (int) gd.getNextNumber(); int imageNumber= (int) gd.getNextNumber();
int start_set= (int) gd.getNextNumber();
int end_set= (int) gd.getNextNumber();
if (imageNumber>=0) processAll=true; // no additional filtering if (imageNumber>=0) processAll=true; // no additional filtering
int numMatched=LENS_DISTORTIONS.applyHintedGrids( int numMatched=LENS_DISTORTIONS.applyHintedGrids(
...@@ -5977,6 +5991,8 @@ if (MORE_BUTTONS) { ...@@ -5977,6 +5991,8 @@ if (MORE_BUTTONS) {
ignoreLaserPointers, ignoreLaserPointers,
processBlind, processBlind,
imageNumber, imageNumber,
start_set,
end_set,
useSetsData, useSetsData,
THREADS_MAX, //int threadsMax, THREADS_MAX, //int threadsMax,
UPDATE_STATUS, // boolean updateStatus, UPDATE_STATUS, // boolean updateStatus,
...@@ -1718,12 +1718,12 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -1718,12 +1718,12 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
Arrays.fill(numMatchedPointersEnabledPerStation[n], 0); Arrays.fill(numMatchedPointersEnabledPerStation[n], 0);
} }
int [] numHintedMatch= new int [matchedPointersIndex.length]; int [] numHintedMatch= new int [hintedMatchIndex.length];
int [] numHintedMatchSelected=new int [matchedPointersIndex.length]; int [] numHintedMatchSelected=new int [hintedMatchIndex.length];
int [] numHintedMatchEnabled= new int [matchedPointersIndex.length]; int [] numHintedMatchEnabled= new int [hintedMatchIndex.length];
int [][] numHintedMatchPerStation= new int [matchedPointersIndex.length][]; int [][] numHintedMatchPerStation= new int [hintedMatchIndex.length][];
int [][] numHintedMatchSelectedPerStation=new int [matchedPointersIndex.length][]; int [][] numHintedMatchSelectedPerStation=new int [hintedMatchIndex.length][];
int [][] numHintedMatchEnabledPerStation= new int [matchedPointersIndex.length][]; int [][] numHintedMatchEnabledPerStation= new int [hintedMatchIndex.length][];
for (int n=0;n<numHintedMatch.length;n++){ for (int n=0;n<numHintedMatch.length;n++){
numHintedMatch[n]=0; numHintedMatch[n]=0;
numHintedMatchSelected[n]=0; numHintedMatchSelected[n]=0;
...@@ -1771,9 +1771,12 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -1771,9 +1771,12 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
} }
numMatchedPointersEnabledPerStation[mpi][imageStations[i]]++; numMatchedPointersEnabledPerStation[mpi][imageStations[i]]++;
numMatchedPointersEnabled[mpi]++; numMatchedPointersEnabled[mpi]++;
if (hmi>=numHintedMatchEnabledPerStation.length) {
numHintedMatchEnabledPerStation[hmi][imageStations[i]]++; System.out.println("*** Bug: hmi>=numHintedMatchEnabledPerStation.length");
numHintedMatchEnabled[hmi]++; } else {
numHintedMatchEnabledPerStation[hmi][imageStations[i]]++;
numHintedMatchEnabled[hmi]++;
}
} }
...@@ -2013,6 +2016,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2013,6 +2016,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
return; return;
} }
int numSubCams=this.distortionCalibrationData.getNumSubCameras();
int [] choice_offsets = new int [this.parameterEnable.length]; int [] choice_offsets = new int [this.parameterEnable.length];
// //
String header="Strategy #\tType"; String header="Strategy #\tType";
...@@ -2061,12 +2065,14 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2061,12 +2065,14 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
int subMaxNum = -1; int subMaxNum = -1;
if (this.distortionCalibrationData.isSubcameraParameter(parIndex)) { // only for subcamera parameters if (this.distortionCalibrationData.isSubcameraParameter(parIndex)) { // only for subcamera parameters
if (zeroAndOther) { if (zeroAndOther) {
subMaxNum = this.distortionCalibrationData.firstInGroup(subCam)?-1:0; //this.distortionCalibrationData.getSubGroup(subCam); // subMaxNum = this.distortionCalibrationData.firstInGroup(subCam)?-1:0; //this.distortionCalibrationData.getSubGroup(subCam);
subMaxNum = (this.distortionCalibrationData.sourceToCopy(subCam) < 0)?-1:0; //this.distortionCalibrationData.getSubGroup(subCam);
} else { } else {
subMaxNum = subCam-1; // 0 will be -1 - this may be wrong to align to higher index subMaxNum = subCam-1; // 0 will be -1 - this may be wrong to align to higher index
} }
} }
/*=========*/ /*=========*/
String [] commonChoices = (isTilt?this.definedModesTiltEq:(noWeak?this.definedModesNoWeak:this.definedModes)); String [] commonChoices = (isTilt?this.definedModesTiltEq:(noWeak?this.definedModesNoWeak:this.definedModes));
...@@ -2080,24 +2086,33 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2080,24 +2086,33 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
thisChoice = this.definedModesAll[this.parameterMode[numSeries][ipar]]; thisChoice = this.definedModesAll[this.parameterMode[numSeries][ipar]];
} else { // only can happen if (!isTilt) && (noWeak) } else { // only can happen if (!isTilt) && (noWeak)
choice_offsets[ipar] = commonChoices.length; choice_offsets[ipar] = commonChoices.length;
theseChoices = new String [commonChoices.length + subMaxNum + 1]; // theseChoices = new String [commonChoices.length + subMaxNum + 1];
theseChoices = new String [commonChoices.length];
for (int ch = 0; ch < commonChoices.length; ch++) theseChoices[ch] = commonChoices[ch]; for (int ch = 0; ch < commonChoices.length; ch++) theseChoices[ch] = commonChoices[ch];
/*
if (zeroAndOther) { if (zeroAndOther) {
if (subMaxNum >=0) { // can only be 0 if (subMaxNum >=0) { // can only be 0
theseChoices[commonChoices.length] = "same as "+this.distortionCalibrationData.masterSub(subCam); // theseChoices[commonChoices.length] = "same as "+this.distortionCalibrationData.masterSub(subCam);
// TODO: Make human-readable channel name?
theseChoices[commonChoices.length] = "same as "+this.distortionCalibrationData.sourceToCopy(subCam);
} }
} else { } else {
for (int ch = 0; ch <= subMaxNum; ch++) { for (int ch = 0; ch <= subMaxNum; ch++) {
theseChoices[ch + commonChoices.length] = "same as "+ch; theseChoices[ch + commonChoices.length] = "same as "+ch;
} }
} }
*/
// choice index for "same as ..." starts with this.definedModesAll.length, but in the listbox index is lower // choice index for "same as ..." starts with this.definedModesAll.length, but in the listbox index is lower
int indx = this.parameterMode[numSeries][ipar]; int indx = this.parameterMode[numSeries][ipar];
if (indx >= this.definedModesAll.length) { if (indx >= this.definedModesAll.length) {
indx -= (this.definedModesAll.length - choice_offsets[ipar]); indx -= (this.definedModesAll.length - choice_offsets[ipar]);
} }
thisChoice = theseChoices[indx]; if (indx < theseChoices.length) {
thisChoice = theseChoices[indx];
} else {
thisChoice = "same as "+ (indx - theseChoices.length);
}
// System.out.println("selectStrategyStep(): this.parameterMode["+numSeries+"]["+ipar+"]=" + this.parameterMode[numSeries][ipar]+" indx = "+indx); // System.out.println("selectStrategyStep(): this.parameterMode["+numSeries+"]["+ipar+"]=" + this.parameterMode[numSeries][ipar]+" indx = "+indx);
} }
if (thisChoice.equals("fixed")) thisChoice = "-"; if (thisChoice.equals("fixed")) thisChoice = "-";
...@@ -2278,7 +2293,8 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2278,7 +2293,8 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
int subMaxNum = -1; int subMaxNum = -1;
if (this.distortionCalibrationData.isSubcameraParameter(parIndex)) { // only for subcamera parameters if (this.distortionCalibrationData.isSubcameraParameter(parIndex)) { // only for subcamera parameters
if (zeroAndOther) { if (zeroAndOther) {
subMaxNum = this.distortionCalibrationData.firstInGroup(subCam)?-1:0; //this.distortionCalibrationData.getSubGroup(subCam); // subMaxNum = this.distortionCalibrationData.firstInGroup(subCam)?-1:0; //this.distortionCalibrationData.getSubGroup(subCam);
subMaxNum = (this.distortionCalibrationData.sourceToCopy(subCam) < 0)?-1:0; //this.distortionCalibrationData.getSubGroup(subCam);
} else { } else {
subMaxNum = subCam-1; // 0 will be -1 - this may be wrong to align to higher index subMaxNum = subCam-1; // 0 will be -1 - this may be wrong to align to higher index
} }
...@@ -2297,7 +2313,9 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2297,7 +2313,9 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
for (int ch = 0; ch < commonChoices.length; ch++) theseChoices[ch] = commonChoices[ch]; for (int ch = 0; ch < commonChoices.length; ch++) theseChoices[ch] = commonChoices[ch];
if (zeroAndOther) { if (zeroAndOther) {
if (subMaxNum >=0) { if (subMaxNum >=0) {
theseChoices[commonChoices.length] = "same as "+this.distortionCalibrationData.masterSub(subCam); // theseChoices[commonChoices.length] = "same as "+this.distortionCalibrationData.masterSub(subCam);
// TODO: Make human-readable channel name?
theseChoices[commonChoices.length] = "same as "+this.distortionCalibrationData.sourceToCopy(subCam);
} }
} else { } else {
for (int ch = 0; ch <= subMaxNum; ch++) { for (int ch = 0; ch <= subMaxNum; ch++) {
...@@ -2309,6 +2327,12 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2309,6 +2327,12 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
if (indx >= this.definedModesAll.length) { if (indx >= this.definedModesAll.length) {
indx -= (this.definedModesAll.length - choice_offsets[i]); indx -= (this.definedModesAll.length - choice_offsets[i]);
} }
// currently only out of limits can occur with a single choice, so
if (indx >= theseChoices.length) {
indx = theseChoices.length - 1;
}
thisChoice = theseChoices[indx]; thisChoice = theseChoices[indx];
System.out.println("selectStrategyStep(): this.parameterMode["+numSeries+"]["+i+"]=" + this.parameterMode[numSeries][i]+" indx = "+indx); System.out.println("selectStrategyStep(): this.parameterMode["+numSeries+"]["+i+"]=" + this.parameterMode[numSeries][i]+" indx = "+indx);
} }
...@@ -2474,6 +2498,10 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2474,6 +2498,10 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
// make adjustment for "same as (other lower numbered subcamera)" // make adjustment for "same as (other lower numbered subcamera)"
if ((choice_offsets[i] > 0) && (this.parameterMode[numSeries][i] >= choice_offsets[i])){ if ((choice_offsets[i] > 0) && (this.parameterMode[numSeries][i] >= choice_offsets[i])){
if (zeroAndOther) { // add reference channel
int ref_chn = this.distortionCalibrationData.sourceToCopy(this.parameterList[i][0]);
this.parameterMode[numSeries][i] += ref_chn;
}
System.out.print("selectStrategyStep(): choice_offsets["+i+"]="+choice_offsets[i]+ " this.parameterMode["+numSeries+"]["+i+"]=" + this.parameterMode[numSeries][i]); System.out.print("selectStrategyStep(): choice_offsets["+i+"]="+choice_offsets[i]+ " this.parameterMode["+numSeries+"]["+i+"]=" + this.parameterMode[numSeries][i]);
this.parameterMode[numSeries][i] += (this.definedModesAll.length - choice_offsets[i]); this.parameterMode[numSeries][i] += (this.definedModesAll.length - choice_offsets[i]);
System.out.println(", corrected=" + this.parameterMode[numSeries][i]); System.out.println(", corrected=" + this.parameterMode[numSeries][i]);
...@@ -2485,12 +2513,14 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -2485,12 +2513,14 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
selectGroups(numSeries,i); selectGroups(numSeries,i);
} }
} }
if (zeroAndOther){ if (zeroAndOther ){
for (int i =0; i<this.parameterEnable.length;i++) { for (int i =0; i<this.parameterEnable.length;i++) {
// if ((this.parameterList[i][0]>1) && (this.parameterList[i][0]!=24)){ // "other" subchannels - copy from subchannel1 // if ((this.parameterList[i][0]>1) && (this.parameterList[i][0]!=24)){ // "other" subchannels - copy from subchannel1
if (!this.distortionCalibrationData.firstInGroup(this.parameterList[i][0])){ // "other" subchannels - copy from subchannel1 if (!this.distortionCalibrationData.firstInGroup(this.parameterList[i][0])){ // "other" subchannels - copy from subchannel1
/// if (this.distortionCalibrationData.sourceToCopy(this.parameterList[i][0]) >= 0){ // "other" subchannels - copy from subchannel1
// int refChannel=(this.parameterList[i][0]<24)?1:24; // int refChannel=(this.parameterList[i][0]<24)?1:24;
int refChannel= this.distortionCalibrationData.masterSub(this.parameterList[i][0]); int refChannel= this.distortionCalibrationData.masterSub(this.parameterList[i][0]);
/// int refChannel= this.distortionCalibrationData.sourceToCopy(this.parameterList[i][0]);
int iSub1=getParameterNumber(refChannel, this.parameterList[i][1]); int iSub1=getParameterNumber(refChannel, this.parameterList[i][1]);
if (this.parameterEnable[iSub1]){ if (this.parameterEnable[iSub1]){
......
...@@ -6136,7 +6136,7 @@ public class MatchSimulatedPattern { ...@@ -6136,7 +6136,7 @@ public class MatchSimulatedPattern {
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
SimulationPattern.SimulParameters simulParameters, SimulationPattern.SimulParameters simulParameters,
boolean equalizeGreens, boolean equalizeGreens,
ImagePlus imp, // image to process ImagePlus imp, // image to process // has WOI_TOP and possibly - WOI_COMPENSATED
LaserPointer laserPointer, // LaserPointer object or null LaserPointer laserPointer, // LaserPointer object or null
boolean removeOutOfGridPointers, // boolean removeOutOfGridPointers, //
double [][][] hintGrid, // predicted grid array (or null) double [][][] hintGrid, // predicted grid array (or null)
......
...@@ -626,7 +626,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy) ...@@ -626,7 +626,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
float [][] simArray=new float [2][]; float [][] simArray=new float [2][];
simArray[0]=(new SimulationPattern(simulParameters)).combineWithCanvas(0.0, k*width, k*height, scaledWoi,simArray0[0]); 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]); 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; return simArray;
} }
......
...@@ -1325,6 +1325,11 @@ import ij.gui.GenericDialog; ...@@ -1325,6 +1325,11 @@ import ij.gui.GenericDialog;
public int getSensorWidth(int subCam) { return this.eyesisSubCameras[0][subCam].getSensorWidth();} // for the future? different sensors public int getSensorWidth(int subCam) { return this.eyesisSubCameras[0][subCam].getSensorWidth();} // for the future? different sensors
public int getSensorHeight(int subCam) { return this.eyesisSubCameras[0][subCam].getSensorHeight();}// for the future? different sensors public int getSensorHeight(int subCam) { return this.eyesisSubCameras[0][subCam].getSensorHeight();}// for the future? different sensors
public int [] getSensorWidthHeight(int subCam) {
int [] wh = {getSensorWidth( subCam), getSensorHeight( subCam)};
return wh;
}
public int getDecimateMasks(int subCam) { return this.eyesisSubCameras[0][subCam].getDecimateMasks();}// for the future? different sensors public int getDecimateMasks(int subCam) { return this.eyesisSubCameras[0][subCam].getDecimateMasks();}// for the future? different sensors
public void setSensorWidth(int subCam, int v) { public void setSensorWidth(int subCam, int v) {
......
package com.elphel.imagej.common; package com.elphel.imagej.common;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.Map;
import java.util.Properties;
import ij.IJ; import ij.IJ;
import ij.ImagePlus; import ij.ImagePlus;
...@@ -654,5 +656,86 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg ...@@ -654,5 +656,86 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
} }
/**
* Pad acquired Bayer image to the full sensor width/height. Used when optical center pixel coordinates do not match for channels
* and WOI is adjusted during image capture to avoid ERS mismatch between horizontal pairs
* @param imp_src source image with WOI specified as properties (sizes and offsets should be even)
* @param wh {sesnor_width, sensor_height} in pixels
* @param replicate fill gaps by replicating existing pixels
* @return full size image
*/
public static ImagePlus padBayerToFullSize(
ImagePlus imp_src,
int [] wh, // null OK - will use {woi_left+width, woi_top+height}
boolean replicate) {
int woi_top = Integer.parseInt((String) imp_src.getProperty("WOI_TOP")); // enforce even
int woi_left = Integer.parseInt((String) imp_src.getProperty("WOI_LEFT"));
int woi_width = imp_src.getWidth(); // Integer.parseInt((String) imp_src.getProperty("WOI_WIDTH"));
int woi_height = imp_src.getHeight(); // Integer.parseInt((String) imp_src.getProperty("WOI_HEIGHT"));
Properties properties = imp_src.getProperties();
if (wh == null) {
wh = new int [2];
wh[0] = woi_left + woi_width;
wh[1] = woi_top + woi_height;
}
if ((woi_top == 0) && (woi_left == 0) && (woi_width == wh[0]) && (woi_height == wh[1])){
return imp_src; // good as is
}
float [] full_pixels = new float [wh[0]*wh[1]];
float [] pixels=(float []) imp_src.getProcessor().getPixels();
int dst_col = woi_left;
int copy_width = woi_width;
if ((dst_col + copy_width) > wh[0]) {
copy_width = wh[0] - dst_col;
}
for (int src_row = 0; src_row < woi_height; src_row++) {
int dst_row = src_row + woi_top;
if (dst_row < wh[1]) {
System.arraycopy( pixels, src_row * woi_width, full_pixels, dst_row * wh[0] + dst_col, copy_width);
}
}
if (replicate) {
// replicate top
for (int dst_row = 0; dst_row < woi_top; dst_row++) {
int src_row = woi_top + (dst_row & 1);
System.arraycopy( full_pixels, src_row * wh[0] + dst_col, full_pixels, dst_row * wh[0] + dst_col, copy_width);
}
// replicate bottom
for (int dst_row = woi_top + woi_height; dst_row < wh[1]; dst_row++) {
int src_row = woi_top + woi_height - 2 + (dst_row & 1);
System.arraycopy( full_pixels, src_row * wh[0] + dst_col, full_pixels, dst_row * wh[0] + dst_col, copy_width);
}
// right and left are not likely, as there is no need to use them - horizontal mismatch does not influence ERS
for (int col = 0; col < woi_left; col++) {
for (int row = 0; row < wh[1]; row++) {
full_pixels[row*wh[0] + col] = full_pixels[row*wh[0] + woi_left + (col & 1)];
}
}
for (int col = woi_left + woi_width; col < wh[0]; col++) {
for (int row = 0; row < wh[1]; row++) {
full_pixels[row*wh[0] + col] = full_pixels[row*wh[0] + woi_left + woi_width - 2 +(col & 1)];
}
}
}
ImageProcessor ip = new FloatProcessor(wh[0],wh[1]);
ip.setPixels(full_pixels);
ip.resetMinAndMax(); // is it needed here?
ImagePlus imp = new ImagePlus(imp_src.getTitle(),ip); // OK to have the same name?
for (Map.Entry<?, ?> entry: properties.entrySet()) {
String key = (String) entry.getKey();
String value = (String) entry.getValue();
imp.setProperty(key, value);
}
imp.setProperty("WOI_WIDTH", wh[0]+"");
imp.setProperty("WOI_HEIGHTH", wh[1]+"");
imp.setProperty("WOI_TOP", "0");
imp.setProperty("WOI_LEFT", "0");
return imp;
}
} }
...@@ -619,6 +619,7 @@ private Panel panel1, ...@@ -619,6 +619,7 @@ private Panel panel1,
addButton("CLT reset 3D", panelClt2, color_stop); addButton("CLT reset 3D", panelClt2, color_stop);
addButton("MAIN extrinsics", panelClt2, color_process); addButton("MAIN extrinsics", panelClt2, color_process);
addButton("CLT Poly corr", panelClt2, color_process); addButton("CLT Poly corr", panelClt2, color_process);
addButton("DRY RUN", panelClt2, color_configure);
addButton("CLT 3D", panelClt2, color_process); addButton("CLT 3D", panelClt2, color_process);
addButton("CLT planes", panelClt2, color_conf_process); addButton("CLT planes", panelClt2, color_conf_process);
addButton("CLT ASSIGN", panelClt2, color_process); addButton("CLT ASSIGN", panelClt2, color_process);
...@@ -4407,14 +4408,16 @@ private Panel panel1, ...@@ -4407,14 +4408,16 @@ private Panel panel1,
/// ============================================ /// ============================================
} else if (label.equals("CLT 3D") || label.equals("MAIN extrinsics") || label.equals("CLT Poly corr")) { } else if (label.equals("CLT 3D") || label.equals("MAIN extrinsics") || label.equals("CLT Poly corr") || label.equals("DRY RUN")) {
boolean adjust_extrinsics = label.equals("MAIN extrinsics") || label.equals("CLT Poly corr"); boolean adjust_extrinsics = label.equals("MAIN extrinsics") || label.equals("CLT Poly corr");
boolean adjust_poly = label.equals("CLT Poly corr"); boolean adjust_poly = label.equals("CLT Poly corr");
boolean dry_run = label.equals("DRY RUN");// init kernel/geometry only
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
clt3d(adjust_extrinsics, adjust_poly); clt3d(adjust_extrinsics, adjust_poly, dry_run);
return; return;
} else if (label.equals("AUX extrinsics") || label.equals("AUX Poly corr")) { } else if (label.equals("AUX extrinsics") || label.equals("AUX Poly corr")) {
boolean adjust_extrinsics = label.equals("AUX extrinsics") || label.equals("AUX Poly corr"); boolean adjust_extrinsics = label.equals("AUX extrinsics") || label.equals("AUX Poly corr");
...@@ -5562,7 +5565,8 @@ private Panel panel1, ...@@ -5562,7 +5565,8 @@ private Panel panel1,
public boolean clt3d( public boolean clt3d(
boolean adjust_extrinsics, boolean adjust_extrinsics,
boolean adjust_poly boolean adjust_poly,
boolean dry_run // init kernel/geometry only
) { ) {
if (QUAD_CLT == null){ if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT ( QUAD_CLT = new QuadCLT (
...@@ -5607,7 +5611,9 @@ private Panel panel1, ...@@ -5607,7 +5611,9 @@ private Panel panel1,
return false; return false;
} }
} }
if (dry_run) {
return true;
}
QUAD_CLT.processCLTQuads3d( QUAD_CLT.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics, adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly, adjust_poly, // boolean adjust_poly,
...@@ -5639,7 +5645,9 @@ private Panel panel1, ...@@ -5639,7 +5645,9 @@ private Panel panel1,
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) { if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) {
boolean OK = clt3d( boolean OK = clt3d(
false, // boolean adjust_extrinsics, false, // boolean adjust_extrinsics,
false); // boolean adjust_poly); false, // boolean adjust_poly);
false); // boolean dry_run // init kernel/geometry only
if (! OK) { if (! OK) {
String msg = "DSI data is not available and \"CLT 3D\" failed"; String msg = "DSI data is not available and \"CLT 3D\" failed";
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
...@@ -5680,7 +5688,8 @@ private Panel panel1, ...@@ -5680,7 +5688,8 @@ private Panel panel1,
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) { if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) {
boolean OK = clt3d( boolean OK = clt3d(
false, // boolean adjust_extrinsics, false, // boolean adjust_extrinsics,
false); // boolean adjust_poly); false, // boolean adjust_poly);
false); // boolean dry_run // init kernel/geometry only
if (! OK) { if (! OK) {
String msg = "DSI data is not available and \"CLT 3D\" failed"; String msg = "DSI data is not available and \"CLT 3D\" failed";
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
......
...@@ -1810,12 +1810,32 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1810,12 +1810,32 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
System.out.println("heading =\t"+ heading+"\tdegrees"); System.out.println("heading =\t"+ heading+"\tdegrees");
System.out.println("numSensors =\t"+ numSensors); System.out.println("numSensors =\t"+ numSensors);
System.out.println("'=== Individual input parameters ==="); System.out.println("'=== Individual input parameters ===");
System.out.print ("forward = ");for (int i = 0; i < numSensors;i++) System.out.print("\t"+forward[i]); System.out.println("\tmm");
System.out.print ("right = "); for (int i = 0; i < numSensors;i++) System.out.print("\t"+right[i]); System.out.println("\tmm"); System.out.print ("forward = ");
System.out.print ("height = "); for (int i = 0; i < numSensors;i++) System.out.print("\t"+height[i]); System.out.println("\tmm"); if (forward != null) {
System.out.print ("roll = "); for (int i = 0; i < numSensors;i++) System.out.print("\t"+roll[i]); System.out.println("\tdegrees"); for (int i = 0; i < numSensors;i++) System.out.print("\t"+forward[i]); System.out.println("\tmm");
System.out.print ("px0 = "); for (int i = 0; i < numSensors;i++) System.out.print("\t"+pXY0[i][0]); System.out.println("\tpix"); } else System.out.println("\tnull");
System.out.print ("py0 = "); for (int i = 0; i < numSensors;i++) System.out.print("\t"+pXY0[i][1]); System.out.println("\tpix"); System.out.print ("right = ");
if (right != null) {
for (int i = 0; i < numSensors;i++) System.out.print("\t"+right[i]); System.out.println("\tmm");
} else System.out.println("\tnull");
System.out.print ("height = ");
if (height != null) {
for (int i = 0; i < numSensors;i++) System.out.print("\t"+height[i]); System.out.println("\tmm");
} else System.out.println("\tnull");
System.out.print ("roll = ");
if (roll != null) {
for (int i = 0; i < numSensors;i++) System.out.print("\t"+roll[i]); System.out.println("\tdegrees");
} else System.out.println("\tnull");
System.out.print ("px0 = ");
if (pXY0 != null) {
for (int i = 0; i < numSensors;i++) System.out.print("\t"+pXY0[i][0]); System.out.println("\tpix");
} else System.out.println("\tnull");
System.out.print ("py0 = ");
if (pXY0 != null) {
for (int i = 0; i < numSensors;i++) System.out.print("\t"+pXY0[i][1]); System.out.println("\tpix");
} else System.out.println("\tnull");
System.out.println("'=== Common calculated parameters ==="); System.out.println("'=== Common calculated parameters ===");
System.out.println("common_right =\t"+common_right + "\tmm"); System.out.println("common_right =\t"+common_right + "\tmm");
...@@ -1827,19 +1847,35 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1827,19 +1847,35 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
if (showAll){ if (showAll){
System.out.println("'=== Intermediate data: coordinates corrected for common elevation and heading ==="); System.out.println("'=== Intermediate data: coordinates corrected for common elevation and heading ===");
System.out.print ("X_he ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_he[i][0]); System.out.println("\tmm"); if (XYZ_he != null) {
System.out.print ("Y_he ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_he[i][1]); System.out.println("\tmm"); System.out.print ("X_he ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_he[i][0]); System.out.println("\tmm");
System.out.print ("Z_he ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_he[i][2]); System.out.println("\tmm"); System.out.print ("Y_he ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_he[i][1]); System.out.println("\tmm");
System.out.print ("Z_he ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_he[i][2]); System.out.println("\tmm");
} else {
System.out.println("X_he, Y_he and Z_he are null");
}
System.out.println("'=== Intermediate data: coordinates corrected for common elevation, heading and roll ==="); System.out.println("'=== Intermediate data: coordinates corrected for common elevation, heading and roll ===");
System.out.print ("X_her ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_her[i][0]); System.out.println("\tmm"); if (XYZ_her != null) {
System.out.print ("Y_her ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_her[i][1]); System.out.println("\tmm"); System.out.print ("X_her ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_her[i][0]); System.out.println("\tmm");
System.out.print ("Z_her ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_her[i][2]); System.out.println("\tmm"); System.out.print ("Y_her ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_her[i][1]); System.out.println("\tmm");
System.out.print ("Z_her ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+XYZ_her[i][2]); System.out.println("\tmm");
} else {
System.out.println("X_her, Y_her and Z_her are null");
}
} }
System.out.println("'=== Individual calculated parameters ==="); System.out.println("'=== Individual calculated parameters ===");
System.out.print ("residual_roll = "); for (int i = 0; i < numSensors;i++) System.out.print("\t"+(roll[i]-common_roll));System.out.println("\tdegrees");
System.out.print ("residual_roll = ");
if (roll != null) {
for (int i = 0; i < numSensors;i++) System.out.print("\t"+(roll[i]-common_roll));System.out.println("\tdegrees");
} else System.out.println("\tnull");
if (rXY != null) {
System.out.print ("X_rel ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+rXY[i][0]); System.out.println("\trelative to disparityRadius"); System.out.print ("X_rel ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+rXY[i][0]); System.out.println("\trelative to disparityRadius");
System.out.print ("Y_rel ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+rXY[i][1]); System.out.println("\trelative to disparityRadius"); System.out.print ("Y_rel ="); for (int i = 0; i < numSensors;i++) System.out.print("\t"+rXY[i][1]); System.out.println("\trelative to disparityRadius");
} else {
System.out.println("X_rel and Y_rel are null");
}
} }
// return distance from disparity (in pixel units) for the current camera geometry // return distance from disparity (in pixel units) for the current camera geometry
......
...@@ -35,7 +35,6 @@ import java.nio.file.attribute.PosixFilePermission; ...@@ -35,7 +35,6 @@ import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -59,7 +58,6 @@ import ij.WindowManager; ...@@ -59,7 +58,6 @@ import ij.WindowManager;
//import ij.gui.Overlay; //import ij.gui.Overlay;
import ij.io.FileSaver; import ij.io.FileSaver;
import ij.process.ColorProcessor; import ij.process.ColorProcessor;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor; import ij.process.ImageProcessor;
...@@ -875,12 +873,12 @@ public class QuadCLT { ...@@ -875,12 +873,12 @@ public class QuadCLT {
for (int i=0;i<sharpKernelPaths.length;i++){ for (int i=0;i<sharpKernelPaths.length;i++){
System.out.println(i+":"+sharpKernelPaths[i]); System.out.println(i+":"+sharpKernelPaths[i]);
} }
if (clt_kernels == null){ if (clt_kernels == null){
clt_kernels = new double[eyesisCorrections.usedChannels.length][][][][][]; clt_kernels = new double[eyesisCorrections.usedChannels.length][][][][][];
for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){
clt_kernels[chn] = null; clt_kernels[chn] = null;
} }
} }
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays();
for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){
...@@ -2714,7 +2712,7 @@ public class QuadCLT { ...@@ -2714,7 +2712,7 @@ public class QuadCLT {
eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info
if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]); if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]);
} }
imp_srcs[srcChannel] = padBayerToFullSize( imp_srcs[srcChannel] = ShowDoubleFloatArrays.padBayerToFullSize(
imp_srcs[srcChannel], // ImagePlus imp_src, imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(), eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate); true); // boolean replicate);
...@@ -3279,81 +3277,6 @@ public class QuadCLT { ...@@ -3279,81 +3277,6 @@ public class QuadCLT {
return nf; return nf;
} }
/**
* Pad acquired Bayer image to the full sensor width/height. Used when optical center pixel coordinates do not match for channels
* and WOI is adjusted during image capture to avoid ERS mismatch between horizontal pairs
* @param imp_src source image with WOI specified as properties (sizes and offsets should be even)
* @param wh {sesnor_width, sensor_height} in pixels
* @param replicate fill gaps by replicating existing pixels
* @return full size image
*/
ImagePlus padBayerToFullSize(
ImagePlus imp_src,
int [] wh,
boolean replicate) {
int woi_top = Integer.parseInt((String) imp_src.getProperty("WOI_TOP")); // enforce even
int woi_left = Integer.parseInt((String) imp_src.getProperty("WOI_LEFT"));
int woi_width = imp_src.getWidth(); // Integer.parseInt((String) imp_src.getProperty("WOI_WIDTH"));
int woi_height = imp_src.getHeight(); // Integer.parseInt((String) imp_src.getProperty("WOI_HEIGHT"));
Properties properties = imp_src.getProperties();
if ((woi_top == 0) && (woi_left == 0) && (woi_width == wh[0]) && (woi_height == wh[1])){
return imp_src; // good as is
}
float [] full_pixels = new float [wh[0]*wh[1]];
float [] pixels=(float []) imp_src.getProcessor().getPixels();
int dst_col = woi_left;
int copy_width = woi_width;
if ((dst_col + copy_width) > wh[0]) {
copy_width = wh[0] - dst_col;
}
for (int src_row = 0; src_row < woi_height; src_row++) {
int dst_row = src_row + woi_top;
if (dst_row < wh[1]) {
System.arraycopy( pixels, src_row * woi_width, full_pixels, dst_row * wh[0] + dst_col, copy_width);
}
}
if (replicate) {
// replicate top
for (int dst_row = 0; dst_row < woi_top; dst_row++) {
int src_row = woi_top + (dst_row & 1);
System.arraycopy( full_pixels, src_row * wh[0] + dst_col, full_pixels, dst_row * wh[0] + dst_col, copy_width);
}
// replicate bottom
for (int dst_row = woi_top + woi_height; dst_row < wh[1]; dst_row++) {
int src_row = woi_top + woi_height - 2 + (dst_row & 1);
System.arraycopy( full_pixels, src_row * wh[0] + dst_col, full_pixels, dst_row * wh[0] + dst_col, copy_width);
}
// right and left are not likely, as there is no need to use them - horizontal mismatch does not influence ERS
for (int col = 0; col < woi_left; col++) {
for (int row = 0; row < wh[1]; row++) {
full_pixels[row*wh[0] + col] = full_pixels[row*wh[0] + woi_left + (col & 1)];
}
}
for (int col = woi_left + woi_width; col < wh[0]; col++) {
for (int row = 0; row < wh[1]; row++) {
full_pixels[row*wh[0] + col] = full_pixels[row*wh[0] + woi_left + woi_width - 2 +(col & 1)];
}
}
}
ImageProcessor ip = new FloatProcessor(wh[0],wh[1]);
ip.setPixels(full_pixels);
ip.resetMinAndMax(); // is it needed here?
ImagePlus imp = new ImagePlus(imp_src.getTitle(),ip); // OK to have the same name?
for (Map.Entry<?, ?> entry: properties.entrySet()) {
String key = (String) entry.getKey();
String value = (String) entry.getValue();
imp.setProperty(key, value);
}
imp.setProperty("WOI_WIDTH", wh[0]+"");
imp.setProperty("WOI_HEIGHTH", wh[1]+"");
imp.setProperty("WOI_TOP", "0");
imp.setProperty("WOI_LEFT", "0");
return imp;
}
/** /**
* Conditions images for a single image set * Conditions images for a single image set
...@@ -3417,7 +3340,7 @@ public class QuadCLT { ...@@ -3417,7 +3340,7 @@ public class QuadCLT {
// imp_srcs[srcChannel].show(); // REMOVE ME! // imp_srcs[srcChannel].show(); // REMOVE ME!
this.geometryCorrection.woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP")); this.geometryCorrection.woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
imp_srcs[srcChannel] = padBayerToFullSize( imp_srcs[srcChannel] = ShowDoubleFloatArrays.padBayerToFullSize(
imp_srcs[srcChannel], // ImagePlus imp_src, imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(), eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate); true); // boolean replicate);
...@@ -5006,7 +4929,7 @@ public class QuadCLT { ...@@ -5006,7 +4929,7 @@ public class QuadCLT {
eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info
if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]); if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]);
} }
imp_srcs[srcChannel] = padBayerToFullSize( imp_srcs[srcChannel] = ShowDoubleFloatArrays.padBayerToFullSize(
imp_srcs[srcChannel], // ImagePlus imp_src, imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(), eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate); true); // boolean replicate);
...@@ -8907,7 +8830,7 @@ public class QuadCLT { ...@@ -8907,7 +8830,7 @@ public class QuadCLT {
eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_srcs[srcChannel]); // decode existent properties from info
if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]); if (debugLevel>0) System.out.println("Processing "+sourceFiles[nFile]);
} }
imp_srcs[srcChannel] = padBayerToFullSize( imp_srcs[srcChannel] = ShowDoubleFloatArrays.padBayerToFullSize(
imp_srcs[srcChannel], // ImagePlus imp_src, imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(), eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate); true); // boolean replicate);
......
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