Commit 10143f8f authored by Andrey Filippov's avatar Andrey Filippov

committing w/o breaking - 6

parent 069dd00f
...@@ -9163,9 +9163,10 @@ if (MORE_BUTTONS) { ...@@ -9163,9 +9163,10 @@ if (MORE_BUTTONS) {
EYESIS_ABERRATIONS.createPartialKernels( EYESIS_ABERRATIONS.createPartialKernels(
this.SYNC_COMMAND.stopRequested, this.SYNC_COMMAND.stopRequested,
MAP_FFT_SIZE, // scanImageForPatterns:FFT size //int mapFFTsize, // scanImageForPatterns:FFT size LWIR_PARAMETERS,
FFT_OVERLAP, ////int fft_overlap, // MAP_FFT_SIZE, // scanImageForPatterns:FFT size //int mapFFTsize, // scanImageForPatterns:FFT size
FFT_SIZE, //int fft_size, // FFT_OVERLAP, ////int fft_overlap,
// FFT_SIZE, //int fft_size,
PSF_SUBPIXEL, // //int PSF_subpixel, PSF_SUBPIXEL, // //int PSF_subpixel,
OTF_FILTER, // //OTFFilterParameters otfFilterParameters, OTF_FILTER, // //OTFFilterParameters otfFilterParameters,
PSF_PARS, //PSFParameters psfParameters, PSF_PARS, //PSFParameters psfParameters,
...@@ -14,6 +14,7 @@ import com.elphel.imagej.common.DoubleGaussianBlur; ...@@ -14,6 +14,7 @@ import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools; import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.jp4.JP46_Reader_camera; import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.LwirReaderParameters;
import ij.IJ; import ij.IJ;
import ij.ImagePlus; import ij.ImagePlus;
...@@ -1056,15 +1057,12 @@ public class EyesisAberrations { ...@@ -1056,15 +1057,12 @@ public class EyesisAberrations {
} }
return fileList; return fileList;
} }
/*
int numChannels=this.fittingStrategy.distortionCalibrationData.getNumChannels(); // number of used channels
*/
public boolean createPartialKernels( public boolean createPartialKernels(
AtomicInteger stopRequested, // 1 - stop now, 2 - when convenient AtomicInteger stopRequested, // 1 - stop now, 2 - when convenient
int mapFFTsize, // scanImageForPatterns:FFT size LwirReaderParameters lwirReaderParameters, // null is OK
int fft_overlap, // int fft_overlap,
int fft_size, // int fft_size,
int PSF_subpixel, int PSF_subpixel,
OTFFilterParameters otfFilterParameters, OTFFilterParameters otfFilterParameters,
PSFParameters psfParameters, PSFParameters psfParameters,
...@@ -1245,6 +1243,10 @@ public class EyesisAberrations { ...@@ -1245,6 +1243,10 @@ public class EyesisAberrations {
if (debugLevel>0) System.out.println("Processing file #"+(imgNum+1)+ " ( of "+files.length+") :"+files[imgNum][0]); 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 ImagePlus imp=new ImagePlus(files[imgNum][0]); // read source file
JP4_INSTANCE.decodeProperiesFromInfo(imp); 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);
// pad image to full sensor size // pad image to full sensor size
int numGridImage=fileIndices[imgNum]; int numGridImage=fileIndices[imgNum];
int chn = distortions.fittingStrategy.distortionCalibrationData.gIP[numGridImage].getChannel(); int chn = distortions.fittingStrategy.distortionCalibrationData.gIP[numGridImage].getChannel();
...@@ -1335,7 +1337,7 @@ public class EyesisAberrations { ...@@ -1335,7 +1337,7 @@ public class EyesisAberrations {
null, // int [][][] sampleList, // optional (or null) 2-d array: list of coordinate pairs (2d - to match existent PSF_KERNEL_MAP structure) null, // int [][][] sampleList, // optional (or null) 2-d array: list of coordinate pairs (2d - to match existent PSF_KERNEL_MAP structure)
multiFilePSF.overexposedMaxFraction, //MULTIFILE_PSF.overexposedMaxFraction, multiFilePSF.overexposedMaxFraction, //MULTIFILE_PSF.overexposedMaxFraction,
simulParameters, //SIMUL, //simulation parameters simulParameters, //SIMUL, //simulation parameters
mapFFTsize, // MAP_FFT_SIZE, // scanImageForPatterns:FFT size int mapFFTsize, // scanImageForPatterns:FFT size // mapFFTsize, // MAP_FFT_SIZE, // scanImageForPatterns:FFT size int mapFFTsize, // scanImageForPatterns:FFT size
patternDetectParameters, //PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, patternDetectParameters, //PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
fft_overlap, //FFT_OVERLAP, // int fft_overlap, fft_overlap, //FFT_OVERLAP, // int fft_overlap,
fft_size, // FFT_SIZE, // int fft_size, fft_size, // FFT_SIZE, // int fft_size,
...@@ -2241,7 +2243,7 @@ public class EyesisAberrations { ...@@ -2241,7 +2243,7 @@ public class EyesisAberrations {
final int [][][] sampleList, // optional (or null) 2-d array: list of coordinate pairs (2d - to match existent pdfKernelMap structure) final int [][][] sampleList, // optional (or null) 2-d array: list of coordinate pairs (2d - to match existent pdfKernelMap structure)
final double overexposedAllowed, // fraction of pixels OK to be overexposed final double overexposedAllowed, // fraction of pixels OK to be overexposed
final SimulationPattern.SimulParameters simulParameters, final SimulationPattern.SimulParameters simulParameters,
final int mapFFTsize, // scanImageForPatterns:FFT size // final int mapFFTsize, // scanImageForPatterns:FFT size
final MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, final MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
final int fft_overlap, final int fft_overlap,
final int fft_size, final int fft_size,
...@@ -2653,7 +2655,7 @@ public class EyesisAberrations { ...@@ -2653,7 +2655,7 @@ public class EyesisAberrations {
public double [][] getPSFKernels ( ImagePlus imp, public double [][] getPSFKernels ( ImagePlus imp,
float [][] simArray, //simulation image, scaled PSF_subpixel/2 (or null), [0] - main pixels, [1] - shifted diagonally by 0.5 pixels (for checker greens) float [][] simArray, //simulation image, scaled PSF_subpixel/2 (or null), [0] - main pixels, [1] - shifted diagonally by 0.5 pixels (for checker greens)
int size, // size in pixels (twice FFT_SIZE) int tile_size, // size in pixels (twice FFT_SIZE)
int x0, // top left corner X (pixels) int x0, // top left corner X (pixels)
int y0, // top left corner Y (pixels) int y0, // top left corner Y (pixels)
SimulationPattern simulationPattern, SimulationPattern simulationPattern,
...@@ -2677,14 +2679,14 @@ public class EyesisAberrations { ...@@ -2677,14 +2679,14 @@ public class EyesisAberrations {
if (globalDebugLevel>1){ if (globalDebugLevel>1){
System.out.println("getPSFKernels(), simArray is "+((simArray==null)?"":"not ")+"null"); System.out.println("getPSFKernels(), simArray is "+((simArray==null)?"":"not ")+"null");
} }
boolean is_mono = false;
if (imp==null) return null; // Maybe convert to double pixel array once to make it faster? if (imp==null) return null; // Maybe convert to double pixel array once to make it faster?
if (fht_instance==null) fht_instance=new DoubleFHT(); // move upstream to reduce number of initializations if (fht_instance==null) fht_instance=new DoubleFHT(); // move upstream to reduce number of initializations
double [][] kernels= new double[6][]; // was global double [][] kernels= new double[6][]; // was global
String title=imp.getTitle()+"X"+x0+"Y"+y0; String title=imp.getTitle()+"X"+x0+"Y"+y0;
Rectangle PSFCell=new Rectangle (x0,y0,size,size); Rectangle PSFCell=new Rectangle (x0,y0,tile_size,tile_size);
int fft_size=size/2; int fft_size=tile_size/2;
double [][] input_bayer=matchSimulatedPattern.splitBayer(imp,PSFCell,colorComponents.equalizeGreens); // does it work trhe same? double [][] input_bayer_or_mono=matchSimulatedPattern.splitBayer(imp,PSFCell,colorComponents.equalizeGreens); // does it work trhe same?
//int greensToProcess=4; //int greensToProcess=4;
int i,j,l; int i,j,l;
double [][] simul_pixels; double [][] simul_pixels;
...@@ -2698,7 +2700,7 @@ public class EyesisAberrations { ...@@ -2698,7 +2700,7 @@ public class EyesisAberrations {
if ((simArray==null) || (psfParameters.approximateGrid)){ // just for testing(never here?) if ((simArray==null) || (psfParameters.approximateGrid)){ // just for testing(never here?)
/* Calculate pattern parameters, including distortion */ /* Calculate pattern parameters, including distortion */
if (matchSimulatedPattern.PATTERN_GRID==null) { if (matchSimulatedPattern.PATTERN_GRID==null) {
double[][] distortedPattern= matchSimulatedPattern.findPatternDistorted(input_bayer, // pixel array to process (no windowing!) double[][] distortedPattern= matchSimulatedPattern.findPatternDistorted(input_bayer_or_mono, // pixel array to process (no windowing!)
patternDetectParameters, patternDetectParameters,
patternDetectParameters.minGridPeriod/2, patternDetectParameters.minGridPeriod/2,
patternDetectParameters.maxGridPeriod/2, patternDetectParameters.maxGridPeriod/2,
...@@ -2737,7 +2739,7 @@ public class EyesisAberrations { ...@@ -2737,7 +2739,7 @@ public class EyesisAberrations {
double[][] distPatPars= matchSimulatedPattern.findPatternFromGrid( double[][] distPatPars= matchSimulatedPattern.findPatternFromGrid(
x0, // top-left pixel of the square WOI x0, // top-left pixel of the square WOI
y0, y0,
size, // size of square (pixels) tile_size, // size of square (pixels)
Hamming, // only half-window! Hamming, // only half-window!
false, // use linear approximation (instead of quadratic) false, // use linear approximation (instead of quadratic)
1.0E-10, // thershold ratio of matrix determinant to norm for linear approximation (det too low - fail) 1.0E-10, // thershold ratio of matrix determinant to norm for linear approximation (det too low - fail)
...@@ -2755,12 +2757,10 @@ public class EyesisAberrations { ...@@ -2755,12 +2757,10 @@ public class EyesisAberrations {
double [] phases={ double [] phases={
1.0*Math.PI*(distPatPars[0][2]-iUV[0]+(negative?(-0.5):0.5)), // measured from the center of white 1.0*Math.PI*(distPatPars[0][2]-iUV[0]+(negative?(-0.5):0.5)), // measured from the center of white
1.0*Math.PI*(distPatPars[1][2]-iUV[1]+0.5)}; 1.0*Math.PI*(distPatPars[1][2]-iUV[1]+0.5)};
// double [][]wVectors={{distPatPars[0][0],distPatPars[0][1]},{distPatPars[1][0],distPatPars[1][1]}};
wVectors[0][0]=distPatPars[0][0]; wVectors[0][0]=distPatPars[0][0];
wVectors[0][1]=distPatPars[0][1]; wVectors[0][1]=distPatPars[0][1];
wVectors[1][0]=distPatPars[1][0]; wVectors[1][0]=distPatPars[1][0];
wVectors[1][1]=distPatPars[1][1]; wVectors[1][1]=distPatPars[1][1];
// simulationPattern.simulatePatternFullPattern( // Not thread safe!
localBarray=simulationPattern.simulatePatternFullPatternSafe( localBarray=simulationPattern.simulatePatternFullPatternSafe(
wVectors[0][0], wVectors[0][0],
wVectors[0][1], wVectors[0][1],
...@@ -2774,7 +2774,6 @@ public class EyesisAberrations { ...@@ -2774,7 +2774,6 @@ public class EyesisAberrations {
simulParameters.center_for_g2, simulParameters.center_for_g2,
false);//boolean mono false);//boolean mono
} }
// simul_pixels= simulationPattern.extractSimulPatterns (
simul_pixels= simulationPattern.extractSimulPatterns ( simul_pixels= simulationPattern.extractSimulPatterns (
localBarray, // this version is thread safe localBarray, // this version is thread safe
simulParameters, simulParameters,
...@@ -2792,10 +2791,9 @@ public class EyesisAberrations { ...@@ -2792,10 +2791,9 @@ public class EyesisAberrations {
simul_pixels= normalizeAndWindow (simul_pixels, fullHamming); simul_pixels= normalizeAndWindow (simul_pixels, fullHamming);
} else { } else {
Rectangle PSFCellSim=new Rectangle (x0*subpixel/2,y0*subpixel/2,size*subpixel/2,size*subpixel/2); // getting here Rectangle PSFCellSim=new Rectangle (x0*subpixel/2,y0*subpixel/2,tile_size*subpixel/2,tile_size*subpixel/2); // getting here
simul_pixels=new double[6][]; simul_pixels=new double[6][];
// simulationPattern.debugLevel=globalDebugLevel;
for (i=0;i<simul_pixels.length; i++) { for (i=0;i<simul_pixels.length; i++) {
if (colorComponents.colorsToCorrect[i]) simul_pixels[i]=simulationPattern.extractBayerSim ( if (colorComponents.colorsToCorrect[i]) simul_pixels[i]=simulationPattern.extractBayerSim (
simArray, // [0] - regular pixels, [1] - shifted by 1/2 diagonally, for checker greens simArray, // [0] - regular pixels, [1] - shifted by 1/2 diagonally, for checker greens
...@@ -2805,9 +2803,7 @@ public class EyesisAberrations { ...@@ -2805,9 +2803,7 @@ public class EyesisAberrations {
i); i);
else simul_pixels[i]=null; else simul_pixels[i]=null;
} }
//System.out.println("PSFCell.y="+PSFCell.y+" PSFCell.height="+PSFCell.height+" imgWidth="+imgWidth+" PSFCell.x="+PSFCell.x+" PSFCell.width="+PSFCell.width+" matchSimulatedPattern.UV_INDEX.length="+matchSimulatedPattern.UV_INDEX.length);
int index=matchSimulatedPattern.getUVIndex((PSFCell.y+PSFCell.height/2)*imgWidth+(PSFCell.x+PSFCell.width/2)); int index=matchSimulatedPattern.getUVIndex((PSFCell.y+PSFCell.height/2)*imgWidth+(PSFCell.x+PSFCell.width/2));
// int index=matchSimulatedPattern.getUVIndex((PSFCell.y+PSFCell.height/2)*matchSimulatedPattern.getWOI().width+(PSFCell.x+PSFCell.width/2));
if (index<0) { if (index<0) {
System.out.println ("Error, No UV pattern @ x="+(PSFCell.x+PSFCell.width/2)+", y="+(PSFCell.y+PSFCell.height/2)); System.out.println ("Error, No UV pattern @ x="+(PSFCell.x+PSFCell.width/2)+", y="+(PSFCell.y+PSFCell.height/2));
...@@ -2833,7 +2829,7 @@ public class EyesisAberrations { ...@@ -2833,7 +2829,7 @@ public class EyesisAberrations {
wVectors[1]=matchSimulatedPattern.getDArray(iUV[1],iUV[0],2); wVectors[1]=matchSimulatedPattern.getDArray(iUV[1],iUV[0],2);
// should it be averaged WV? // should it be averaged WV?
if (globalDebugLevel>2) System.out.println ( " x0="+x0+" y0="+y0); if (globalDebugLevel>2) System.out.println ( " x0="+x0+" y0="+y0);
if (globalDebugLevel>2) SDFA_INSTANCE.showArrays(input_bayer, true, title+"-in"); if (globalDebugLevel>2) SDFA_INSTANCE.showArrays(input_bayer_or_mono, true, title+"-in");
if (globalDebugLevel>2) SDFA_INSTANCE.showArrays(simul_pixels, true, title+"-S"); if (globalDebugLevel>2) SDFA_INSTANCE.showArrays(simul_pixels, true, title+"-S");
//if (globalDebugLevel>2) System.out.println (simArray[0][-1]); // cause error //if (globalDebugLevel>2) System.out.println (simArray[0][-1]); // cause error
if (masterDebugLevel>1){ if (masterDebugLevel>1){
...@@ -2846,21 +2842,21 @@ public class EyesisAberrations { ...@@ -2846,21 +2842,21 @@ public class EyesisAberrations {
simul_pixels= normalizeAndWindow (simul_pixels, fullHamming); simul_pixels= normalizeAndWindow (simul_pixels, fullHamming);
} }
input_bayer= normalizeAndWindow (input_bayer, Hamming); input_bayer_or_mono= normalizeAndWindow (input_bayer_or_mono, Hamming);
if (subpixel>1) { if (subpixel>1) {
input_bayer= oversampleFFTInput (input_bayer,subpixel); input_bayer_or_mono= oversampleFFTInput (input_bayer_or_mono,subpixel);
if (colorComponents.colorsToCorrect[5]) input_bayer=combineCheckerGreens (input_bayer, // pixel arrays after oversampleFFTInput() or extractSimulPatterns()) if (colorComponents.colorsToCorrect[5]) input_bayer_or_mono=combineCheckerGreens (input_bayer_or_mono, // pixel arrays after oversampleFFTInput() or extractSimulPatterns())
subpixel); // same as used in oversampleFFTInput() - oversampling ratio subpixel); // same as used in oversampleFFTInput() - oversampling ratio
} }
for (i=0;i<4;i++) if (!colorComponents.colorsToCorrect[i]) input_bayer[i]=null; // leave composite greens even if disabled for (i=0;i<4;i++) if (!colorComponents.colorsToCorrect[i]) input_bayer_or_mono[i]=null; // leave composite greens even if disabled
if (debugThis) { if (debugThis) {
// SDFA_INSTANCE.showArrays(input_bayer, fft_size*subpixel, fft_size*subpixel, title); // SDFA_INSTANCE.showArrays(input_bayer, fft_size*subpixel, fft_size*subpixel, title);
} }
if (globalDebugLevel>2) System.out.println ( " input_bayer.length="+input_bayer.length+" simul_pixels.length="+simul_pixels.length+" fft_size*subpixel="+fft_size*subpixel); if (globalDebugLevel>2) System.out.println ( " input_bayer.length="+input_bayer_or_mono.length+" simul_pixels.length="+simul_pixels.length+" fft_size*subpixel="+fft_size*subpixel);
for (i=0;(i<input_bayer.length) && (i<simul_pixels.length);i++) if ((colorComponents.colorsToCorrect[i]) && (input_bayer[i]!=null)){ for (i=0;(i<input_bayer_or_mono.length) && (i<simul_pixels.length);i++) if ((colorComponents.colorsToCorrect[i]) && (input_bayer_or_mono[i]!=null)){
if (globalDebugLevel>2) System.out.println ( "input_bayer["+i+"].length="+input_bayer[i].length+" simul_pixels["+i+"].length="+simul_pixels[i].length); if (globalDebugLevel>2) System.out.println ( "input_bayer["+i+"].length="+input_bayer_or_mono[i].length+" simul_pixels["+i+"].length="+simul_pixels[i].length);
} }
if (debugThis) SDFA_INSTANCE.showArrays(input_bayer, true, title+"-input"); if (debugThis) SDFA_INSTANCE.showArrays(input_bayer_or_mono, true, title+"-input");
if (debugThis) SDFA_INSTANCE.showArrays(simul_pixels, true, title+"-SIM"); if (debugThis) SDFA_INSTANCE.showArrays(simul_pixels, true, title+"-SIM");
//if (globalDebugLevel>2)globalDebugLevel=0; //************************************************************ //if (globalDebugLevel>2)globalDebugLevel=0; //************************************************************
...@@ -2868,10 +2864,10 @@ public class EyesisAberrations { ...@@ -2868,10 +2864,10 @@ public class EyesisAberrations {
double wvAverage=Math.sqrt(0.5*(wVectors[0][0]*wVectors[0][0]+wVectors[0][1]*wVectors[0][1]+ double wvAverage=Math.sqrt(0.5*(wVectors[0][0]*wVectors[0][0]+wVectors[0][1]*wVectors[0][1]+
wVectors[1][0]*wVectors[1][0]+wVectors[1][1]*wVectors[1][1])); wVectors[1][0]*wVectors[1][0]+wVectors[1][1]*wVectors[1][1]));
for (i=0;(i<input_bayer.length) && (i<simul_pixels.length);i++) if ((colorComponents.colorsToCorrect[i]) && (input_bayer[i]!=null)){ for (i=0;(i<input_bayer_or_mono.length) && (i<simul_pixels.length);i++) if ((colorComponents.colorsToCorrect[i]) && (input_bayer_or_mono[i]!=null)){
if (globalDebugLevel>2) System.out.println ( "Color "+colorComponents.getColorName(i)+" is re-calculated into bayer pixels "); if (globalDebugLevel>2) System.out.println ( "Color "+colorComponents.getColorName(i)+" is re-calculated into bayer pixels ");
if (globalDebugLevel>2) System.out.println ( "input_bayer["+i+"].length="+input_bayer[i].length+" simul_pixels["+i+"].length="+simul_pixels[i].length); if (globalDebugLevel>2) System.out.println ( "input_bayer["+i+"].length="+input_bayer_or_mono[i].length+" simul_pixels["+i+"].length="+simul_pixels[i].length);
inverted[i]=limitedInverseOfFHT(input_bayer[i], inverted[i]=limitedInverseOfFHT(input_bayer_or_mono[i],
simul_pixels[i], simul_pixels[i],
fft_size*subpixel, fft_size*subpixel,
(i==5), // boolean checker // checkerboard pattern in the source file (use when filtering) (i==5), // boolean checker // checkerboard pattern in the source file (use when filtering)
...@@ -2879,9 +2875,9 @@ public class EyesisAberrations { ...@@ -2879,9 +2875,9 @@ public class EyesisAberrations {
subpixel, subpixel,
otfFilterParameters, otfFilterParameters,
fht_instance, fht_instance,
psfParameters.mask1_sigma*size*wvAverage, // normalize to wave vectors! psfParameters.mask1_sigma*tile_size*wvAverage, // normalize to wave vectors!
psfParameters.mask1_threshold, psfParameters.mask1_threshold,
psfParameters.gaps_sigma*size*wvAverage, psfParameters.gaps_sigma*tile_size*wvAverage,
psfParameters.mask_denoise, psfParameters.mask_denoise,
debug, debug,
globalDebugLevel, globalDebugLevel,
...@@ -2892,20 +2888,21 @@ public class EyesisAberrations { ...@@ -2892,20 +2888,21 @@ public class EyesisAberrations {
/* correct composite greens */ /* correct composite greens */
/* Here we divide wave vectors by subpixel as the pixels are already added */ /* Here we divide wave vectors by subpixel as the pixels are already added */
double [][] wVrotMatrix= {{0.5,0.5},{-0.5,0.5}}; double [][] wVrotMatrix= {{0.5,0.5},{-0.5,0.5}};
double [][]wVectors4= new double [2][2]; double [][]wVectors4= new double [2][2]; // Will only be used for color, combined diagonal greens
for (i=0;i<2;i++) for (j=0;j<2;j++) { for (i=0;i<2;i++) for (j=0;j<2;j++) {
wVectors4[i][j]=0.0; wVectors4[i][j]=0.0;
for (l=0;l<2;l++) wVectors4[i][j]+=wVectors[i][l]*wVrotMatrix[l][j]; for (l=0;l<2;l++) wVectors4[i][j]+=wVectors[i][l]*wVrotMatrix[l][j];
} }
double [][] PSF_shifts= new double [input_bayer.length][]; // X/Y shift of the PSF array, in Bayer component pixel coordinates (same as PSF arrays)
double [][] PSF_centroids= new double [input_bayer.length][]; // X/Y coordinates of the centroids of PSF in Bayer component pioxel coordinates (same as PSF arrays) (after they were optionally shifted) double [][] PSF_shifts = new double [input_bayer_or_mono.length][]; // X/Y shift of the PSF array, in Bayer component pixel coordinates (same as PSF arrays)
double [][] lateralChromatic= new double [input_bayer.length][]; // X/Y coordinates of the centroids of Bayer component PSF in sensor pixel coordinates double [][] PSF_centroids = new double [input_bayer_or_mono.length][]; // X/Y coordinates of the centroids of PSF in Bayer component pioxel coordinates (same as PSF arrays) (after they were optionally shifted)
double [][] kernelsForFFT= new double [input_bayer.length][]; double [][] lateralChromatic = new double [input_bayer_or_mono.length][]; // X/Y coordinates of the centroids of Bayer component PSF in sensor pixel coordinates
double [][] psf_inverted= new double [input_bayer.length][]; double [][] kernelsForFFT = new double [input_bayer_or_mono.length][];
double [][] psf_inverted_masked=new double [input_bayer.length][]; double [][] psf_inverted = new double [input_bayer_or_mono.length][];
double [] lateralChromaticAbs=new double [input_bayer.length]; double [][] psf_inverted_masked = new double [input_bayer_or_mono.length][];
double [] lateralChromaticAbs = new double [input_bayer_or_mono.length];
double [] zeroVector={0.0,0.0}; double [] zeroVector={0.0,0.0};
for (i=input_bayer.length-1;i>=0;i--) { for (i=input_bayer_or_mono.length-1;i>=0;i--) {
if (colorComponents.colorsToCorrect[i]) { if (colorComponents.colorsToCorrect[i]) {
PSF_shifts[i]= zeroVector.clone(); PSF_shifts[i]= zeroVector.clone();
PSF_centroids[i]= zeroVector.clone(); PSF_centroids[i]= zeroVector.clone();
...@@ -2922,15 +2919,15 @@ public class EyesisAberrations { ...@@ -2922,15 +2919,15 @@ public class EyesisAberrations {
} }
//int [][] clusterMask; //int [][] clusterMask;
/* Start with referenceComp */ /* Start with referenceComp */
i= referenceComp; i = referenceComp; // now 0 for mono
if (globalDebugLevel>debugThreshold) { if (globalDebugLevel > debugThreshold) {
System.out.println(x0+":"+y0+"1-PSF_shifts.length= "+PSF_shifts.length+" i="+i+" input_bayer.length="+input_bayer.length); System.out.println(x0+":"+y0+"1-PSF_shifts.length= "+PSF_shifts.length+" i="+i+" input_bayer.length="+input_bayer_or_mono.length);
System.out.println("Before: color Component "+i+" PSF_shifts["+i+"][0]="+IJ.d2s(PSF_shifts[i][0],3)+ System.out.println("Before: color Component "+i+" PSF_shifts["+i+"][0]="+IJ.d2s(PSF_shifts[i][0],3)+
" PSF_shifts["+i+"][1]="+IJ.d2s(PSF_shifts[i][1],3)); " PSF_shifts["+i+"][1]="+IJ.d2s(PSF_shifts[i][1],3));
} }
kernels[i]=combinePSF (
kernels[i]=combinePSF (inverted[i], // Square array of pixels with multiple repeated PSF (alternating sign) inverted[i], // Square array of pixels with multiple repeated PSF (alternating sign)
!psfParameters.absoluteCenter, //true, // master, force ignoreChromatic !psfParameters.absoluteCenter, //true, // master, force ignoreChromatic
PSF_shifts[i], // centerXY[] - will be modified inside combinePSF() if PSF_PARS.ignoreChromatic is true PSF_shifts[i], // centerXY[] - will be modified inside combinePSF() if PSF_PARS.ignoreChromatic is true
PSF_centroids[i], // will return array of XY coordinates of the result centroid PSF_centroids[i], // will return array of XY coordinates of the result centroid
...@@ -2941,11 +2938,12 @@ public class EyesisAberrations { ...@@ -2941,11 +2938,12 @@ public class EyesisAberrations {
(globalDebugLevel>4), (globalDebugLevel>4),
globalDebugLevel globalDebugLevel
); );
if (globalDebugLevel>debugThreshold) System.out.println(x0+":"+y0+"After-1: color Component "+i+" PSF_shifts["+i+"][0]="+IJ.d2s(PSF_shifts [i][0],3)+" PSF_shifts["+i+"][1]="+IJ.d2s( PSF_shifts[i][1],3)); if (globalDebugLevel>debugThreshold) System.out.println(x0+":"+y0+"After-1: color Component "+i+" PSF_shifts["+i+"][0]="+IJ.d2s(PSF_shifts [i][0],3)+" PSF_shifts["+i+"][1]="+IJ.d2s( PSF_shifts[i][1],3));
if (globalDebugLevel>debugThreshold) System.out.println(x0+":"+y0+"After-1: color Component "+i+" PSF_centroids["+i+"][0]="+IJ.d2s(PSF_centroids[i][0],3)+" PSF_centroids["+i+"][1]="+IJ.d2s(PSF_centroids[i][1],3)); if (globalDebugLevel>debugThreshold) System.out.println(x0+":"+y0+"After-1: color Component "+i+" PSF_centroids["+i+"][0]="+IJ.d2s(PSF_centroids[i][0],3)+" PSF_centroids["+i+"][1]="+IJ.d2s(PSF_centroids[i][1],3));
if (!psfParameters.ignoreChromatic && !psfParameters.absoluteCenter) { /* Recalculate center to pixels from greens (diagonal)) and supply it to other colors (lateral chromatic aberration correction) */ if (!psfParameters.ignoreChromatic && !psfParameters.absoluteCenter) { /* Recalculate center to pixels from greens (diagonal)) and supply it to other colors (lateral chromatic aberration correction) */
for (j=0;j<input_bayer.length;j++) if ((colorComponents.colorsToCorrect[j]) && (j!=referenceComp)) { for (j=0;j<input_bayer_or_mono.length;j++) if ((colorComponents.colorsToCorrect[j]) && (j!=referenceComp)) {
PSF_shifts[j]=shiftSensorToBayer (shiftBayerToSensor(PSF_shifts[referenceComp],referenceComp,subpixel),j,subpixel); PSF_shifts[j]=shiftSensorToBayer (shiftBayerToSensor(PSF_shifts[referenceComp],referenceComp,subpixel),j,subpixel);
if (globalDebugLevel>debugThreshold) System.out.println(x0+":"+y0+"After-2 (recalc): color Component "+j+" PSF_shifts["+j+"][0]="+IJ.d2s(PSF_shifts[j][0],3)+" PSF_shifts["+j+"][1]="+IJ.d2s(PSF_shifts[j][1],3)); if (globalDebugLevel>debugThreshold) System.out.println(x0+":"+y0+"After-2 (recalc): color Component "+j+" PSF_shifts["+j+"][0]="+IJ.d2s(PSF_shifts[j][0],3)+" PSF_shifts["+j+"][1]="+IJ.d2s(PSF_shifts[j][1],3));
} }
...@@ -2956,10 +2954,12 @@ public class EyesisAberrations { ...@@ -2956,10 +2954,12 @@ public class EyesisAberrations {
i, i,
subpixel); subpixel);
lateralChromaticAbs[i]=Math.sqrt(lateralChromatic[i][0]*lateralChromatic[i][0]+lateralChromatic[i][1]*lateralChromatic[i][1]); lateralChromaticAbs[i]=Math.sqrt(lateralChromatic[i][0]*lateralChromatic[i][0]+lateralChromatic[i][1]*lateralChromatic[i][1]);
/* Now process all the other components */ /* Now process all the other components */
for (i=0; i<input_bayer.length;i++) if ((i!=referenceComp) && (colorComponents.colorsToCorrect[i])) { for (i=0; i<input_bayer_or_mono.length;i++) if ((i!=referenceComp) && (colorComponents.colorsToCorrect[i])) {
// Will never get here for mono
if (globalDebugLevel>debugThreshold) { if (globalDebugLevel>debugThreshold) {
System.out.println(x0+":"+y0+"2-PSF_shifts.length= "+PSF_shifts.length+" i="+i+" input_bayer.length="+input_bayer.length); System.out.println(x0+":"+y0+"2-PSF_shifts.length= "+PSF_shifts.length+" i="+i+" input_bayer.length="+input_bayer_or_mono.length);
System.out.println(x0+":"+y0+"Before: color Component "+i+" PSF_shifts["+i+"][0]="+IJ.d2s(PSF_shifts[i][0],3)+ System.out.println(x0+":"+y0+"Before: color Component "+i+" PSF_shifts["+i+"][0]="+IJ.d2s(PSF_shifts[i][0],3)+
" PSF_shifts["+i+"][1]="+IJ.d2s(PSF_shifts[i][1],3)); " PSF_shifts["+i+"][1]="+IJ.d2s(PSF_shifts[i][1],3));
...@@ -2998,27 +2998,31 @@ public class EyesisAberrations { ...@@ -2998,27 +2998,31 @@ public class EyesisAberrations {
" lateralChromatic["+i+"][1]="+IJ.d2s(lateralChromatic[i][1],3)); " lateralChromatic["+i+"][1]="+IJ.d2s(lateralChromatic[i][1],3));
} }
} }
if (colorComponents.colorsToCorrect[referenceComp]) for (i=0;i<colorComponents.colorsToCorrect.length;i++) if ((colorComponents.colorsToCorrect[i])&& (i!=referenceComp)){ if (colorComponents.colorsToCorrect[referenceComp]) {
for (i=0;i<colorComponents.colorsToCorrect.length;i++) {
if ((colorComponents.colorsToCorrect[i])&& (i!=referenceComp)){
System.out.println("#!# "+x0+":"+y0+" "+colorComponents.getColorName(i)+" lateral chromatic (from green) "+IJ.d2s(lateralChromaticAbs[i],3)+"pix(sensor): ["+i+"][0]="+IJ.d2s(lateralChromatic[i][0]-lateralChromatic[referenceComp][0],3)+ System.out.println("#!# "+x0+":"+y0+" "+colorComponents.getColorName(i)+" lateral chromatic (from green) "+IJ.d2s(lateralChromaticAbs[i],3)+"pix(sensor): ["+i+"][0]="+IJ.d2s(lateralChromatic[i][0]-lateralChromatic[referenceComp][0],3)+
" ["+i+"][1]="+IJ.d2s(lateralChromatic[i][1]-lateralChromatic[referenceComp][1],3)); " ["+i+"][1]="+IJ.d2s(lateralChromatic[i][1]-lateralChromatic[referenceComp][1],3));
} }
}
}
System.out.println("#!# "+x0+":"+y0+" "+"Lateral shift green from simulation "+IJ.d2s(lateralChromaticAbs[referenceComp],3)+"pix(sensor): ["+referenceComp+"][0]="+IJ.d2s(lateralChromatic[referenceComp][0],3)+ System.out.println("#!# "+x0+":"+y0+" "+"Lateral shift green from simulation "+IJ.d2s(lateralChromaticAbs[referenceComp],3)+"pix(sensor): ["+referenceComp+"][0]="+IJ.d2s(lateralChromatic[referenceComp][0],3)+
" ["+referenceComp+"][1]="+IJ.d2s(lateralChromatic[referenceComp][1],3)); " ["+referenceComp+"][1]="+IJ.d2s(lateralChromatic[referenceComp][1],3));
} }
if (debugLateralTile!=null) for (i=0;i<PSF_shifts.length;i++) { if (debugLateralTile != null) {
if (colorComponents.colorsToCorrect[i]){ for (i = 0; i < PSF_shifts.length; i++) {
debugLateralTile[i]=new double [6]; if (is_mono || colorComponents.colorsToCorrect[i]){
debugLateralTile[i][0]=lateralChromatic[i][0]; debugLateralTile[i] = new double [6];
debugLateralTile[i][1]=lateralChromatic[i][1]; debugLateralTile[i][0] = lateralChromatic[i][0];
debugLateralTile[i][2]=PSF_shifts[i][0]; debugLateralTile[i][1] = lateralChromatic[i][1];
debugLateralTile[i][3]=PSF_shifts[i][1]; debugLateralTile[i][2] = PSF_shifts[i][0];
debugLateralTile[i][4]=PSF_centroids[i][0]; debugLateralTile[i][3] = PSF_shifts[i][1];
debugLateralTile[i][5]=PSF_centroids[i][1]; debugLateralTile[i][4] = PSF_centroids[i][0];
debugLateralTile[i][5] = PSF_centroids[i][1];
} else { } else {
debugLateralTile[i]=null; debugLateralTile[i] = null;
}
} }
} }
if (debugThis && (kernels!=null)){ if (debugThis && (kernels!=null)){
int debugSize=0; int debugSize=0;
......
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