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
01246a62
Commit
01246a62
authored
Jan 04, 2016
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2 from luxigo/master
Allow running Eyesis_Correction and JP46_Reader_camera in headless mode
parents
103e97e7
3ae3cafd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
170 additions
and
141 deletions
+170
-141
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+6
-0
EyesisCorrections.java
src/main/java/EyesisCorrections.java
+2
-2
EyesisTiff.java
src/main/java/EyesisTiff.java
+15
-2
Eyesis_Correction.java
src/main/java/Eyesis_Correction.java
+119
-99
JP46_Reader_camera.java
src/main/java/JP46_Reader_camera.java
+28
-38
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
01246a62
...
...
@@ -61,6 +61,7 @@ public class EyesisCorrectionParameters {
public
double
outputRangeFP
=
255.0
;
// 1.0 intensity will be saved as 255.0 (in float 32-bit mode)
public
boolean
imageJTags
=
false
;
// encode ImageJ info data to the TIFF output header
public
String
tiffCompression
=
"UNCOMPRESSED"
;
// tiff compression codec
public
boolean
jpeg
=
true
;
// convert to RGB and save JPEG (if save is true)
public
boolean
save
=
true
;
public
boolean
save16
=
false
;
// save 16-bit tiff also if the end result is 8 bit
...
...
@@ -201,6 +202,7 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"equirectangularFormat"
)!=
null
)
this
.
equirectangularFormat
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"equirectangularFormat"
));
if
(
properties
.
getProperty
(
prefix
+
"outputRangeInt"
)!=
null
)
this
.
outputRangeInt
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"outputRangeInt"
));
if
(
properties
.
getProperty
(
prefix
+
"outputRangeFP"
)!=
null
)
this
.
outputRangeFP
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"outputRangeFP"
));
if
(
properties
.
getProperty
(
prefix
+
"tiffCompression"
)!=
null
)
this
.
tiffCompression
=
properties
.
getProperty
(
prefix
+
"tiffCompression"
);
if
(
properties
.
getProperty
(
prefix
+
"imageJTags"
)!=
null
)
this
.
imageJTags
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"imageJTags"
));
if
(
properties
.
getProperty
(
prefix
+
"jpeg"
)!=
null
)
this
.
jpeg
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"jpeg"
));
// convert to RGB and save jpeg (if save is true)
if
(
properties
.
getProperty
(
prefix
+
"save"
)!=
null
)
this
.
save
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"save"
));
...
...
@@ -283,6 +285,8 @@ public class EyesisCorrectionParameters {
gd
.
addCheckbox
(
"Save chroma denoise mask (white - use hi-res, black - low-res)"
,
this
.
saveChromaDenoiseMask
);
gd
.
addCheckbox
(
"Rotate result image"
,
this
.
rotate
);
gd
.
addCheckbox
(
"Crop result image to the original size"
,
this
.
crop
);
String
[]
tiffCompressionChoices
={
"UNCOMPRESSED"
,
"LZW"
,
"JPEG"
,
"JPEG_2000"
,
"ALT_JPEG2000"
};
int
tiffCompressionIndex
=
0
;
String
[]
equirectangularFormatChoices
={
"RGBA 8-bit"
,
"RGBA 16-bit"
,
"RGBA 32-bit integer"
,
"RGBA 32-bit float"
,
"ImageJ stack"
};
int
[]
equirectangularFormats
={
0
,
1
,
2
,
3
,
4
};
int
equirectangularFormatIndex
=
0
;
...
...
@@ -294,6 +298,7 @@ public class EyesisCorrectionParameters {
gd
.
addNumericField
(
"Map 1.0 intensity to this fraction of the full range 8/16/32-bit integer mode output"
,
100
*
this
.
outputRangeInt
,
2
,
6
,
"%"
);
gd
.
addNumericField
(
"Map 1.0 intensity to this value in 32-bit floating point output mode"
,
this
.
outputRangeFP
,
2
,
6
,
""
);
gd
.
addCheckbox
(
"Encode ImageJ specific Info metadata to the output file TIFF header"
,
this
.
imageJTags
);
gd
.
addChoice
(
"TIFF lossless compression codec"
,
tiffCompressionChoices
,
tiffCompressionChoices
[
tiffCompressionIndex
]);
gd
.
addCheckbox
(
"Convert to RGB48"
,
this
.
toRGB
);
gd
.
addCheckbox
(
"Convert to 8 bit RGB (and save JPEG if save is enabled)"
,
this
.
jpeg
);
...
...
@@ -372,6 +377,7 @@ public class EyesisCorrectionParameters {
this
.
outputRangeInt
=
0.01
*
gd
.
getNextNumber
();
this
.
outputRangeFP
=
gd
.
getNextNumber
();
this
.
imageJTags
=
gd
.
getNextBoolean
();
this
.
tiffCompression
=
tiffCompressionChoices
[
gd
.
getNextChoiceIndex
()];
this
.
toRGB
=
gd
.
getNextBoolean
();
this
.
jpeg
=
gd
.
getNextBoolean
();
this
.
save
=
gd
.
getNextBoolean
();
...
...
src/main/java/EyesisCorrections.java
View file @
01246a62
...
...
@@ -473,7 +473,7 @@ public class EyesisCorrections {
this
.
defectsDiff
[
srcChannel
]=
this
.
pixelMapping
.
getDefectsDiff
(
srcChannel
);
if
(
this
.
debugLevel
>
0
){
if
(
this
.
defectsXY
[
srcChannel
]==
null
){
System
.
out
.
println
(
"No pixel defects info is availab
e
le for channel "
+
srcChannel
);
System
.
out
.
println
(
"No pixel defects info is available for channel "
+
srcChannel
);
}
else
{
System
.
out
.
println
(
"Extracted "
+
this
.
defectsXY
[
srcChannel
].
length
+
" pixel outlayers for channel "
+
srcChannel
+
" (x:y:difference"
);
...
...
@@ -701,7 +701,7 @@ public class EyesisCorrections {
if
(
path
!=
null
){
path
+=
Prefs
.
getFileSeparator
()+
imp
.
getTitle
()+
".tiff"
;
if
(
this
.
debugLevel
>
0
)
System
.
out
.
println
(
"Saving equirectangular result to "
+
path
);
(
new
EyesisTiff
()).
saveTiff
(
(
new
EyesisTiff
(
correctionsParameters
.
tiffCompression
)).
saveTiff
(
imp
,
path
,
correctionsParameters
.
equirectangularFormat
,
...
...
src/main/java/EyesisTiff.java
View file @
01246a62
...
...
@@ -34,6 +34,7 @@ import java.util.Arrays;
//import org.apache.log4j.Logger;
import
ij.IJ
;
import
ij.ImagePlus
;
import
ij.WindowManager
;
...
...
@@ -42,20 +43,31 @@ import loci.common.RandomAccessInputStream;
import
loci.common.services.DependencyException
;
import
loci.common.services.ServiceException
;
import
loci.formats.FormatException
;
import
loci.formats.codec.CodecOptions
;
import
loci.formats.tiff.IFD
;
import
loci.formats.tiff.IFDList
;
import
loci.formats.tiff.TiffParser
;
import
loci.formats.tiff.TiffRational
;
import
loci.formats.tiff.TiffSaver
;
import
loci.formats.tiff.TiffCompression
;
public
class
EyesisTiff
{
// private static org.apache.log4j.Logger log= Logger.getLogger(EyesisTiff.class);
private
String
codec
=
"UNCOMPRESSED"
;
public
EyesisTiff
(){
// Please initialize the log4j system properly
}
public
EyesisTiff
(
String
codec
){
// Please initialize the log4j system properly
this
.
codec
=
codec
;
}
public
void
saveTiff
(
ImagePlus
imp
,
String
path
,
...
...
@@ -175,7 +187,7 @@ public EyesisTiff(){
ifd
.
putIFDValue
(
IFD
.
SOFTWARE
,
"Elphel Eyesis"
);
ifd
.
putIFDValue
(
IFD
.
IMAGE_DESCRIPTION
,
description
);
// copy some other data?
ifd
.
putIFDValue
(
IFD
.
COMPRESSION
,
1
);
//TiffCompression.UNCOMPRESSED
);
ifd
.
putIFDValue
(
IFD
.
COMPRESSION
,
TiffCompression
.
valueOf
(
codec
).
getCode
()
);
ifd
.
putIFDValue
(
IFD
.
PHOTOMETRIC_INTERPRETATION
,
2
);
// RGB
ifd
.
putIFDValue
(
IFD
.
EXTRA_SAMPLES
,
2
);
// 0 = Unspecified data 1 = Associated alpha data (with pre-multiplied color) 2 = Unassociated alpha data
// int [] bpsArray={8,8,8,8};
...
...
@@ -212,6 +224,7 @@ public EyesisTiff(){
TiffSaver
tiffSaver
=
new
TiffSaver
(
path
);
tiffSaver
.
setWritingSequentially
(
true
);
tiffSaver
.
setLittleEndian
(
false
);
tiffSaver
.
setCodecOptions
(
TiffCompression
.
valueOf
(
codec
).
getCompressionCodecOptions
(
ifd
));
tiffSaver
.
writeHeader
();
// tiffSaver.writeIFD(ifd,0); //* SHould not write here, some fields are calculated during writeImage, that writes IFD too
// System.out.println("bytes.length="+bytes.length);
...
...
@@ -257,7 +270,7 @@ public EyesisTiff(){
ifd
.
putIFDValue
(
IFD
.
SOFTWARE
,
"Elphel Eyesis"
);
ifd
.
putIFDValue
(
IFD
.
IMAGE_DESCRIPTION
,
description
);
// copy some other data?
ifd
.
putIFDValue
(
IFD
.
COMPRESSION
,
1
);
//TiffCompression.UNCOMPRESSED
);
ifd
.
putIFDValue
(
IFD
.
COMPRESSION
,
TiffCompression
.
valueOf
(
codec
).
getCode
()
);
ifd
.
putIFDValue
(
IFD
.
PHOTOMETRIC_INTERPRETATION
,
2
);
// RGB
ifd
.
putIFDValue
(
IFD
.
EXTRA_SAMPLES
,
2
);
// extra bytes (over 3) meaning Unassociated alpha data
...
...
src/main/java/Eyesis_Correction.java
View file @
01246a62
...
...
@@ -33,6 +33,7 @@ import ij.io.FileSaver;
import
ij.io.OpenDialog
;
import
ij.io.Opener
;
import
ij.plugin.frame.*
;
import
ij.plugin.PlugIn
;
import
java.awt.*
;
import
java.awt.event.*
;
...
...
@@ -60,10 +61,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
,
panel3
,
panel4
,
panel5
,
panel5a
,
panel6
,
panel7
,
panelPostProcessing1
,
panelPostProcessing2
,
panelPostProcessing3
;
JP46_Reader_camera
JP4_INSTANCE
=
null
;
...
...
@@ -309,10 +314,14 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
public
AtomicInteger
stopRequested
=
new
AtomicInteger
(
0
);
// 0 - not requested, 1 - ASAP, 2 - gracefully
public
String
buttonLabel
=
""
;
}
public
Eyesis_Correction
()
{
super
(
"Eyesis_Correction"
);
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
();
...
...
@@ -322,21 +331,36 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
);
instance
=
this
;
addKeyListener
(
IJ
.
getInstance
());
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
=(
Frame
)
plugInFrame
;
plugInFrame
.
addKeyListener
(
IJ
.
getInstance
());
int
menuRows
=
4
+
(
ADVANCED_MODE
?
4
:
0
)
+
(
MODE_3D
?
3
:
0
);
setLayout
(
new
GridLayout
(
menuRows
,
1
));
plugInFrame
.
setLayout
(
new
GridLayout
(
menuRows
,
1
));
panel6
=
new
Panel
();
panel6
.
setLayout
(
new
GridLayout
(
1
,
0
,
5
,
5
));
addButton
(
"Save"
,
panel6
);
...
...
@@ -344,13 +368,13 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
);
...
...
@@ -358,7 +382,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
...
...
@@ -368,13 +392,13 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
));
...
...
@@ -382,14 +406,14 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
));
...
...
@@ -402,7 +426,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
addButton
(
"Tiff Writer"
,
panel7
);
addButton
(
"Tiff Properties"
,
panel7
);
}
add
(
panel7
);
plugInFrame
.
add
(
panel7
);
if
(
MODE_3D
){
panelPostProcessing1
=
new
Panel
();
...
...
@@ -412,7 +436,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
));
...
...
@@ -423,19 +447,19 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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
);
}
pack
();
p
lugInFrame
.
p
ack
();
GUI
.
center
(
this
);
setVisible
(
true
);
GUI
.
center
(
plugInFrame
);
plugInFrame
.
setVisible
(
true
);
FHT_INSTANCE
=
new
DoubleFHT
();
SDFA_INSTANCE
=
new
showDoubleFloatArrays
();
// main loop
...
...
@@ -464,7 +488,6 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
}
}
private
String
prefsPath
=
Prefs
.
getPrefsDir
()+
Prefs
.
getFileSeparator
()+
"Eyesis_Correction.xml"
;
private
Properties
prefsProperties
=
new
Properties
();
public
void
loadPrefs
()
throws
IOException
{
...
...
@@ -478,6 +501,8 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
}
try
{
prefsProperties
.
loadFromXML
(
is
);
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
;
...
...
@@ -490,7 +515,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
// 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
);
...
...
@@ -536,13 +561,6 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
b
.
addKeyListener
(
IJ
.
getInstance
());
panel
.
add
(
b
);
}
public
void
processWindowEvent
(
WindowEvent
e
)
{
super
.
processWindowEvent
(
e
);
if
(
e
.
getID
()==
WindowEvent
.
WINDOW_CLOSING
)
{
instance
=
null
;
}
}
public
void
actionPerformed
(
ActionEvent
e
)
{
String
label
=
e
.
getActionCommand
();
if
(
label
.
equals
(
"Abort"
))
{
...
...
@@ -569,6 +587,70 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
}
// 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();
...
...
@@ -982,69 +1064,7 @@ private Panel panel1,panel2,panel3,panel4,panel5,panel5a, panel6,panel7,panelPos
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"
))
{
...
...
@@ -5673,7 +5693,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
*/
public
static
void
main
(
String
[]
args
)
{
// set the plugins.dir property to make the plugin appear in the Plugins menu
Class
<?>
clazz
=
Aberration_Calibra
tion
.
class
;
Class
<?>
clazz
=
Eyesis_Correc
tion
.
class
;
String
url
=
clazz
.
getResource
(
"/"
+
clazz
.
getName
().
replace
(
'.'
,
'/'
)
+
".class"
).
toString
();
String
pluginsDir
=
url
.
substring
(
5
,
url
.
length
()
-
clazz
.
getName
().
length
()
-
6
);
System
.
setProperty
(
"plugins.dir"
,
pluginsDir
);
...
...
src/main/java/JP46_Reader_camera.java
View file @
01246a62
...
...
@@ -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
;
...
...
@@ -72,47 +73,34 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
public
String
camera_jp46settings
=
""
;
public
boolean
IS_SILENT
=
true
;
public
boolean
ABSOLUTELY_SILENT
=
false
;
public
boolean
demux
=
true
;
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
;
}
instance
=
this
;
addKeyListener
(
IJ
.
getInstance
());
panel1
=
new
Panel
();
public
void
run
(
String
arg
)
{
}
panel1
.
setLayout
(
new
GridLayout
(
6
,
1
,
50
,
5
));
public
JP46_Reader_camera
(
Boolean
showGui
)
{
if
(
showGui
)
initGui
();
}
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
()
{
initGui
();
}
add
(
panel1
);
private
void
initGui
()
{
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,12 +112,14 @@ 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
);
plugInFrame
.
pack
();
GUI
.
center
(
plugInFrame
);
plugInFrame
.
setVisible
(
true
);
}
void
addButton
(
String
label
,
Panel
panel
)
{
Button
b
=
new
Button
(
label
);
b
.
addActionListener
(
this
);
...
...
@@ -1321,7 +1311,7 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
*/
public
static
void
main
(
String
[]
args
)
{
// set the plugins.dir property to make the plugin appear in the Plugins menu
Class
<?>
clazz
=
Aberration_Calibration
.
class
;
Class
<?>
clazz
=
JP46_Reader_camera
.
class
;
String
url
=
clazz
.
getResource
(
"/"
+
clazz
.
getName
().
replace
(
'.'
,
'/'
)
+
".class"
).
toString
();
String
pluginsDir
=
url
.
substring
(
5
,
url
.
length
()
-
clazz
.
getName
().
length
()
-
6
);
System
.
setProperty
(
"plugins.dir"
,
pluginsDir
);
...
...
@@ -1330,7 +1320,7 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
// run the plugin
IJ
.
runPlugIn
(
clazz
.
getName
(),
""
);
}
}
...
...
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