Commit d531d201 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

merged with nc393 branch

parents 01246a62 b759e500
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2514,8 +2514,8 @@ if (PROCESS_PARAMETERS.saveSettings) saveProperties(FILE_PARAMETERS.resultsDirec
					  tileY = nTile /tilesX;
					  tileX = nTile % tilesX;
					  if (tileX==0) {
						  if (updateStatus) IJ.showStatus("Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY);
						  if (MASTER_DEBUG_LEVEL>2) System.out.println("Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY+" : "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
						  if (updateStatus) IJ.showStatus("(3)Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY);
						  if (MASTER_DEBUG_LEVEL>2) System.out.println("(3)Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY+" : "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
					  }
				  
					  if ((tileY==yTileDebug) && (tileX==xTileDebug)) DEBUG_LEVEL=4;
+357 −144

File changed.

Preview size limit exceeded, changes collapsed.

+151 −86
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import ij.ImageStack;

import java.util.concurrent.atomic.AtomicInteger;

import javax.swing.SwingUtilities;


public class DebayerScissors {
//	showDoubleFloatArrays SDFA_INSTANCE=   new showDoubleFloatArrays();
@@ -96,7 +98,29 @@ public class DebayerScissors {
  	  final Thread[] threads = newThreadArray(threadsMax);
  	  final AtomicInteger ai = new AtomicInteger(0);
  	  final int numberOfKernels=tilesY*tilesX;
  	  
	  int indx,dx,dy,tx,ty,li;
	  final int [] nonOverlapSeq = new int[numberOfKernels];
	  int [] nextFirstFindex=new int[4];
	  indx = 0;
	  li=0;
	  
	  for (dy=0;dy<2;dy++) for (dx=0;dx<2;dx++) {
		  for (ty=dy; ty < tilesY; ty+=2) for (tx=dx; tx < tilesX; tx+=2){
			  nonOverlapSeq[indx++] = ty*tilesX + tx;
		  }
		  nextFirstFindex[li++] = indx;
	  }
	  final AtomicInteger aStopIndex = new AtomicInteger(0);
  	  final long startTime = System.nanoTime();
  	  final AtomicInteger tilesFinishedAtomic = new AtomicInteger(1); // first finished will be 1
  	  if (updateStatus) IJ.showStatus("Reducing sampling aliases, "+tilesY+" rows, threadsMax="+threadsMax);
  	  if (updateStatus) System.out.println("Reducing sampling aliases, "+tilesY+" rows, threadsMax="+threadsMax);
  	  for (li = 0; li < nextFirstFindex.length; li++){
  		  aStopIndex.set(nextFirstFindex[li]);
  		  if (li>0){
  			  ai.set(nextFirstFindex[li-1]);
  		  }
  		  for (int ithread = 0; ithread < threads.length; ithread++) {
  			  threads[ithread] = new Thread() {
  				  public void run() {
@@ -114,17 +138,19 @@ public class DebayerScissors {
  							  debayerParameters.debayerRelativeWidthRedblue, // result red/blue mask mpy by scaled default (square)
  							  debayerParameters.debayerRelativeWidthRedblueMain, // green mask when applied to red/blue, main (center)
  							  debayerParameters.debayerRelativeWidthRedblueClones);// green mask when applied to red/blue, clones 
  					  //  					  for (int nTile0 = ai.getAndIncrement(); nTile0 < numberOfKernels; nTile0 = ai.getAndIncrement()) {
  					  for (int nTile0 = ai.getAndIncrement(); nTile0 < aStopIndex.get(); nTile0 = ai.getAndIncrement()) {
 						  
  				  for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) {
  						  int nTile = nonOverlapSeq[nTile0];
  						  tileY = nTile /tilesX;
  						  tileX = nTile % tilesX;
  					  if (tileX==0) {
  						  if (updateStatus) IJ.showStatus("Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY);
  						  if (globalDebugLevel>2) System.out.println("Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY+" : "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
  						  if (tileX < 2) {
  							  int trow=(tileY+((2*(tileY & 1) + (tileX & 1))*tilesY))/4;
  							  if (updateStatus) IJ.showStatus("Reducing sampling aliases, row "+(trow+1)+" of "+tilesY);
  							  //  						  System.out.println("(1)Reducing sampling aliases, row "+(tileY+1)+" of "+tilesY+" ("+nTile+"/"+nTile0+") col="+(tileX+1));
  							  if (globalDebugLevel>2) System.out.println("Reducing sampling aliases, row "+(trow+1)+" of "+tilesY+" : "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
  						  }

//  					  if ((tileY==yTileDebug) && (tileX==xTileDebug)) this.debugLevel=4;
//  					  else this.debugLevel=wasDebugLevel;
  						  for (chn=0;chn<nChn;chn++){
  							  extractSquareTile( pixels[chn], // source pixel array,
  									  tile[chn], // will be filled, should have correct size before call
@@ -149,8 +175,8 @@ public class DebayerScissors {
  								  debayerParameters.debayerThreshold, // no high frequencies - use default uniform filter
  								  debayerParameters.debayerGamma, // power function applied to the amplitudes before generating spectral masks
  								  debayerParameters.debayerBonus, // scale far pixels as (1.0+bonus*r/rmax)
  							  debayerParameters.mainToAlias,// relative main/alias amplitudes to enable lixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
  							  debayerParameters.debayerMaskBlur, // for both masks  sigma for gaussian blur of the binary masks (<0 -do not use "scissors")
  								  debayerParameters.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)
  								  debayerParameters.debayerMaskBlur, // for both masks  sigma for Gaussian blur of the binary masks (<0 -do not use "scissors")
  								  debayerParameters.debayerUseScissors, // use "scissors", if false - just apply "diamond" ands "square" with DEBAYER_PARAMETERS.debayerRelativeWidthGreen and DEBAYER_PARAMETERS.debayerRelativeWidthRedblue
  								  ((tileY==yTileDebug) && (tileX==xTileDebug))?4:1);
  						  //                                               1); // internal debug level ((this.debugLevel>2) && (yTile==yTile0) && (xTile==xTile0))?3:1;
@@ -166,11 +192,13 @@ public class DebayerScissors {
  							  fht_instance.inverseTransform(tile[chn]);
  							  fht_instance.swapQuadrants(tile[chn]);
  							  /* accumulate result */
  						  /*This is synchronized method. It is possible to make threads to write to non-overlapping regions of the outPixles, but as the accumulation
  						   * takes just small fraction of severtal FHTs, it should be OK - reasonable number of threads will spread and not "stay in line"
  							  /*This is (now was) a synchronized method. It is possible to make threads to write to non-overlapping regions of the outPixles, 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"
  							   */

  						  accumulateSquareTile(outPixles[chn], //  float pixels array to accumulate tile
  							  //accumulateSquareTile(
  							  nonSyncAccumulateSquareTile (
  									  outPixles[chn], //  float pixels array to accumulate tile
  									  tile[chn], // data to accumulate to the pixels array
  									  imgWidth, // width of pixels array
  									  tileX*step, // left corner X
@@ -178,22 +206,34 @@ public class DebayerScissors {
  						  }
  						  if ((tileY==yTileDebug) && (tileX==xTileDebug) && (SDFA_instance!=null)) SDFA_instance.showArrays (tile.clone(),debayerParameters.size,debayerParameters.size, "B00");
  						  
  						  final int numFinished=tilesFinishedAtomic.getAndIncrement();
//  						  final double dprogr= (1.0+numFinished)/numberOfKernels;
  						  if (numFinished % (numberOfKernels/50+1) == 0) {
//  							  System.out.print(numFinished);
  							  SwingUtilities.invokeLater(new Runnable() {
  								  public void run() {
//  									  System.out.println(" --- "+numFinished+"("+numberOfKernels+"): "+dprogr);
  									  IJ.showProgress(numFinished, numberOfKernels);
  								  }
  							  });
  						  }
  					  }
  				  }
  			  };
  		  }		      
  		  startAndJoin(threads);
 // 	  this.debugLevel=wasDebugLevel;
 	      IJ.showProgress(tilesFinishedAtomic.get(), numberOfKernels);
  	  }
//  	  System.out.println("tilesFinishedAtomic.get()="+tilesFinishedAtomic.get()+", numberOfKernels="+numberOfKernels);
  	  if (updateStatus) IJ.showStatus("Reducing sampling aliases DONE");
  	  IJ.showProgress(1.0);
  	  /* prepare result stack to return */
  	  ImageStack outStack=new ImageStack(imgWidth,imgHeight);
  	  for (chn=0;chn<nChn;chn++) {
  		  outStack.addSlice(imageStack.getSliceLabel(chn+1), outPixles[chn]);
  	  }
  	  debayerEnergyWidth=	 (debayerEnergy!=null)?tilesX:0; // for the image to be displayed externally 
//  	  if (debayerParameters.showEnergy) {
//  		  SDFA_INSTANCE.showArrays (debayerEnergy,tilesX,tilesY, "Debayer-Energy");
//  	  }

	  if (globalDebugLevel>0) System.out.println("Reducing sampling aliases done in "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
  	  return outStack;
    }

@@ -273,6 +313,31 @@ public class DebayerScissors {
   		  }
   	  }
     }

     void  nonSyncAccumulateSquareTile(
      		  float [] pixels, //  float pixels array to accumulate tile
      		  double []  tile, // data to accumulate to the pixels array
      		  int       width, // width of pixels array
      		  int          x0, // left corner X
      		  int          y0) { // top corner Y
      	  int length=tile.length;
      	  int size=(int) Math.sqrt(length);
      	  int i,j,x,y;
      	  int height=pixels.length/width;
      	  int index=0;
      	  for (i=0;i<size;i++) {
      		  y=y0+i;
      		  if ((y>=0) && (y<height)) {
      			  index=i*size;
      			  for (j=0;j<size;j++) {
      				  x=x0+j;
      				  if ((x>=0) && (x<width)) pixels[y*width+x]+=tile [index];
      				  index++;
      			  }
      		  }
      	  }
        }
     
     synchronized void  accumulateSquareTile(
   		  double [] pixels, //  float pixels array to accumulate tile
   		  double []  tile, // data to accumulate to the pixels array
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public class DenseCorrespondence {



	private void disparitySweepTile (
	public void disparitySweepTile ( // never used so far
			int tileX,
			int tileY,
			CyclopeanTile [][] allCyclopeanMap,
+2 −0
Original line number Diff line number Diff line
@@ -5989,6 +5989,8 @@ List calibration
    	imp.setProperty("channel",  ""+numSensor);
    	imp.setProperty("comment_subcamera", "number of the subcamera with individual IP, starting with 0");
    	imp.setProperty("subcamera",  ""+camerasInterface.getSubCamera(numSensor));
		imp.setProperty("sensor_port",""+camerasInterface.getSensorPort(numSensor)); 
    	
    	imp.setProperty("comment_subchannel", "number of the sensor port on a subcamera (0..2)");
    	imp.setProperty("subchannel",  ""+camerasInterface.getSubChannel(numSensor));
    	imp.setProperty("comment_entrancePupilForward",  "entrance pupil distance from the azimuth/radius/height, outwards in mm");
Loading