Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
da48d22b
Commit
da48d22b
authored
Jun 25, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing headless run
parent
1b78d16a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
914 additions
and
1015 deletions
+914
-1015
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+179
-179
Eyesis_Correction.java
src/main/java/Eyesis_Correction.java
+658
-749
JP46_Reader_camera.java
src/main/java/JP46_Reader_camera.java
+77
-87
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
da48d22b
...
...
@@ -573,7 +573,7 @@ public class EyesisCorrectionParameters {
String
[]
sensorFiles
=
null
;
// try reading all matching files
File
dir
=
new
File
(
this
.
sensorDirectory
);
//
if (debugLevel>1) System.out.println("selectSensorFiles, dir="+this.sensorDirectory);
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"selectSensorFiles, dir="
+
this
.
sensorDirectory
);
File
[]
fileList
=
null
;
if
(
dir
.
exists
())
{
fileList
=
dir
.
listFiles
(
sensorFilter
);
...
...
src/main/java/Eyesis_Correction.java
View file @
da48d22b
...
...
@@ -25,17 +25,16 @@
**
*/
import
ij.*
;
import
ij.process.*
;
import
ij.gui.*
;
import
ij.io.FileInfo
;
import
ij.io.FileSaver
;
import
ij.io.OpenDialog
;
import
ij.io.Opener
;
import
ij.plugin.frame.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.Button
;
import
java.awt.Color
;
import
java.awt.Frame
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.GridLayout
;
import
java.awt.Panel
;
import
java.awt.Rectangle
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.WindowEvent
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
...
...
@@ -53,6 +52,28 @@ import java.util.concurrent.atomic.AtomicInteger;
import
javax.swing.JFileChooser
;
import
javax.swing.filechooser.FileFilter
;
import
ij.CompositeImage
;
import
ij.IJ
;
import
ij.ImageJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.Macro
;
import
ij.Prefs
;
import
ij.WindowManager
;
import
ij.gui.GUI
;
import
ij.gui.GenericDialog
;
import
ij.gui.Plot
;
import
ij.gui.PlotWindow
;
import
ij.gui.Roi
;
import
ij.io.FileInfo
;
import
ij.io.FileSaver
;
import
ij.io.OpenDialog
;
import
ij.io.Opener
;
import
ij.plugin.PlugIn
;
import
ij.plugin.frame.PlugInFrame
;
import
ij.process.ColorProcessor
;
import
ij.process.FloatProcessor
;
import
ij.process.ImageProcessor
;
import
loci.common.services.DependencyException
;
import
loci.common.services.ServiceException
;
import
loci.formats.FormatException
;
...
...
@@ -60,10 +81,14 @@ import loci.formats.FormatException;
//import javax.swing.SwingUtilities;
//import javax.swing.UIManager;
public
class
Eyesis_Correction
extends
PlugInFrame
implements
ActionListener
{
public
class
Eyesis_Correction
implements
PlugIn
,
ActionListener
{
/**
*
*/
private
Boolean
headless
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
().
isHeadlessInstance
();
private
PlugInFrame
plugInFrame
;
String
prefsPath
;
private
static
final
long
serialVersionUID
=
-
1507307664341265263L
;
private
Panel
panel1
,
panel2
,
...
...
@@ -341,9 +366,14 @@ private Panel panel1,
public
String
buttonLabel
=
""
;
}
public
Eyesis_Correction
()
{
super
(
"Eyesis_Correction"
);
@Override
public
void
run
(
String
arg
)
{
String
options
=
Macro
.
getOptions
();
try
{
prefsPath
=
Macro
.
getValue
(
options
,
"prefs"
,
Prefs
.
getPrefsDir
()+
Prefs
.
getFileSeparator
()+
"Eyesis_Correction.xml"
);
}
catch
(
Exception
e
)
{
prefsPath
=
Prefs
.
getPrefsDir
()+
Prefs
.
getFileSeparator
()+
"Eyesis_Correction.xml"
;
}
if
(
IJ
.
versionLessThan
(
"1.43q"
))
return
;
if
(
instance
!=
null
)
{
instance
.
toFront
();
...
...
@@ -353,14 +383,38 @@ private Panel panel1,
loadPrefs
();
}
catch
(
IOException
e1
)
{
System
.
out
.
println
(
"failed to load preferences"
);
//
e1.printStackTrace();
e1
.
printStackTrace
();
}
EYESIS_CORRECTIONS
=
new
EyesisCorrections
(
SYNC_COMMAND
.
stopRequested
,
CORRECTION_PARAMETERS
);
if
(
options
!=
null
||
headless
)
{
processFiles
();
}
else
{
initGui
();
}
}
public
void
initGui
()
{
Color
color_configure
=
new
Color
(
200
,
200
,
160
);
Color
color_process
=
new
Color
(
180
,
180
,
240
);
Color
color_conf_process
=
new
Color
(
180
,
240
,
240
);
Color
color_restore
=
new
Color
(
180
,
240
,
180
);
Color
color_stop
=
new
Color
(
255
,
160
,
160
);
//<<<<<<< HEAD
plugInFrame
=
new
PlugInFrame
(
"Eyesis_Correction"
)
{
private
static
final
long
serialVersionUID
=
-
4138832568507690332L
;
@Override
public
void
processWindowEvent
(
WindowEvent
e
)
{
super
.
processWindowEvent
(
e
);
if
(
e
.
getID
()==
WindowEvent
.
WINDOW_CLOSING
)
{
instance
=
null
;
}
}
};
instance
=
plugInFrame
;
plugInFrame
.
addKeyListener
(
IJ
.
getInstance
());
int
menuRows
=
4
+
(
ADVANCED_MODE
?
4
:
0
)
+
(
MODE_3D
?
3
:
0
);
plugInFrame
.
setLayout
(
new
GridLayout
(
menuRows
,
1
));
/*=======
instance = this;
...
...
@@ -368,6 +422,8 @@ private Panel panel1,
int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?2:0);
setLayout(new GridLayout(menuRows, 1));
>>>>>>> origin/dct
*/
panel6
=
new
Panel
();
panel6
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Save"
,
panel6
);
...
...
@@ -375,13 +431,13 @@ private Panel panel1,
addButton
(
"Stop"
,
panel6
,
color_stop
);
addButton
(
"Abort"
,
panel6
,
color_stop
);
add
(
panel6
);
plugInFrame
.
add
(
panel6
);
panel5
=
new
Panel
();
panel5
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Configure spilt"
,
panel5
,
color_configure
);
addButton
(
"Configure demosaic"
,
panel5
,
color_configure
);
add
(
panel5
);
plugInFrame
.
add
(
panel5
);
panel5a
=
new
Panel
();
panel5a
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Configure convolution"
,
panel5a
,
color_configure
);
...
...
@@ -389,7 +445,7 @@ private Panel panel1,
addButton
(
"Configure color"
,
panel5a
,
color_configure
);
addButton
(
"Channel gains"
,
panel5a
,
color_configure
);
addButton
(
"Configure RGB"
,
panel5a
,
color_configure
);
add
(
panel5a
);
plugInFrame
.
add
(
panel5a
);
// Debug/development options
...
...
@@ -399,13 +455,13 @@ private Panel panel1,
panel1
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
// rows, columns, vgap, hgap
addButton
(
"Split Image"
,
panel1
);
addButton
(
"Debayer Image"
,
panel1
);
add
(
panel1
);
plugInFrame
.
add
(
panel1
);
panel2
=
new
Panel
();
panel2
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Select kernel stack"
,
panel2
);
addButton
(
"Convolve with stack"
,
panel2
);
add
(
panel2
);
plugInFrame
.
add
(
panel2
);
panel3
=
new
Panel
();
panel3
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
...
...
@@ -413,14 +469,14 @@ private Panel panel1,
addButton
(
"Combine pair"
,
panel3
);
addButton
(
"Colors"
,
panel3
);
addButton
(
"RGB"
,
panel3
);
add
(
panel3
);
plugInFrame
.
add
(
panel3
);
panel4
=
new
Panel
();
panel4
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Test"
,
panel4
);
addButton
(
"Test Debayer"
,
panel4
);
add
(
panel4
);
plugInFrame
.
add
(
panel4
);
}
panel7
=
new
Panel
();
panel7
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
...
...
@@ -433,7 +489,7 @@ private Panel panel1,
addButton
(
"Tiff Writer"
,
panel7
);
addButton
(
"Tiff Properties"
,
panel7
);
}
add
(
panel7
);
plugInFrame
.
add
(
panel7
);
if
(
MODE_3D
){
panelPostProcessing1
=
new
Panel
();
...
...
@@ -443,7 +499,7 @@ private Panel panel1,
addButton
(
"ConvertPP"
,
panelPostProcessing1
,
color_process
);
addButton
(
"Linear Features"
,
panelPostProcessing1
);
addButton
(
"Intercam correlations"
,
panelPostProcessing1
);
add
(
panelPostProcessing1
);
plugInFrame
.
add
(
panelPostProcessing1
);
panelPostProcessing2
=
new
Panel
();
panelPostProcessing2
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
...
...
@@ -454,15 +510,18 @@ private Panel panel1,
addButton
(
"Fill FG gaps"
,
panelPostProcessing2
);
addButton
(
"Filter Z-map"
,
panelPostProcessing2
);
addButton
(
"Occluding FG"
,
panelPostProcessing2
);
add
(
panelPostProcessing2
);
plugInFrame
.
add
(
panelPostProcessing2
);
panelPostProcessing3
=
new
Panel
();
panelPostProcessing3
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Refine Disparities"
,
panelPostProcessing3
);
addButton
(
"Init Photometry"
,
panelPostProcessing3
);
addButton
(
"Plane Likely"
,
panelPostProcessing3
);
add
(
panelPostProcessing3
);
plugInFrame
.
add
(
panelPostProcessing3
);
}
// <<<<<<< HEAD
plugInFrame
.
pack
();
/* =======
if (DCT_MODE) {
panelDct1 = new Panel();
panelDct1.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
...
...
@@ -490,16 +549,16 @@ private Panel panel1,
addButton("CLT stack", panelClt1, color_process);
addButton("Select second CLT image", panelClt1, color_configure);
addButton("CLT correlate", panelClt1, color_process);
addButton
(
"Create CLT kernels"
,
panelClt1
,
color_process
);
addButton
(
"Read CLT kernels"
,
panelClt1
,
color_process
);
addButton
(
"Reset CLT kernels"
,
panelClt1
,
color_stop
);
addButton
(
"CLT process files"
,
panelClt1
,
color_process
);
addButton("CLT test 2", panelClt1, color_process);
addButton("CLT test 3", panelClt1, color_process);
addButton("CLT test 4", panelClt1, color_process);
add(panelClt1);
}
pack();
GUI
.
center
(
this
);
setVisible
(
true
);
>>>>>>> origin/dct
*/
GUI
.
center
(
plugInFrame
);
plugInFrame
.
setVisible
(
true
);
FHT_INSTANCE
=
new
DoubleFHT
();
SDFA_INSTANCE
=
new
showDoubleFloatArrays
();
// main loop
...
...
@@ -528,7 +587,6 @@ private Panel panel1,
}
}
private
String
prefsPath
=
Prefs
.
getPrefsDir
()+
Prefs
.
getFileSeparator
()+
"Eyesis_Correction.xml"
;
private
Properties
prefsProperties
=
new
Properties
();
public
void
loadPrefs
()
throws
IOException
{
...
...
@@ -543,6 +601,13 @@ private Panel panel1,
try
{
prefsProperties
.
loadFromXML
(
is
);
if
(!
headless
){
System
.
out
.
println
(
"Skipping getAllProperties(prefsProperties)"
);
}
else
{
getAllProperties
(
prefsProperties
);
if
(
DEBUG_LEVEL
>
0
)
System
.
out
.
println
(
"Configuration parameters are restored from "
+
this
.
prefsPath
);
}
}
catch
(
IOException
e
)
{
String
msg
=
"Failed to read XML configuration file: "
+
this
.
prefsPath
;
IJ
.
showMessage
(
"Error"
,
msg
);
...
...
@@ -554,7 +619,7 @@ private Panel panel1,
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
String
sValue
=
this
.
prefsProperties
.
getProperty
(
"ADVANCED_MODE"
);
String
sValue
=
this
.
prefsProperties
.
getProperty
(
"ADVANCED_MODE"
);
if
(
sValue
!=
null
)
{
ADVANCED_MODE
=
Boolean
.
parseBoolean
(
sValue
);
System
.
out
.
println
(
"Read ADVANCED_MODE="
+
ADVANCED_MODE
);
...
...
@@ -609,13 +674,7 @@ private Panel panel1,
b
.
addKeyListener
(
IJ
.
getInstance
());
panel
.
add
(
b
);
}
public
void
processWindowEvent
(
WindowEvent
e
)
{
super
.
processWindowEvent
(
e
);
if
(
e
.
getID
()==
WindowEvent
.
WINDOW_CLOSING
)
{
instance
=
null
;
}
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
String
label
=
e
.
getActionCommand
();
if
(
label
.
equals
(
"Abort"
))
{
...
...
@@ -642,6 +701,70 @@ private Panel panel1,
}
// matchSimulatedPattern.FFT_SIZE=FFT_SIZE;
}
public
void
processFiles
()
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
String
configPath
=
null
;
if
(!
headless
&&
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
EYESIS_CORRECTIONS
.
initSensorFiles
(
DEBUG_LEVEL
);
int
numChannels
=
EYESIS_CORRECTIONS
.
getNumChannels
();
NONLIN_PARAMETERS
.
modifyNumChannels
(
numChannels
);
CHANNEL_GAINS_PARAMETERS
.
modifyNumChannels
(
numChannels
);
if
(
CORRECTION_PARAMETERS
.
deconvolve
&&
(
NONLIN_PARAMETERS
.
noiseGainPower
!=
0
))
{
EYESIS_CORRECTIONS
.
updateImageNoiseGains
(
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
CONVOLVE_FFT_SIZE
,
//int fftSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX
,
// int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
// boolean updateStatus,
DEBUG_LEVEL
);
//int globalDebugLevel){
}
EYESIS_CORRECTIONS
.
processChannelImages
(
SPLIT_PARAMETERS
,
// EyesisCorrectionParameters.SplitParameters splitParameters,
DEBAYER_PARAMETERS
,
//EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
COLOR_PROC_PARAMETERS
,
//EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS
,
//CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS
,
//EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS
,
// EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
CONVOLVE_FFT_SIZE
,
//int convolveFFTSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
}
public
void
runMenuCommand
(
String
label
){
int
i
,
j
;
//,l,iq;
// String label = e.getActionCommand();
...
...
@@ -1055,69 +1178,7 @@ private Panel panel1,
return
;
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Process files"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
String
configPath
=
null
;
if
(
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
EYESIS_CORRECTIONS
.
initSensorFiles
(
DEBUG_LEVEL
);
int
numChannels
=
EYESIS_CORRECTIONS
.
getNumChannels
();
NONLIN_PARAMETERS
.
modifyNumChannels
(
numChannels
);
CHANNEL_GAINS_PARAMETERS
.
modifyNumChannels
(
numChannels
);
if
(
CORRECTION_PARAMETERS
.
deconvolve
&&
(
NONLIN_PARAMETERS
.
noiseGainPower
!=
0
))
{
EYESIS_CORRECTIONS
.
updateImageNoiseGains
(
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
CONVOLVE_FFT_SIZE
,
//int fftSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX
,
// int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
// boolean updateStatus,
DEBUG_LEVEL
);
//int globalDebugLevel){
}
EYESIS_CORRECTIONS
.
processChannelImages
(
SPLIT_PARAMETERS
,
// EyesisCorrectionParameters.SplitParameters splitParameters,
DEBAYER_PARAMETERS
,
//EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
COLOR_PROC_PARAMETERS
,
//EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS
,
//CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS
,
//EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS
,
// EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
CONVOLVE_FFT_SIZE
,
//int convolveFFTSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
processFiles
();
return
;
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Tiff Writer"
))
{
...
...
@@ -2579,7 +2640,7 @@ private Panel panel1,
for
(
int
ii
=
0
;
ii
<
n
;
ii
++)
{
dindex
[
ii
]
=
(
double
)
ii
;
dindex
[
ii
]
=
ii
;
x
[
ii
]
=
0.0
;
}
// x[1] = 1.0;
...
...
@@ -2890,7 +2951,16 @@ private Panel panel1,
int
numChannels
=
EYESIS_CORRECTIONS
.
getNumChannels
();
NONLIN_PARAMETERS
.
modifyNumChannels
(
numChannels
);
CHANNEL_GAINS_PARAMETERS
.
modifyNumChannels
(
numChannels
);
/*
if (CORRECTION_PARAMETERS.deconvolve && (NONLIN_PARAMETERS.noiseGainPower!=0)) {
EYESIS_CORRECTIONS.updateImageNoiseGains(
NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
CONVOLVE_FFT_SIZE, //int fftSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX, // int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, // boolean updateStatus,
DEBUG_LEVEL); //int globalDebugLevel){
}
*/
if
(!
EYESIS_DCT
.
DCTKernelsAvailable
()){
if
(
DEBUG_LEVEL
>
0
){
System
.
out
.
println
(
"Reading/converting DCT kernels"
);
...
...
@@ -2905,7 +2975,11 @@ private Panel panel1,
EYESIS_DCT
.
showKernels
();
// show restored kernels
}
}
// EYESIS_CORRECTIONS.processChannelImages(
EYESIS_DCT
.
processDCTChannelImages
(
// SPLIT_PARAMETERS, // EyesisCorrectionParameters.SplitParameters splitParameters,
DCT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS
,
//EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
...
...
@@ -3780,9 +3854,6 @@ private Panel panel1,
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"CLT correlate"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
runtime
.
gc
();
System
.
out
.
println
(
"--- Free memory="
+
runtime
.
freeMemory
()+
" (of "
+
runtime
.
totalMemory
()+
")"
);
// IJ.showMessage("DCT test 1");
if
(!
CLT_PARAMETERS
.
showDialog
())
return
;
// process selected image stack
...
...
@@ -3988,7 +4059,6 @@ private Panel panel1,
for
(
int
chn
=
0
;
chn
<
clt_corr
.
length
;
chn
++)
{
image_dtt
.
clt_dtt2
(
// DCCT2, DSCT2, DCST2, DSST2 - in-place
clt_corr
[
chn
],
// final double [][][][] clt_data,
true
,
// final boolean transpose, // when doing inverse transform, the data comes in transposed form, so CS <->SC
THREADS_MAX
,
// maximal number of threads to launch
DEBUG_LEVEL
);
// globalDebugLevel)
}
...
...
@@ -4032,193 +4102,28 @@ private Panel panel1,
DBG_IMP
.
getTitle
()+
"-C"
+
suffix
,
titles_rbg
);
}
//==============================================================================
}
else
if
(
label
.
equals
(
"Create CLT kernels"
))
{
if
(!
CLT_PARAMETERS
.
showDialog
())
return
;
if
(
EYESIS_DCT
==
null
){
EYESIS_DCT
=
new
EyesisDCT
(
EYESIS_CORRECTIONS
,
CORRECTION_PARAMETERS
,
DCT_PARAMETERS
);
}
String
configPath
=
null
;
if
(
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
EYESIS_CORRECTIONS
.
initSensorFiles
(
DEBUG_LEVEL
);
EYESIS_DCT
.
createCLTKernels
(
CLT_PARAMETERS
,
CONVOLVE_FFT_SIZE
/
2
,
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
//"Reset DCT kernels"
}
else
if
(
label
.
equals
(
"Reset CLT kernels"
))
{
if
(
EYESIS_DCT
!=
null
){
EYESIS_DCT
.
resetCLTKernels
();
}
}
else
if
(
label
.
equals
(
"Read CLT kernels"
))
{
if
(!
CLT_PARAMETERS
.
showDialog
())
return
;
if
(
EYESIS_DCT
==
null
){
EYESIS_DCT
=
new
EyesisDCT
(
EYESIS_CORRECTIONS
,
CORRECTION_PARAMETERS
,
DCT_PARAMETERS
);
}
String
configPath
=
null
;
if
(
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
EYESIS_CORRECTIONS
.
initSensorFiles
(
DEBUG_LEVEL
);
EYESIS_DCT
.
readCLTKernels
(
CLT_PARAMETERS
,
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
if
(
DEBUG_LEVEL
>
-
1
){
EYESIS_DCT
.
showCLTKernels
(
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
}
return
;
}
else
if
(
label
.
equals
(
"CLT process files"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
if
(
EYESIS_DCT
==
null
){
EYESIS_DCT
=
new
EyesisDCT
(
EYESIS_CORRECTIONS
,
CORRECTION_PARAMETERS
,
DCT_PARAMETERS
);
if
(
DEBUG_LEVEL
>
0
){
System
.
out
.
println
(
"Created new EyesisDCT instance, will need to read CLT kernels"
);
}
}
String
configPath
=
null
;
if
(
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
EYESIS_CORRECTIONS
.
initSensorFiles
(
DEBUG_LEVEL
);
int
numChannels
=
EYESIS_CORRECTIONS
.
getNumChannels
();
NONLIN_PARAMETERS
.
modifyNumChannels
(
numChannels
);
CHANNEL_GAINS_PARAMETERS
.
modifyNumChannels
(
numChannels
);
if
(!
EYESIS_DCT
.
CLTKernelsAvailable
()){
if
(
DEBUG_LEVEL
>
0
){
System
.
out
.
println
(
"Reading CLT kernels"
);
}
EYESIS_DCT
.
readCLTKernels
(
CLT_PARAMETERS
,
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
if
(
DEBUG_LEVEL
>
1
){
EYESIS_DCT
.
showCLTKernels
(
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
}
/*
double [][] iclt_data = new double [clt_data.length][];
for (int chn=0; chn<iclt_data.length;chn++){
iclt_data[chn] = image_dtt.iclt_2d(
clt_data[chn], // scanline representation of dcd data, organized as dct_size x dct_size tiles
CLT_PARAMETERS.transform_size, // final int
CLT_PARAMETERS.clt_window, //window_type
CLT_PARAMETERS.iclt_mask, //which of 4 to transform back
CLT_PARAMETERS.dbg_mode, //which of 4 to transform back
THREADS_MAX, // maximal number of threads to launch
DEBUG_LEVEL); // globalDebugLevel)
}
///========================================
EYESIS_DCT
.
processCLTChannelImages
(
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS
,
//EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
COLOR_PROC_PARAMETERS
,
//EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS
,
//CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS
,
//EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS
,
// EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
CONVOLVE_FFT_SIZE
,
//int convolveFFTSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
null
,
// use as default directory if path==null
SDFA_INSTANCE.showArrays(
iclt_data,
(tilesX + 1) * CLT_PARAMETERS.transform_size,
(tilesY + 1) * CLT_PARAMETERS.transform_size,
true,
PROPERTIES
);
}
DBG_IMP.getTitle()+"-ICLT-"+CLT_PARAMETERS.iclt_mask);
*/
return
;
// End of buttons code
...
...
@@ -4429,6 +4334,7 @@ private Panel panel1,
public
MultipleExtensionsFileFilter
(
String
[]
patterns
)
{
this
.
patterns
=
patterns
.
clone
();
}
@Override
public
boolean
accept
(
File
file
)
{
int
i
;
String
name
=
file
.
getName
();
...
...
@@ -4438,6 +4344,7 @@ private Panel panel1,
}
return
false
;
}
@Override
public
String
getDescription
()
{
return
description
;
}
...
...
@@ -5736,6 +5643,7 @@ private Panel panel1,
final
long
startTime
=
System
.
nanoTime
();
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
float
[]
pixels
=
null
;
// will be initialized at first use
float
[]
kernelPixels
=
null
;
// will be initialized at first use
...
...
@@ -5878,6 +5786,7 @@ private Panel panel1,
final
long
startTime
=
System
.
nanoTime
();
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
double
[][]
tile
=
new
double
[
nChn
][
debayerParameters
.
size
*
debayerParameters
.
size
];
double
[][]
both_masks
;
...
...
@@ -6125,6 +6034,7 @@ private Panel panel1,
final
long
startTime
=
System
.
nanoTime
();
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
double
[]
tile
=
new
double
[
size
*
size
];
int
tileY
,
tileX
;
...
...
@@ -7449,4 +7359,3 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
}
}
src/main/java/JP46_Reader_camera.java
View file @
da48d22b
...
...
@@ -30,6 +30,7 @@ import ij.process.*;
import
ij.gui.*
;
import
ij.plugin.frame.*
;
import
ij.text.*
;
import
ij.plugin.PlugIn
;
import
java.awt.*
;
import
java.awt.event.*
;
...
...
@@ -50,9 +51,8 @@ import org.xml.sax.InputSource;
import
org.xml.sax.SAXException
;
/* This plugin opens images in Elphel JP4/JP46 format (opens as JPEG, reads MakerNote and converts). */
public
class
JP46_Reader_camera
extends
PlugInFrame
implements
ActionListener
{
public
class
JP46_Reader_camera
implements
PlugIn
,
ActionListener
{
/**
*
...
...
@@ -61,6 +61,7 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
Panel
panel1
;
Panel
confpanel
;
Frame
instance
;
PlugInFrame
plugInFrame
;
String
arg
;
...
...
@@ -75,44 +76,33 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
public
boolean
demux
=
true
;
public
String
imageTitle
=
"cameraImage"
;
private
int
ExifOffset
=
0x0c
;
private
Boolean
headless
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
().
isHeadlessInstance
();
public
JP46_Reader_camera
()
{
super
(
"JP46 Reader Camera"
);
if
(
IJ
.
versionLessThan
(
"1.39t"
))
return
;
if
(
instance
!=
null
)
{
instance
.
toFront
();
return
;
public
void
run
(
String
arg
)
{
}
instance
=
this
;
addKeyListener
(
IJ
.
getInstance
());
panel1
=
new
Panel
();
panel1
.
setLayout
(
new
GridLayout
(
6
,
1
,
50
,
5
));
addButton
(
"Open JP4/JP46..."
,
panel1
);
addButton
(
"Open JP4/JP46 from camera"
,
panel1
);
addButton
(
"Configure..."
,
panel1
);
addButton
(
"Show image properties"
,
panel1
);
addButton
(
"Decode image info to properties"
,
panel1
);
addButton
(
"Split Bayer"
,
panel1
);
public
JP46_Reader_camera
(
Boolean
showGui
)
{
if
(
showGui
)
initGui
();
}
public
JP46_Reader_camera
()
{
initGui
();
}
add
(
panel1
);
public
void
initGui
()
{
//super("JP46 Reader Camera");
if
(
headless
)
return
;
pack
();
GUI
.
center
(
this
);
setVisible
(
true
);
}
public
JP46_Reader_camera
(
boolean
showGUI
)
{
super
(
"JP46 Reader Camera"
);
if
(
IJ
.
versionLessThan
(
"1.39t"
))
return
;
if
(
instance
!=
null
)
{
instance
.
toFront
();
return
;
}
instance
=
this
;
addKeyListener
(
IJ
.
getInstance
());
plugInFrame
=
new
PlugInFrame
(
"JP46 Reader Camera"
);
instance
=
(
Frame
)
plugInFrame
;
plugInFrame
.
addKeyListener
(
IJ
.
getInstance
());
panel1
=
new
Panel
();
...
...
@@ -124,10 +114,10 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
addButton
(
"Show image properties"
,
panel1
);
addButton
(
"Decode image info to properties"
,
panel1
);
addButton
(
"Split Bayer"
,
panel1
);
add
(
panel1
);
pack
();
GUI
.
center
(
this
);
setVisible
(
showGUI
);
plugInFrame
.
add
(
panel1
);
p
lugInFrame
.
p
ack
();
GUI
.
center
(
plugInFrame
);
plugInFrame
.
setVisible
(
true
);
}
void
addButton
(
String
label
,
Panel
panel
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment