Loading src/main/java/EyesisCorrectionParameters.java +22 −22 Original line number Original line Diff line number Diff line Loading @@ -1767,32 +1767,32 @@ public class EyesisCorrectionParameters { } } } } public static class DCTParameters { public static class DCTParameters { public int dct_size = 32; // public int dct_size = 8; // public int asym_size = 6; // public int asym_size = 15; // public int asym_pixels = 10; // maximal number of non-zero pixels in direct convolution kernel public int asym_pixels = 4; // maximal number of non-zero pixels in direct convolution kernel public int asym_distance = 2; // how far to try a new asym kernel pixel from existing ones public int asym_distance = 1; // how far to try a new asym kernel pixel from existing ones public int dct_window = 1; // currently only 3 types of windows - 0 (none), 1 and 2 public int dct_window = 1; // currently only 3 types of windows - 0 (none), 1 and 2 public int LMA_steps = 100; public int LMA_steps = 100; public double fact_precision= 0.003; // stop iterations if error rms less than this part of target kernel rms public double fact_precision= 0.003; // stop iterations if error rms less than this part of target kernel rms public double compactness = 0.02; public double compactness = 0.0; public double sym_compactness = 0.01; public double sym_compactness = 0.5; public double dc_weight = 10; // importance of dc realtive to rms_pure public double dc_weight = 1.0; // importance of dc realtive to rms_pure public int asym_tax_free = 5; // "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free public int asym_tax_free = 0; // "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free public int seed_size = 8; // number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells) public int seed_size = 1; // number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells) public double asym_random; // initialize asym_kernel with random numbers public double asym_random = -1; // initialize asym_kernel with random numbers public double dbg_x =0; public double dbg_x = 2.7; public double dbg_y =0; public double dbg_y = 0.0; public double dbg_x1 =0; public double dbg_x1 = -1.3; public double dbg_y1 =0; public double dbg_y1 = 2.0; public double dbg_sigma =2.0; public double dbg_sigma = 0.8; public String dbg_mask = ".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::........."; public String dbg_mask = ".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::........."; public int dbg_mode = 1; // 0 - old LMA, 1 - new LMA - *** not used anymore *** public int dbg_mode = 1; // 0 - old LMA, 1 - new LMA - *** not used anymore *** public int dbg_window_mode = 2; // 0 - none, 1 - square, 2 - sin 3 - sin^2 public int dbg_window_mode = 1; // 0 - none, 1 - square, 2 - sin 3 - sin^2 Now _should_ be square !!! public boolean centerWindowToTarget = true; public boolean centerWindowToTarget = true; // parameters to extract a kernel from the kernel image file // parameters to extract a kernel from the kernel image file public int color_channel = 2; // green (<0 - use simulated kernel, also will use simulated if kernels are not set) public int color_channel = 2; // green (<0 - use simulated kernel, also will use simulated if kernels are not set) public int decimation = 2; // decimate original kernel this much in each direction public int decimation = 2; // decimate original kernel this much in each direction public double decimateSigma = 0.4; // what is the optimal value for each decimation? public double decimateSigma = -1.0; // special mode for 2:1 deciamtion public int tileX = 82; // number of kernel tile (0..163) public int tileX = 82; // number of kernel tile (0..163) public int tileY = 62; // number of kernel tile (0..122) public int tileY = 62; // number of kernel tile (0..122) public boolean subtract_dc = false;//subtract/restore dc public boolean subtract_dc = false;//subtract/restore dc Loading src/main/java/EyesisDCT.java +47 −29 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import ij.IJ; import ij.ImagePlus; import ij.ImagePlus; import ij.ImageStack; import ij.ImageStack; import ij.Prefs; import ij.Prefs; import ij.io.FileSaver; import ij.process.FloatProcessor; import ij.process.FloatProcessor; import ij.process.ImageProcessor; import ij.process.ImageProcessor; Loading Loading @@ -107,31 +108,10 @@ public class EyesisDCT { } } } } showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? // String [] sensor_files = correctionsParameters.selectSensorFiles(eyesisCorrections.debugLevel); for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ if (eyesisCorrections.usedChannels[chn] && (sharpKernelPaths[chn]!=null) && (kernels[chn]==null)){ if (eyesisCorrections.usedChannels[chn] && (sharpKernelPaths[chn]!=null) && (kernels[chn]==null)){ // if ((sensor_files!= null) && (sensor_files.length > chn) && (sensor_files[chn]!=null)){ /* double [][] vignetting = null; int vign_width = 0; int vign_height = 0; int vign_decimation = 1; if ((pixelMapping != null) && (pixelMapping.sensors != null) && (pixelMapping.sensors[chn] != null) && (pixelMapping.sensors[chn].pixelCorrection != null) && (pixelMapping.sensors[chn].pixelCorrection.length >=6)){ vignetting = new double[3][]; vignetting[0] = pixelMapping.sensors[chn].pixelCorrection[3]; // red vignetting[2] = pixelMapping.sensors[chn].pixelCorrection[4]; // green vignetting[1] = pixelMapping.sensors[chn].pixelCorrection[5]; // blue vign_width = pixelMapping.sensors[chn].pixelCorrectionWidth; vign_height = pixelMapping.sensors[chn].pixelCorrectionHeight; vign_decimation = pixelMapping.sensors[chn].pixelCorrectionDecimation; } */ ImagePlus imp_kernel_sharp=new ImagePlus(sharpKernelPaths[chn]); ImagePlus imp_kernel_sharp=new ImagePlus(sharpKernelPaths[chn]); if (imp_kernel_sharp.getStackSize()<3) { if (imp_kernel_sharp.getStackSize()<3) { System.out.println("Need a 3-layer stack with kernels"); System.out.println("Need a 3-layer stack with kernels"); Loading @@ -145,22 +125,60 @@ public class EyesisDCT { kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels srcKernelSize, // final int kernelSize, // 64 srcKernelSize, // final int kernelSize, // 64 dct_parameters, // final double blurSigma, dct_parameters, // final double blurSigma, /* vignetting, vign_width, vign_height, vign_decimation, */ threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch updateStatus, updateStatus, debugLevel); // update status info debugLevel); // update status info int sym_width = kernels.numHor * kernels.dct_size; int sym_width = kernels.numHor * kernels.dct_size; int sym_height = kernels.sym_kernels[0].length /sym_width; int sym_height = kernels.sym_kernels[0].length /sym_width; sdfa_instance.showArrays(kernels.sym_kernels, sym_width, sym_height, true, imp_kernel_sharp.getTitle()+"-sym"); // save files String [] symNames = {"red_sym","blue_sym","green_sym"}; String [] asymNames = {"red_asym","blue_asym","green_asym"}; ImageStack symStack = sdfa_instance.makeStack( kernels.sym_kernels, sym_width, sym_height, symNames); String symPath=correctionsParameters.dctKernelDirectory+ Prefs.getFileSeparator()+ correctionsParameters.dctKernelPrefix+ String.format("%02d",chn)+ correctionsParameters.dctSymSuffix; String msg="Saving symmetrical convolution kernels to "+symPath; IJ.showStatus(msg); if (debugLevel>0) System.out.println(msg); ImagePlus imp_sym=new ImagePlus(imp_kernel_sharp.getTitle()+"-sym",symStack); if (debugLevel > 1) { imp_sym.getProcessor().resetMinAndMax(); imp_sym.show(); } FileSaver fs=new FileSaver(imp_sym); fs.saveAsTiffStack(symPath); // sdfa_instance.showArrays(kernels.sym_kernels, sym_width, sym_height, true, imp_kernel_sharp.getTitle()+"-sym"); int asym_width = kernels.numHor * kernels.asym_size; int asym_width = kernels.numHor * kernels.asym_size; int asym_height = kernels.asym_kernels[0].length /asym_width; int asym_height = kernels.asym_kernels[0].length /asym_width; sdfa_instance.showArrays(kernels.asym_kernels, asym_width, asym_height, true, imp_kernel_sharp.getTitle()+"-asym"); ImageStack asymStack = sdfa_instance.makeStack( kernels.asym_kernels, asym_width, asym_height, asymNames); String asymPath=correctionsParameters.dctKernelDirectory+ Prefs.getFileSeparator()+ correctionsParameters.dctKernelPrefix+ String.format("%02d",chn)+ correctionsParameters.dctAsymSuffix; msg="Saving asymmetrical convolution kernels "+asymPath; IJ.showStatus(msg); if (debugLevel>0) System.out.println(msg); ImagePlus imp_asym=new ImagePlus(imp_kernel_sharp.getTitle()+"-asym",asymStack); if (debugLevel > 1) { imp_asym.getProcessor().resetMinAndMax(); imp_asym.show(); } fs=new FileSaver(imp_asym); fs.saveAsTiffStack(asymPath); // sdfa_instance.showArrays(kernels.asym_kernels, asym_width, asym_height, true, imp_kernel_sharp.getTitle()+"-asym"); } } } } return true; return true; Loading Loading
src/main/java/EyesisCorrectionParameters.java +22 −22 Original line number Original line Diff line number Diff line Loading @@ -1767,32 +1767,32 @@ public class EyesisCorrectionParameters { } } } } public static class DCTParameters { public static class DCTParameters { public int dct_size = 32; // public int dct_size = 8; // public int asym_size = 6; // public int asym_size = 15; // public int asym_pixels = 10; // maximal number of non-zero pixels in direct convolution kernel public int asym_pixels = 4; // maximal number of non-zero pixels in direct convolution kernel public int asym_distance = 2; // how far to try a new asym kernel pixel from existing ones public int asym_distance = 1; // how far to try a new asym kernel pixel from existing ones public int dct_window = 1; // currently only 3 types of windows - 0 (none), 1 and 2 public int dct_window = 1; // currently only 3 types of windows - 0 (none), 1 and 2 public int LMA_steps = 100; public int LMA_steps = 100; public double fact_precision= 0.003; // stop iterations if error rms less than this part of target kernel rms public double fact_precision= 0.003; // stop iterations if error rms less than this part of target kernel rms public double compactness = 0.02; public double compactness = 0.0; public double sym_compactness = 0.01; public double sym_compactness = 0.5; public double dc_weight = 10; // importance of dc realtive to rms_pure public double dc_weight = 1.0; // importance of dc realtive to rms_pure public int asym_tax_free = 5; // "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free public int asym_tax_free = 0; // "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free public int seed_size = 8; // number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells) public int seed_size = 1; // number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells) public double asym_random; // initialize asym_kernel with random numbers public double asym_random = -1; // initialize asym_kernel with random numbers public double dbg_x =0; public double dbg_x = 2.7; public double dbg_y =0; public double dbg_y = 0.0; public double dbg_x1 =0; public double dbg_x1 = -1.3; public double dbg_y1 =0; public double dbg_y1 = 2.0; public double dbg_sigma =2.0; public double dbg_sigma = 0.8; public String dbg_mask = ".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::........."; public String dbg_mask = ".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::........."; public int dbg_mode = 1; // 0 - old LMA, 1 - new LMA - *** not used anymore *** public int dbg_mode = 1; // 0 - old LMA, 1 - new LMA - *** not used anymore *** public int dbg_window_mode = 2; // 0 - none, 1 - square, 2 - sin 3 - sin^2 public int dbg_window_mode = 1; // 0 - none, 1 - square, 2 - sin 3 - sin^2 Now _should_ be square !!! public boolean centerWindowToTarget = true; public boolean centerWindowToTarget = true; // parameters to extract a kernel from the kernel image file // parameters to extract a kernel from the kernel image file public int color_channel = 2; // green (<0 - use simulated kernel, also will use simulated if kernels are not set) public int color_channel = 2; // green (<0 - use simulated kernel, also will use simulated if kernels are not set) public int decimation = 2; // decimate original kernel this much in each direction public int decimation = 2; // decimate original kernel this much in each direction public double decimateSigma = 0.4; // what is the optimal value for each decimation? public double decimateSigma = -1.0; // special mode for 2:1 deciamtion public int tileX = 82; // number of kernel tile (0..163) public int tileX = 82; // number of kernel tile (0..163) public int tileY = 62; // number of kernel tile (0..122) public int tileY = 62; // number of kernel tile (0..122) public boolean subtract_dc = false;//subtract/restore dc public boolean subtract_dc = false;//subtract/restore dc Loading
src/main/java/EyesisDCT.java +47 −29 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import ij.IJ; import ij.ImagePlus; import ij.ImagePlus; import ij.ImageStack; import ij.ImageStack; import ij.Prefs; import ij.Prefs; import ij.io.FileSaver; import ij.process.FloatProcessor; import ij.process.FloatProcessor; import ij.process.ImageProcessor; import ij.process.ImageProcessor; Loading Loading @@ -107,31 +108,10 @@ public class EyesisDCT { } } } } showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? // String [] sensor_files = correctionsParameters.selectSensorFiles(eyesisCorrections.debugLevel); for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ if (eyesisCorrections.usedChannels[chn] && (sharpKernelPaths[chn]!=null) && (kernels[chn]==null)){ if (eyesisCorrections.usedChannels[chn] && (sharpKernelPaths[chn]!=null) && (kernels[chn]==null)){ // if ((sensor_files!= null) && (sensor_files.length > chn) && (sensor_files[chn]!=null)){ /* double [][] vignetting = null; int vign_width = 0; int vign_height = 0; int vign_decimation = 1; if ((pixelMapping != null) && (pixelMapping.sensors != null) && (pixelMapping.sensors[chn] != null) && (pixelMapping.sensors[chn].pixelCorrection != null) && (pixelMapping.sensors[chn].pixelCorrection.length >=6)){ vignetting = new double[3][]; vignetting[0] = pixelMapping.sensors[chn].pixelCorrection[3]; // red vignetting[2] = pixelMapping.sensors[chn].pixelCorrection[4]; // green vignetting[1] = pixelMapping.sensors[chn].pixelCorrection[5]; // blue vign_width = pixelMapping.sensors[chn].pixelCorrectionWidth; vign_height = pixelMapping.sensors[chn].pixelCorrectionHeight; vign_decimation = pixelMapping.sensors[chn].pixelCorrectionDecimation; } */ ImagePlus imp_kernel_sharp=new ImagePlus(sharpKernelPaths[chn]); ImagePlus imp_kernel_sharp=new ImagePlus(sharpKernelPaths[chn]); if (imp_kernel_sharp.getStackSize()<3) { if (imp_kernel_sharp.getStackSize()<3) { System.out.println("Need a 3-layer stack with kernels"); System.out.println("Need a 3-layer stack with kernels"); Loading @@ -145,22 +125,60 @@ public class EyesisDCT { kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels srcKernelSize, // final int kernelSize, // 64 srcKernelSize, // final int kernelSize, // 64 dct_parameters, // final double blurSigma, dct_parameters, // final double blurSigma, /* vignetting, vign_width, vign_height, vign_decimation, */ threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch updateStatus, updateStatus, debugLevel); // update status info debugLevel); // update status info int sym_width = kernels.numHor * kernels.dct_size; int sym_width = kernels.numHor * kernels.dct_size; int sym_height = kernels.sym_kernels[0].length /sym_width; int sym_height = kernels.sym_kernels[0].length /sym_width; sdfa_instance.showArrays(kernels.sym_kernels, sym_width, sym_height, true, imp_kernel_sharp.getTitle()+"-sym"); // save files String [] symNames = {"red_sym","blue_sym","green_sym"}; String [] asymNames = {"red_asym","blue_asym","green_asym"}; ImageStack symStack = sdfa_instance.makeStack( kernels.sym_kernels, sym_width, sym_height, symNames); String symPath=correctionsParameters.dctKernelDirectory+ Prefs.getFileSeparator()+ correctionsParameters.dctKernelPrefix+ String.format("%02d",chn)+ correctionsParameters.dctSymSuffix; String msg="Saving symmetrical convolution kernels to "+symPath; IJ.showStatus(msg); if (debugLevel>0) System.out.println(msg); ImagePlus imp_sym=new ImagePlus(imp_kernel_sharp.getTitle()+"-sym",symStack); if (debugLevel > 1) { imp_sym.getProcessor().resetMinAndMax(); imp_sym.show(); } FileSaver fs=new FileSaver(imp_sym); fs.saveAsTiffStack(symPath); // sdfa_instance.showArrays(kernels.sym_kernels, sym_width, sym_height, true, imp_kernel_sharp.getTitle()+"-sym"); int asym_width = kernels.numHor * kernels.asym_size; int asym_width = kernels.numHor * kernels.asym_size; int asym_height = kernels.asym_kernels[0].length /asym_width; int asym_height = kernels.asym_kernels[0].length /asym_width; sdfa_instance.showArrays(kernels.asym_kernels, asym_width, asym_height, true, imp_kernel_sharp.getTitle()+"-asym"); ImageStack asymStack = sdfa_instance.makeStack( kernels.asym_kernels, asym_width, asym_height, asymNames); String asymPath=correctionsParameters.dctKernelDirectory+ Prefs.getFileSeparator()+ correctionsParameters.dctKernelPrefix+ String.format("%02d",chn)+ correctionsParameters.dctAsymSuffix; msg="Saving asymmetrical convolution kernels "+asymPath; IJ.showStatus(msg); if (debugLevel>0) System.out.println(msg); ImagePlus imp_asym=new ImagePlus(imp_kernel_sharp.getTitle()+"-asym",asymStack); if (debugLevel > 1) { imp_asym.getProcessor().resetMinAndMax(); imp_asym.show(); } fs=new FileSaver(imp_asym); fs.saveAsTiffStack(asymPath); // sdfa_instance.showArrays(kernels.asym_kernels, asym_width, asym_height, true, imp_kernel_sharp.getTitle()+"-asym"); } } } } return true; return true; Loading