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 { ...@@ -613,7 +613,6 @@ public class CalibrationIllustration {
} }
} }
} }
// (new ShowDoubleFloatArrays()).showArrays(rslt, wh[0],wh[1], true,"kernels_compressed");
return nonzero ? rslt : null; return nonzero ? rslt : null;
} }
...@@ -638,7 +637,7 @@ public class CalibrationIllustration { ...@@ -638,7 +637,7 @@ public class CalibrationIllustration {
pseudo_pixels[3][i] = 1.0; // alpha pseudo_pixels[3][i] = 1.0; // alpha
} }
String [] rgb_titles = {"red","green","blue","alpha"}; String [] rgb_titles = {"red","green","blue","alpha"};
ImageStack stack = (new ShowDoubleFloatArrays()).makeStack( ImageStack stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, pseudo_pixels,
width, width,
dpixels.length/width, dpixels.length/width,
...@@ -680,7 +679,7 @@ public class CalibrationIllustration { ...@@ -680,7 +679,7 @@ public class CalibrationIllustration {
pseudo_pixels[3][i] = 1.0; // alpha pseudo_pixels[3][i] = 1.0; // alpha
} }
String [] rgb_titles = {"red","green","blue","alpha"}; String [] rgb_titles = {"red","green","blue","alpha"};
ImageStack stack = (new ShowDoubleFloatArrays()).makeStack( ImageStack stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, pseudo_pixels,
width, width,
dpixels[0].length/width, dpixels[0].length/width,
...@@ -840,7 +839,6 @@ public class CalibrationIllustration { ...@@ -840,7 +839,6 @@ public class CalibrationIllustration {
(1 << LwirReaderParameters.TYPE_LWIR), // final int types_mask, // +1 - TYPE_EO, +2 - TYPE_LWIR (1 << LwirReaderParameters.TYPE_LWIR), // final int types_mask, // +1 - TYPE_EO, +2 - TYPE_LWIR
null); // final double [][] pixels) // if not null - will fill null); // final double [][] pixels) // if not null - will fill
windows = getWindows (imps,illustrationParameters.auto_range_wnd_type); windows = getWindows (imps,illustrationParameters.auto_range_wnd_type);
// (new ShowDoubleFloatArrays()).showArrays(windows, width, height, true, "windows");
double [][] offs_gains = balanceOffsGains( double [][] offs_gains = balanceOffsGains(
balancing_scenes, // CapturedScene [] scenes, balancing_scenes, // CapturedScene [] scenes,
windows, // double [][] window, windows, // double [][] window,
...@@ -1081,7 +1079,7 @@ public class CalibrationIllustration { ...@@ -1081,7 +1079,7 @@ public class CalibrationIllustration {
} }
String [] rgb_titles = {"red","green","blue","alpha"}; String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack( stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data, pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size, width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size, height, // (tilesY + 0) * clt_parameters.transform_size,
...@@ -1477,7 +1475,7 @@ public class CalibrationIllustration { ...@@ -1477,7 +1475,7 @@ public class CalibrationIllustration {
} }
String [] rgb_titles = {"red","green","blue","alpha"}; String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack( stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data, pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size, width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size, height, // (tilesY + 0) * clt_parameters.transform_size,
...@@ -1552,7 +1550,7 @@ public class CalibrationIllustration { ...@@ -1552,7 +1550,7 @@ public class CalibrationIllustration {
String [] rgb_titles = {"red","green","blue","alpha"}; String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack( stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data, pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size, width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size, height, // (tilesY + 0) * clt_parameters.transform_size,
...@@ -2194,7 +2192,7 @@ public class CalibrationIllustration { ...@@ -2194,7 +2192,7 @@ public class CalibrationIllustration {
} }
String [] rgb_titles = {"red","green","blue","alpha"}; String [] rgb_titles = {"red","green","blue","alpha"};
stack = (new ShowDoubleFloatArrays()).makeStack( stack = ShowDoubleFloatArrays.makeStack(
pseudo_pixels, // iclt_data, pseudo_pixels, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size, width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size, height, // (tilesY + 0) * clt_parameters.transform_size,
......
...@@ -37,7 +37,7 @@ public class DeBayerScissors { ...@@ -37,7 +37,7 @@ public class DeBayerScissors {
private double [][][] lopass=null; private double [][][] lopass=null;
private int size; private int size;
private double lastMidEnergy; // last midrange spectral energy 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 DoubleFHT fht_instance;
private int [][] aliasMapRedBlue={ private int [][] aliasMapRedBlue={
{-2,-2},{-2,-1},{-2,0},{-2,1}, {-2,-2},{-2,-1},{-2,0},{-2,1},
...@@ -56,7 +56,6 @@ public class DeBayerScissors { ...@@ -56,7 +56,6 @@ public class DeBayerScissors {
double debayer_width_redblue_clones){// green mask when applied to red/blue, clones double debayer_width_redblue_clones){// green mask when applied to red/blue, clones
size=isize; size=isize;
fht_instance= new DoubleFHT(); 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 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, Math.PI,
size/2-2, // width of the polar array - should be <= size/2-2 size/2-2, // width of the polar array - should be <= size/2-2
...@@ -118,7 +117,7 @@ public class DeBayerScissors { ...@@ -118,7 +117,7 @@ public class DeBayerScissors {
for (i=0;i<green_amp.length;i++) if (green_amp[i]>dmax) dmax=green_amp[i]; for (i=0;i<green_amp.length;i++) if (green_amp[i]>dmax) dmax=green_amp[i];
dmax=1.0/dmax; dmax=1.0/dmax;
for (i=0;i<green_amp.length;i++) green_amp[i]= Math.pow(green_amp[i]*dmax,debayer_gamma); 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); double midRangeSpectral=pol_instace.maxAmpInRing (green_amp);
boolean useFancyDebayer=(midRangeSpectral>=debayer_threshold); boolean useFancyDebayer=(midRangeSpectral>=debayer_threshold);
...@@ -130,10 +129,10 @@ public class DeBayerScissors { ...@@ -130,10 +129,10 @@ public class DeBayerScissors {
debayer_bonus, // hack - here it is "bonus" debayer_bonus, // hack - here it is "bonus"
this_debug);// 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) { if (debayer_mask_blur>0) {
blurDouble(green_mask, size, debayer_mask_blur, debayer_mask_blur, 0.01); 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_main= green_mask.clone();
double [] green_mask_for_redblue_clones=green_mask.clone(); double [] green_mask_for_redblue_clones=green_mask.clone();
...@@ -143,8 +142,8 @@ public class DeBayerScissors { ...@@ -143,8 +142,8 @@ public class DeBayerScissors {
} }
if (this_debug>2) { if (this_debug>2) {
SDFA_instance.showArrays(green_mask_for_redblue_main, "MAIN"); ShowDoubleFloatArrays.showArrays(green_mask_for_redblue_main, "MAIN");
SDFA_instance.showArrays(green_mask_for_redblue_main, "CLONES"); ShowDoubleFloatArrays.showArrays(green_mask_for_redblue_main, "CLONES");
} }
/* Maybe here we need to unmasked (wide bandwidth) green_amp? */ /* Maybe here we need to unmasked (wide bandwidth) green_amp? */
...@@ -159,10 +158,10 @@ public class DeBayerScissors { ...@@ -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) */ /* 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) { if (debayer_mask_blur>0) {
blurDouble(red_blue_mask, size,debayer_mask_blur, debayer_mask_blur, 0.01); 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]; 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 } else { // debayer_mask_blur<0 : use default masks
...@@ -180,7 +179,7 @@ public class DeBayerScissors { ...@@ -180,7 +179,7 @@ public class DeBayerScissors {
double [][] result =new double [2][]; double [][] result =new double [2][];
result[0]= green_mask; result[0]= green_mask;
result[1]= red_blue_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 */ /* normalize masks to have exactly 1.0 at 0:0 - it can be reduced by blurring */
...@@ -188,7 +187,7 @@ public class DeBayerScissors { ...@@ -188,7 +187,7 @@ public class DeBayerScissors {
dmax=1.0/result[i][0]; dmax=1.0/result[i][0];
for (j=0;j<result[i].length;j++) result[i][j]*=dmax; 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; return result;
} }
...@@ -224,8 +223,8 @@ public class DeBayerScissors { ...@@ -224,8 +223,8 @@ public class DeBayerScissors {
{ 1,-2},{ 1,-1},{ 1,0},{ 1,1}}; { 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 // 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) ShowDoubleFloatArrays.showArrays(amp.clone(), "amp");
if (this_debug>2) SDFA_instance.showArrays(amp_clones, "amp_clones"); if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp_clones, "amp_clones");
for (i=0;i<=hsize;i++) for (j=0;j<size;j++) { for (i=0;i<=hsize;i++) for (j=0;j<size;j++) {
index=i*size+j; index=i*size+j;
...@@ -275,8 +274,8 @@ public class DeBayerScissors { ...@@ -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 // 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) ShowDoubleFloatArrays.showArrays(amp.clone(), "amp");
if (this_debug>2) SDFA_instance.showArrays(amp_clones, "amp_clones"); if (this_debug>2) ShowDoubleFloatArrays.showArrays(amp_clones, "amp_clones");
for (i=0;i<=hsize;i++) for (j=0;j<size;j++) { for (i=0;i<=hsize;i++) for (j=0;j<size;j++) {
index = speedTable[i][j][0][0]; // i*size+j; index = speedTable[i][j][0][0]; // i*size+j;
...@@ -297,30 +296,30 @@ public class DeBayerScissors { ...@@ -297,30 +296,30 @@ public class DeBayerScissors {
// End of replacement code // 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; if (pol_instace==null) return mask;
/* Now apply mask to amplitudes and use ray processing (same as with greens)*/ /* Now apply mask to amplitudes and use ray processing (same as with greens)*/
for (i=0;i<amp.length;i++) amp[i]*=mask[i]; 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); double [] polar_amp=pol_instace.cartesianToPolar(amp);
int width = pol_instace.getWidth(); int width = pol_instace.getWidth();
int height = pol_instace.getHeight(); 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; 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; 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 [] 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); double [] cart_mask_pixels= pol_instace.polarToCartesian (polar_mask_pixels,size,0.0);
if (this_debug>2) { if (this_debug>2) {
SDFA_instance.showArrays(polar_amp, width, height, "RB-amp-bonus"); ShowDoubleFloatArrays.showArrays(polar_amp, width, height, "RB-amp-bonus");
SDFA_instance.showArrays(polar_mask_pixels, width, height, "pRBm"); ShowDoubleFloatArrays.showArrays(polar_mask_pixels, width, height, "pRBm");
SDFA_instance.showArrays(cart_mask_pixels, size, size, "cRBm"); ShowDoubleFloatArrays.showArrays(cart_mask_pixels, size, size, "cRBm");
} }
if (this_debug>2) { if (this_debug>2) {
double [] polar_mask_pixels1=pol_instace.genPolarRedBlueMask(polar_amp,1); double [] polar_mask_pixels1=pol_instace.genPolarRedBlueMask(polar_amp,1);
double [] cart_mask_pixels1= pol_instace.polarToCartesian (polar_mask_pixels1,size,0.0); double [] cart_mask_pixels1= pol_instace.polarToCartesian (polar_mask_pixels1,size,0.0);
SDFA_instance.showArrays(polar_mask_pixels1, width, height, "pRBm1"); ShowDoubleFloatArrays.showArrays(polar_mask_pixels1, width, height, "pRBm1");
SDFA_instance.showArrays(cart_mask_pixels1, size, size, "cRBm1"); ShowDoubleFloatArrays.showArrays(cart_mask_pixels1, size, size, "cRBm1");
} }
return cart_mask_pixels; return cart_mask_pixels;
...@@ -334,23 +333,23 @@ public class DeBayerScissors { ...@@ -334,23 +333,23 @@ public class DeBayerScissors {
int length=amp_pixels.length; int length=amp_pixels.length;
int size = (int) Math.sqrt(length); int size = (int) Math.sqrt(length);
double [] polar_amp_pixels=pol_instace.cartesianToPolar(amp_pixels); 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(); 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; 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 [] 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); double [] cart_green_mask_pixels= pol_instace.polarToCartesian (polar_green_mask_pixels,size,0.0);
if (this_debug>2) { if (this_debug>2) {
SDFA_instance.showArrays(polar_amp_pixels, pol_instace.getWidth(),pol_instace.getHeight(), "amp-bonus"); ShowDoubleFloatArrays.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"); ShowDoubleFloatArrays.showArrays(polar_green_mask_pixels,pol_instace.getWidth(),pol_instace.getHeight(), "pgm");
SDFA_instance.showArrays(cart_green_mask_pixels,size,size, "cgm"); ShowDoubleFloatArrays.showArrays(cart_green_mask_pixels,size,size, "cgm");
} }
if (this_debug>2) { if (this_debug>2) {
double [] polar_green_mask_pixels1=pol_instace.genPolarGreenMask(polar_amp_pixels,1); 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); 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"); ShowDoubleFloatArrays.showArrays(polar_green_mask_pixels1,pol_instace.getWidth(),pol_instace.getHeight(), "PGM1");
SDFA_instance.showArrays(cart_green_mask_pixels1,size,size, "CGM1"); ShowDoubleFloatArrays.showArrays(cart_green_mask_pixels1,size,size, "CGM1");
} }
return cart_green_mask_pixels; return cart_green_mask_pixels;
......
...@@ -169,8 +169,7 @@ public class DebayerScissorsClass { ...@@ -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 ? */ /* 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; for (i=0;i<tile[greenChn].length;i++) tile[greenChn][i]*=0.5;
if ((tileY==yTileDebug) && (tileX==xTileDebug)) { if ((tileY==yTileDebug) && (tileX==xTileDebug)) {
if (SDFA_instance==null) SDFA_instance= new ShowDoubleFloatArrays(); ShowDoubleFloatArrays.showArrays (tile.clone(),debayerParameters.size,debayerParameters.size, "x"+(tileX*step)+"_y"+(tileY*step));
SDFA_instance.showArrays (tile.clone(),debayerParameters.size,debayerParameters.size, "x"+(tileX*step)+"_y"+(tileY*step));
} }
for (chn=0;chn<nChn;chn++){ for (chn=0;chn<nChn;chn++){
fht_instance.swapQuadrants(tile[chn]); fht_instance.swapQuadrants(tile[chn]);
......
...@@ -91,7 +91,7 @@ import ij.text.TextWindow; ...@@ -91,7 +91,7 @@ import ij.text.TextWindow;
//pixelsXY, pixelsUV should match, second dimension is variable //pixelsXY, pixelsUV should match, second dimension is variable
public boolean updateStatus=true; public boolean updateStatus=true;
public int debugLevel=2; 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) { public static int pathToChannel(String path) {
int last_dash = path.lastIndexOf('-'); int last_dash = path.lastIndexOf('-');
...@@ -438,7 +438,7 @@ import ij.text.TextWindow; ...@@ -438,7 +438,7 @@ import ij.text.TextWindow;
} }
} }
} }
(new ShowDoubleFloatArrays()).showArrays( ShowDoubleFloatArrays.showArrays(
dbg_img, dbg_img,
width, width,
height, height,
...@@ -4264,7 +4264,7 @@ import ij.text.TextWindow; ...@@ -4264,7 +4264,7 @@ import ij.text.TextWindow;
dbgData[0]=diffs2.clone(); dbgData[0]=diffs2.clone();
dbgData[2]=dbgData[0].clone(); dbgData[2]=dbgData[0].clone();
for (int i=0;i< dbgData[2].length;i++) if (!localWorst[i]) dbgData[2][i]=-1.0; 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) { if (replaceBad) {
...@@ -4449,7 +4449,7 @@ import ij.text.TextWindow; ...@@ -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"}; 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}; int [] nums = {numWorst, numBad};
return nums; return nums;
...@@ -5201,7 +5201,6 @@ import ij.text.TextWindow; ...@@ -5201,7 +5201,6 @@ import ij.text.TextWindow;
int numChannels=getNumChannels(); int numChannels=getNumChannels();
this.sensorMasks=new double [numChannels][]; this.sensorMasks=new double [numChannels][];
DoubleGaussianBlur gb=new DoubleGaussianBlur(); 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+")"); if (this.debugLevel>2)System.out.println("calculateSensorMasks("+width+","+height+","+shrinkGridForMask+","+sigmaUV+")");
for (int chNum=0;chNum<numChannels; chNum++){ for (int chNum=0;chNum<numChannels; chNum++){
this.sensorMasks[chNum]=new double[dWidth*dHeight]; this.sensorMasks[chNum]=new double[dWidth*dHeight];
...@@ -5233,7 +5232,6 @@ import ij.text.TextWindow; ...@@ -5233,7 +5232,6 @@ import ij.text.TextWindow;
int numChannels=getNumChannels(); int numChannels=getNumChannels();
this.sensorMasks=new double [numChannels][]; this.sensorMasks=new double [numChannels][];
DoubleGaussianBlur gb=new DoubleGaussianBlur(); 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+")"); if (this.debugLevel>2)System.out.println("calculateSensorMasks("+shrinkGridForMask+","+sigmaUV+")");
for (int chNum=0;chNum<numChannels; chNum++){ for (int chNum=0;chNum<numChannels; chNum++){
int decimate = eyesisCameraParameters.getDecimateMasks(chNum); int decimate = eyesisCameraParameters.getDecimateMasks(chNum);
...@@ -5259,7 +5257,7 @@ import ij.text.TextWindow; ...@@ -5259,7 +5257,7 @@ import ij.text.TextWindow;
if(sigma<0) sigma*=-rAverage; if(sigma<0) sigma*=-rAverage;
gb.blurDouble(this.sensorMasks[chNum], dWidth, dHeight, sigma/decimate, sigma/decimate, 0.01); gb.blurDouble(this.sensorMasks[chNum], dWidth, dHeight, sigma/decimate, sigma/decimate, 0.01);
if (this.debugLevel >1) { if (this.debugLevel >1) {
(new ShowDoubleFloatArrays()).showArrays( ShowDoubleFloatArrays.showArrays(
this.sensorMasks[chNum], this.sensorMasks[chNum],
dWidth, dWidth,
dHeight, dHeight,
...@@ -5271,7 +5269,6 @@ import ij.text.TextWindow; ...@@ -5271,7 +5269,6 @@ import ij.text.TextWindow;
public double [] calculateSensorMasks(int chNum, int shrinkGridForMask, double sigmaUV) { public double [] calculateSensorMasks(int chNum, int shrinkGridForMask, double sigmaUV) {
DoubleGaussianBlur gb=new DoubleGaussianBlur(); 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+")"); if (this.debugLevel>2)System.out.println("calculateSensorMasks("+shrinkGridForMask+","+sigmaUV+")");
int decimate = eyesisCameraParameters.getDecimateMasks(chNum); int decimate = eyesisCameraParameters.getDecimateMasks(chNum);
int width = eyesisCameraParameters.getSensorWidth(chNum); int width = eyesisCameraParameters.getSensorWidth(chNum);
...@@ -5375,7 +5372,6 @@ import ij.text.TextWindow; ...@@ -5375,7 +5372,6 @@ import ij.text.TextWindow;
int dWidth= (width -1)/decimate+1; int dWidth= (width -1)/decimate+1;
int dHeight= (height-1)/decimate+1; int dHeight= (height-1)/decimate+1;
DoubleGaussianBlur gb=new DoubleGaussianBlur(); 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+")"); if (this.debugLevel>2)System.out.println("calculateSensorMasks("+width+","+height+","+shrinkGridForMask+","+sigmaUV+")");
double [][] preMask=preCalculateSingleImageMask(imgNum, decimate, width, height, shrinkGridForMask); double [][] preMask=preCalculateSingleImageMask(imgNum, decimate, width, height, shrinkGridForMask);
if (preMask==null) return null; //nothing in this channel if (preMask==null) return null; //nothing in this channel
...@@ -5465,7 +5461,7 @@ import ij.text.TextWindow; ...@@ -5465,7 +5461,7 @@ import ij.text.TextWindow;
} }
String [] dbgTitles={"X","Y","iMask"}; 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 // shrink the grid
...@@ -5491,7 +5487,7 @@ import ij.text.TextWindow; ...@@ -5491,7 +5487,7 @@ import ij.text.TextWindow;
} }
String [] dbgTitles={"X","Y","iMask"}; 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) // now in remaining grid nodes iMask[v][u]>0 (0 and negative - no grid)
...@@ -5717,8 +5713,8 @@ import ij.text.TextWindow; ...@@ -5717,8 +5713,8 @@ import ij.text.TextWindow;
} }
} }
if (bdebug) { if (bdebug) {
(new ShowDoubleFloatArrays()).showArrays(base_contrast, base_width, base_height, "base_sigma-"+sigma); 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(test_contrast, test_width, test_height, "test_sigma-"+sigma);
} }
for (int dy = -search_rad; dy <= search_rad; dy++) { for (int dy = -search_rad; dy <= search_rad; dy++) {
...@@ -5740,7 +5736,7 @@ import ij.text.TextWindow; ...@@ -5740,7 +5736,7 @@ import ij.text.TextWindow;
} }
} }
if (bdebug) { if (bdebug) {
(new ShowDoubleFloatArrays()).showArrays(corr, "corr_sigma-"+sigma); ShowDoubleFloatArrays.showArrays(corr, "corr_sigma-"+sigma);
} }
int [] indx_max_even_odd = {-1,-1}; int [] indx_max_even_odd = {-1,-1};
for (int i = 1; i < corr.length; i++) { for (int i = 1; i < corr.length; i++) {
......
...@@ -6186,7 +6186,7 @@ public boolean LevenbergMarquardt( ...@@ -6186,7 +6186,7 @@ public boolean LevenbergMarquardt(
} }
index++; index++;
} }
(new ShowDoubleFloatArrays()). showArrays( ShowDoubleFloatArrays. showArrays(
pixels, pixels,
width, width,
numSamples/width, numSamples/width,
......
...@@ -50,9 +50,6 @@ horizontal axis: ...@@ -50,9 +50,6 @@ horizontal axis:
64 - pulses per revolution 64 - pulses per revolution
5682.48889 per degree 5682.48889 per degree
*/ */
private ShowDoubleFloatArrays sdfaInstance = new ShowDoubleFloatArrays(); // just
// for
// debugging
public CamerasInterface cameras = null; public CamerasInterface cameras = null;
public LwirReader lwirReader = null; public LwirReader lwirReader = null;
public Lwir16Reader lwir16Reader = null; public Lwir16Reader lwir16Reader = null;
...@@ -886,7 +883,7 @@ horizontal axis: ...@@ -886,7 +883,7 @@ horizontal axis:
double[] test_uv = new double[this.matchSimulatedPatterns[numSensor].UV_INDEX.length]; double[] test_uv = new double[this.matchSimulatedPatterns[numSensor].UV_INDEX.length];
for (int i = 0; i < this.matchSimulatedPatterns[numSensor].UV_INDEX.length; i++) for (int i = 0; i < this.matchSimulatedPatterns[numSensor].UV_INDEX.length; i++)
test_uv[i] = this.matchSimulatedPatterns[numSensor].UV_INDEX[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].getImageWidth(),
this.matchSimulatedPatterns[numSensor].getImageHeight(), "UV_INDEX"); this.matchSimulatedPatterns[numSensor].getImageHeight(), "UV_INDEX");
} }
......
...@@ -34,10 +34,8 @@ import ij.gui.GenericDialog; ...@@ -34,10 +34,8 @@ import ij.gui.GenericDialog;
// Started to move methods from Aberration_Calibration // Started to move methods from Aberration_Calibration
public class LensAdjustment { 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 x0, // lens center on the sensor
double y0, // lens center on the sensor double y0, // lens center on the sensor
ImagePlus imp, ImagePlus imp,
...@@ -195,7 +193,7 @@ public class LensAdjustment { ...@@ -195,7 +193,7 @@ public class LensAdjustment {
double [] test_masked=new double [matchSimulatedPattern.focusMask.length]; double [] test_masked=new double [matchSimulatedPattern.focusMask.length];
float [] pixels_eq=(float []) imp_eq.getProcessor().getPixels(); 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; 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 { ...@@ -203,7 +201,7 @@ public class LensAdjustment {
if (debug_level>2) { if (debug_level>2) {
double [] test_uv=new double [matchSimulatedPattern.UV_INDEX.length]; 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]; 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; return numAbsolutePoints;
......
...@@ -45,7 +45,6 @@ public class SimulationPattern { ...@@ -45,7 +45,6 @@ public class SimulationPattern {
public double barraySigma=0.0; public double barraySigma=0.0;
public int debugLevel=2; public int debugLevel=2;
private DoubleGaussianBlur gb = new DoubleGaussianBlur(); private DoubleGaussianBlur gb = new DoubleGaussianBlur();
private ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays(); // just for debugging?
public SimulationPattern (){ public SimulationPattern (){
this.bPattern=null; this.bPattern=null;
...@@ -135,9 +134,9 @@ public class SimulationPattern { ...@@ -135,9 +134,9 @@ public class SimulationPattern {
} }
} }
// apply blur // 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); 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 // remove margins
for (i=0;i<size;i++) for (j=0;j<size;j++) { for (i=0;i<size;i++) for (j=0;j<size;j++) {
this.bPattern[i*size+j]= bPatternM[(i+margin)*sizeM+(j+margin)]; this.bPattern[i*size+j]= bPatternM[(i+margin)*sizeM+(j+margin)];
...@@ -267,9 +266,9 @@ public class SimulationPattern { ...@@ -267,9 +266,9 @@ public class SimulationPattern {
// Blur barray pattern if sigma >0 // Blur barray pattern if sigma >0
if (this.barraySigma>0) { if (this.barraySigma>0) {
double sigma=this.barraySigma*subdiv; //*/ 2? 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); 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; return localBarray;
} }
...@@ -626,7 +625,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy) ...@@ -626,7 +625,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>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; return simArray;
} }
...@@ -664,7 +663,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy) ...@@ -664,7 +663,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
threadsMax, threadsMax,
updateStatus, updateStatus,
debug_level); // debug level 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)); if (globalDebugLevel>1) System.out.println("Grid simulation is finished at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
return simArray; return simArray;
} }
...@@ -989,7 +988,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy) ...@@ -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; return simul_pixels;
} }
...@@ -1071,7 +1070,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy) ...@@ -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]; for (int i=0;i<simul_pixels.length;i++) s+=simul_pixels[i];
System.out.println("sum of pixels="+s); 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; return simul_pixels;
} }
......
...@@ -171,17 +171,17 @@ public class WavePatternGenerator { ...@@ -171,17 +171,17 @@ public class WavePatternGenerator {
mask[base+ix]=Math.exp(kLong*cLong*cLong+kLat*cLat*cLat); mask[base+ix]=Math.exp(kLong*cLong*cLong+kLat*cLat*cLat);
} }
} }
(new ShowDoubleFloatArrays()).showArrays(data, "input data"); ShowDoubleFloatArrays.showArrays(data, "input data");
(new ShowDoubleFloatArrays()).showArrays(mask, "mask"); ShowDoubleFloatArrays.showArrays(mask, "mask");
DoubleFHT fht =new DoubleFHT(); DoubleFHT fht =new DoubleFHT();
fht.swapQuadrants(data); fht.swapQuadrants(data);
fht.transform( 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]; 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.inverseTransform(data);
fht.swapQuadrants (data); fht.swapQuadrants (data);
// (new showDoubleFloatArrays()).showArrays(data, "restored data"); // ShowDoubleFloatArrays.showArrays(data, "restored data");
float [] pixels = new float [data.length]; 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; 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]; else for (int i=0;i<data.length;i++) pixels[i] = (float) data[i];
......
...@@ -383,7 +383,14 @@ public class CLTParameters { ...@@ -383,7 +383,14 @@ public class CLTParameters {
public boolean photo_debug = false; // Generate images and text 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 show_textures = true; // show generated textures
public boolean debug_filters = false;// show intermediate results of filtering public boolean debug_filters = false;// show intermediate results of filtering
...@@ -1378,6 +1385,15 @@ public class CLTParameters { ...@@ -1378,6 +1385,15 @@ public class CLTParameters {
properties.setProperty(prefix+"photo_offs", this.photo_offs+""); // double properties.setProperty(prefix+"photo_offs", this.photo_offs+""); // double
properties.setProperty(prefix+"photo_debug", this.photo_debug+""); // boolean 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+"show_textures", this.show_textures+"");
properties.setProperty(prefix+"debug_filters", this.debug_filters+""); properties.setProperty(prefix+"debug_filters", this.debug_filters+"");
...@@ -2249,6 +2265,15 @@ public class CLTParameters { ...@@ -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_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+"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+"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")); if (properties.getProperty(prefix+"debug_filters")!=null) this.debug_filters=Boolean.parseBoolean(properties.getProperty(prefix+"debug_filters"));
...@@ -3271,6 +3296,24 @@ public class CLTParameters { ...@@ -3271,6 +3296,24 @@ public class CLTParameters {
"Generate debug images an text output."); "Generate debug images an text output.");
gd.addTab ("3D", "3D reconstruction"); 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 generated textures", this.show_textures);
gd.addCheckbox ("show intermediate results of filtering", this.debug_filters); gd.addCheckbox ("show intermediate results of filtering", this.debug_filters);
...@@ -4275,9 +4318,17 @@ public class CLTParameters { ...@@ -4275,9 +4318,17 @@ public class CLTParameters {
this.photo_offs_set = (int) gd.getNextNumber(); this.photo_offs_set = (int) gd.getNextNumber();
this.photo_offs = gd.getNextNumber(); this.photo_offs = gd.getNextNumber();
this.photo_debug = gd.getNextBoolean(); 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.show_textures= gd.getNextBoolean();
this.debug_filters= gd.getNextBoolean(); this.debug_filters= gd.getNextBoolean();
this.min_smth= gd.getNextNumber(); this.min_smth= gd.getNextNumber();
......
...@@ -61,7 +61,6 @@ public class DoubleFHT { ...@@ -61,7 +61,6 @@ public class DoubleFHT {
private double [] translateFHTdXY=null; private double [] translateFHTdXY=null;
private int translateFHTN=0; private int translateFHTN=0;
public boolean debug=false; public boolean debug=false;
private ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays(); // just for debugging?
public DoubleFHT() { public DoubleFHT() {
this.C = null; this.C = null;
this.S = null; this.S = null;
...@@ -502,18 +501,18 @@ public class DoubleFHT { ...@@ -502,18 +501,18 @@ public class DoubleFHT {
double [] data, double [] data,
double dx, double dx,
double dy){ 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); swapQuadrants(data);
if (!transform(data,false)) return null; // direct FHT if (!transform(data,false)) return null; // direct FHT
if ((this.maxN!=translateFHTN) || (dx!=translateFHTdXY[0]) || (dy!=translateFHTdXY[1])){ if ((this.maxN!=translateFHTN) || (dx!=translateFHTdXY[0]) || (dy!=translateFHTdXY[1])){
calcTranslateFHT(dx,dy); calcTranslateFHT(dx,dy);
} }
if (debug) SDFA_INSTANCE.showArrays(data, "fht-source-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3)); if (debug) ShowDoubleFloatArrays.showArrays(data, "fht-source-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
data= multiply(data, this.translateFHT, false); // convolution, not correlation data= multiply(data, this.translateFHT, false); // convolution, not correlation
if (debug) SDFA_INSTANCE.showArrays(data, "fht-multiplied-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3)); if (debug) ShowDoubleFloatArrays.showArrays(data, "fht-multiplied-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
transform(data,true) ; // inverse transform transform(data,true) ; // inverse transform
swapQuadrants(data); swapQuadrants(data);
if (debug) SDFA_INSTANCE.showArrays(data, "result-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3)); if (debug) ShowDoubleFloatArrays.showArrays(data, "result-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
return data; return data;
} }
...@@ -559,7 +558,7 @@ public class DoubleFHT { ...@@ -559,7 +558,7 @@ public class DoubleFHT {
this.translateFHTdXY[0]=dx; this.translateFHTdXY[0]=dx;
this.translateFHTdXY[1]=dy; this.translateFHTdXY[1]=dy;
this.translateFHTN=this.maxN; this.translateFHTN=this.maxN;
if (debug) SDFA_INSTANCE.showArrays(this.translateFHT, "translateFHT-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3)); if (debug) ShowDoubleFloatArrays.showArrays(this.translateFHT, "translateFHT-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
} }
private boolean updateMaxN(double [] data){ private boolean updateMaxN(double [] data){
...@@ -1265,7 +1264,7 @@ public class DoubleFHT { ...@@ -1265,7 +1264,7 @@ public class DoubleFHT {
} }
String [] titles={"amp","phase","weight","d/dx","d/dy"}; String [] titles={"amp","phase","weight","d/dx","d/dy"};
SDFA_INSTANCE.showArrays( ShowDoubleFloatArrays.showArrays(
debugdPHdXdY, debugdPHdXdY,
this.maxN, this.maxN,
this.maxN, this.maxN,
...@@ -1483,7 +1482,7 @@ public class DoubleFHT { ...@@ -1483,7 +1482,7 @@ public class DoubleFHT {
String [] titles=new String[numAngles+1]; String [] titles=new String[numAngles+1];
for (int n=0;n<numAngles;n++) titles[n]=IJ.d2s(180.0*n/numAngles,1); for (int n=0;n<numAngles;n++) titles[n]=IJ.d2s(180.0*n/numAngles,1);
titles[numAngles]="usage number"; titles[numAngles]="usage number";
SDFA_INSTANCE.showArrays( ShowDoubleFloatArrays.showArrays(
debugPolarPhaseMasks, debugPolarPhaseMasks,
this.maxN, this.maxN,
this.maxN, this.maxN,
...@@ -1921,7 +1920,7 @@ public class DoubleFHT { ...@@ -1921,7 +1920,7 @@ public class DoubleFHT {
} }
/* /*
if (this.debug){ if (this.debug){
SDFA_INSTANCE.showArrays( ShowDoubleFloatArrays.showArrays(
amplitude, amplitude,
this.maxN, this.maxN,
halfN, halfN,
...@@ -1942,7 +1941,7 @@ public class DoubleFHT { ...@@ -1942,7 +1941,7 @@ public class DoubleFHT {
} }
} }
SDFA_INSTANCE.showArrays( ShowDoubleFloatArrays.showArrays(
debugAmplitude, debugAmplitude,
this.maxN, this.maxN,
this.maxN, this.maxN,
......
...@@ -42,7 +42,6 @@ public class BlueLeak { ...@@ -42,7 +42,6 @@ public class BlueLeak {
private int height; private int height;
private int length; private int length;
ColorProcParameters colorProcParameters; ColorProcParameters colorProcParameters;
private ShowDoubleFloatArrays SDFA_INSTANCE;
private int [] dirs20; private int [] dirs20;
private double [] weights20; private double [] weights20;
private int [] dirs8; private int [] dirs8;
...@@ -56,14 +55,12 @@ public class BlueLeak { ...@@ -56,14 +55,12 @@ public class BlueLeak {
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
double [][] rgb, double [][] rgb,
int width, int width,
ShowDoubleFloatArrays SDFA_INSTANCE,
String dbgImgTitle, String dbgImgTitle,
int debugLevel){ int debugLevel){
length=rgb[0].length; length=rgb[0].length;
rgb_in=rgb; rgb_in=rgb;
this.width=width; this.width=width;
height=length/width; height=length/width;
this.SDFA_INSTANCE=SDFA_INSTANCE;
this.colorProcParameters=colorProcParameters; this.colorProcParameters=colorProcParameters;
if (debugLevel>2) System.out.println("width="+width+" height="+height+" length="+length); if (debugLevel>2) System.out.println("width="+width+" height="+height+" length="+length);
int [] dirs8 = {-width,-width+1, 1, width+1, width,width-1,-1,-width-1}; int [] dirs8 = {-width,-width+1, 1, width+1, width,width-1,-1,-width-1};
...@@ -188,7 +185,7 @@ public class BlueLeak { ...@@ -188,7 +185,7 @@ public class BlueLeak {
dbgImg[0]=rgb_in[2]; dbgImg[0]=rgb_in[2];
dbgImg[1]=yRef; dbgImg[1]=yRef;
dbgImg[2]=dbgStateToDouble(state); dbgImg[2]=dbgStateToDouble(state);
SDFA_INSTANCE.showArrays(dbgImg, width, height, true, "blue_overexp_expanded", channel_blue_titles); ShowDoubleFloatArrays.showArrays(dbgImg, width, height, true, "blue_overexp_expanded", channel_blue_titles);
} }
int numStep=0; int numStep=0;
...@@ -290,7 +287,7 @@ public class BlueLeak { ...@@ -290,7 +287,7 @@ public class BlueLeak {
dbgImg[2]=yRef; dbgImg[2]=yRef;
dbgImg[3]=leak; dbgImg[3]=leak;
dbgImg[4]=dbgStateToDouble(state); dbgImg[4]=dbgStateToDouble(state);
SDFA_INSTANCE.showArrays(dbgImg, width, height, true, "blue_overexp_expanded__"+numStep, channel_blue_titles); ShowDoubleFloatArrays.showArrays(dbgImg, width, height, true, "blue_overexp_expanded__"+numStep, channel_blue_titles);
} }
blue=new double[length]; blue=new double[length];
for (int i=0;i<length;i++) blue[i]=rgb_in[2][i]; // just copy for (int i=0;i<length;i++) blue[i]=rgb_in[2][i]; // just copy
...@@ -383,7 +380,7 @@ public class BlueLeak { ...@@ -383,7 +380,7 @@ public class BlueLeak {
dbgImg[0]=rgb_in[2]; dbgImg[0]=rgb_in[2];
dbgImg[1]=blue; dbgImg[1]=blue;
dbgImg[2]=dbgStateToDouble(state); dbgImg[2]=dbgStateToDouble(state);
SDFA_INSTANCE.showArrays(dbgImg, width, height, true, dbgImgTitle, channel_blue_titles); ShowDoubleFloatArrays.showArrays(dbgImg, width, height, true, dbgImgTitle, channel_blue_titles);
} }
return blue; // corrected blue channel return blue; // corrected blue channel
...@@ -731,7 +728,7 @@ public class BlueLeak { ...@@ -731,7 +728,7 @@ public class BlueLeak {
} }
if (debugLevel>1) System.out.println("Marked "+numDet+" blue pixels as if not overexposed (trees, wires)"); if (debugLevel>1) System.out.println("Marked "+numDet+" blue pixels as if not overexposed (trees, wires)");
if (debugLevel>1) { if (debugLevel>1) {
SDFA_INSTANCE.showArrays(details, width, height,"Details"); ShowDoubleFloatArrays.showArrays(details, width, height,"Details");
} }
} }
...@@ -743,7 +740,7 @@ public class BlueLeak { ...@@ -743,7 +740,7 @@ public class BlueLeak {
dbg_proc[9]=overExpPix[1]; dbg_proc[9]=overExpPix[1];
dbg_proc[10]=overExpPix[2]; dbg_proc[10]=overExpPix[2];
SDFA_INSTANCE.showArrays(dbg_proc, width, height, true, "test_chn",channel_titles); ShowDoubleFloatArrays.showArrays(dbg_proc, width, height, true, "test_chn",channel_titles);
} }
/// public void showArraysSparse(double[][] pixels, int width, int height, boolean asStack, String title, String [] titles) { /// public void showArraysSparse(double[][] pixels, int width, int height, boolean asStack, String title, String [] titles) {
double [] blue = findBlueSolutions( double [] blue = findBlueSolutions(
......
...@@ -40,7 +40,6 @@ import ij.gui.GenericDialog; ...@@ -40,7 +40,6 @@ import ij.gui.GenericDialog;
public class CorrectionColorProc { public class CorrectionColorProc {
ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays();
public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient
double [] denoiseMaskChroma; double [] denoiseMaskChroma;
int denoiseMaskChromaWidth; int denoiseMaskChromaWidth;
...@@ -131,7 +130,6 @@ public class CorrectionColorProc { ...@@ -131,7 +130,6 @@ public class CorrectionColorProc {
colorProcParameters, colorProcParameters,
blueLeakRgb, blueLeakRgb,
width, width,
SDFA_INSTANCE,
null, // "blue_corr", //TODO: add normal generation/saving of the intermediate images null, // "blue_corr", //TODO: add normal generation/saving of the intermediate images
debugLevel); // debug level debugLevel); // debug level
double [][] blueRemovedRGB= blueLeak.process(); // will later return corrected RGB to use double [][] blueRemovedRGB= blueLeak.process(); // will later return corrected RGB to use
...@@ -229,11 +227,11 @@ public class CorrectionColorProc { ...@@ -229,11 +227,11 @@ public class CorrectionColorProc {
gb.blurDouble(dpixels_pr_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01); gb.blurDouble(dpixels_pr_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
gb.blurDouble(dpixels_pb_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01); gb.blurDouble(dpixels_pb_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
if (debugLevel> 2) { if (debugLevel> 2) {
SDFA_INSTANCE.showArrays(dmask, width, height,"dmask"); ShowDoubleFloatArrays.showArrays(dmask, width, height,"dmask");
SDFA_INSTANCE.showArrays(dpixels_pr, width, height,"dpixels_pr"); ShowDoubleFloatArrays.showArrays(dpixels_pr, width, height,"dpixels_pr");
SDFA_INSTANCE.showArrays(dpixels_pb, width, height,"dpixels_pb"); ShowDoubleFloatArrays.showArrays(dpixels_pb, width, height,"dpixels_pb");
SDFA_INSTANCE.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark"); ShowDoubleFloatArrays.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark");
SDFA_INSTANCE.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark"); ShowDoubleFloatArrays.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark");
} }
double mp; double mp;
double k =1.0/(colorProcParameters.maskMax-colorProcParameters.maskMin); double k =1.0/(colorProcParameters.maskMax-colorProcParameters.maskMin);
...@@ -422,11 +420,11 @@ public class CorrectionColorProc { ...@@ -422,11 +420,11 @@ public class CorrectionColorProc {
gb.blurDouble(dpixels_pr_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01); gb.blurDouble(dpixels_pr_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
gb.blurDouble(dpixels_pb_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01); gb.blurDouble(dpixels_pb_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
if (debugLevel>2) { if (debugLevel>2) {
SDFA_INSTANCE.showArrays(dmask, width, height,"dmask"); ShowDoubleFloatArrays.showArrays(dmask, width, height,"dmask");
SDFA_INSTANCE.showArrays(dpixels_pr, width, height,"dpixels_pr"); ShowDoubleFloatArrays.showArrays(dpixels_pr, width, height,"dpixels_pr");
SDFA_INSTANCE.showArrays(dpixels_pb, width, height,"dpixels_pb"); ShowDoubleFloatArrays.showArrays(dpixels_pb, width, height,"dpixels_pb");
SDFA_INSTANCE.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark"); ShowDoubleFloatArrays.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark");
SDFA_INSTANCE.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark"); ShowDoubleFloatArrays.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark");
} }
double mp; double mp;
double k =1.0/(colorProcParameters.maskMax-colorProcParameters.maskMin); double k =1.0/(colorProcParameters.maskMax-colorProcParameters.maskMin);
......
...@@ -38,7 +38,6 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays; ...@@ -38,7 +38,6 @@ import com.elphel.imagej.common.ShowDoubleFloatArrays;
public class CorrectionDenoise { public class CorrectionDenoise {
ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays();
public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient
double [] denoiseMask; double [] denoiseMask;
int denoiseMaskWidth; int denoiseMaskWidth;
...@@ -104,16 +103,16 @@ public class CorrectionDenoise { ...@@ -104,16 +103,16 @@ public class CorrectionDenoise {
// diffGreens[i]=d*d; // diffGreens[i]=d*d;
diffGreens[i]=hipassPixels[i]-lopassPixels[i]; diffGreens[i]=hipassPixels[i]-lopassPixels[i];
} }
if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-nofilter"); if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-nofilter");
if (nonlinParameters.blurSigma>0) { if (nonlinParameters.blurSigma>0) {
if (debugLevel>1) System.out.println ( "Applying gaussian blur to difference hi/lo pass, blurSigma="+nonlinParameters.blurSigma); if (debugLevel>1) System.out.println ( "Applying gaussian blur to difference hi/lo pass, blurSigma="+nonlinParameters.blurSigma);
gb.blurDouble(diffGreens, imgWidth, imgHeight, nonlinParameters.blurSigma, nonlinParameters.blurSigma, 0.01); gb.blurDouble(diffGreens, imgWidth, imgHeight, nonlinParameters.blurSigma, nonlinParameters.blurSigma, 0.01);
} }
if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-blurred"); if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-blurred");
for (i=0;i<lopassPixels.length;i++) { for (i=0;i<lopassPixels.length;i++) {
diffGreens[i]=diffGreens[i]*diffGreens[i]; diffGreens[i]=diffGreens[i]*diffGreens[i];
} }
if ((debugLevel>2) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(lopassPixels.clone(), imgWidth, imgHeight,"lopassPixels"); if ((debugLevel>2) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(lopassPixels.clone(), imgWidth, imgHeight,"lopassPixels");
for (i=0;i<lopassPixels.length;i++) { for (i=0;i<lopassPixels.length;i++) {
if (max<lopassPixels[i]) max=lopassPixels[i]; if (max<lopassPixels[i]) max=lopassPixels[i];
...@@ -122,12 +121,12 @@ public class CorrectionDenoise { ...@@ -122,12 +121,12 @@ public class CorrectionDenoise {
// max*=((float) NONLIN_PARAMETERS.threshold); // max*=((float) NONLIN_PARAMETERS.threshold);
// Make threshold absolute - when (blured) intensity is below thershold, the divisor is not decreasing // Make threshold absolute - when (blured) intensity is below thershold, the divisor is not decreasing
max=((float) nonlinParameters.threshold); max=((float) nonlinParameters.threshold);
if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-squared"); if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-squared");
for (i=0;i<lopassPixels.length;i++) { for (i=0;i<lopassPixels.length;i++) {
diffGreens[i]/=(float) Math.max(max,lopassPixels[i]); diffGreens[i]/=(float) Math.max(max,lopassPixels[i]);
} }
// if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffG-norm-limited"); // if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffG-norm-limited");
if ((debugLevel>1) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffG-norm-limited"); if ((debugLevel>1) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffG-norm-limited");
if (nonlinParameters.useRejectBlocksFilter) { // use frequency domain filtering if (nonlinParameters.useRejectBlocksFilter) { // use frequency domain filtering
double lowpassSigmaFreq=1.0*nonlinParameters.maskFFTSize/(2*Math.PI*nonlinParameters.lowPassSigma); // low pass sigma in frequency domain double lowpassSigmaFreq=1.0*nonlinParameters.maskFFTSize/(2*Math.PI*nonlinParameters.lowPassSigma); // low pass sigma in frequency domain
...@@ -136,7 +135,7 @@ public class CorrectionDenoise { ...@@ -136,7 +135,7 @@ public class CorrectionDenoise {
nonlinParameters.blockPeriod, // period (pixels) of the block artifacts to reject (32) nonlinParameters.blockPeriod, // period (pixels) of the block artifacts to reject (32)
nonlinParameters.rejectFreqSigma, // sigma of the rejection spots ( 0.0 - just zero a single point) nonlinParameters.rejectFreqSigma, // sigma of the rejection spots ( 0.0 - just zero a single point)
lowpassSigmaFreq); // sigma of the low pass filter (frequency units, 0.0 - do not filter) lowpassSigmaFreq); // sigma of the low pass filter (frequency units, 0.0 - do not filter)
if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(filterFHT,"filterFHT"); if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(filterFHT,"filterFHT");
// Extend at least by half sliding window in each direction to reduce border effect // Extend at least by half sliding window in each direction to reduce border effect
diffGreens1=extendDoubleArrayForSlidingWindow( diffGreens1=extendDoubleArrayForSlidingWindow(
diffGreens, // input pixel array diffGreens, // input pixel array
...@@ -145,7 +144,7 @@ public class CorrectionDenoise { ...@@ -145,7 +144,7 @@ public class CorrectionDenoise {
int extendedWidth= extendDimension(imgWidth, (nonlinParameters.maskFFTSize/2)); int extendedWidth= extendDimension(imgWidth, (nonlinParameters.maskFFTSize/2));
int extendedHeight= extendDimension(imgHeight,(nonlinParameters.maskFFTSize/2)); int extendedHeight= extendDimension(imgHeight,(nonlinParameters.maskFFTSize/2));
if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens1.clone(),extendedWidth, extendedHeight,"diffGreens-extended"); if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens1.clone(),extendedWidth, extendedHeight,"diffGreens-extended");
// run block rejection filter // run block rejection filter
diffGreens1=filterMaskFromBlockArtifacts( diffGreens1=filterMaskFromBlockArtifacts(
...@@ -157,7 +156,7 @@ public class CorrectionDenoise { ...@@ -157,7 +156,7 @@ public class CorrectionDenoise {
threadsMax, // maximal step in pixels on the maxRadius for 1 angular step (i.e. 0.5) threadsMax, // maximal step in pixels on the maxRadius for 1 angular step (i.e. 0.5)
updateStatus, // update status info updateStatus, // update status info
debugLevel); debugLevel);
if ((debugLevel>3) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens1.clone(),extendedWidth, if ((debugLevel>3) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens1.clone(),extendedWidth,
extendedHeight,"diffGreens-filtered-extended");/**/ extendedHeight,"diffGreens-filtered-extended");/**/
// cut extra margins, crop to original size // cut extra margins, crop to original size
diffGreens1=reducedDoubleArrayAfterSlidingWindow( diffGreens1=reducedDoubleArrayAfterSlidingWindow(
...@@ -165,7 +164,7 @@ public class CorrectionDenoise { ...@@ -165,7 +164,7 @@ public class CorrectionDenoise {
imgWidth, // width of the image imgWidth, // width of the image
imgHeight, imgHeight,
nonlinParameters.maskFFTSize/2); // size of sliding step (half of the sliding window size) nonlinParameters.maskFFTSize/2); // size of sliding step (half of the sliding window size)
if ((debugLevel>2) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens1.clone(),imgWidth, if ((debugLevel>2) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens1.clone(),imgWidth,
imgHeight,"diffGreens-filtered"); imgHeight,"diffGreens-filtered");
if (nonlinParameters.combineBothModes) { if (nonlinParameters.combineBothModes) {
// DoubleGaussianBlur gb=new DoubleGaussianBlur(); // DoubleGaussianBlur gb=new DoubleGaussianBlur();
...@@ -181,7 +180,7 @@ public class CorrectionDenoise { ...@@ -181,7 +180,7 @@ public class CorrectionDenoise {
// DoubleGaussianBlur gb=new DoubleGaussianBlur(); // DoubleGaussianBlur gb=new DoubleGaussianBlur();
gb.blurDouble(diffGreens, imgWidth, imgHeight, nonlinParameters.lowPassSigma, nonlinParameters.lowPassSigma, 0.01); gb.blurDouble(diffGreens, imgWidth, imgHeight, nonlinParameters.lowPassSigma, nonlinParameters.lowPassSigma, 0.01);
} }
if ((debugLevel>1) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-filtered"); if ((debugLevel>1) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-filtered");
// final double [][] noiseMask, // 2-d array of kernelsNoiseGain (divide mask by it) // final double [][] noiseMask, // 2-d array of kernelsNoiseGain (divide mask by it)
// final int noiseStep, // linear pixels per noiseMask pixels (32) // final int noiseStep, // linear pixels per noiseMask pixels (32)
...@@ -197,7 +196,7 @@ public class CorrectionDenoise { ...@@ -197,7 +196,7 @@ public class CorrectionDenoise {
diffGreens[i]/=noiseMask[j][k]; diffGreens[i]/=noiseMask[j][k];
} }
} }
if ((debugLevel>1) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-noise"); if ((debugLevel>1) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-noise");
if (nonlinParameters.useRingFilter) { if (nonlinParameters.useRingFilter) {
diffGreens=ringFilter(diffGreens, // mask to be filtered diffGreens=ringFilter(diffGreens, // mask to be filtered
imgWidth, // mask width imgWidth, // mask width
...@@ -206,7 +205,7 @@ public class CorrectionDenoise { ...@@ -206,7 +205,7 @@ public class CorrectionDenoise {
nonlinParameters.overRingLimit, // limit for the pixels in the center ring relative to the maximum in a ring nonlinParameters.overRingLimit, // limit for the pixels in the center ring relative to the maximum in a ring
nonlinParameters.ringIR, // ring inner radius nonlinParameters.ringIR, // ring inner radius
nonlinParameters.ringOR); // ring outer radius nonlinParameters.ringOR); // ring outer radius
if ((debugLevel>1) && nonlinParameters.showMask) SDFA_INSTANCE.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-ring"); if ((debugLevel>1) && nonlinParameters.showMask) ShowDoubleFloatArrays.showArrays(diffGreens.clone(), imgWidth, imgHeight,"diffGreens-ring");
} }
if (debugLevel>1) System.out.println ( "filtMax="+filtMax+" filtMin="+filtMin); if (debugLevel>1) System.out.println ( "filtMax="+filtMax+" filtMin="+filtMin);
d= (float) ( 1.0/(filtMax-filtMin)); d= (float) ( 1.0/(filtMax-filtMin));
...@@ -218,7 +217,7 @@ public class CorrectionDenoise { ...@@ -218,7 +217,7 @@ public class CorrectionDenoise {
} }
} }
// if (nonlinParameters.showMask) { // if (nonlinParameters.showMask) {
// SDFA_INSTANCE.showArrays(diffGreens, imgWidth, imgHeight,"mask"); // ShowDoubleFloatArrays.showArrays(diffGreens, imgWidth, imgHeight,"mask");
// } // }
this.denoiseMask=diffGreens; this.denoiseMask=diffGreens;
this.denoiseMaskWidth=imgWidth; this.denoiseMaskWidth=imgWidth;
...@@ -289,7 +288,6 @@ public class CorrectionDenoise { ...@@ -289,7 +288,6 @@ public class CorrectionDenoise {
double [] tile= new double[size * size ]; double [] tile= new double[size * size ];
int tileY,tileX; int tileY,tileX;
DoubleFHT fht_instance = new DoubleFHT(); // provide DoubleFHT instance to save on initializations (or null) DoubleFHT fht_instance = new DoubleFHT(); // provide DoubleFHT instance to save on initializations (or null)
// showDoubleFloatArrays SDFA_instance=null; // just for debugging?
for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) {
tileY = nTile /tilesX; tileY = nTile /tilesX;
tileX = nTile % tilesX; tileX = nTile % tilesX;
......
...@@ -60,9 +60,6 @@ import loci.formats.FormatException; ...@@ -60,9 +60,6 @@ import loci.formats.FormatException;
public class EyesisCorrections { public class EyesisCorrections {
public JP46_Reader_camera JP4_INSTANCE= new JP46_Reader_camera(false); public JP46_Reader_camera JP4_INSTANCE= new JP46_Reader_camera(false);
// public ImagejJp4Tiff imagejJp4Tiff = new ImagejJp4Tiff();
ShowDoubleFloatArrays SDFA_INSTANCE= new ShowDoubleFloatArrays();
DebayerScissorsClass debayerScissors=null; DebayerScissorsClass debayerScissors=null;
public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient
public PixelMapping pixelMapping=null; public PixelMapping pixelMapping=null;
...@@ -700,7 +697,7 @@ public class EyesisCorrections { ...@@ -700,7 +697,7 @@ public class EyesisCorrections {
} }
} }
if (debugLevel>0){ if (debugLevel>0){
SDFA_INSTANCE.showArrays( ShowDoubleFloatArrays.showArrays(
channelVignettingCorrection[srcChannel], channelVignettingCorrection[srcChannel],
pixelMapping.sensors[srcChannel].pixelCorrectionWidth, pixelMapping.sensors[srcChannel].pixelCorrectionWidth,
pixelMapping.sensors[srcChannel].pixelCorrectionHeight, pixelMapping.sensors[srcChannel].pixelCorrectionHeight,
...@@ -793,8 +790,8 @@ public class EyesisCorrections { ...@@ -793,8 +790,8 @@ public class EyesisCorrections {
float [] pixels=(float[]) imp.getProcessor().getPixels(); float [] pixels=(float[]) imp.getProcessor().getPixels();
double [] pixelsFlat=new double [corrFF.length]; double [] pixelsFlat=new double [corrFF.length];
for (int i=0;i<corrFF.length;i++) pixelsFlat[i]=pixels[i]*corrFF[i]; for (int i=0;i<corrFF.length;i++) pixelsFlat[i]=pixels[i]*corrFF[i];
SDFA_INSTANCE.showArrays(corrFF, imp.getWidth(), imp.getHeight(), srcChannel+"-FF-correction"); ShowDoubleFloatArrays.showArrays(corrFF, imp.getWidth(), imp.getHeight(), srcChannel+"-FF-correction");
SDFA_INSTANCE.showArrays(pixelsFlat, imp.getWidth(), imp.getHeight(), srcChannel+"-flat-"+imp.getTitle()); ShowDoubleFloatArrays.showArrays(pixelsFlat, imp.getWidth(), imp.getHeight(), srcChannel+"-flat-"+imp.getTitle());
} }
} }
...@@ -1218,7 +1215,7 @@ public class EyesisCorrections { ...@@ -1218,7 +1215,7 @@ public class EyesisCorrections {
debugLevel); debugLevel);
if (this.correctionsParameters.saveDebayerEnergy || this.correctionsParameters.showDebayerEnergy) { if (this.correctionsParameters.saveDebayerEnergy || this.correctionsParameters.showDebayerEnergy) {
if (debayerScissors.getDebayerEnergy()!=null) { if (debayerScissors.getDebayerEnergy()!=null) {
ImagePlus debayerMask=SDFA_INSTANCE.makeArrays (debayerScissors.getDebayerEnergy(), ImagePlus debayerMask=ShowDoubleFloatArrays.makeArrays (debayerScissors.getDebayerEnergy(),
debayerScissors.getDebayerEnergyWidth(), debayerScissors.getDebayerEnergyWidth(),
debayerScissors.getDebayerEnergy().length/debayerScissors.getDebayerEnergyWidth(), debayerScissors.getDebayerEnergy().length/debayerScissors.getDebayerEnergyWidth(),
title+"-DEBAYER-ENERGY"); title+"-DEBAYER-ENERGY");
...@@ -1323,7 +1320,7 @@ public class EyesisCorrections { ...@@ -1323,7 +1320,7 @@ public class EyesisCorrections {
updateStatus, // update status info updateStatus, // update status info
debugLevel); debugLevel);
if (this.correctionsParameters.saveDenoiseMask || this.correctionsParameters.showDenoiseMask) { if (this.correctionsParameters.saveDenoiseMask || this.correctionsParameters.showDenoiseMask) {
ImagePlus denoiseMask=SDFA_INSTANCE.makeArrays ( ImagePlus denoiseMask=ShowDoubleFloatArrays.makeArrays (
correctionDenoise.getDenoiseMask(), correctionDenoise.getDenoiseMask(),
correctionDenoise.getDenoiseMaskWidth(), correctionDenoise.getDenoiseMaskWidth(),
correctionDenoise.getDenoiseMask().length/correctionDenoise.getDenoiseMaskWidth(), correctionDenoise.getDenoiseMask().length/correctionDenoise.getDenoiseMaskWidth(),
...@@ -1445,7 +1442,7 @@ public class EyesisCorrections { ...@@ -1445,7 +1442,7 @@ public class EyesisCorrections {
// Show/save color denoise mask // Show/save color denoise mask
if ((this.correctionsParameters.saveChromaDenoiseMask || this.correctionsParameters.showChromaDenoiseMask) && (correctionColorProc.getDenoiseMaskChroma()!=null)) { if ((this.correctionsParameters.saveChromaDenoiseMask || this.correctionsParameters.showChromaDenoiseMask) && (correctionColorProc.getDenoiseMaskChroma()!=null)) {
ImagePlus chromaDenoiseMask=SDFA_INSTANCE.makeArrays (correctionColorProc.getDenoiseMaskChroma(), ImagePlus chromaDenoiseMask=ShowDoubleFloatArrays.makeArrays (correctionColorProc.getDenoiseMaskChroma(),
correctionColorProc.getDenoiseMaskChromaWidth(), correctionColorProc.getDenoiseMaskChromaWidth(),
correctionColorProc.getDenoiseMaskChroma().length/correctionColorProc.getDenoiseMaskChromaWidth(), correctionColorProc.getDenoiseMaskChroma().length/correctionColorProc.getDenoiseMaskChromaWidth(),
title+"-MASK_CHROMA"); title+"-MASK_CHROMA");
...@@ -2172,7 +2169,7 @@ public class EyesisCorrections { ...@@ -2172,7 +2169,7 @@ public class EyesisCorrections {
// for (i=0;i<doubleKernel.length;i++) debug_sum+=doubleKernel[i]; // for (i=0;i<doubleKernel.length;i++) debug_sum+=doubleKernel[i];
// if (globalDebugLevel>1) System.out.println("kernel sum="+debug_sum); // if (globalDebugLevel>1) System.out.println("kernel sum="+debug_sum);
//if ((tileY==tilesY/2) && (tileX==tilesX/2)) SDFA_INSTANCE.showArrays(doubleKernel,size,size, "doubleKernel-"+chn); //if ((tileY==tilesY/2) && (tileX==tilesX/2)) ShowDoubleFloatArrays.showArrays(doubleKernel,size,size, "doubleKernel-"+chn);
/* FHT transform of the kernel */ /* FHT transform of the kernel */
fht_instance.swapQuadrants(doubleKernel); fht_instance.swapQuadrants(doubleKernel);
fht_instance.transform( doubleKernel); fht_instance.transform( doubleKernel);
...@@ -2182,7 +2179,7 @@ public class EyesisCorrections { ...@@ -2182,7 +2179,7 @@ public class EyesisCorrections {
fht_instance.inverseTransform(outTile); fht_instance.inverseTransform(outTile);
fht_instance.swapQuadrants(outTile); fht_instance.swapQuadrants(outTile);
/* accumulate result */ /* accumulate result */
//if ((tileY==tilesY/2) && (tileX==tilesX/2)) SDFA_INSTANCE.showArrays(outTile,size,size, "out-"+chn); //if ((tileY==tilesY/2) && (tileX==tilesX/2)) ShowDoubleFloatArrays.showArrays(outTile,size,size, "out-"+chn);
/*This is synchronized method. It is possible to make threads to write to non-overlapping regions of the outPixels, but as the accumulation /*This is synchronized method. It is possible to make threads to write to non-overlapping regions of the outPixels, but as the accumulation
* takes just small fraction of several FHTs, it should be OK - reasonable number of threads will spread and not "stay in line" * takes just small fraction of several FHTs, it should be OK - reasonable number of threads will spread and not "stay in line"
*/ */
......
...@@ -296,8 +296,6 @@ public class EyesisDCT { ...@@ -296,8 +296,6 @@ public class EyesisDCT {
kernels[chn] = null; kernels[chn] = null;
} }
} }
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
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)){
...@@ -322,7 +320,7 @@ public class EyesisDCT { ...@@ -322,7 +320,7 @@ public class EyesisDCT {
// save files // save files
String [] symNames = {"red_sym","blue_sym","green_sym"}; String [] symNames = {"red_sym","blue_sym","green_sym"};
String [] asymNames = {"red_asym","blue_asym","green_asym"}; String [] asymNames = {"red_asym","blue_asym","green_asym"};
ImageStack symStack = sdfa_instance.makeStack( ImageStack symStack = ShowDoubleFloatArrays.makeStack(
kernels.sym_kernels, kernels.sym_kernels,
sym_width, sym_width,
sym_height, sym_height,
...@@ -342,12 +340,9 @@ public class EyesisDCT { ...@@ -342,12 +340,9 @@ public class EyesisDCT {
} }
FileSaver fs=new FileSaver(imp_sym); FileSaver fs=new FileSaver(imp_sym);
fs.saveAsTiffStack(symPath); 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;
ImageStack asymStack = sdfa_instance.makeStack( ImageStack asymStack = ShowDoubleFloatArrays.makeStack(
kernels.asym_kernels, kernels.asym_kernels,
asym_width, asym_width,
asym_height, asym_height,
...@@ -367,7 +362,6 @@ public class EyesisDCT { ...@@ -367,7 +362,6 @@ public class EyesisDCT {
} }
fs=new FileSaver(imp_asym); fs=new FileSaver(imp_asym);
fs.saveAsTiffStack(asymPath); fs.saveAsTiffStack(asymPath);
// sdfa_instance.showArrays(kernels.asym_kernels, asym_width, asym_height, true, imp_kernel_sharp.getTitle()+"-asym");
} }
} }
return true; return true;
...@@ -623,8 +617,6 @@ public class EyesisDCT { ...@@ -623,8 +617,6 @@ public class EyesisDCT {
} }
} }
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
DttRad2 dtt = new DttRad2(dct_parameters.dct_size); DttRad2 dtt = new DttRad2(dct_parameters.dct_size);
for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){ for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){
...@@ -828,8 +820,8 @@ public class EyesisDCT { ...@@ -828,8 +820,8 @@ public class EyesisDCT {
} }
// Debug will be removed later, the // Debug will be removed later, the
if (debugLevel > 0) { if (debugLevel > 0) {
sdfa_instance.showArrays(kernels[chn].sym_kernels, sym_width, sym_height, true, symKernelPaths[chn]); ShowDoubleFloatArrays.showArrays(kernels[chn].sym_kernels, sym_width, sym_height, true, symKernelPaths[chn]);
sdfa_instance.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, asymKernelPaths[chn]); ShowDoubleFloatArrays.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, asymKernelPaths[chn]);
} }
kernels[chn].sym_kernels = null; // not needed anymore kernels[chn].sym_kernels = null; // not needed anymore
kernels[chn].asym_kernels = null; // not needed anymore kernels[chn].asym_kernels = null; // not needed anymore
...@@ -866,7 +858,6 @@ public class EyesisDCT { ...@@ -866,7 +858,6 @@ public class EyesisDCT {
kernels[chn].asym_kernels = new double [nColors][asym_width*asym_height]; kernels[chn].asym_kernels = new double [nColors][asym_width*asym_height];
int sym_kernel_inc_index = numHor * dct_size; int sym_kernel_inc_index = numHor * dct_size;
int asym_kernel_inc_index = numHor * asym_size; int asym_kernel_inc_index = numHor * asym_size;
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
for (int nc = 0; nc < nColors; nc++){ for (int nc = 0; nc < nColors; nc++){
for (int tileY = 0; tileY < numVert; tileY++){ for (int tileY = 0; tileY < numVert; tileY++){
for (int tileX = 0; tileX < numHor; tileX++){ for (int tileX = 0; tileX < numHor; tileX++){
...@@ -922,10 +913,10 @@ public class EyesisDCT { ...@@ -922,10 +913,10 @@ public class EyesisDCT {
System.out.println("asym_width="+asym_width+" asym_height="+asym_height); System.out.println("asym_width="+asym_width+" asym_height="+asym_height);
System.out.println("kernels["+chn+"].asym_kernels.length="+kernels[chn].asym_kernels.length); System.out.println("kernels["+chn+"].asym_kernels.length="+kernels[chn].asym_kernels.length);
System.out.println("kernels["+chn+"][0].asym_kernels.length="+kernels[chn].asym_kernels[0].length); System.out.println("kernels["+chn+"][0].asym_kernels.length="+kernels[chn].asym_kernels[0].length);
sdfa_instance.showArrays(kernels[chn].sym_kernels, sym_width, sym_height, true, "restored-sym-"+chn); ShowDoubleFloatArrays.showArrays(kernels[chn].sym_kernels, sym_width, sym_height, true, "restored-sym-"+chn);
sdfa_instance.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, "restored-asym-"+chn); ShowDoubleFloatArrays.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, "restored-asym-"+chn);
if (kernels[chn].st_direct != null){ if (kernels[chn].st_direct != null){
sdfa_instance.showArrays(kernels[chn].sym_direct, sym_width, sym_height, true, "restored-direct-"+chn); ShowDoubleFloatArrays.showArrays(kernels[chn].sym_direct, sym_width, sym_height, true, "restored-direct-"+chn);
} }
kernels[chn].sym_kernels = null; // not needed anymore kernels[chn].sym_kernels = null; // not needed anymore
kernels[chn].asym_kernels = null; // not needed anymore kernels[chn].asym_kernels = null; // not needed anymore
...@@ -1210,7 +1201,6 @@ public class EyesisDCT { ...@@ -1210,7 +1201,6 @@ public class EyesisDCT {
return result; return result;
} }
// ================= // =================
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
if (debugLevel > 0) { if (debugLevel > 0) {
System.out.println("Showing image BEFORE_PROC"); System.out.println("Showing image BEFORE_PROC");
ImagePlus imp_dbg= new ImagePlus("BEFORE_PROC",stack); ImagePlus imp_dbg= new ImagePlus("BEFORE_PROC",stack);
...@@ -1276,7 +1266,7 @@ public class EyesisDCT { ...@@ -1276,7 +1266,7 @@ public class EyesisDCT {
debugLevel); debugLevel);
} }
// System.out.println("dct_dc.length="+dct_dc.length+" dct_ac.length="+dct_ac.length); // System.out.println("dct_dc.length="+dct_dc.length+" dct_ac.length="+dct_ac.length);
sdfa_instance.showArrays(dct, ShowDoubleFloatArrays.showArrays(dct,
tilesX*dct_parameters.dct_size, tilesX*dct_parameters.dct_size,
tilesY*dct_parameters.dct_size, tilesY*dct_parameters.dct_size,
true, true,
...@@ -1292,7 +1282,7 @@ public class EyesisDCT { ...@@ -1292,7 +1282,7 @@ public class EyesisDCT {
debugLevel); debugLevel);
} }
if (dct_parameters.color_DCT){ // convert RBG -> YPrPb if (dct_parameters.color_DCT){ // convert RBG -> YPrPb
if (debugLevel > 0) sdfa_instance.showArrays( if (debugLevel > 0) ShowDoubleFloatArrays.showArrays(
idct_data, idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
...@@ -1316,7 +1306,7 @@ public class EyesisDCT { ...@@ -1316,7 +1306,7 @@ public class EyesisDCT {
dct_parameters.denoise_c_corn, // final double denoise_c_corn, // = 0.5; // weight of the 4 corner pixels during denoise y (relative to 4 straight) dct_parameters.denoise_c_corn, // final double denoise_c_corn, // = 0.5; // weight of the 4 corner pixels during denoise y (relative to 4 straight)
dct_parameters.dct_size, //, // final int threadsMax, // maximal number of threads to launch dct_parameters.dct_size, //, // final int threadsMax, // maximal number of threads to launch
debugLevel); // final int globalDebugLevel) debugLevel); // final int globalDebugLevel)
if (debugLevel > 0) sdfa_instance.showArrays( if (debugLevel > 0) ShowDoubleFloatArrays.showArrays(
idct_data, idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
...@@ -1333,7 +1323,7 @@ public class EyesisDCT { ...@@ -1333,7 +1323,7 @@ public class EyesisDCT {
} else { } else {
if (dct_parameters.post_debayer){ // post_debayer if (dct_parameters.post_debayer){ // post_debayer
if (debugLevel > -1) System.out.println("Applying post-debayer"); if (debugLevel > -1) System.out.println("Applying post-debayer");
if (debugLevel > -1) sdfa_instance.showArrays( if (debugLevel > -1) ShowDoubleFloatArrays.showArrays(
idct_data, idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
...@@ -1347,7 +1337,7 @@ public class EyesisDCT { ...@@ -1347,7 +1337,7 @@ public class EyesisDCT {
dct_parameters.dct_size, // final int threadsMax, // maximal number of threads to launch dct_parameters.dct_size, // final int threadsMax, // maximal number of threads to launch
debugLevel); // final int globalDebugLevel) debugLevel); // final int globalDebugLevel)
// add here YPrPb conversion, then edge_emphasis // add here YPrPb conversion, then edge_emphasis
if (debugLevel > -1) sdfa_instance.showArrays( if (debugLevel > -1) ShowDoubleFloatArrays.showArrays(
idct_data, idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
...@@ -1355,7 +1345,7 @@ public class EyesisDCT { ...@@ -1355,7 +1345,7 @@ public class EyesisDCT {
result.getTitle()+"-rbg_after"); result.getTitle()+"-rbg_after");
} else { } else {
if (debugLevel > -1) System.out.println("Applyed LPF, sigma = "+dct_parameters.dbg_sigma); if (debugLevel > -1) System.out.println("Applyed LPF, sigma = "+dct_parameters.dbg_sigma);
if (debugLevel > -1) sdfa_instance.showArrays( if (debugLevel > -1) ShowDoubleFloatArrays.showArrays(
idct_data, idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
...@@ -1364,7 +1354,7 @@ public class EyesisDCT { ...@@ -1364,7 +1354,7 @@ public class EyesisDCT {
} }
} }
if (debugLevel > 0) sdfa_instance.showArrays(idct_data, if (debugLevel > 0) ShowDoubleFloatArrays.showArrays(idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
true, true,
...@@ -1372,7 +1362,7 @@ public class EyesisDCT { ...@@ -1372,7 +1362,7 @@ public class EyesisDCT {
// convert to ImageStack of 3 slices // convert to ImageStack of 3 slices
String [] sliceNames = {"red", "blue", "green"}; String [] sliceNames = {"red", "blue", "green"};
stack = sdfa_instance.makeStack( stack = ShowDoubleFloatArrays.makeStack(
idct_data, idct_data,
(tilesX + 1) * dct_parameters.dct_size, (tilesX + 1) * dct_parameters.dct_size,
(tilesY + 1) * dct_parameters.dct_size, (tilesY + 1) * dct_parameters.dct_size,
......
...@@ -73,7 +73,6 @@ public class PostProcessing { ...@@ -73,7 +73,6 @@ public class PostProcessing {
public PixelMapping pixelMapping=new PixelMapping(debugLevel); // just to access PixelMapping.InterSensor public PixelMapping pixelMapping=new PixelMapping(debugLevel); // just to access PixelMapping.InterSensor
// public double [][][] aYCbCr=null; // public double [][][] aYCbCr=null;
public int [] channels; public int [] channels;
private ShowDoubleFloatArrays sdfaInstance=new ShowDoubleFloatArrays(); // just for debugging?
public PixelMapping.InterSensor interSensor=null; public PixelMapping.InterSensor interSensor=null;
public void setProperties(String prefix,Properties properties){ // currently prefix =="" public void setProperties(String prefix,Properties properties){ // currently prefix ==""
this.postProcessingParameters.setProperties(prefix+"POST_PROCESSING_PARAMETERS.", properties); this.postProcessingParameters.setProperties(prefix+"POST_PROCESSING_PARAMETERS.", properties);
...@@ -130,7 +129,7 @@ public class PostProcessing { ...@@ -130,7 +129,7 @@ public class PostProcessing {
for (int i=0;i<titles.length;i++){ for (int i=0;i<titles.length;i++){
titles[i]=titles0[i%titles0.length]+(i/titles0.length); titles[i]=titles0[i%titles0.length]+(i/titles0.length);
} }
this.sdfaInstance.showArrays( ShowDoubleFloatArrays.showArrays(
interSensor.overlapImages, interSensor.overlapImages,
width, width,
height, height,
...@@ -437,7 +436,7 @@ public class PostProcessing { ...@@ -437,7 +436,7 @@ public class PostProcessing {
titlesSlices[i]=img[i%img.length]+channelNames[channels[i/img.length]]; titlesSlices[i]=img[i%img.length]+channelNames[channels[i/img.length]];
} }
if (debugLevel>1){ if (debugLevel>1){
(new ShowDoubleFloatArrays()).showArrays( ShowDoubleFloatArrays.showArrays(
slices, slices,
size, size,
size, size,
...@@ -587,7 +586,7 @@ public class PostProcessing { ...@@ -587,7 +586,7 @@ public class PostProcessing {
String title="DSH"; String title="DSH";
for (int i=0;i<numImg;i++) titleSlices+="-"+img[i]; for (int i=0;i<numImg;i++) titleSlices+="-"+img[i];
titleSlices+="_D"+IJ.d2s(dd,2)+"_X"+IJ.d2s(dX,2)+"_Y"+IJ.d2s(dY,2); titleSlices+="_D"+IJ.d2s(dd,2)+"_X"+IJ.d2s(dX,2)+"_Y"+IJ.d2s(dY,2);
(new ShowDoubleFloatArrays()).showArrays( ShowDoubleFloatArrays.showArrays(
results, results,
size, size,
size, size,
...@@ -753,7 +752,7 @@ public class PostProcessing { ...@@ -753,7 +752,7 @@ public class PostProcessing {
} }
} }
this.sdfaInstance.showArrays( ShowDoubleFloatArrays.showArrays(
linearFeatures, linearFeatures,
interSensor.mapWidth, interSensor.mapWidth,
interSensor.mapHeight, interSensor.mapHeight,
...@@ -815,7 +814,7 @@ public class PostProcessing { ...@@ -815,7 +814,7 @@ public class PostProcessing {
} }
} }
//TODO: just show linearFeatures array and measure time //TODO: just show linearFeatures array and measure time
this.sdfaInstance.showArrays( ShowDoubleFloatArrays.showArrays(
filteredFeaturesImage, filteredFeaturesImage,
interSensor.mapWidth, interSensor.mapWidth,
interSensor.mapHeight, interSensor.mapHeight,
......
...@@ -1014,7 +1014,7 @@ public class FactorConvKernel { ...@@ -1014,7 +1014,7 @@ public class FactorConvKernel {
return lMAData.getTargetRMSW(); return lMAData.getTargetRMSW();
} }
public double [] generateAsymWeights( public static double [] generateAsymWeights(
int asym_size, int asym_size,
double scale, double scale,
double xc, double xc,
...@@ -1249,7 +1249,8 @@ public class FactorConvKernel { ...@@ -1249,7 +1249,8 @@ public class FactorConvKernel {
System.out.println(); System.out.println();
} }
} }
if ((RMSes!=null) && (RMSes[1] < this.goal_rms_pure)){ // if ((RMSes!=null) && (RMSes[1] < this.goal_rms_pure)){
if (RMSes[1] < this.goal_rms_pure) {
if (debugLevel > 0){ if (debugLevel > 0){
System.out.println("calcKernels(): reached goal: "+RMSes[1]+" < "+this.goal_rms_pure); System.out.println("calcKernels(): reached goal: "+RMSes[1]+" < "+this.goal_rms_pure);
} }
...@@ -1803,20 +1804,16 @@ public class FactorConvKernel { ...@@ -1803,20 +1804,16 @@ public class FactorConvKernel {
System.out.println("sym_kernel.length="+sym_kernel.length); System.out.println("sym_kernel.length="+sym_kernel.length);
System.out.println("asym_kernel.length="+asym_kernel.length); System.out.println("asym_kernel.length="+asym_kernel.length);
System.out.println("target_kernel.length="+target_kernel.length); System.out.println("target_kernel.length="+target_kernel.length);
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging? ShowDoubleFloatArrays.showArrays(sym_kernel, sym_radius, sym_radius, "init-sym_kernel");
sdfa_instance.showArrays(sym_kernel, sym_radius, sym_radius, "init-sym_kernel"); ShowDoubleFloatArrays.showArrays(asym_kernel, asym_size, asym_size, "init-asym_kernel");
sdfa_instance.showArrays(asym_kernel, asym_size, asym_size, "init-asym_kernel"); ShowDoubleFloatArrays.showArrays(target_kernel, conv_size, conv_size, "target_kernel");
sdfa_instance.showArrays(target_kernel, conv_size, conv_size, "target_kernel");
} }
return kernels; return kernels;
} }
public int getNumPars(double [] kvect){ public static int getNumPars(double [] kvect){
int num_pars = 0; int num_pars = 0;
for (int i = 0; i<kvect.length ; i++){ for (int i = 0; i<kvect.length ; i++){
if (!Double.isNaN(kvect[i]))num_pars++; if (!Double.isNaN(kvect[i]))num_pars++;
......
...@@ -887,7 +887,7 @@ public class GpuQuad{ // quad camera description ...@@ -887,7 +887,7 @@ public class GpuQuad{ // quad camera description
* @param disparity_corr - add to all disparities (minus disparity at infinity) * @param disparity_corr - add to all disparities (minus disparity at infinity)
* @param out_image from which camera channels to generate image (currently 0/1) * @param out_image from which camera channels to generate image (currently 0/1)
* @param corr_mask from which correlation pairs to generate (0x3f - all 6) * @param corr_mask from which correlation pairs to generate (0x3f - all 6)
* @param threadsMax - historic * @param THREADS_MAX - historic
* @param debugLevel - not yet used * @param debugLevel - not yet used
* @return per-tile array of TpTask instances (need to be finalized by the GPU kernel) * @return per-tile array of TpTask instances (need to be finalized by the GPU kernel)
*/ */
...@@ -931,7 +931,7 @@ public class GpuQuad{ // quad camera description ...@@ -931,7 +931,7 @@ public class GpuQuad{ // quad camera description
* @param disparity_corr - add to all disparities (minus disparity at infinity) * @param disparity_corr - add to all disparities (minus disparity at infinity)
* @param out_images per-tile array [tilesX*tilesY] from which tiles to generate image (currently 0/1) * @param out_images per-tile array [tilesX*tilesY] from which tiles to generate image (currently 0/1)
* @param corr_mask per-tile array [tilesX*tilesY] from which correlation pairs to generate (0x3f - all 6) * @param corr_mask per-tile array [tilesX*tilesY] from which correlation pairs to generate (0x3f - all 6)
* @param threadsMax - historic * @param THREADS_MAX - historic
* @param debugLevel - not yet used * @param debugLevel - not yet used
* @return per-tile array of TpTask instances (need to be finalized by the GPU kernel) * @return per-tile array of TpTask instances (need to be finalized by the GPU kernel)
*/ */
...@@ -2672,26 +2672,6 @@ public class GpuQuad{ // quad camera description ...@@ -2672,26 +2672,6 @@ public class GpuQuad{ // quad camera description
cuMemcpyHtoD(gpu_color_weights, Pointer.to(fcolor_weights), fcolor_weights.length * Sizeof.FLOAT); cuMemcpyHtoD(gpu_color_weights, Pointer.to(fcolor_weights), fcolor_weights.length * Sizeof.FLOAT);
/*
dim3 threads0(CONVERT_DIRECT_INDEXING_THREADS, 1, 1);
dim3 blocks0 ((tp_task_size + CONVERT_DIRECT_INDEXING_THREADS -1) >> CONVERT_DIRECT_INDEXING_THREADS_LOG2,1, 1);
int linescan_order = 1; // output low-res in linescan order, 0 - in gpu_texture_indices order
printf("threads0=(%d, %d, %d)\n",threads0.x,threads0.y,threads0.z);
printf("blocks0=(%d, %d, %d)\n",blocks0.x,blocks0.y,blocks0.z);
int cpu_pnum_texture_tiles = 0;
int * gpu_pnum_texture_tiles;
checkCudaErrors (cudaMalloc((void **)&gpu_pnum_texture_tiles, sizeof(int)));
#define CONVERT_DIRECT_INDEXING_THREADS_LOG2 5
#define CONVERT_DIRECT_INDEXING_THREADS (1 << CONVERT_DIRECT_INDEXING_THREADS_LOG2) // 32
int tp_task_size = TILESX * TILESY; // sizeof(ftask_data)/sizeof(float)/task_size; // number of task tiles
cpu_pnum_texture_tiles = 0;
checkCudaErrors(cudaMemcpy(
gpu_pnum_texture_tiles,
&cpu_pnum_texture_tiles,
sizeof(int),
cudaMemcpyHostToDevice));
*/
int CONVERT_DIRECT_INDEXING_THREADS_LOG2 = 5; int CONVERT_DIRECT_INDEXING_THREADS_LOG2 = 5;
int CONVERT_DIRECT_INDEXING_THREADS = (1 << CONVERT_DIRECT_INDEXING_THREADS_LOG2); // 32 int CONVERT_DIRECT_INDEXING_THREADS = (1 << CONVERT_DIRECT_INDEXING_THREADS_LOG2); // 32
...@@ -2699,16 +2679,6 @@ public class GpuQuad{ // quad camera description ...@@ -2699,16 +2679,6 @@ public class GpuQuad{ // quad camera description
int [] blocks0 = {(num_task_tiles + CONVERT_DIRECT_INDEXING_THREADS -1) >> CONVERT_DIRECT_INDEXING_THREADS_LOG2,1, 1}; int [] blocks0 = {(num_task_tiles + CONVERT_DIRECT_INDEXING_THREADS -1) >> CONVERT_DIRECT_INDEXING_THREADS_LOG2,1, 1};
int [] cpu_pnum_texture_tiles = {0}; int [] cpu_pnum_texture_tiles = {0};
cuMemcpyHtoD(gpu_texture_indices_len, Pointer.to(cpu_pnum_texture_tiles), 1 * Sizeof.INT); cuMemcpyHtoD(gpu_texture_indices_len, Pointer.to(cpu_pnum_texture_tiles), 1 * Sizeof.INT);
/*
create_nonoverlap_list<<<blocks0,threads0>>>(
num_cams, // int num_cams,
gpu_ftasks, // float * gpu_ftasks, // flattened tasks, 27 floats for quad EO, 99 floats for LWIR16
tp_task_size, // int num_tiles, // number of tiles in task
TILESX, // int width, // number of tiles in a row
gpu_texture_indices, // int * nonoverlap_list, // pointer to the calculated number of non-zero tiles
gpu_pnum_texture_tiles); // int * pnonoverlap_length) // indices to gpu_tasks // should be initialized to zero
cudaDeviceSynchronize();
*/
Pointer kp_create_nonoverlap_list = Pointer.to( Pointer kp_create_nonoverlap_list = Pointer.to(
Pointer.to(new int[] {num_cams}), // int num_cams, // number of sensors Pointer.to(new int[] {num_cams}), // int num_cams, // number of sensors
Pointer.to(gpu_ftasks), // float * gpu_ftasks, // flattened tasks, 29 floats for quad EO, 101 floats for LWIR16 Pointer.to(gpu_ftasks), // float * gpu_ftasks, // flattened tasks, 29 floats for quad EO, 101 floats for LWIR16
...@@ -2725,31 +2695,7 @@ public class GpuQuad{ // quad camera description ...@@ -2725,31 +2695,7 @@ public class GpuQuad{ // quad camera description
0, null, // Shared memory size and stream (shared - only dynamic, static is in code) 0, null, // Shared memory size and stream (shared - only dynamic, static is in code)
kp_create_nonoverlap_list, null); // Kernel- and extra parameters kp_create_nonoverlap_list, null); // Kernel- and extra parameters
cuCtxSynchronize(); cuCtxSynchronize();
/*
checkCudaErrors(cudaMemcpy(
&cpu_pnum_texture_tiles,
gpu_pnum_texture_tiles,
sizeof(int),
cudaMemcpyDeviceToHost));
*/
cuMemcpyDtoH(Pointer.to(cpu_pnum_texture_tiles), gpu_texture_indices_len, 1 * Sizeof.FLOAT); cuMemcpyDtoH(Pointer.to(cpu_pnum_texture_tiles), gpu_texture_indices_len, 1 * Sizeof.FLOAT);
/*
printf("cpu_pnum_texture_tiles = %d\n", cpu_pnum_texture_tiles);
int num_cams_per_thread = NUM_THREADS / TEXTURE_THREADS_PER_TILE; // 4 cameras parallel, then repeat
dim3 threads_texture1(TEXTURE_THREADS_PER_TILE, num_cams_per_thread, 1); // TEXTURE_TILES_PER_BLOCK, 1);
dim3 grid_texture1((cpu_pnum_texture_tiles + TEXTURE_TILES_PER_BLOCK-1) / TEXTURE_TILES_PER_BLOCK,1,1);
printf("threads_texture1=(%d, %d, %d)\n",threads_texture1.x,threads_texture1.y,threads_texture1.z);
printf("grid_texture1=(%d, %d, %d)\n",grid_texture1.x,grid_texture1.y,grid_texture1.z);
int shared_size = host_get_textures_shared_size( // in bytes
num_cams, // int num_cams, // actual number of cameras
texture_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono
0); // int * offsets); // in floats
printf("\n1. shared_size=%d, num_cams=%d, colors=%d\n",shared_size,num_cams, texture_colors);
cudaFuncSetAttribute(textures_accumulate, cudaFuncAttributeMaxDynamicSharedMemorySize, 65536); // for CC 7.5
cudaFuncSetAttribute(textures_accumulate, cudaFuncAttributePreferredSharedMemoryCarveout,cudaSharedmemCarveoutMaxShared);
*/
int num_cams_per_thread = GPUTileProcessor.NUM_THREADS / GPUTileProcessor.TEXTURE_THREADS_PER_TILE; // 4 cameras parallel, then repeat int num_cams_per_thread = GPUTileProcessor.NUM_THREADS / GPUTileProcessor.TEXTURE_THREADS_PER_TILE; // 4 cameras parallel, then repeat
int[] threads_texture = {GPUTileProcessor.TEXTURE_THREADS_PER_TILE, num_cams_per_thread, 1}; // TEXTURE_TILES_PER_BLOCK, 1); int[] threads_texture = {GPUTileProcessor.TEXTURE_THREADS_PER_TILE, num_cams_per_thread, 1}; // TEXTURE_TILES_PER_BLOCK, 1);
int[] grid_texture = {(cpu_pnum_texture_tiles[0] + GPUTileProcessor.TEXTURE_TILES_PER_BLOCK-1) / GPUTileProcessor.TEXTURE_TILES_PER_BLOCK,1,1}; int[] grid_texture = {(cpu_pnum_texture_tiles[0] + GPUTileProcessor.TEXTURE_TILES_PER_BLOCK-1) / GPUTileProcessor.TEXTURE_TILES_PER_BLOCK,1,1};
...@@ -2757,35 +2703,6 @@ public class GpuQuad{ // quad camera description ...@@ -2757,35 +2703,6 @@ public class GpuQuad{ // quad camera description
num_cams, // int num_cams, // actual number of cameras num_cams, // int num_cams, // actual number of cameras
num_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono num_colors, // int num_colors, // actual number of colors: 3 for RGB, 1 for LWIR/mono
null); // int * offsets); // in floats null); // int * offsets); // in floats
/*
textures_accumulate <<<grid_texture1,threads_texture1, shared_size>>>( // 65536>>>( //
num_cams, // int num_cams, // number of cameras used
(int *) 0, // int * woi, // x, y, width,height
gpu_clt, // float ** gpu_clt, // [num_cams] ->[TILES-Y][TILES-X][colors][DTT_SIZE*DTT_SIZE]
cpu_pnum_texture_tiles, // *pnum_texture_tiles, // size_t num_texture_tiles, // number of texture tiles to process
0, // gpu_texture_indices_offset,// add to gpu_texture_indices
gpu_texture_indices, // int * gpu_texture_indices,// packed tile + bits (now only (1 << 7)
gpu_geometry_correction, // struct gc * gpu_geometry_correction,
texture_colors, // int colors, // number of colors (3/1)
(texture_colors == 1), // int is_lwir, // do not perform shot correction
generate_RBGA_params[0], // min_shot, // float min_shot, // 10.0
generate_RBGA_params[1], // scale_shot, // float scale_shot, // 3.0
generate_RBGA_params[2], // diff_sigma, // float diff_sigma, // pixel value/pixel change
generate_RBGA_params[3], // diff_threshold,// float diff_threshold, // pixel value/pixel change
generate_RBGA_params[4], // min_agree, // float min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
gpu_color_weights, // float weights[3], // scale for R,B,G
1, // dust_remove, // int dust_remove, // Do not reduce average weight when only one image differs much from the average
keep_texture_weights, // 0, // 1 // int keep_weights, // return channel weights after A in RGBA (was removed) (should be 0 if gpu_texture_rbg)?
// combining both non-overlap and overlap (each calculated if pointer is not null )
0, // size_t texture_rbg_stride, // in floats
(float *) 0, // float * gpu_texture_rbg, // (number of colors +1 + ?)*16*16 rgba texture tiles
dstride_textures /sizeof(float), // texture_stride, // size_t texture_stride, // in floats (now 256*4 = 1024)
gpu_textures, // (float *) 0, // gpu_texture_tiles, //(float *)0);// float * gpu_texture_tiles); // (number of colors +1 + ?)*16*16 rgba texture tiles
linescan_order, // int linescan_order, // if !=0 then output gpu_diff_rgb_combo in linescan order, else - in gpu_texture_indices order
gpu_diff_rgb_combo, //); // float * gpu_diff_rgb_combo) // diff[num_cams], R[num_cams], B[num_cams],G[num_cams]
TILESX);
*/
cuFuncSetAttribute(this.gpuTileProcessor.GPU_TEXTURES_ACCUMULATE_kernel, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, 65536); cuFuncSetAttribute(this.gpuTileProcessor.GPU_TEXTURES_ACCUMULATE_kernel, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, 65536);
Pointer kp_textures_accumulate = Pointer.to( Pointer kp_textures_accumulate = Pointer.to(
Pointer.to(new int[] {num_cams}), // int num_cams, Pointer.to(new int[] {num_cams}), // int num_cams,
......
...@@ -665,7 +665,7 @@ public class ImagejJp4Tiff { ...@@ -665,7 +665,7 @@ public class ImagejJp4Tiff {
} }
if (dbg_img != null) { if (dbg_img != null) {
(new ShowDoubleFloatArrays()).showArrays( // out of boundary 15 ShowDoubleFloatArrays.showArrays( // out of boundary 15
dbg_img, dbg_img,
width, width,
height, height,
...@@ -806,7 +806,7 @@ public class ImagejJp4Tiff { ...@@ -806,7 +806,7 @@ public class ImagejJp4Tiff {
} }
if (dbg_img != null) { if (dbg_img != null) {
(new ShowDoubleFloatArrays()).showArrays( // out of boundary 15 ShowDoubleFloatArrays.showArrays( // out of boundary 15
dbg_img, dbg_img,
width, width,
height, height,
......
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