Commit 238bf728 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

next snapshot

parent f606663c
Loading
Loading
Loading
Loading
+56 −4
Original line number Diff line number Diff line
@@ -1914,12 +1914,20 @@ public class EyesisCorrectionParameters {
  		
  		public int        tile_task_op =      0xff;   // bitmask of operation modes applied to tiles (0 - nothing), bits TBD later
  		                                           // +(0..f) - images, +(00.f0) - process pairs +256 - force disparity when combining images
  		// window to process tiles;
  		// window to process tiles (later arbitrary masks will be generated to follow particular stages);
  		public int        tile_task_wl =      0;   // 
  		public int        tile_task_wt =      0;   // 
  		public int        tile_task_ww =      324; // 
  		public int        tile_task_wh =      242; //
  		
  		public double     diff_thershold =    5.0;   // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
  		public boolean    diff_gauss =        true;  // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
  		
  		public boolean    sharp_alpha =       false; // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
  		public boolean    gen_chn_img =       false; // generate shifted channel images
  		public boolean    show_nonoverlap =   true;  // show result RGBA before overlap combined (first channels, then RGBA combined?)
  		public boolean    show_overlap =      true;  // show result RGBA (first channels, then RGBA combined?)
  		
  		

  		
@@ -1943,7 +1951,6 @@ public class EyesisCorrectionParameters {
  			properties.setProperty(prefix+"novignetting_r",   this.novignetting_r+"");
  			properties.setProperty(prefix+"novignetting_g",   this.novignetting_g+"");
  			properties.setProperty(prefix+"novignetting_b",   this.novignetting_b+"");
  			
  			properties.setProperty(prefix+"scale_r",          this.scale_r+"");
  			properties.setProperty(prefix+"scale_g",          this.scale_g+"");
  			properties.setProperty(prefix+"scale_b",          this.scale_b+"");
@@ -1964,6 +1971,17 @@ public class EyesisCorrectionParameters {
  			properties.setProperty(prefix+"max_corr_sigma",   this.max_corr_sigma +"");
  			properties.setProperty(prefix+"max_corr_radius",  this.max_corr_radius +"");
  			properties.setProperty(prefix+"corr_border_contrast", this.corr_border_contrast +"");
  			properties.setProperty(prefix+"tile_task_op",     this.tile_task_op+"");
  			properties.setProperty(prefix+"tile_task_wl",     this.tile_task_wl+"");
  			properties.setProperty(prefix+"tile_task_wt",     this.tile_task_wt+"");
  			properties.setProperty(prefix+"tile_task_ww",     this.tile_task_ww+"");
  			properties.setProperty(prefix+"tile_task_wh",     this.tile_task_wh+"");
  			properties.setProperty(prefix+"diff_thershold",   this.diff_thershold +"");
			properties.setProperty(prefix+"diff_gauss",       this.diff_gauss+"");
			properties.setProperty(prefix+"sharp_alpha",      this.sharp_alpha+"");
			properties.setProperty(prefix+"gen_chn_img",      this.gen_chn_img+"");
			properties.setProperty(prefix+"show_nonoverlap",  this.show_nonoverlap+"");
			properties.setProperty(prefix+"show_overlap",     this.show_overlap+"");
  			
  		}
  		public void getProperties(String prefix,Properties properties){
@@ -2005,6 +2023,18 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"max_corr_sigma")!=null) this.max_corr_sigma=Double.parseDouble(properties.getProperty(prefix+"max_corr_sigma"));
  			if (properties.getProperty(prefix+"max_corr_radius")!=null) this.max_corr_radius=Double.parseDouble(properties.getProperty(prefix+"max_corr_radius"));
  			if (properties.getProperty(prefix+"corr_border_contrast")!=null) this.corr_border_contrast=Double.parseDouble(properties.getProperty(prefix+"corr_border_contrast"));
  			if (properties.getProperty(prefix+"tile_task_op")!=null)   this.tile_task_op=Integer.parseInt(properties.getProperty(prefix+"tile_task_op"));
  			if (properties.getProperty(prefix+"tile_task_wl")!=null)   this.tile_task_wl=Integer.parseInt(properties.getProperty(prefix+"tile_task_wl"));
  			if (properties.getProperty(prefix+"tile_task_wt")!=null)   this.tile_task_wt=Integer.parseInt(properties.getProperty(prefix+"tile_task_wt"));
  			if (properties.getProperty(prefix+"tile_task_ww")!=null)   this.tile_task_ww=Integer.parseInt(properties.getProperty(prefix+"tile_task_ww"));
  			if (properties.getProperty(prefix+"tile_task_wh")!=null)   this.tile_task_wh=Integer.parseInt(properties.getProperty(prefix+"tile_task_wh"));
  			if (properties.getProperty(prefix+"diff_thershold")!=null) this.diff_thershold=Double.parseDouble(properties.getProperty(prefix+"diff_thershold"));
  			if (properties.getProperty(prefix+"diff_gauss")!=null)     this.diff_gauss=Boolean.parseBoolean(properties.getProperty(prefix+"v"));
  			if (properties.getProperty(prefix+"sharp_alpha")!=null)    this.sharp_alpha=Boolean.parseBoolean(properties.getProperty(prefix+"sharp_alpha"));
  			if (properties.getProperty(prefix+"gen_chn_img")!=null)    this.gen_chn_img=Boolean.parseBoolean(properties.getProperty(prefix+"gen_chn_img"));
  			if (properties.getProperty(prefix+"show_nonoverlap")!=null)this.show_nonoverlap=Boolean.parseBoolean(properties.getProperty(prefix+"show_nonoverlap"));
  			if (properties.getProperty(prefix+"show_overlap")!=null)   this.show_overlap=Boolean.parseBoolean(properties.getProperty(prefix+"show_overlap"));
  			
  		}
  		
  		public boolean showDialog() {
@@ -2047,6 +2077,18 @@ public class EyesisCorrectionParameters {
  			gd.addNumericField("Sigma for weights of points around global max to find fractional",        this.max_corr_sigma,  3);
  			gd.addNumericField("Maximal distance from int max to consider",                               this.max_corr_radius,  3);
  			gd.addNumericField("Contrast of dotted border on correlation results",                        this.corr_border_contrast,  6);
  			gd.addMessage("--- tiles tasks ---");
  			gd.addNumericField("Tile operations bits: +(0..f) - images, +(00.f0) - process pairs +256, ... ",  this.tile_task_op,            0);
  			gd.addNumericField("Tile operations window left (in 8x8 tiles)",                              this.tile_task_wl,            0);
  			gd.addNumericField("Tile operations window top",                                              this.tile_task_wt,            0);
  			gd.addNumericField("Tile operations window width",                                            this.tile_task_ww,            0);
  			gd.addNumericField("Tile operations window height",                                           this.tile_task_wh,            0);
  			gd.addNumericField("RMS difference from average to discard channel (255 full scale image)",   this.diff_thershold,  4);
  			gd.addCheckbox    ("Gaussian as weight when averaging images (false - sharp all/nothing)",    this.diff_gauss);
  			gd.addCheckbox    ("Alpha channel: use center 8x8 (unchecked - treat same as RGB)",           this.sharp_alpha);
  			gd.addCheckbox    ("Generate shifted channel images",                                         this.gen_chn_img);
  			gd.addCheckbox    ("Show result RGBA before overlap combined",                                this.show_nonoverlap);
  			gd.addCheckbox    ("Show result RGBA ",                                                       this.show_overlap);

  			WindowTools.addScrollBars(gd);
  			gd.showDialog();
@@ -2090,7 +2132,17 @@ public class EyesisCorrectionParameters {
  			this.max_corr_sigma=        gd.getNextNumber();
  			this.max_corr_radius=       gd.getNextNumber();
  			this.corr_border_contrast=  gd.getNextNumber();
  			
  			this.tile_task_op=    (int) gd.getNextNumber();
  			this.tile_task_wl=    (int) gd.getNextNumber();
  			this.tile_task_wt=    (int) gd.getNextNumber();
  			this.tile_task_ww=    (int) gd.getNextNumber();
  			this.tile_task_wh=    (int) gd.getNextNumber();
  			this.diff_thershold=        gd.getNextNumber();
  			this.diff_gauss=            gd.getNextBoolean();
  			this.sharp_alpha=           gd.getNextBoolean();
  			this.gen_chn_img=           gd.getNextBoolean();
  			this.show_nonoverlap=       gd.getNextBoolean();
  			this.show_overlap=          gd.getNextBoolean();
  			return true;
  		}
    }
+344 −243
Original line number Diff line number Diff line
@@ -2920,6 +2920,7 @@ public class EyesisDCT {
						  image_dtt.clt_lpf(
								  clt_parameters.corr_sigma,
								  clt_data[chn],
								  clt_parameters.transform_size,
								  threadsMax,
								  debugLevel);
					  }
@@ -3612,6 +3613,7 @@ public class EyesisDCT {
						  image_dtt.clt_lpf(
								  clt_parameters.corr_sigma,
								  clt_data[chn],
								  clt_parameters.transform_size,
								  threadsMax,
								  debugLevel);
					  }
@@ -4237,6 +4239,7 @@ public class EyesisDCT {
					  image_dtt.clt_lpf(
							  clt_parameters.corr_sigma,
							  clt_data[iQuad][chn],
							  clt_parameters.transform_size,
							  threadsMax,
							  debugLevel);
				  }
@@ -4814,22 +4817,65 @@ public class EyesisDCT {

		  int tilesY = imp_quad[0].getHeight()/clt_parameters.transform_size;
		  int tilesX = imp_quad[0].getWidth()/clt_parameters.transform_size;
		  // temporary setting up tile task file (one integer per tile, bitmask
		  // for testing defined for a window, later the tiles to process will be calculated based on previous passes results
		  int [][] tile_op = new int [tilesY][tilesX]; // all zero
		  int txl =  clt_parameters.tile_task_wl;
		  int txr =  txl + clt_parameters.tile_task_wl;
		  int tyt =  clt_parameters.tile_task_wl;
		  int tyb =  tyt + clt_parameters.tile_task_wh;
		  if      (txl < 0)       txl = 0;
		  else if (txl >= tilesX) txl = tilesX - 1;

		  if      (txr <= txl)    txr = txl + 1;
		  else if (txr >  tilesX) txr = tilesX;

		  if      (tyt < 0)       tyt = 0;
		  else if (tyt >= tilesY) tyt = tilesY - 1;

		  if      (tyb <= tyt)    tyb = tyt + 1;
		  else if (tyb >  tilesY) tyb = tilesY;

		  for (int i = tyt; i < tyb; i++) {
			  for (int j = txl; j < txr; j++) {
				  tile_op[i][j] = clt_parameters.tile_task_op;
			  }
		  }
		  //TODO: Add array of default disparity - use for combining images in force disparity mode (no correlation), when disparity is predicted from other tiles

		  double [][][][]     clt_corr_combo =   null;
		  double [][][][][]   clt_corr_partial = null;
		  double [][][][]     texture_tiles =    null; // [tilesY][tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualizaion mode full 16 or overlapped
		  // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
		  if (clt_parameters.correlate){
			  clt_corr_combo =    new double [2][tilesY][tilesX][];
			  texture_tiles =     new double [tilesY][tilesX]["RGBA".length()][];
			  for (int i = 0; i < tilesY; i++){
				  for (int j = 0; j < tilesX; j++){
					  clt_corr_combo[0][i][j] = null;
					  clt_corr_combo[1][i][j] = null;
					  texture_tiles[i][j] = null;
				  }
			  }
			  if (clt_parameters.corr_keep){
				  clt_corr_partial = new double [tilesY][tilesX][][][];
				  for (int i = 0; i < tilesY; i++){
					  for (int j = 0; j < tilesX; j++){
						  clt_corr_partial[i][j] = null;
					  }
				  }
			  }
		  }
		  double [][] disparity_map = new double [8][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)  
		  double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
				  tile_op,                      // per-tile operation bit codes
				  clt_parameters.disparity,     // final double            disparity,
				  double_stacks,                // final double [][][]      imade_data, // first index - number of image in a quad
				  // correlation results - final and partial          
				  clt_corr_combo,               // [tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
				  clt_corr_partial,             // [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
				  disparity_map,                // [2][tilesY * tilesX]
				  texture_tiles,                // [tilesY][tilesX]["RGBA".length()][]; 			  
				  imp_quad[0].getWidth(),       // final int width,
				  clt_parameters.fat_zero,      // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
				  clt_parameters.corr_sym,
@@ -4859,8 +4905,50 @@ public class EyesisDCT {

		  System.out.println("clt_data.length="+clt_data.length+" clt_data[0].length="+clt_data[0].length
				  +" clt_data[0][0].length="+clt_data[0][0].length+" clt_data[0][0][0].length="+
				  clt_data[0][0][0].length+" clt_data[0][0][0][0].length="+clt_data[0][0][0][0].length+
				  " clt_data[0][0][0][0][0].length="+clt_data[0][0][0][0][0].length);
				  clt_data[0][0][0].length); 
//		  +" clt_data[0][0][0][0].length="+clt_data[0][0][0][0].length+
//				  " clt_data[0][0][0][0][0].length="+clt_data[0][0][0][0][0].length);
		  // visualize texture tiles as RGBA slices
		  double [][] texture_nonoverlap = null;
		  double [][] texture_overlap = null;
		  String [] rgba_titles = {"red","green","blue","alpha"};
		  if (texture_tiles != null){
			  if (clt_parameters.show_nonoverlap){
				  texture_nonoverlap = image_dtt.combineRGBATiles(
						  texture_tiles,                 // array [tilesY][tilesX][4][4*transform_size] or [tilesY][tilesX]{null}   
						  clt_parameters.transform_size,
						  false,                         // when false - output each tile as 16x16, true - overlap to make 8x8
						  clt_parameters.sharp_alpha,    // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only 
						  threadsMax,                    // maximal number of threads to launch                         
						  debugLevel);
				  sdfa_instance.showArrays(
						  texture_nonoverlap,
						  tilesX * (2 * clt_parameters.transform_size),
						  tilesY * (2 * clt_parameters.transform_size),
						  true,
						  name + "-TXTNOL-D"+clt_parameters.disparity,
						  rgba_titles );

			  }
			  if (clt_parameters.show_overlap){
				  texture_overlap = image_dtt.combineRGBATiles(
						  texture_tiles,                 // array [tilesY][tilesX][4][4*transform_size] or [tilesY][tilesX]{null}   
						  clt_parameters.transform_size,
						  true,                         // when false - output each tile as 16x16, true - overlap to make 8x8
						  clt_parameters.sharp_alpha,    // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only 
						  threadsMax,                    // maximal number of threads to launch                         
						  debugLevel);
				  sdfa_instance.showArrays(
						  texture_overlap,
						  tilesX * clt_parameters.transform_size,
						  tilesY * clt_parameters.transform_size,
						  true,
						  name + "-TXTOL-D"+clt_parameters.disparity,
						  rgba_titles );

			  }

		  }
		  // visualize correlation results
		  if (clt_corr_combo!=null){
			  if (disparity_map != null){
@@ -4884,6 +4972,7 @@ public class EyesisDCT {
				  for (int i = 0; i<corr_rslt.length; i++) {
					  corr_rslt[i] = image_dtt.corr_dbg(
							  clt_corr_combo[i],
							  2*clt_parameters.transform_size - 1,
							  clt_parameters.corr_border_contrast,
							  threadsMax,
							  debugLevel);
@@ -4898,7 +4987,7 @@ public class EyesisDCT {
						  titles );
			  }

			  if (debugLevel > -1){
			  if (debugLevel > 0){ // -1
				  if (clt_corr_partial!=null){
					  String [] allColorNames = {"red","blue","green","combo"};
					  String [] titles = new String[clt_corr_partial.length];
@@ -4907,6 +4996,9 @@ public class EyesisDCT {
					  }
					  double [][] corr_rslt_partial = image_dtt.corr_partial_dbg(
							  clt_corr_partial,
							  2*clt_parameters.transform_size - 1,	//final int corr_size,
							  4,	// final int pairs,
							  4,    // final int colors,
							  clt_parameters.corr_border_contrast,
							  threadsMax,
							  debugLevel);
@@ -4921,7 +5013,8 @@ public class EyesisDCT {
			  }
		  }


		  if (clt_parameters.gen_chn_img) {
			  ImagePlus [] imps_RGB = new ImagePlus[clt_data.length];
			  for (int iQuad = 0; iQuad < clt_data.length; iQuad++){

				  String title=name+"-"+String.format("%02d", iQuad);
@@ -4932,6 +5025,7 @@ public class EyesisDCT {
						  image_dtt.clt_lpf(
								  clt_parameters.corr_sigma,
								  clt_data[iQuad][chn],
								  clt_parameters.transform_size,
								  threadsMax,
								  debugLevel);
					  }
@@ -4973,7 +5067,7 @@ public class EyesisDCT {
							  debugLevel);

				  }
			  if (debugLevel > 0) sdfa_instance.showArrays(
				  if (debugLevel > 0) sdfa_instance.showArrays( // -1
						  iclt_data,
						  (tilesX + 0) * clt_parameters.transform_size,
						  (tilesY + 0) * clt_parameters.transform_size,
@@ -5108,7 +5202,7 @@ public class EyesisDCT {
							  eyesisCorrections.correctionsParameters.JPEG_quality); // save, no show
				  }
				  // convert to RGB48 (16 bits per color component)
			  ImagePlus imp_RGB;
				  //				  ImagePlus imp_RGB;
				  stack=eyesisCorrections.convertRGB32toRGB16Stack(
						  stack,
						  rgbParameters); 
@@ -5132,33 +5226,40 @@ public class EyesisDCT {
					  //				  eyesisCorrections.saveAndShow(compositeImage, this.correctionsParameters, this.correctionsParameters.save16, true); // save, no show
				  }

			  imp_RGB=eyesisCorrections.convertRGB48toRGB24(
				  imps_RGB[iQuad]=eyesisCorrections.convertRGB48toRGB24(
						  stack,
						  title+"-RGB24-D"+clt_parameters.disparity,
						  0, 65536, // r range 0->0, 65536->256
						  0, 65536, // g range
						  0, 65536);// b range
				  if (JPEG_scale!=1.0){
				  ImageProcessor ip=imp_RGB.getProcessor();
					  ImageProcessor ip=imps_RGB[iQuad].getProcessor();
					  ip.setInterpolationMethod(ImageProcessor.BICUBIC);
					  ip=ip.resize((int)(ip.getWidth()*JPEG_scale),(int) (ip.getHeight()*JPEG_scale));
				  imp_RGB= new ImagePlus(imp_RGB.getTitle(),ip);
				  imp_RGB.updateAndDraw();
					  imps_RGB[iQuad]= new ImagePlus(imps_RGB[iQuad].getTitle(),ip);
					  imps_RGB[iQuad].updateAndDraw();
				  }
				  if (iQuad <0) eyesisCorrections.saveAndShow(imps_RGB[iQuad], this.correctionsParameters); // individual images (just commented out)
			  } // and generating shifted channle images
			  // combine to a sliced color image
			  int [] slice_seq = {0,1,3,2}; //clockwise
			  int width = imps_RGB[0].getWidth();
			  int height = imps_RGB[0].getHeight();
			  ImageStack array_stack=new ImageStack(width,height);
			  for (int i = 0; i<slice_seq.length; i++){
				  if (imps_RGB[slice_seq[i]] != null) {
					  array_stack.addSlice("port_"+slice_seq[i], imps_RGB[slice_seq[i]].getProcessor().getPixels());
				  } else {
					  array_stack.addSlice("port_"+slice_seq[i], results[slice_seq[i]].getProcessor().getPixels());
				  }
			  eyesisCorrections.saveAndShow(imp_RGB, this.correctionsParameters);
			  }
			  ImagePlus imp_stack = new ImagePlus(name+"-SHIFTED-D"+clt_parameters.disparity, array_stack);
			  imp_stack.getProcessor().resetMinAndMax();
			  imp_stack.updateAndDraw();
			  //imp_stack.getProcessor().resetMinAndMax();
			  //imp_stack.show();
			  eyesisCorrections.saveAndShow(imp_stack, this.correctionsParameters);
		  }
		  return results;
	  }


	  
	  
	  
	  
	  
	  
	  
	  
	  

}
+3 −1
Original line number Diff line number Diff line
@@ -3968,6 +3968,7 @@ private Panel panel1,
        		image_dtt.clt_lpf( // filter in-place
        				CLT_PARAMETERS.corr_sigma,            // final double          sigma,
        				clt_corr[chn],                        // final double [][][][] clt_data,
        				CLT_PARAMETERS.transform_size,
        				THREADS_MAX,                          // maximal number of threads to launch                         
        				DEBUG_LEVEL);                        // globalDebugLevel)
        	}
@@ -4018,11 +4019,12 @@ private Panel panel1,
        			THREADS_MAX,
        			DEBUG_LEVEL);
        }
        if (DEBUG_LEVEL > -1){
        if (DEBUG_LEVEL > 0){ //==============   -1 =================
            double [][] corr_rslt = new double [clt_corr.length][];
            for (int chn = 0; chn < clt_corr.length; chn++) {
            	corr_rslt[chn] = image_dtt.corr_dbg(
            			corr_tiles[chn],
            			2*CLT_PARAMETERS.transform_size - 1,
            			CLT_PARAMETERS.corr_border_contrast,
            			THREADS_MAX,
            			DEBUG_LEVEL);
+209 −57

File changed.

Preview size limit exceeded, changes collapsed.