Commit 4ffb8a32 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

working on calculating grids for low frequency pattern

parent 78aea970
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -1413,9 +1413,13 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
	    NodeList allNodes=doc.getDocumentElement().getElementsByTagName("*");
	    NodeList allNodes=doc.getDocumentElement().getElementsByTagName("*");
	    for (int i=0;i<allNodes.getLength();i++) {
	    for (int i=0;i<allNodes.getLength();i++) {
	        String name= allNodes.item(i).getNodeName();
	        String name= allNodes.item(i).getNodeName();
            String value=allNodes.item(i).getFirstChild().getNodeValue();
	        String value="";
    		imp.setProperty(name, value);
	        try {
	        	value=allNodes.item(i).getFirstChild().getNodeValue();
	        } catch(Exception e) {


	        }
    		imp.setProperty(name, value);
	    }
	    }


		return true;
		return true;
+338 −131

File changed.

Preview size limit exceeded, changes collapsed.

+37 −15
Original line number Original line Diff line number Diff line
@@ -23,15 +23,16 @@ package com.elphel.imagej.calibration;
 **
 **
 */
 */


import ij.IJ;
import ij.Prefs;
import ij.gui.GenericDialog;

import java.io.File;
import java.io.File;
import java.io.FilenameFilter;
import java.util.Properties;
import java.util.Properties;


import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.common.WindowTools;


import ij.IJ;
import ij.Prefs;
import ij.gui.GenericDialog;



    public class DistortionProcessConfiguration{
    public class DistortionProcessConfiguration{
    	public String  sourceDirectory="";
    	public String  sourceDirectory="";
@@ -207,4 +208,25 @@ import com.elphel.imagej.common.WindowTools;
	       	return sourceFiles;
	       	return sourceFiles;
    	}
    	}


        public String[] selectSourceSets() {
			File dir= new File (this.sourceDirectory);
			if (this.debugLevel>1) System.out.println("selectSourceSets, dir="+this.sourceDirectory);
			if (!dir.exists()) {
				String error="Source directory "+this.sourceDirectory+" does not exist.";
        		IJ.showMessage("No files selected");
				if (this.debugLevel>1) System.out.println("selectSourceFiles() ERROR:"+error);
				return null;
			}
			File [] sourceFileSets = dir.listFiles(new FilenameFilter() {
			  @Override
			  public boolean accept(File current, String name) {
			    return new File(current, name).isDirectory();
			  }
			  }
			});
			String [] sourceSets = new String[sourceFileSets.length];
			for (int i=0;i<sourceSets.length;i++) sourceSets[i]=sourceFileSets[i].getPath();
			return sourceSets;
        }

    }
+267 −260
Original line number Original line Diff line number Diff line
package com.elphel.imagej.calibration;
package com.elphel.imagej.calibration;
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.Prefs;
import ij.gui.GenericDialog;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;

import java.awt.Rectangle;
import java.awt.Rectangle;
import java.io.File;
import java.io.File;
import java.util.ArrayList;
import java.util.ArrayList;
@@ -19,14 +9,22 @@ import java.util.concurrent.atomic.AtomicInteger;


import javax.swing.SwingUtilities;
import javax.swing.SwingUtilities;


import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.calibration.SimulationPattern.SimulParameters;
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.jp4.JP46_Reader_camera;


import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.Prefs;
import ij.gui.GenericDialog;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;

public class EyesisAberrations {
public class EyesisAberrations {
	public double [][][][] pdfKernelMap=null;
	public double [][][][] pdfKernelMap=null;
	JP46_Reader_camera JP4_INSTANCE=       new JP46_Reader_camera(false);
	JP46_Reader_camera JP4_INSTANCE=       new JP46_Reader_camera(false);
@@ -181,6 +179,7 @@ public class EyesisAberrations {
		final int numberOfKernelsInChn=tilesY*tilesX;
		final int numberOfKernelsInChn=tilesY*tilesX;
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					float [] pixels=null;
					float [] pixels=null;
					double [] kernel= new double[inverseParameters.dSize*inverseParameters.dSize];
					double [] kernel= new double[inverseParameters.dSize*inverseParameters.dSize];
@@ -555,7 +554,7 @@ public class EyesisAberrations {
						iy=-iy;
						iy=-iy;
					}
					}
					ix= (ix+size) % size;
					ix= (ix+size) % size;
					floatPixels[i]=(float) clusterMap[iy][ix];
					floatPixels[i]=clusterMap[iy][ix];
				}
				}
				ip.setPixels(floatPixels);
				ip.setPixels(floatPixels);
				ip.resetMinAndMax();
				ip.resetMinAndMax();
@@ -639,8 +638,8 @@ public class EyesisAberrations {
				row2=(fftsize-row1) %fftsize;
				row2=(fftsize-row1) %fftsize;
				for (col1=0;col1 < fftsize;col1++) {
				for (col1=0;col1 < fftsize;col1++) {
					col2=(fftsize-col1) %fftsize;
					col2=(fftsize-col1) %fftsize;
					fht_pixels[row1*fftsize+col1]=(double) (fft[row1][col1][0]-fft[row1][col1][1]);
					fht_pixels[row1*fftsize+col1]=fft[row1][col1][0]-fft[row1][col1][1];
					fht_pixels[row2*fftsize+col2]=(double) (fft[row1][col1][0]+fft[row1][col1][1]);
					fht_pixels[row2*fftsize+col2]=fft[row1][col1][0]+fft[row1][col1][1];
				}
				}
			}
			}
			return fht_pixels;
			return fht_pixels;
@@ -1281,6 +1280,8 @@ public class EyesisAberrations {
        			int rslt=matchSimulatedPattern.calculateDistortions(
        			int rslt=matchSimulatedPattern.calculateDistortions(
        					distortionParameters, //
        					distortionParameters, //
        					patternDetectParameters,
        					patternDetectParameters,
        					patternDetectParameters.minGridPeriod/2,
        		            patternDetectParameters.maxGridPeriod/2,
        					simulParameters,
        					simulParameters,
        					colorComponents.equalizeGreens,
        					colorComponents.equalizeGreens,
        					imp,
        					imp,
@@ -2313,6 +2314,7 @@ public class EyesisAberrations {
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			// Concurrently run in as many threads as CPUs
			// Concurrently run in as many threads as CPUs
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {


					// Each thread processes a few items in the total list
					// Each thread processes a few items in the total list
@@ -2399,6 +2401,7 @@ public class EyesisAberrations {
						}
						}
   						final int numFinished=tilesFinishedAtomic.getAndIncrement();
   						final int numFinished=tilesFinishedAtomic.getAndIncrement();
   						SwingUtilities.invokeLater(new Runnable() {
   						SwingUtilities.invokeLater(new Runnable() {
   							@Override
							public void run() {
							public void run() {
   								IJ.showProgress(numFinished,patternCells);
   								IJ.showProgress(numFinished,patternCells);
   							}
   							}
@@ -2679,6 +2682,8 @@ public class EyesisAberrations {
			if (matchSimulatedPattern.PATTERN_GRID==null) {
			if (matchSimulatedPattern.PATTERN_GRID==null) {
				double[][] distortedPattern= matchSimulatedPattern.findPatternDistorted(input_bayer, // pixel array to process (no windowing!)
				double[][] distortedPattern= matchSimulatedPattern.findPatternDistorted(input_bayer, // pixel array to process (no windowing!)
						patternDetectParameters,
						patternDetectParameters,
						patternDetectParameters.minGridPeriod/2,
			            patternDetectParameters.maxGridPeriod/2,
						true, //(greensToProcess==4), // boolean greens, // this is a pattern for combined greens (diagonal), adjust results accordingly
						true, //(greensToProcess==4), // boolean greens, // this is a pattern for combined greens (diagonal), adjust results accordingly
						title); // title prefix to use for debug  images
						title); // title prefix to use for debug  images


@@ -4148,7 +4153,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
					ImageProcessor ip = new FloatProcessor(size,size);
					ImageProcessor ip = new FloatProcessor(size,size);
					float [] floatPixels = new float [size*size];
					float [] floatPixels = new float [size*size];
					for (i=0;i<floatPixels.length;i++) {
					for (i=0;i<floatPixels.length;i++) {
						floatPixels[i]=(float) clusterMap[i/size][i%size];
						floatPixels[i]=clusterMap[i/size][i%size];
					}
					}
					ip.setPixels(floatPixels);
					ip.setPixels(floatPixels);
					ip.resetMinAndMax();
					ip.resetMinAndMax();
@@ -4404,11 +4409,11 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
			if (debug) {
			if (debug) {
				SDFA_INSTANCE.showArrays(debugPixels, title+"_mask_PSF");
				SDFA_INSTANCE.showArrays(debugPixels, title+"_mask_PSF");
				double [] doublePixelsPSFCount=new double [pixelsPSF.length];
				double [] doublePixelsPSFCount=new double [pixelsPSF.length];
				for (j=0;j<doublePixelsPSFCount.length;j++) doublePixelsPSFCount[j]=(double)pixelsPSFCount[j];
				for (j=0;j<doublePixelsPSFCount.length;j++) doublePixelsPSFCount[j]=pixelsPSFCount[j];
				SDFA_INSTANCE.showArrays(doublePixelsPSFCount, title+"_PSF_bin_count");
				SDFA_INSTANCE.showArrays(doublePixelsPSFCount, title+"_PSF_bin_count");
				SDFA_INSTANCE.showArrays(pixelsPSFWeight,      title+"_PSF_bin_weight");
				SDFA_INSTANCE.showArrays(pixelsPSFWeight,      title+"_PSF_bin_weight");
				double [] doubleContrastCache=new double [contrastCache.length];
				double [] doubleContrastCache=new double [contrastCache.length];
				for (j=0;j<doubleContrastCache.length;j++) doubleContrastCache[j]=(double)((contrastCache[j]>=0.0)?contrastCache[j]:-0.00001);
				for (j=0;j<doubleContrastCache.length;j++) doubleContrastCache[j]=(contrastCache[j]>=0.0)?contrastCache[j]:-0.00001;
				SDFA_INSTANCE.showArrays(doubleContrastCache,  title+"_ContrastCache");
				SDFA_INSTANCE.showArrays(doubleContrastCache,  title+"_ContrastCache");
			}
			}
			return pixelsPSF;
			return pixelsPSF;
@@ -4988,6 +4993,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
			this.thresholdHigh = thresholdHigh;
			this.thresholdHigh = thresholdHigh;
			this.thresholdLow = thresholdLow;
			this.thresholdLow = thresholdLow;
		}
		}
        @Override
		public OTFFilterParameters clone() {
		public OTFFilterParameters clone() {
        	return new OTFFilterParameters(
        	return new OTFFilterParameters(
        			this.deconvInvert,
        			this.deconvInvert,
@@ -5076,6 +5082,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************




		}
		}
        @Override
		public PSFParameters clone(){
		public PSFParameters clone(){
        	return new PSFParameters(
        	return new PSFParameters(
        			this.minContrast,
        			this.minContrast,
+4 −0
Original line number Original line Diff line number Diff line
@@ -668,6 +668,8 @@ horizontal axis:
						// allow more of grid around pointers?
						// allow more of grid around pointers?
						distortionParameters, //
						distortionParameters, //
						this.patternDetectParameters,
						this.patternDetectParameters,
						this.patternDetectParameters.minGridPeriod/2,
						this.patternDetectParameters.maxGridPeriod/2,
						simulParameters,
						simulParameters,
						equalizeGreens, imp_eq,
						equalizeGreens, imp_eq,
						this.laserPointers, // null, //LASER_POINTERS, //
						this.laserPointers, // null, //LASER_POINTERS, //
@@ -841,6 +843,8 @@ horizontal axis:
								// allow more of grid around pointers?
								// allow more of grid around pointers?
								distortionParameters, //
								distortionParameters, //
								this.patternDetectParameters,
								this.patternDetectParameters,
								this.patternDetectParameters.minGridPeriod/2,
								this.patternDetectParameters.maxGridPeriod/2,
								simulParameters,
								simulParameters,
								equalizeGreens, imp_eq,
								equalizeGreens, imp_eq,
								this.laserPointers, // null, //LASER_POINTERS, //
								this.laserPointers, // null, //LASER_POINTERS, //
Loading