Commit 3a520ab0 authored by Andrey Filippov's avatar Andrey Filippov

refactored ShowDoubleFloatArrays to static methods, tested unfinished

textures
parent 4bdc8501
......@@ -613,7 +613,6 @@ public class CalibrationIllustration {
}
}
}
// (new ShowDoubleFloatArrays()).showArrays(rslt, wh[0],wh[1], true,"kernels_compressed");
return nonzero ? rslt : null;
}
......@@ -638,7 +637,7 @@ public class CalibrationIllustration {
pseudo_pixels[3][i] = 1.0; // alpha
}
String [] rgb_titles = {"red","green","blue","alpha"};
ImageStack stack = (new ShowDoubleFloatArrays()).makeStack(
ImageStack stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels,
width,
dpixels.length/width,
......@@ -680,7 +679,7 @@ public class CalibrationIllustration {
pseudo_pixels[3][i] = 1.0; // alpha
}
String [] rgb_titles = {"red","green","blue","alpha"};
ImageStack stack = (new ShowDoubleFloatArrays()).makeStack(
ImageStack stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels,
width,
dpixels[0].length/width,
......@@ -840,7 +839,6 @@ public class CalibrationIllustration {
(1 << LwirReaderParameters.TYPE_LWIR), // final int types_mask, // +1 - TYPE_EO, +2 - TYPE_LWIR
null); // final double [][] pixels) // if not null - will fill
windows = getWindows (imps,illustrationParameters.auto_range_wnd_type);
// (new ShowDoubleFloatArrays()).showArrays(windows, width, height, true, "windows");
double [][] offs_gains = balanceOffsGains(
balancing_scenes, // CapturedScene [] scenes,
windows, // double [][] window,
......@@ -1081,7 +1079,7 @@ public class CalibrationIllustration {
}
String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack(
stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size,
......@@ -1477,7 +1475,7 @@ public class CalibrationIllustration {
}
String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack(
stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size,
......@@ -1552,7 +1550,7 @@ public class CalibrationIllustration {
String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack(
stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size,
......@@ -2194,7 +2192,7 @@ public class CalibrationIllustration {
}
String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack(
stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size,
......
......@@ -37,7 +37,7 @@ public class DeBayerScissors {
private double [][][] lopass=null;
private int size;
private double lastMidEnergy; // last midrange spectral energy
private ShowDoubleFloatArrays SDFA_instance; // just for debugging?
// private ShowDoubleFloatArrays SDFA_instance; // just for debugging?
private DoubleFHT fht_instance;
private int [][] aliasMapRedBlue={
{-2,-2},{-2,-1},{-2,0},{-2,1},
......@@ -56,7 +56,6 @@ public class DeBayerScissors {
double debayer_width_redblue_clones){// green mask when applied to red/blue, clones
size=isize;
fht_instance= new DoubleFHT();
SDFA_instance= new ShowDoubleFloatArrays();
pol_instace=new PolarSpectrums(size, // size of the square array, centar is at size/2, size/2, only top half+line will be used
Math.PI,
size/2-2, // width of the polar array - should be <= size/2-2
......@@ -118,7 +117,7 @@ public class DeBayerScissors {
for (i=0;i<green_amp.length;i++) if (green_amp[i]>dmax) dmax=green_amp[i];
dmax=1.0/dmax;
for (i=0;i<green_amp.length;i++) green_amp[i]= Math.pow(green_amp[i]*dmax,debayer_gamma);
if (this_debug>2) SDFA_instance.showArrays(green_amp, "DT-gam"); // only top half+1 will be used
if (this_debug>2) ShowDoubleFloatArrays.showArrays(green_amp, "DT-gam"); // only top half+1 will be used
double midRangeSpectral=pol_instace.maxAmpInRing (green_amp);
boolean useFancyDebayer=(midRangeSpectral>=debayer_threshold);
......@@ -130,10 +129,10 @@ public class DeBayerScissors {
debayer_bonus, // hack - here it is "bonus"
this_debug);//
if (this_debug>3) SDFA_instance.showArrays(green_mask, "G-raw");
if (this_debug>3) ShowDoubleFloatArrays.showArrays(green_mask, "G-raw");
if (debayer_mask_blur>0) {
blurDouble(green_mask, size, debayer_mask_blur, debayer_mask_blur, 0.01);
if (this_debug>3) SDFA_instance.showArrays(green_mask, "G-blurred");
if (this_debug>3) ShowDoubleFloatArrays.showArrays(green_mask, "G-blurred");
}
double [] green_mask_for_redblue_main= green_mask.clone();
double [] green_mask_for_redblue_clones=green_mask.clone();
......@@ -143,8 +142,8 @@ public class DeBayerScissors {
}
if (this_debug>2) {
SDFA_instance.showArrays(green_mask_for_redblue_main, "MAIN");
SDFA_instance.showArrays(green_mask_for_redblue_main, "CLONES");
ShowDoubleFloatArrays.showArrays(green_mask_for_redblue_main, "MAIN");
ShowDoubleFloatArrays.showArrays(green_mask_for_redblue_main, "CLONES");
}
/* Maybe here we need to unmasked (wide bandwidth) green_amp? */
......@@ -159,10 +158,10 @@ public class DeBayerScissors {
/* add double mainToAlias){// relative main/alias amplitudes to enable pixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out) */
if (this_debug>3) SDFA_instance.showArrays(red_blue_mask, "RB-raw");
if (this_debug>3) ShowDoubleFloatArrays.showArrays(red_blue_mask, "RB-raw");
if (debayer_mask_blur>0) {
blurDouble(red_blue_mask, size,debayer_mask_blur, debayer_mask_blur, 0.01);
if (this_debug>3) SDFA_instance.showArrays(red_blue_mask, "RB-blurred");
if (this_debug>3) ShowDoubleFloatArrays.showArrays(red_blue_mask, "RB-blurred");
}
for (i=0;i<red_blue_mask.length;i++) red_blue_mask[i]*=lopass[1][1][i]; // scaled, red-blue - was red_blue_lopass[i];
} else { // debayer_mask_blur<0 : use default masks
......@@ -180,7 +179,7 @@ public class DeBayerScissors {
double [][] result =new double [2][];
result[0]= green_mask;
result[1]= red_blue_mask;
// if (this_debug>3) SDFA_instance.showArrays(result, "before_norm_masks");
// if (this_debug>3) ShowDoubleFloatArrays.showArrays(result, "before_norm_masks");
/* normalize masks to have exactly 1.0 at 0:0 - it can be reduced by blurring */
......@@ -188,7 +187,7 @@ public class DeBayerScissors {
dmax=1.0/result[i][0];
for (j=0;j<result[i].length;j++) result[i][j]*=dmax;
}
// if (this_debug>3) SDFA_instance.showArrays(result, "masks");
// if (this_debug>3) ShowDoubleFloatArrays.showArrays(result, "masks");
return result;
}
......@@ -224,8 +223,8 @@ public class DeBayerScissors {
{ 1,-2},{ 1,-1},{ 1,0},{ 1,1}};
// First step - mask out all the pixels where at least one of the alias amplitude is above the main one
if (this_debug>2) SDFA_instance.showArrays(amp.clone(), "amp");
if (this_debug>2) SDFA_instance.showArrays(amp_clones, "amp_clones");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp.clone(), "amp");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp_clones, "amp_clones");
for (i=0;i<=hsize;i++) for (j=0;j<size;j++) {
index=i*size+j;
......@@ -275,8 +274,8 @@ public class DeBayerScissors {
*/
// First step - mask out all the pixels where at least one of the alias amplitude is above the main one
if (this_debug>2) SDFA_instance.showArrays(amp.clone(), "amp");
if (this_debug>2) SDFA_instance.showArrays(amp_clones, "amp_clones");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp.clone(), "amp");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp_clones, "amp_clones");
for (i=0;i<=hsize;i++) for (j=0;j<size;j++) {
index = speedTable[i][j][0][0]; // i*size+j;
......@@ -297,30 +296,30 @@ public class DeBayerScissors {
// End of replacement code
if (this_debug>2) SDFA_instance.showArrays(mask, "mask");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(mask, "mask");
if (pol_instace==null) return mask;
/* Now apply mask to amplitudes and use ray processing (same as with greens)*/
for (i=0;i<amp.length;i++) amp[i]*=mask[i];
if (this_debug>2) SDFA_instance.showArrays(amp, "amp-mask");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp, "amp-mask");
double [] polar_amp=pol_instace.cartesianToPolar(amp);
int width = pol_instace.getWidth();
int height = pol_instace.getHeight();
if (this_debug>2) SDFA_instance.showArrays(polar_amp.clone(),width, height, "RB-polar-amp");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(polar_amp.clone(),width, height, "RB-polar-amp");
double k= bonus/width;
for (i=0;i<pol_instace.getHeight();i++) for (j = 0; j < width; j++) polar_amp[i * width + j]*=1.0+k*j;
double [] polar_mask_pixels=pol_instace.genPolarRedBlueMask(polar_amp,0); // 0 - just 1.0/0.0, 1 - "analog"
double [] cart_mask_pixels= pol_instace.polarToCartesian (polar_mask_pixels,size,0.0);
if (this_debug>2) {
SDFA_instance.showArrays(polar_amp, width, height, "RB-amp-bonus");
SDFA_instance.showArrays(polar_mask_pixels, width, height, "pRBm");
SDFA_instance.showArrays(cart_mask_pixels, size, size, "cRBm");
ShowDoubleFloatArrays.showArrays(polar_amp, width, height, "RB-amp-bonus");
ShowDoubleFloatArrays.showArrays(polar_mask_pixels, width, height, "pRBm");
ShowDoubleFloatArrays.showArrays(cart_mask_pixels, size, size, "cRBm");
}
if (this_debug>2) {
double [] polar_mask_pixels1=pol_instace.genPolarRedBlueMask(polar_amp,1);
double [] cart_mask_pixels1= pol_instace.polarToCartesian (polar_mask_pixels1,size,0.0);
SDFA_instance.showArrays(polar_mask_pixels1, width, height, "pRBm1");
SDFA_instance.showArrays(cart_mask_pixels1, size, size, "cRBm1");
ShowDoubleFloatArrays.showArrays(polar_mask_pixels1, width, height, "pRBm1");
ShowDoubleFloatArrays.showArrays(cart_mask_pixels1, size, size, "cRBm1");
}
return cart_mask_pixels;
......@@ -334,23 +333,23 @@ public class DeBayerScissors {
int length=amp_pixels.length;
int size = (int) Math.sqrt(length);
double [] polar_amp_pixels=pol_instace.cartesianToPolar(amp_pixels);
if (this_debug>2) SDFA_instance.showArrays(polar_amp_pixels.clone(),pol_instace.getWidth(),pol_instace.getHeight(), "polar-amp");
if (this_debug>2) ShowDoubleFloatArrays.showArrays(polar_amp_pixels.clone(),pol_instace.getWidth(),pol_instace.getHeight(), "polar-amp");
double k= bonus/pol_instace.getWidth();
for (int i=0;i<pol_instace.getHeight();i++) for (int j=0;j<pol_instace.getWidth();j++) polar_amp_pixels[i*pol_instace.getWidth()+j]*=1.0+k*j;
double [] polar_green_mask_pixels=pol_instace.genPolarGreenMask(polar_amp_pixels,0); // 0 - just 1.0/0.0, 1 - "analog"
double [] cart_green_mask_pixels= pol_instace.polarToCartesian (polar_green_mask_pixels,size,0.0);
if (this_debug>2) {
SDFA_instance.showArrays(polar_amp_pixels, pol_instace.getWidth(),pol_instace.getHeight(), "amp-bonus");
SDFA_instance.showArrays(polar_green_mask_pixels,pol_instace.getWidth(),pol_instace.getHeight(), "pgm");
SDFA_instance.showArrays(cart_green_mask_pixels,size,size, "cgm");
ShowDoubleFloatArrays.showArrays(polar_amp_pixels, pol_instace.getWidth(),pol_instace.getHeight(), "amp-bonus");
ShowDoubleFloatArrays.showArrays(polar_green_mask_pixels,pol_instace.getWidth(),pol_instace.getHeight(), "pgm");
ShowDoubleFloatArrays.showArrays(cart_green_mask_pixels,size,size, "cgm");
}
if (this_debug>2) {
double [] polar_green_mask_pixels1=pol_instace.genPolarGreenMask(polar_amp_pixels,1);
double [] cart_green_mask_pixels1= pol_instace.polarToCartesian (polar_green_mask_pixels1,size,0.0);
SDFA_instance.showArrays(polar_green_mask_pixels1,pol_instace.getWidth(),pol_instace.getHeight(), "PGM1");
SDFA_instance.showArrays(cart_green_mask_pixels1,size,size, "CGM1");
ShowDoubleFloatArrays.showArrays(polar_green_mask_pixels1,pol_instace.getWidth(),pol_instace.getHeight(), "PGM1");
ShowDoubleFloatArrays.showArrays(cart_green_mask_pixels1,size,size, "CGM1");
}
return cart_green_mask_pixels;
......
......@@ -169,8 +169,7 @@ public class DebayerScissorsClass {
/* Scale green channel x0.5 as there are twice more pixels there as in red or blue. Or move it somewhere else and multiply to original range ? */
for (i=0;i<tile[greenChn].length;i++) tile[greenChn][i]*=0.5;
if ((tileY==yTileDebug) && (tileX==xTileDebug)) {
if (SDFA_instance==null) SDFA_instance= new ShowDoubleFloatArrays();
SDFA_instance.showArrays (tile.clone(),debayerParameters.size,debayerParameters.size, "x"+(tileX*step)+"_y"+(tileY*step));
ShowDoubleFloatArrays.showArrays (tile.clone(),debayerParameters.size,debayerParameters.size, "x"+(tileX*step)+"_y"+(tileY*step));
}
for (chn=0;chn<nChn;chn++){
fht_instance.swapQuadrants(tile[chn]);
......
......@@ -91,7 +91,7 @@ import ij.text.TextWindow;
//pixelsXY, pixelsUV should match, second dimension is variable
public boolean updateStatus=true;
public int debugLevel=2;
private ShowDoubleFloatArrays SDFA_INSTANCE=null; // just for debugging
// private ShowDoubleFloatArrays ShowDoubleFloatArrays=null; // just for debugging
public static int pathToChannel(String path) {
int last_dash = path.lastIndexOf('-');
......@@ -438,7 +438,7 @@ import ij.text.TextWindow;
}
}
}
(new ShowDoubleFloatArrays()).showArrays(
ShowDoubleFloatArrays.showArrays(
dbg_img,
width,
height,
......@@ -4264,7 +4264,7 @@ import ij.text.TextWindow;
dbgData[0]=diffs2.clone();
dbgData[2]=dbgData[0].clone();
for (int i=0;i< dbgData[2].length;i++) if (!localWorst[i]) dbgData[2][i]=-1.0;
// (new showDoubleFloatArrays()).showArrays(diffs2, width, height, "diffs2");
// ShowDoubleFloatArrays.showArrays(diffs2, width, height, "diffs2");
}
if (replaceBad) {
......@@ -4449,7 +4449,7 @@ import ij.text.TextWindow;
}
String [] dbgTitles={"diff20","diff2Mod","localWorst", "old-X", "old-Y", "new-X", "new-Y","old-new-X","old-new-Y"};
if (dbgTitle!=null) (new ShowDoubleFloatArrays()).showArrays(dbgData, width, height, true, dbgTitle, dbgTitles);
if (dbgTitle!=null) ShowDoubleFloatArrays.showArrays(dbgData, width, height, true, dbgTitle, dbgTitles);
}
int [] nums = {numWorst, numBad};
return nums;
......@@ -5201,7 +5201,6 @@ import ij.text.TextWindow;
int numChannels=getNumChannels();
this.sensorMasks=new double [numChannels][];
DoubleGaussianBlur gb=new DoubleGaussianBlur();
if ((this.debugLevel>1) && (SDFA_INSTANCE==null)) SDFA_INSTANCE=new ShowDoubleFloatArrays();
if (this.debugLevel>2)System.out.println("calculateSensorMasks("+width+","+height+","+shrinkGridForMask+","+sigmaUV+")");
for (int chNum=0;chNum<numChannels; chNum++){
this.sensorMasks[chNum]=new double[dWidth*dHeight];
......@@ -5233,7 +5232,6 @@ import ij.text.TextWindow;
int numChannels=getNumChannels();
this.sensorMasks=new double [numChannels][];
DoubleGaussianBlur gb=new DoubleGaussianBlur();
if ((this.debugLevel>1) && (SDFA_INSTANCE==null)) SDFA_INSTANCE=new ShowDoubleFloatArrays();
if (this.debugLevel>2)System.out.println("calculateSensorMasks("+shrinkGridForMask+","+sigmaUV+")");
for (int chNum=0;chNum<numChannels; chNum++){
int decimate = eyesisCameraParameters.getDecimateMasks(chNum);
......@@ -5259,7 +5257,7 @@ import ij.text.TextWindow;
if(sigma<0) sigma*=-rAverage;
gb.blurDouble(this.sensorMasks[chNum], dWidth, dHeight, sigma/decimate, sigma/decimate, 0.01);
if (this.debugLevel >1) {
(new ShowDoubleFloatArrays()).showArrays(
ShowDoubleFloatArrays.showArrays(
this.sensorMasks[chNum],
dWidth,
dHeight,
......@@ -5271,7 +5269,6 @@ import ij.text.TextWindow;
public double [] calculateSensorMasks(int chNum, int shrinkGridForMask, double sigmaUV) {
DoubleGaussianBlur gb=new DoubleGaussianBlur();
if ((this.debugLevel>1) && (SDFA_INSTANCE==null)) SDFA_INSTANCE=new ShowDoubleFloatArrays();
if (this.debugLevel>2)System.out.println("calculateSensorMasks("+shrinkGridForMask+","+sigmaUV+")");
int decimate = eyesisCameraParameters.getDecimateMasks(chNum);
int width = eyesisCameraParameters.getSensorWidth(chNum);
......@@ -5375,7 +5372,6 @@ import ij.text.TextWindow;
int dWidth= (width -1)/decimate+1;
int dHeight= (height-1)/decimate+1;
DoubleGaussianBlur gb=new DoubleGaussianBlur();
if ((this.debugLevel>1) && (SDFA_INSTANCE==null)) SDFA_INSTANCE=new ShowDoubleFloatArrays();
if (this.debugLevel>2)System.out.println("calculateSensorMasks("+width+","+height+","+shrinkGridForMask+","+sigmaUV+")");
double [][] preMask=preCalculateSingleImageMask(imgNum, decimate, width, height, shrinkGridForMask);
if (preMask==null) return null; //nothing in this channel
......@@ -5465,7 +5461,7 @@ import ij.text.TextWindow;
}
String [] dbgTitles={"X","Y","iMask"};
this.SDFA_INSTANCE.showArrays(testArray, pXY[0].length, pXY.length, true, "original", dbgTitles);
ShowDoubleFloatArrays.showArrays(testArray, pXY[0].length, pXY.length, true, "original", dbgTitles);
}
// shrink the grid
......@@ -5491,7 +5487,7 @@ import ij.text.TextWindow;
}
String [] dbgTitles={"X","Y","iMask"};
this.SDFA_INSTANCE.showArrays(testArray1, pXY[0].length, pXY.length, true, "shrank", dbgTitles);
ShowDoubleFloatArrays.showArrays(testArray1, pXY[0].length, pXY.length, true, "shrank", dbgTitles);
}
// now in remaining grid nodes iMask[v][u]>0 (0 and negative - no grid)
......@@ -5717,8 +5713,8 @@ import ij.text.TextWindow;
}
}
if (bdebug) {
(new ShowDoubleFloatArrays()).showArrays(base_contrast, base_width, base_height, "base_sigma-"+sigma);
(new ShowDoubleFloatArrays()).showArrays(test_contrast, test_width, test_height, "test_sigma-"+sigma);
ShowDoubleFloatArrays.showArrays(base_contrast, base_width, base_height, "base_sigma-"+sigma);
ShowDoubleFloatArrays.showArrays(test_contrast, test_width, test_height, "test_sigma-"+sigma);
}
for (int dy = -search_rad; dy <= search_rad; dy++) {
......@@ -5740,7 +5736,7 @@ import ij.text.TextWindow;
}
}
if (bdebug) {
(new ShowDoubleFloatArrays()).showArrays(corr, "corr_sigma-"+sigma);
ShowDoubleFloatArrays.showArrays(corr, "corr_sigma-"+sigma);
}
int [] indx_max_even_odd = {-1,-1};
for (int i = 1; i < corr.length; i++) {
......
......@@ -6186,7 +6186,7 @@ public boolean LevenbergMarquardt(
}
index++;
}
(new ShowDoubleFloatArrays()). showArrays(
ShowDoubleFloatArrays. showArrays(
pixels,
width,
numSamples/width,
......
......@@ -50,9 +50,6 @@ horizontal axis:
64 - pulses per revolution
5682.48889 per degree
*/
private ShowDoubleFloatArrays sdfaInstance = new ShowDoubleFloatArrays(); // just
// for
// debugging
public CamerasInterface cameras = null;
public LwirReader lwirReader = null;
public Lwir16Reader lwir16Reader = null;
......@@ -886,7 +883,7 @@ horizontal axis:
double[] test_uv = new double[this.matchSimulatedPatterns[numSensor].UV_INDEX.length];
for (int i = 0; i < this.matchSimulatedPatterns[numSensor].UV_INDEX.length; i++)
test_uv[i] = this.matchSimulatedPatterns[numSensor].UV_INDEX[i];
sdfaInstance.showArrays(test_uv,
ShowDoubleFloatArrays.showArrays(test_uv,
this.matchSimulatedPatterns[numSensor].getImageWidth(),
this.matchSimulatedPatterns[numSensor].getImageHeight(), "UV_INDEX");
}
......
......@@ -34,10 +34,8 @@ import ij.gui.GenericDialog;
// Started to move methods from Aberration_Calibration
public class LensAdjustment {
private ShowDoubleFloatArrays sdfaInstance =new ShowDoubleFloatArrays(); // just for debugging?
// public int debugLevel=2;
public int updateFocusGrid(
public static int updateFocusGrid(
double x0, // lens center on the sensor
double y0, // lens center on the sensor
ImagePlus imp,
......@@ -195,7 +193,7 @@ public class LensAdjustment {
double [] test_masked=new double [matchSimulatedPattern.focusMask.length];
float [] pixels_eq=(float []) imp_eq.getProcessor().getPixels();
for (int i=0;i<test_masked.length;i++) test_masked[i]=matchSimulatedPattern.focusMask[i]?pixels_eq[i]:0.0;
sdfaInstance.showArrays(test_masked,matchSimulatedPattern.getImageWidth(), matchSimulatedPattern.getImageHeight(), "MASKED");
ShowDoubleFloatArrays.showArrays(test_masked,matchSimulatedPattern.getImageWidth(), matchSimulatedPattern.getImageHeight(), "MASKED");
}
}
......@@ -203,7 +201,7 @@ public class LensAdjustment {
if (debug_level>2) {
double [] test_uv=new double [matchSimulatedPattern.UV_INDEX.length];
for (int i=0;i<matchSimulatedPattern.UV_INDEX.length;i++) test_uv[i]=matchSimulatedPattern.UV_INDEX[i];
sdfaInstance.showArrays(test_uv,matchSimulatedPattern.getImageWidth(), matchSimulatedPattern.getImageHeight(), "UV_INDEX");
ShowDoubleFloatArrays.showArrays(test_uv,matchSimulatedPattern.getImageWidth(), matchSimulatedPattern.getImageHeight(), "UV_INDEX");
}
return numAbsolutePoints;
......
......@@ -45,7 +45,6 @@ public class SimulationPattern {
public double barraySigma=0.0;
public int debugLevel=2;
private DoubleGaussianBlur gb = new DoubleGaussianBlur();
private ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays(); // just for debugging?
public SimulationPattern (){
this.bPattern=null;
......@@ -135,9 +134,9 @@ public class SimulationPattern {
}
}
// apply blur
if (this.debugLevel>3) SDFA_INSTANCE.showArrays(bPatternM,sizeM,sizeM, "bPatternM");
if (this.debugLevel>3) ShowDoubleFloatArrays.showArrays(bPatternM,sizeM,sizeM, "bPatternM");
this.gb.blurDouble(bPatternM,sizeM,sizeM,size*this.bPatternSigma,size*this.bPatternSigma, 0.01);
if (this.debugLevel>3) SDFA_INSTANCE.showArrays(bPatternM,sizeM,sizeM, "bPatternM-blured");
if (this.debugLevel>3) ShowDoubleFloatArrays.showArrays(bPatternM,sizeM,sizeM, "bPatternM-blured");
// remove margins
for (i=0;i<size;i++) for (j=0;j<size;j++) {
this.bPattern[i*size+j]= bPatternM[(i+margin)*sizeM+(j+margin)];
......@@ -267,9 +266,9 @@ public class SimulationPattern {
// Blur barray pattern if sigma >0
if (this.barraySigma>0) {
double sigma=this.barraySigma*subdiv; //*/ 2?
if (this.debugLevel>3) SDFA_INSTANCE.showArrays(localBarray, "localBarray");
if (this.debugLevel>3) ShowDoubleFloatArrays.showArrays(localBarray, "localBarray");
this.gb.blurDouble(localBarray,fullSize,fullSize,sigma,sigma, 0.01);
if (this.debugLevel>3) SDFA_INSTANCE.showArrays(localBarray, "localBarray-blured");
if (this.debugLevel>3) ShowDoubleFloatArrays.showArrays(localBarray, "localBarray-blured");
}
return localBarray;
}
......@@ -626,7 +625,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
float [][] simArray=new float [2][];
simArray[0]=(new SimulationPattern(simulParameters)).combineWithCanvas(0.0, k*width, k*height, scaledWoi,simArray0[0]);
simArray[1]=(new SimulationPattern(simulParameters)).combineWithCanvas(0.0, k*width, k*height, scaledWoi,simArray0[1]);
if (globalDebugLevel>0) SDFA_INSTANCE.showArrays(simArray,width*k,height*k,true, "full-simulation");
if (globalDebugLevel>0) ShowDoubleFloatArrays.showArrays(simArray,width*k,height*k,true, "full-simulation");
return simArray;
}
......@@ -664,7 +663,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
threadsMax,
updateStatus,
debug_level); // debug level
if (globalDebugLevel>2) SDFA_INSTANCE.showArrays(simArray,matchSimulatedPattern.getWOI().width*simulParameters.subdiv/2,matchSimulatedPattern.getWOI().height*simulParameters.subdiv/2,true, "a-simulation");
if (globalDebugLevel>2) ShowDoubleFloatArrays.showArrays(simArray,matchSimulatedPattern.getWOI().width*simulParameters.subdiv/2,matchSimulatedPattern.getWOI().height*simulParameters.subdiv/2,true, "a-simulation");
if (globalDebugLevel>1) System.out.println("Grid simulation is finished at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
return simArray;
}
......@@ -989,7 +988,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
}
}
if (this.debugLevel>2) SDFA_INSTANCE.showArrays(simul_pixels,size,size, "SIMUL");
if (this.debugLevel>2) ShowDoubleFloatArrays.showArrays(simul_pixels,size,size, "SIMUL");
return simul_pixels;
}
......@@ -1071,7 +1070,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
for (int i=0;i<simul_pixels.length;i++) s+=simul_pixels[i];
System.out.println("sum of pixels="+s);
}
if (this.debugLevel>2) SDFA_INSTANCE.showArrays(simul_pixels,size,size, "SIMUL");
if (this.debugLevel>2) ShowDoubleFloatArrays.showArrays(simul_pixels,size,size, "SIMUL");
return simul_pixels;
}
......
......@@ -171,17 +171,17 @@ public class WavePatternGenerator {
mask[base+ix]=Math.exp(kLong*cLong*cLong+kLat*cLat*cLat);
}
}
(new ShowDoubleFloatArrays()).showArrays(data, "input data");
(new ShowDoubleFloatArrays()).showArrays(mask, "mask");
ShowDoubleFloatArrays.showArrays(data, "input data");
ShowDoubleFloatArrays.showArrays(mask, "mask");
DoubleFHT fht =new DoubleFHT();
fht.swapQuadrants(data);
fht.transform( data);
(new ShowDoubleFloatArrays()).showArrays(data, "FHT data");
ShowDoubleFloatArrays.showArrays(data, "FHT data");
for (int i=0;i<data.length;i++) data[i]*=mask[i];
(new ShowDoubleFloatArrays()).showArrays(data, "masked FHT data");
ShowDoubleFloatArrays.showArrays(data, "masked FHT data");
fht.inverseTransform(data);
fht.swapQuadrants (data);
// (new showDoubleFloatArrays()).showArrays(data, "restored data");
// ShowDoubleFloatArrays.showArrays(data, "restored data");
float [] pixels = new float [data.length];
if (binary) for (int i=0;i<data.length;i++) pixels[i] = (data[i]>0)?1.0f:0.0f;
else for (int i=0;i<data.length;i++) pixels[i] = (float) data[i];
......
......@@ -383,7 +383,14 @@ public class CLTParameters {
public boolean photo_debug = false; // Generate images and text
public double tex_disp_adiffo = 0.35; // 0.3; disparity absolute tolerance to connect in ortho directions
public double tex_disp_rdiffo = 0.12; // 0.1; disparity relative tolerance to connect in ortho directions
public double tex_disp_adiffd = 0.6; // 0.4; disparity absolute tolerance to connect in diagonal directions
public double tex_disp_rdiffd = 0.18; // 0.12; disparity relative tolerance to connect in diagonal directions
public double tex_disp_fof = 1.5; // Increase tolerance for friend of a friend
public double tex_fg_bg = 0.1; // Minimal FG/BG disparity difference (NaN bg if difference from FG < this)
public double tex_distort = 0.8; // Maximal texture distortion to accumulate multiple scenes (0 - any)
public double tex_mb = 1.0; // Reduce texture weight if motion blur exceeds this (as square of MB length)
public boolean show_textures = true; // show generated textures
public boolean debug_filters = false;// show intermediate results of filtering
......@@ -1378,6 +1385,15 @@ public class CLTParameters {
properties.setProperty(prefix+"photo_offs", this.photo_offs+""); // double
properties.setProperty(prefix+"photo_debug", this.photo_debug+""); // boolean
properties.setProperty(prefix+"tex_disp_adiffo", this.tex_disp_adiffo+""); // double
properties.setProperty(prefix+"tex_disp_rdiffo", this.tex_disp_rdiffo+""); // double
properties.setProperty(prefix+"tex_disp_adiffd", this.tex_disp_adiffd+""); // double
properties.setProperty(prefix+"tex_disp_rdiffd", this.tex_disp_rdiffd+""); // double
properties.setProperty(prefix+"tex_disp_fof", this.tex_disp_fof+""); // double
properties.setProperty(prefix+"tex_fg_bg", this.tex_fg_bg+""); // double
properties.setProperty(prefix+"tex_distort", this.tex_distort+""); // double
properties.setProperty(prefix+"tex_mb", this.tex_mb+""); // double
properties.setProperty(prefix+"show_textures", this.show_textures+"");
properties.setProperty(prefix+"debug_filters", this.debug_filters+"");
......@@ -2249,6 +2265,15 @@ public class CLTParameters {
if (properties.getProperty(prefix+"photo_offs")!=null) this.photo_offs=Double.parseDouble(properties.getProperty(prefix+"photo_offs"));
if (properties.getProperty(prefix+"photo_debug")!=null) this.photo_debug=Boolean.parseBoolean(properties.getProperty(prefix+"photo_debug"));
if (properties.getProperty(prefix+"tex_disp_adiffo")!=null) this.tex_disp_adiffo=Double.parseDouble(properties.getProperty(prefix+"tex_disp_adiffo"));
if (properties.getProperty(prefix+"tex_disp_rdiffo")!=null) this.tex_disp_rdiffo=Double.parseDouble(properties.getProperty(prefix+"tex_disp_rdiffo"));
if (properties.getProperty(prefix+"tex_disp_adiffd")!=null) this.tex_disp_adiffd=Double.parseDouble(properties.getProperty(prefix+"tex_disp_adiffd"));
if (properties.getProperty(prefix+"tex_disp_rdiffd")!=null) this.tex_disp_rdiffd=Double.parseDouble(properties.getProperty(prefix+"tex_disp_rdiffd"));
if (properties.getProperty(prefix+"tex_disp_fof")!=null) this.tex_disp_fof=Double.parseDouble(properties.getProperty(prefix+"tex_disp_fof"));
if (properties.getProperty(prefix+"tex_fg_bg")!=null) this.tex_fg_bg=Double.parseDouble(properties.getProperty(prefix+"tex_fg_bg"));
if (properties.getProperty(prefix+"tex_distort")!=null) this.tex_distort=Double.parseDouble(properties.getProperty(prefix+"tex_distort"));
if (properties.getProperty(prefix+"tex_mb")!=null) this.tex_mb=Double.parseDouble(properties.getProperty(prefix+"tex_mb"));
if (properties.getProperty(prefix+"show_textures")!=null) this.show_textures=Boolean.parseBoolean(properties.getProperty(prefix+"show_textures"));
if (properties.getProperty(prefix+"debug_filters")!=null) this.debug_filters=Boolean.parseBoolean(properties.getProperty(prefix+"debug_filters"));
......@@ -3271,6 +3296,24 @@ public class CLTParameters {
"Generate debug images an text output.");
gd.addTab ("3D", "3D reconstruction");
gd.addMessage ("Meshes clustering for texture generation");
gd.addNumericField("Ortho tolerance absolute", this.tex_disp_adiffo, 5,7,"pix",
"Disparity absolute tolerance to connect in ortho directions.");
gd.addNumericField("Ortho tolerance relative", this.tex_disp_rdiffo, 5,7,"pix",
"Disparity relative tolerance to connect in ortho directions.");
gd.addNumericField("Diagonal tolerance absolute", this.tex_disp_adiffd, 5,7,"pix",
"Disparity absolute tolerance to connect in diagonal directions.");
gd.addNumericField("Diagonal tolerance relative", this.tex_disp_rdiffd, 5,7,"pix",
"Disparity relative tolerance to connect in diagonal directions.");
gd.addNumericField("Relax friend-of-a friend tolerance", this.tex_disp_fof, 5,7,"",
"Relax (increase disparity) tolerance for friend of a friend.");
gd.addNumericField("Minimal FG/BG disparity separation", this.tex_fg_bg, 5,7,"pix",
"Minimal FG/BG disparity difference (NaN bg if difference from FG < this).");
gd.addNumericField("Multiscene texture distortion", this.tex_distort, 5,7,"pix",
"Maximal texture distortion to accumulate multiple scenes (neighbor tile center offset from the uniform grid. 0 - do not filter");
gd.addNumericField("Maximal motion blur to reduce weight",this.tex_mb, 5,7,"pix",
"Reduce texture weight if motion blur exceeds this (as square of MB length).");
gd.addMessage ("Earlier 3D generation parameters");
gd.addCheckbox ("Show generated textures", this.show_textures);
gd.addCheckbox ("show intermediate results of filtering", this.debug_filters);
......@@ -4275,9 +4318,17 @@ public class CLTParameters {
this.photo_offs_set = (int) gd.getNextNumber();
this.photo_offs = gd.getNextNumber();
this.photo_debug = gd.getNextBoolean();
this.tex_disp_adiffo = gd.getNextNumber();
this.tex_disp_rdiffo = gd.getNextNumber();
this.tex_disp_adiffd = gd.getNextNumber();
this.tex_disp_rdiffd = gd.getNextNumber();
this.tex_disp_fof = gd.getNextNumber();
this.tex_fg_bg = gd.getNextNumber();
this.tex_distort = gd.getNextNumber();
this.tex_mb = gd.getNextNumber();
this.show_textures= gd.getNextBoolean();
this.debug_filters= gd.getNextBoolean();
this.min_smth= gd.getNextNumber();
......
......@@ -61,7 +61,6 @@ public class DoubleFHT {
private double [] translateFHTdXY=null;
private int translateFHTN=0;
public boolean debug=false;
private ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays(); // just for debugging?
public DoubleFHT() {
this.C = null;
this.S = null;
......@@ -502,18 +501,18 @@ public class DoubleFHT {
double [] data,
double dx,
double dy){
if (debug) SDFA_INSTANCE.showArrays(data, "source-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
if (debug) ShowDoubleFloatArrays.showArrays(data, "source-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
swapQuadrants(data);
if (!transform(data,false)) return null; // direct FHT
if ((this.maxN!=translateFHTN) || (dx!=translateFHTdXY[0]) || (dy!=translateFHTdXY[1])){
calcTranslateFHT(dx,dy);
}