...
 
Commits (393)
*.cu gitlab-language=cpp
*.cuh gitlab-language=cpp
\ No newline at end of file
......@@ -2,3 +2,11 @@
/.project
/.settings/
/target/
*.backup
NC393I
attic
*.log
FOCUS-PSF*
src/main/resources/trained_model
bioformats*.*
metadata*.*
This diff is collapsed.
This is a set of Elphel plugins for ImageJ 1.x as a Maven project with specified
dependencies,
dependencies.
If cloned and imported as existent Maven project into Eclipse IDE, it allows to launch
ImageJ with plugins in both run and debug modes.
## Java TensorFlow CUDA testing
- As of 2018/09/11 TF for GPU on Maven supports CUDA 9.0 (vs latest 9.2).
Workaround:
```
~$ sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
~$ sudo apt install cuda-9.0
# install or link back to cuda-9.2:
~$ sudo rm /usr/local/cuda; sudo ln -sf /usr/local/cuda-9.2 /usr/local/cuda
Then in Eclipse's Run configurations... add an environment variable:
LD_LIBRARY_PATH = /usr/local/cuda-9.0/lib64
```
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>imagej-elphel</name>
<comment></comment>
<projects>
<project>metadata-extractor</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
......@@ -11,50 +11,95 @@
<version>3.1</version>
<relativePath/>
</parent>
<!--
<properties>
<imagej.app.directory>/home/foxel/Desktop/Fiji.app</imagej.app.directory>
</properties>
-->
<groupId>com.elphel</groupId>
<artifactId>imagej-elphel</artifactId>
<!-- <artifactId>Aberration_Calibration</artifactId> -->
<version>1.0.0-SNAPSHOT</version>
<name>plugins/imagej_elphel.jar</name>
<name>plugins/imagej_elphel.jar</name>
<!-- <name>plugins/Aberration_Calibration.jar</name> -->
<description>A Maven project implementing imagej-elphel plugin</description>
<description>A Maven project implementing imagej-elphel plugin</description>
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
<version>1.50b</version>
<!-- <version>${imagej1.version}</version> -->
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>jama</groupId>
<artifactId>jama</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>ome</groupId>
<artifactId>loci_tools</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
<version>1.52e</version>
</dependency>
<dependency>
<groupId>org.jcuda</groupId>
<artifactId>jcuda</artifactId>
<version>0.9.2</version>
</dependency>
<!--
As of 2018/09/11 TF for GPU on Maven supports CUDA 9.0 (vs latest 9.2)
Workaround:
~$ sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
~$ sudo apt install cuda-9.0
# install or link back to cuda-9.2:
~$ sudo rm /usr/local/cuda; sudo ln -sf /usr/local/cuda-9.2 /usr/local/cuda
Then in Eclipse's Run configurations... add an environment variable:
LD_LIBRARY_PATH = /usr/local/cuda-9.0/lib64
-->
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>libtensorflow</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>libtensorflow_jni_gpu</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-compress</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/gov.nist.math/jama -->
<dependency>
<groupId>gov.nist.math</groupId>
<artifactId>jama</artifactId>
<version>1.0.3</version>
</dependency>
<!--
<dependency>
<groupId>jama</groupId>
<artifactId>jama</artifactId>
<version>1.0.3</version>
</dependency>
-->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>ome</groupId>
<artifactId>loci_tools</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.11.0</version>
<type>java-source</type>
</dependency>
</dependencies>
<build>
<resources>
......@@ -64,6 +109,17 @@
<resource>
<directory>${project.build.sourceDirectory}</directory>
</resource>
<!-- trying to copy deep classes to top for the imageJ to see as plugins-->
<!--
<resource>
<filtering>true</filtering>
<directory>${basedir}/target/classes/com/elphel/imagej/jp4</directory>
<targetPath>${basedir}/target/classes</targetPath>
<includes>
<include>JP46_Reader_camera.class</include>
</includes>
</resource>
-->
</resources>
<testResources>
<testResource>
......@@ -73,29 +129,55 @@
<directory>${project.build.testSourceDirectory}</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>test-compile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-plugin-plugin
</artifactId>
<versionRange>[3.3,)</versionRange>
<goals>
<goal>descriptor</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<version>1.3.2</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<phase>package</phase>
......@@ -105,11 +187,11 @@
</execution>
</executions>
<configuration>
<!-- <mainClass>Aberration_Calibration</mainClass> -->
<mainClass>Eyesis_Correction</mainClass>
<!-- <mainClass>Aberration_Calibration</mainClass> -->
<mainClass>Eyesis_Correction</mainClass>
</configuration>
</plugin>
<plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
......@@ -127,12 +209,13 @@
<format>Build {0,date,yyyy-MM-dd} {0,time,HH:MM:SS} on host {1}</format>
<items>
<item>timestamp</item>
<item>foxel-MRHM7AP</item>
<!-- <item>foxel-MRHM7AP</item> -->
</items>
</configuration>
</plugin>
</plugins>
</plugins>
</pluginManagement>
</build>
<developers>
......@@ -168,10 +251,10 @@
</repositories>
<scm>
<connection>scm:git:git://github.com/Elphel/imagej-elphel</connection>
<developerConnection>scm:git:https://github.com/Elphel/imagej-elphel</developerConnection>
<connection>scm:git:git://git.elphel.com/Elphel/imagej-elphel</connection>
<developerConnection>scm:git:https://git.elphel.com/Elphel/imagej-elphel</developerConnection>
<tag>HEAD</tag>
<url>https://github.com/Elphel/imagej-elphel</url>
<url>https://git.elphel.com/Elphel/imagej-elphel</url>
</scm>
<packaging>maven-plugin</packaging>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** aberrations.java
......@@ -47,8 +48,12 @@ import java.lang.Integer;
import javax.swing.*;
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.jp4.JP46_Reader_camera;
public class aberrations extends PlugInFrame implements ActionListener {
public class AberrationsOld extends PlugInFrame implements ActionListener {
/**
*
*/
......@@ -56,7 +61,7 @@ public class aberrations extends PlugInFrame implements ActionListener {
Panel panel1,panel2;
// Panel panel;
JP46_Reader_camera jp4_instance;
showDoubleFloatArrays SDFA_instance;
ShowDoubleFloatArrays SDFA_instance;
DoubleFHT fht_instance;
static Frame instance;
public static int DEBUG_LEVEL = 2;
......@@ -267,7 +272,7 @@ Panel panel1,panel2;
public static int INVERSE_DIRECT_SIZE= 32; // size (side of square) of direct PSF kernel
public static int INVERSE_REVERSE_SIZE= 64; // size (side of square) of reverse PSF kernel
public static boolean INVERSE_FILTER= true; // apply variable-sigma filetering to the inverted PSF
public static boolean INVERSE_FILTER= true; // apply variable-sigma filtering to the inverted PSF
public static int SPLIT_OVERSAMPLE= 2;
......@@ -316,7 +321,7 @@ Panel panel1,panel2;
public static double DOUBLE_DEBUG_RESULT; // just for temporary passing results from inside the functions
public static ImageStack convolutionKernelStack=null; // select to use for image convolution
public aberrations() {
public AberrationsOld() {
super("Aberrations");
if (IJ.versionLessThan("1.39t")) return;
if (instance!=null) {
......@@ -367,7 +372,7 @@ Panel panel1,panel2;
setVisible(true);
jp4_instance= new JP46_Reader_camera();
fht_instance= new DoubleFHT();
SDFA_instance= new showDoubleFloatArrays();
SDFA_instance= new ShowDoubleFloatArrays();
Hamming=initHamming(FFTSize);
......
/**
** -----------------------------------------------------------------------------**
** aberrations.java
**
** Programs for experimenting with aberrations correction
**
**
**
** Copyright (C) 2010 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** focus_tuning.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
package com.elphel.imagej.calibration;
import ij.*;
import ij.io.*;
......@@ -47,6 +22,10 @@ import java.lang.Integer;
import javax.swing.*;
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.jp4.JP46_Reader_camera;
public class Aberrations_all extends PlugInFrame implements ActionListener {
/**
......@@ -56,7 +35,7 @@ public class Aberrations_all extends PlugInFrame implements ActionListener {
Panel panel1,panel2;
// Panel panel;
JP46_Reader_camera jp4_instance;
showDoubleFloatArrays SDFA_instance;
ShowDoubleFloatArrays SDFA_instance;
DoubleFHT fht_instance;
static Frame instance;
public static int DEBUG_LEVEL = 2;
......@@ -260,7 +239,7 @@ Panel panel1,panel2;
public static int INVERSE_DIRECT_SIZE= 32; // size (side of square) of direct PSF kernel
public static int INVERSE_REVERSE_SIZE= 64; // size (side of square) of reverse PSF kernel
public static boolean INVERSE_FILTER= true; // apply variable-sigma filetering to the inverted PSF
public static boolean INVERSE_FILTER= true; // apply variable-sigma filtering to the inverted PSF
public static int SPLIT_OVERSAMPLE= 2;
......@@ -360,7 +339,7 @@ Panel panel1,panel2;
setVisible(true);
jp4_instance= new JP46_Reader_camera();
fht_instance= new DoubleFHT();
SDFA_instance= new showDoubleFloatArrays();
SDFA_instance= new ShowDoubleFloatArrays();
Hamming=initHamming(FFTSize);
......
import ij.IJ;
import ij.io.OpenDialog;
package com.elphel.imagej.calibration;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
......@@ -10,6 +8,9 @@ import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import ij.IJ;
import ij.io.OpenDialog;
public class CalibrationFileManagement {
public static String DEFAULT_DIRECTORY=null;
......@@ -22,9 +23,9 @@ public class CalibrationFileManagement {
System.out.println("Error: "+msg);
return null;
}
File [] files=dFile.listFiles(filter);
File [] files=dFile.listFiles(filter);
}
*/
/* ======================================================================== */
......@@ -32,7 +33,7 @@ public class CalibrationFileManagement {
return selectDirectoryOrFile(false, save,true, title, button, filter,defaultPath); // always open dialog
}
/**
*
*
* @param smart if true, and defaultPath matches criteria, return it and do not open dialog
* @param save file/directory for writing, new OK
* @param title Dialog title
......@@ -89,7 +90,7 @@ public class CalibrationFileManagement {
}
if ((dir==null) || (!dir.exists())) {
if (DEFAULT_DIRECTORY!=null) {
defaultPath = DEFAULT_DIRECTORY;
defaultPath = DEFAULT_DIRECTORY;
dir = new File(defaultPath);
}
}
......@@ -106,9 +107,9 @@ public class CalibrationFileManagement {
JFileChooser fc= new JFileChooser();
fc.setFileSelectionMode(directory?JFileChooser.DIRECTORIES_ONLY:JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(true);
if ((title!=null) && (title.length()>0)) fc.setDialogTitle(title);
if ((button!=null) && (button.length()>0)) fc.setApproveButtonText(button);
if (filter!=null) fc.setFileFilter(filter) ;
if ((title!=null) && (title.length()>0)) fc.setDialogTitle(title);
if ((button!=null) && (button.length()>0)) fc.setApproveButtonText(button);
if (filter!=null) fc.setFileFilter(filter) ;
if (dir!=null) fc.setCurrentDirectory(dir);
fc.setSelectedFiles(files);
int returnVal = save?(fc.showSaveDialog(IJ.getInstance())):(fc.showOpenDialog(IJ.getInstance()));
......@@ -141,8 +142,8 @@ public class CalibrationFileManagement {
(defaultPath.length()>1) && // skip "/"
save &&
!dir.exists()) dir.mkdirs();
// see if defaultPath matches
if (smart &&
(dir!=null) &&
......@@ -155,7 +156,7 @@ public class CalibrationFileManagement {
if ((dir==null) || (!dir.exists())) {
if (DEFAULT_DIRECTORY!=null) {
defaultPath = DEFAULT_DIRECTORY;
defaultPath = DEFAULT_DIRECTORY;
dir = new File(defaultPath);
}
}
......@@ -172,17 +173,17 @@ public class CalibrationFileManagement {
JFileChooser fc= new JFileChooser();
fc.setFileSelectionMode(directory?JFileChooser.DIRECTORIES_ONLY:JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
if ((title!=null) && (title.length()>0)) fc.setDialogTitle(title);
if ((button!=null) && (button.length()>0)) fc.setApproveButtonText(button);
if (filter!=null) fc.setFileFilter(filter) ;
if ((title!=null) && (title.length()>0)) fc.setDialogTitle(title);
if ((button!=null) && (button.length()>0)) fc.setApproveButtonText(button);
if (filter!=null) fc.setFileFilter(filter) ;
if (dir!=null) fc.setCurrentDirectory(dir);
int returnVal = save?(fc.showSaveDialog(IJ.getInstance())):(fc.showOpenDialog(IJ.getInstance()));
if (returnVal!=JFileChooser.APPROVE_OPTION) return null;
DEFAULT_DIRECTORY=fc.getCurrentDirectory().getPath();
return fc.getSelectedFile().getPath();
}
public static void saveStringToFile (String path,String data){
public static void saveStringToFile (String path,String data){
BufferedWriter writer = null;
try {
writer = new BufferedWriter( new FileWriter( path));
......@@ -191,7 +192,7 @@ public class CalibrationFileManagement {
} catch ( IOException e) {
String msg = e.getMessage();
if (msg==null || msg.equals("")) msg = ""+e;
IJ.showMessage("Error",msg);
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
finally {
......@@ -205,7 +206,7 @@ public class CalibrationFileManagement {
}
/* ======================================================================== */
static class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
public static class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String prefix=""; // case sensitive
......@@ -222,25 +223,28 @@ public class CalibrationFileManagement {
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
public boolean accept (File file) {
int i;
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
return false;
}
public boolean accept (File dir, String name) { // directory - don't care here, only name
@Override
public boolean accept (File dir, String name) { // directory - don't care here, only name
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (int i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
return false;
}
public String getDescription() {
@Override
public String getDescription() {
return description;
}
}
......
package com.elphel.imagej.calibration;
/**
**
** CalibrationHardwareInterface.jave - hardware-related part (cameras, focusing motors,
......@@ -69,6 +70,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import Jama.LUDecomposition;
import Jama.Matrix;
......@@ -297,7 +302,7 @@ public class CalibrationHardwareInterface {
this.triggerURL="http://"+this.cameraSubnet+(this.iBaseIP+this.masterSubCamera)+":"+
(this.imgsrvPort+ (this.masterPort & 3))+"/"+triggerURLcmd;
if (this.debugLevel>1) System.out.println("DEBUG393: initIPs(): this.triggerURL ="+this.triggerURL);
if (this.debugLevel>2) System.out.println("DEBUG393: initIPs(): this.triggerURL ="+this.triggerURL);
}
/*
//pre nc393
......@@ -738,8 +743,15 @@ public class CalibrationHardwareInterface {
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
String sTemperature=((Node) (((Node) dom.getDocumentElement().getElementsByTagName("sensorTemperature").item(0)).getChildNodes().item(0))).getNodeValue();
String sTemperature=null;
if ((dom.getDocumentElement().getElementsByTagName("sensorTemperature").item(0))!=null){
sTemperature=((Node) (((Node) dom.getDocumentElement().getElementsByTagName("sensorTemperature").item(0)).getChildNodes().item(0))).getNodeValue();
}else{
sTemperature= "0.0";
}
// remove opening and closing "
if (sTemperature==null){
String msg="Could not read sensor temperature";
......@@ -2671,7 +2683,7 @@ public class CalibrationHardwareInterface {
}
boolean result=commandToDevice(command);
updateCurrents();
if (result) updateCurrents();
return result;
}
......@@ -2718,7 +2730,8 @@ public class CalibrationHardwareInterface {
String msg = e1.getMessage();
if (msg==null || msg.equals("")) msg = ""+e1;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
return false;
// throw new IllegalArgumentException (msg);
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
return false;
......@@ -3471,7 +3484,9 @@ public class CalibrationHardwareInterface {
IJ.showStatus("");
String error = e1.getMessage();
if (error==null || error.equals("")) error = ""+e1;
IJ.showMessage("commandElphel10364Motors ERRROR", ""+error);
System.out.println("commandElphel10364Motors ERRROR: "+error);
// *********** Temporary removed message box (usually "HOST UNREACHABLE") *************
// IJ.showMessage("commandElphel10364Motors ERRROR", ""+error);
return null;
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
......@@ -6529,7 +6544,9 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
}
public double distFromProbed(int [] position){
double minDist=Double.NaN;
if (this.history.size() <1) return Double.NaN;
if (position==null) position= this.history.get(this.history.size()-1).motorsPos;
if (this.history.size()>0){
for (int i=0;i<this.history.size();i++) if (this.history.get(i).isProbed) {
int [] probedPosition=this.history.get(i).motorsPos;
......
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** Crosstalk_Deconv.java
......
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** deBayerScissors.java
......@@ -28,12 +29,15 @@
import ij.process.*;
import ij.plugin.filter.GaussianBlur;
import java.util.HashSet;
public class deBayerScissors {
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
public class DeBayerScissors {
private PolarSpectrums pol_instace=null;
private double [][][] lopass=null;
private int size;
private double lastMidEnergy; // last midrange spectral energy
private showDoubleFloatArrays SDFA_instance; // just for debugging?
private ShowDoubleFloatArrays SDFA_instance; // just for debugging?
private DoubleFHT fht_instance;
private int [][] aliasMapRedBlue={
{-2,-2},{-2,-1},{-2,0},{-2,1},
......@@ -43,7 +47,7 @@ public class deBayerScissors {
private int [][][][] speedTable = null;
public double getMidEnergy() {return lastMidEnergy; } // instead of the DOUBLE_DEBUG_RESULT
public deBayerScissors(
public DeBayerScissors(
int isize, // size of the square array, centar is at size/2, size/2, only top half+line will be used
double polarStep, // maximal step in pixels on the maxRadius for 1 angular step (i.e. 0.5)
double debayer_width_green, // result green mask mpy by scaled default (diamond)
......@@ -52,7 +56,7 @@ public class deBayerScissors {
double debayer_width_redblue_clones){// green mask when applied to red/blue, clones
size=isize;
fht_instance= new DoubleFHT();
SDFA_instance= new showDoubleFloatArrays();
SDFA_instance= new ShowDoubleFloatArrays();
pol_instace=new PolarSpectrums(size, // size of the square array, centar is at size/2, size/2, only top half+line will be used
Math.PI,
size/2-2, // width of the polar array - should be <= size/2-2
......
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** DebayerScissors.java
**
** Frequency-domain debosaic methods for aberration correction for Eyesis4pi
**
**
**
** Copyright (C) 2012 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
**
** DebayerScissors.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
......@@ -25,28 +26,32 @@
**
*/
import ij.IJ;
import ij.ImageStack;
import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.SwingUtilities;
import com.elphel.imagej.cameras.EyesisCorrectionParameters;
import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import ij.IJ;
import ij.ImageStack;
public class DebayerScissors {
public class DebayerScissorsClass {
// showDoubleFloatArrays SDFA_INSTANCE= new showDoubleFloatArrays();
public AtomicInteger stopRequested=null; // 1 - stop now, 2 - when convenient
double [] debayerEnergy;
int debayerEnergyWidth;
int debugLevel=1;
public DebayerScissors(AtomicInteger stopRequested){
public DebayerScissorsClass(AtomicInteger stopRequested){
this.stopRequested=stopRequested;
}
double [] getDebayerEnergy() {return this.debayerEnergy;}
int getDebayerEnergyWidth() {return this.debayerEnergyWidth;}
void setDebug(int debugLevel){this.debugLevel=debugLevel;}
public double [] getDebayerEnergy() {return this.debayerEnergy;}
public int getDebayerEnergyWidth() {return this.debayerEnergyWidth;}
public void setDebug(int debugLevel){this.debugLevel=debugLevel;}
// uses global OUT_PIXELS to accumulate results
public ImageStack aliasScissorsStack (
final ImageStack imageStack, // stack with 3 colors/slices with the image
......@@ -98,13 +103,13 @@ 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;
......@@ -123,24 +128,25 @@ public class DebayerScissors {
}
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
@Override
public void run() {
double [][] tile= new double[nChn][debayerParameters.size * debayerParameters.size ];
double [][] both_masks;
float [][] pixels= new float[nChn][];
int chn,tileY,tileX,i;
for (chn=0;chn<nChn;chn++) pixels[chn]= (float[]) imageStack.getPixels(chn+1);
DoubleFHT fht_instance = new DoubleFHT(); // provide DoubleFHT instance to save on initializations (or null)
showDoubleFloatArrays SDFA_instance=null; // just for debugging?
ShowDoubleFloatArrays SDFA_instance=null; // just for debugging?
deBayerScissors debayer_instance=new deBayerScissors( debayerParameters.size, // size of the square array, centar is at size/2, size/2, only top half+line will be used
DeBayerScissors debayer_instance=new DeBayerScissors( debayerParameters.size, // size of the square array, centar is at size/2, size/2, only top half+line will be used
debayerParameters.polarStep, // maximal step in pixels on the maxRadius for 1 angular step (i.e. 0.5)
debayerParameters.debayerRelativeWidthGreen, // result green mask mpy by scaled default (diamond)
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
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()) {
int nTile = nonOverlapSeq[nTile0];
tileY = nTile /tilesX;
tileX = nTile % tilesX;
......@@ -163,7 +169,7 @@ public class DebayerScissors {
/* Scale green channel x0.5 as there are twice more pixels there as in red or blue. Or move it somewhere else and multiply to original range ? */
for (i=0;i<tile[greenChn].length;i++) tile[greenChn][i]*=0.5;
if ((tileY==yTileDebug) && (tileX==xTileDebug)) {
if (SDFA_instance==null) SDFA_instance= new showDoubleFloatArrays();
if (SDFA_instance==null) SDFA_instance= new ShowDoubleFloatArrays();
SDFA_instance.showArrays (tile.clone(),debayerParameters.size,debayerParameters.size, "x"+(tileX*step)+"_y"+(tileY*step));
}
for (chn=0;chn<nChn;chn++){
......@@ -205,13 +211,14 @@ public class DebayerScissors {
tileY*step); // top corner Y
}
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() {
@Override
public void run() {
// System.out.println(" --- "+numFinished+"("+numberOfKernels+"): "+dprogr);
IJ.showProgress(numFinished, numberOfKernels);
}
......@@ -220,7 +227,7 @@ public class DebayerScissors {
}
}
};
}
}
startAndJoin(threads);
IJ.showProgress(tilesFinishedAtomic.get(), numberOfKernels);
}
......@@ -232,7 +239,7 @@ public class DebayerScissors {
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
debayerEnergyWidth= (debayerEnergy!=null)?tilesX:0; // for the image to be displayed externally
if (globalDebugLevel>0) System.out.println("Reducing sampling aliases done in "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
return outStack;
}
......@@ -287,7 +294,7 @@ public class DebayerScissors {
}
}
/* ======================================================================== */
/* accumulate square tile to the pixel array (tile may extend beyond the array, will be cropped) */
synchronized void accumulateSquareTile(
......@@ -337,7 +344,7 @@ public class DebayerScissors {
}
}
}
synchronized void accumulateSquareTile(
double [] pixels, // float pixels array to accumulate tile
double [] tile, // data to accumulate to the pixels array
......@@ -374,10 +381,10 @@ public class DebayerScissors {
return mask;
}
/* ======================================================================== */
/* ======================================================================== */
/* Create a Thread[] array as large as the number of processors available.
* From Stephan Preibisch's Multithreading.java class. See:
......@@ -401,7 +408,7 @@ public class DebayerScissors {
}
try
{
{
for (int ithread = 0; ithread < threads.length; ++ithread)
threads[ithread].join();
} catch (InterruptedException ie)
......
package com.elphel.imagej.calibration;
/*
**
** DistortionProcessConfiguration.java
......@@ -5,7 +6,7 @@
** Copyright (C) 2011-2014 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
**
** DistortionProcessConfiguration.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
......@@ -22,14 +23,17 @@
**
*/
import java.io.File;
import java.io.FilenameFilter;
import java.util.Properties;
import com.elphel.imagej.common.WindowTools;
import ij.IJ;
import ij.Prefs;
import ij.gui.GenericDialog;
import java.io.File;
import java.util.Properties;
public class DistortionProcessConfiguration{
public String sourceDirectory="";
public String gridDirectory= "";
......@@ -47,7 +51,7 @@ import java.util.Properties;
public String selectSourceDirectory(boolean smart, String defaultPath, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
newAllowed, // save
"Source (acquired from the camera) image directory", // title
"Select source directory", // button
null, // filter
......@@ -58,7 +62,7 @@ import java.util.Properties;
public String selectGridFileDirectory(boolean smart, String defaultPath, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
newAllowed, // save
"Grid files directory (grid patterns extracted from the images)", // title
"Select grid files directory", // button
null, // filter
......@@ -66,7 +70,7 @@ import java.util.Properties;
if (dir!=null) this.gridDirectory=dir;
return dir;
}
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"sourceDirectory", this.sourceDirectory);
properties.setProperty(prefix+"gridDirectory", this.gridDirectory);
......@@ -120,9 +124,9 @@ import java.util.Properties;
gd.addCheckbox ("Show grid files as images", this.showGridImages);
gd.addCheckbox ("Save grid files", this.saveGridImages);
gd.addCheckbox ("Overwrite existing result files", this.overwriteResultFiles);
gd.addNumericField("Debug level", this.debugLevel,0);
WindowTools.addScrollBars(gd);
gd.showDialog();
......@@ -141,7 +145,7 @@ import java.util.Properties;
this.debugLevel= (int) gd.getNextNumber();
System.out.println("1.newSourceDirectory = "+newSourceDirectory);
System.out.println("1.newGridDirectory = "+ newGridDirectory);
if ((newSourceDirectory.length()==0) || (newSourceDirectory.indexOf('?')>=0))
if ((newSourceDirectory.length()==0) || (newSourceDirectory.indexOf('?')>=0))
newSourceDirectory= selectSourceDirectory(false, this.sourceDirectory, true);
else
newSourceDirectory= selectSourceDirectory(true, newSourceDirectory, true); // if matches, no dialog
......@@ -171,7 +175,7 @@ import java.util.Properties;
if (this.sourceDirectory.length()==0){
defaultPaths[0]="";
}
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files");
String [] sourceFiles=null;
......@@ -203,5 +207,26 @@ import java.util.Properties;
}
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;
}
}
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** MTF_Bayer.java
......
package com.elphel.imagej.calibration;
/*
**
** PatternParameters.java
......@@ -30,6 +31,9 @@ import ij.io.Opener;
import java.awt.Rectangle;
import java.util.Properties;
import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.jp4.JP46_Reader_camera;
/* gridGeometry:
* [v][u][0] - x(mm) of the node(u,v), right (looking to the wall) - positive
* [v][u][1] - y(mm) of the node(u,v), down - positive
......
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** PolarSpectrums.java
......
package com.elphel.imagej.calibration;
/**
** -----------------------------------------------------------------------------**
** focus_tuning.java
......@@ -49,6 +50,8 @@ import java.net.*;
import org.xml.sax.SAXException;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import javax.xml.parsers.ParserConfigurationException;
import java.lang.Integer;
......
/**
*
*/
/**
* @author eyesis
*
*/
package com.elphel.imagej.calibration;
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.