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
3f9c52b0
Commit
3f9c52b0
authored
Jun 07, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Plain Diff
merged with lwir
parents
13959a97
047fdb5e
Changes
13
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
12103 additions
and
10299 deletions
+12103
-10299
JP46_Reader_camera0.java
src/main/java/JP46_Reader_camera0.java
+68
-6
Aberration_Calibration.java
...com/elphel/imagej/calibration/Aberration_Calibration.java
+404
-177
DistortionProcessConfiguration.java
...el/imagej/calibration/DistortionProcessConfiguration.java
+37
-15
EyesisAberrations.java
...java/com/elphel/imagej/calibration/EyesisAberrations.java
+272
-262
Goniometer.java
src/main/java/com/elphel/imagej/calibration/Goniometer.java
+23
-17
LensAdjustment.java
...in/java/com/elphel/imagej/calibration/LensAdjustment.java
+216
-209
MatchSimulatedPattern.java
.../com/elphel/imagej/calibration/MatchSimulatedPattern.java
+10218
-9059
SimulationPattern.java
...java/com/elphel/imagej/calibration/SimulationPattern.java
+524
-450
DoubleFHT.java
src/main/java/com/elphel/imagej/common/DoubleFHT.java
+162
-90
ShowDoubleFloatArrays.java
.../java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
+24
-0
JP46_Reader_camera.java
src/main/java/com/elphel/imagej/jp4/JP46_Reader_camera.java
+11
-2
LwirReaderParameters.java
...ain/java/com/elphel/imagej/lwir/LwirReaderParameters.java
+134
-6
EyesisTiff.java
src/main/java/com/elphel/imagej/readers/EyesisTiff.java
+10
-6
No files found.
src/main/java/JP46_Reader_camera0.java
View file @
3f9c52b0
...
...
@@ -55,6 +55,8 @@ import org.w3c.dom.NodeList;
import
org.xml.sax.InputSource
;
import
org.xml.sax.SAXException
;
import
com.elphel.imagej.readers.ImagejJp4Tiff
;
import
ij.IJ
;
import
ij.ImageJ
;
import
ij.ImagePlus
;
...
...
@@ -69,6 +71,7 @@ import ij.plugin.frame.PlugInFrame;
import
ij.process.ImageConverter
;
import
ij.process.ImageProcessor
;
import
ij.text.TextWindow
;
import
loci.formats.FormatException
;
...
...
@@ -87,6 +90,8 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
static
File
dir
;
ImagejJp4Tiff
imagejJp4Tiff
=
new
ImagejJp4Tiff
();
public
String
camera_url
=
"http://192.168.0.236:8081/"
;
public
String
camera_img
=
"bimg"
;
public
String
camera_img_new
=
"towp/wait/bimg"
;
// will always wait for the next image (repetitive acquisitions get new images)
...
...
@@ -109,8 +114,9 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
panel1
=
new
Panel
();
panel1
.
setLayout
(
new
GridLayout
(
6
,
1
,
50
,
5
));
panel1
.
setLayout
(
new
GridLayout
(
8
,
1
,
50
,
5
));
addButton
(
"Open JP4/Tiff..."
,
panel1
);
addButton
(
"Open JP4/JP46..."
,
panel1
);
addButton
(
"Open JP4/JP46 from camera"
,
panel1
);
addButton
(
"Configure..."
,
panel1
);
...
...
@@ -137,8 +143,8 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
panel1
=
new
Panel
();
panel1
.
setLayout
(
new
GridLayout
(
6
,
1
,
50
,
5
));
panel1
.
setLayout
(
new
GridLayout
(
8
,
1
,
50
,
5
));
addButton
(
"Open JP4/Tiff..."
,
panel1
);
addButton
(
"Open JP4/JP46..."
,
panel1
);
addButton
(
"Open JP4/JP46 from camera"
,
panel1
);
addButton
(
"Configure..."
,
panel1
);
...
...
@@ -169,7 +175,11 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
if
(
label
==
null
)
return
;
/* button */
if
(
label
.
equals
(
"Open JP4/JP46..."
))
{
if
(
label
.
equals
(
"Open JP4/Tiff..."
))
{
read_jp4Tiff
(
arg
,
true
);
}
else
if
(
label
.
equals
(
"Open JP4/Tiff (no scale)..."
))
{
read_jp4Tiff
(
arg
,
false
);
}
else
if
(
label
.
equals
(
"Open JP4/JP46..."
))
{
read_jp46
(
arg
,
true
);
}
else
if
(
label
.
equals
(
"Open JP4/JP46 (no scale)..."
))
{
read_jp46
(
arg
,
false
);
...
...
@@ -227,7 +237,54 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
imp_stack
.
getProcessor
().
resetMinAndMax
();
imp_stack
.
show
();
}
public
void
read_jp4Tiff
(
String
arg
,
// not used?
boolean
scale
)
{
String
LOG_LEVEL
=
ABSOLUTELY_SILENT
?
"OFF"
:
(
IS_SILENT
?
"ERROR"
:
"INFO"
);
boolean
LOG_LEVEL_SET
=
loci
.
common
.
DebugTools
.
enableLogging
(
LOG_LEVEL
);
if
(!
LOG_LEVEL_SET
)
{
// only first time true
loci
.
common
.
DebugTools
.
setRootLevel
(
LOG_LEVEL
);
}
JFileChooser
fc
=
null
;
//try {fc = new JFileChooser();}
fc
=
new
JFileChooser
();
//catch (Throwable e) {IJ.error("This plugin requires Java 2 or Swing."); return;}
fc
.
setMultiSelectionEnabled
(
true
);
if
(
dir
==
null
)
{
String
sdir
=
OpenDialog
.
getDefaultDirectory
();
if
(
sdir
!=
null
)
dir
=
new
File
(
sdir
);
}
if
(
dir
!=
null
)
fc
.
setCurrentDirectory
(
dir
);
int
returnVal
=
fc
.
showOpenDialog
(
IJ
.
getInstance
());
if
(
returnVal
!=
JFileChooser
.
APPROVE_OPTION
)
return
;
File
[]
files
=
fc
.
getSelectedFiles
();
if
(
files
.
length
==
0
)
{
// getSelectedFiles does not work on some JVMs
files
=
new
File
[
1
];
files
[
0
]
=
fc
.
getSelectedFile
();
}
String
path
=
fc
.
getCurrentDirectory
().
getPath
()+
Prefs
.
getFileSeparator
();
dir
=
fc
.
getCurrentDirectory
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
try
{
ImagePlus
imp
=
imagejJp4Tiff
.
readTiffJp4
(
path
+
files
[
i
].
getName
(),
scale
);
// imp.updateAndDraw();
imp
.
show
();
}
catch
(
IOException
|
FormatException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
// throws IOException, FormatException { // std - include non-elphel properties with prefix std
// open(path, files[i].getName(), arg, scale);
}
}
public
void
read_jp46
(
String
arg
,
boolean
scale
)
{
JFileChooser
fc
=
null
;
//try {fc = new JFileChooser();}
...
...
@@ -274,6 +331,7 @@ public class JP46_Reader_camera0 extends PlugInFrame implements ActionListener {
confpanel
=
new
Panel
();
gd
.
addPanel
(
confpanel
);
addButton
(
"Open JP4/Tiff (no scale)..."
,
confpanel
);
addButton
(
"Open JP4/JP46 (no scale)..."
,
confpanel
);
addButton
(
"Open JP4/JP46 from camera (no scale)"
,
confpanel
);
...
...
@@ -1413,9 +1471,13 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
NodeList
allNodes
=
doc
.
getDocumentElement
().
getElementsByTagName
(
"*"
);
for
(
int
i
=
0
;
i
<
allNodes
.
getLength
();
i
++)
{
String
name
=
allNodes
.
item
(
i
).
getNodeName
();
String
value
=
allNodes
.
item
(
i
).
getFirstChild
().
getNodeValue
();
imp
.
setProperty
(
name
,
value
);
String
value
=
""
;
try
{
value
=
allNodes
.
item
(
i
).
getFirstChild
().
getNodeValue
();
}
catch
(
Exception
e
)
{
}
imp
.
setProperty
(
name
,
value
);
}
return
true
;
...
...
src/main/java/com/elphel/imagej/calibration/Aberration_Calibration.java
View file @
3f9c52b0
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/calibration/DistortionProcessConfiguration.java
View file @
3f9c52b0
...
...
@@ -23,15 +23,16 @@ package com.elphel.imagej.calibration;
**
*/
import
ij.IJ
;
import
ij.Prefs
;
import
ij.gui.GenericDialog
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.util.Properties
;
import
com.elphel.imagej.common.WindowTools
;
import
ij.IJ
;
import
ij.Prefs
;
import
ij.gui.GenericDialog
;
public
class
DistortionProcessConfiguration
{
public
String
sourceDirectory
=
""
;
...
...
@@ -207,4 +208,25 @@ import com.elphel.imagej.common.WindowTools;
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
;
}
}
src/main/java/com/elphel/imagej/calibration/EyesisAberrations.java
View file @
3f9c52b0
package
com
.
elphel
.
imagej
.
calibration
;
import
ij.IJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.Prefs
;
import
ij.gui.GenericDialog
;
import
ij.io.FileSaver
;
import
ij.io.Opener
;
import
ij.process.FloatProcessor
;
import
ij.process.ImageProcessor
;
import
java.awt.Rectangle
;
import
java.io.File
;
import
java.util.ArrayList
;
...
...
@@ -19,14 +9,22 @@ import java.util.concurrent.atomic.AtomicInteger;
import
javax.swing.SwingUtilities
;
import
com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter
;
import
com.elphel.imagej.calibration.SimulationPattern.SimulParameters
;
import
com.elphel.imagej.common.DoubleFHT
;
import
com.elphel.imagej.common.DoubleGaussianBlur
;
import
com.elphel.imagej.common.ShowDoubleFloatArrays
;
import
com.elphel.imagej.common.WindowTools
;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
import
ij.IJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.Prefs
;
import
ij.gui.GenericDialog
;
import
ij.io.FileSaver
;
import
ij.io.Opener
;
import
ij.process.FloatProcessor
;
import
ij.process.ImageProcessor
;
public
class
EyesisAberrations
{
public
double
[][][][]
pdfKernelMap
=
null
;
JP46_Reader_camera
JP4_INSTANCE
=
new
JP46_Reader_camera
(
false
);
...
...
@@ -181,6 +179,7 @@ public class EyesisAberrations {
final
int
numberOfKernelsInChn
=
tilesY
*
tilesX
;
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
float
[]
pixels
=
null
;
double
[]
kernel
=
new
double
[
inverseParameters
.
dSize
*
inverseParameters
.
dSize
];
...
...
@@ -555,7 +554,7 @@ public class EyesisAberrations {
iy
=-
iy
;
}
ix
=
(
ix
+
size
)
%
size
;
floatPixels
[
i
]=
(
float
)
clusterMap
[
iy
][
ix
];
floatPixels
[
i
]=
clusterMap
[
iy
][
ix
];
}
ip
.
setPixels
(
floatPixels
);
ip
.
resetMinAndMax
();
...
...
@@ -639,8 +638,8 @@ public class EyesisAberrations {
row2
=(
fftsize
-
row1
)
%
fftsize
;
for
(
col1
=
0
;
col1
<
fftsize
;
col1
++)
{
col2
=(
fftsize
-
col1
)
%
fftsize
;
fht_pixels
[
row1
*
fftsize
+
col1
]=
(
double
)
(
fft
[
row1
][
col1
][
0
]-
fft
[
row1
][
col1
][
1
])
;
fht_pixels
[
row2
*
fftsize
+
col2
]=
(
double
)
(
fft
[
row1
][
col1
][
0
]+
fft
[
row1
][
col1
][
1
])
;
fht_pixels
[
row1
*
fftsize
+
col1
]=
fft
[
row1
][
col1
][
0
]-
fft
[
row1
][
col1
][
1
]
;
fht_pixels
[
row2
*
fftsize
+
col2
]=
fft
[
row1
][
col1
][
0
]+
fft
[
row1
][
col1
][
1
]
;
}
}
return
fht_pixels
;
...
...
@@ -1279,8 +1278,11 @@ public class EyesisAberrations {
}
int
rslt
=
matchSimulatedPattern
.
calculateDistortions
(
null
,
// LwirReaderParameters lwirReaderParameters, // null is OK
distortionParameters
,
//
patternDetectParameters
,
// patternDetectParameters.minGridPeriod/2,
// patternDetectParameters.maxGridPeriod/2,
simulParameters
,
colorComponents
.
equalizeGreens
,
imp
,
...
...
@@ -2313,6 +2315,7 @@ public class EyesisAberrations {
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
// Concurrently run in as many threads as CPUs
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
// Each thread processes a few items in the total list
...
...
@@ -2399,6 +2402,7 @@ public class EyesisAberrations {
}
final
int
numFinished
=
tilesFinishedAtomic
.
getAndIncrement
();
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
IJ
.
showProgress
(
numFinished
,
patternCells
);
}
...
...
@@ -2679,6 +2683,8 @@ public class EyesisAberrations {
if
(
matchSimulatedPattern
.
PATTERN_GRID
==
null
)
{
double
[][]
distortedPattern
=
matchSimulatedPattern
.
findPatternDistorted
(
input_bayer
,
// pixel array to process (no windowing!)
patternDetectParameters
,
patternDetectParameters
.
minGridPeriod
/
2
,
patternDetectParameters
.
maxGridPeriod
/
2
,
true
,
//(greensToProcess==4), // boolean greens, // this is a pattern for combined greens (diagonal), adjust results accordingly
title
);
// title prefix to use for debug images
...
...
@@ -2704,7 +2710,8 @@ public class EyesisAberrations {
distortedPattern
[
2
],
//
simulParameters
.
subdiv
,
fft_size
,
simulParameters
.
center_for_g2
);
simulParameters
.
center_for_g2
,
false
);
//boolean mono
wVectors
[
0
][
0
]=
2.0
*
distortedPattern
[
0
][
0
]/
subpixel
;
wVectors
[
0
][
1
]=
2.0
*
distortedPattern
[
0
][
1
]/
subpixel
;
wVectors
[
1
][
0
]=
2.0
*
distortedPattern
[
1
][
0
]/
subpixel
;
...
...
@@ -2747,7 +2754,8 @@ public class EyesisAberrations {
simCorr
,
//
simulParameters
.
subdiv
,
fft_size
,
simulParameters
.
center_for_g2
);
simulParameters
.
center_for_g2
,
false
);
//boolean mono
}
// simul_pixels= simulationPattern.extractSimulPatterns (
simul_pixels
=
simulationPattern
.
extractSimulPatterns
(
...
...
@@ -4148,7 +4156,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
ImageProcessor
ip
=
new
FloatProcessor
(
size
,
size
);
float
[]
floatPixels
=
new
float
[
size
*
size
];
for
(
i
=
0
;
i
<
floatPixels
.
length
;
i
++)
{
floatPixels
[
i
]=
(
float
)
clusterMap
[
i
/
size
][
i
%
size
];
floatPixels
[
i
]=
clusterMap
[
i
/
size
][
i
%
size
];
}
ip
.
setPixels
(
floatPixels
);
ip
.
resetMinAndMax
();
...
...
@@ -4404,11 +4412,11 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
if
(
debug
)
{
SDFA_INSTANCE
.
showArrays
(
debugPixels
,
title
+
"_mask_PSF"
);
double
[]
doublePixelsPSFCount
=
new
double
[
pixelsPSF
.
length
];
for
(
j
=
0
;
j
<
doublePixelsPSFCount
.
length
;
j
++)
doublePixelsPSFCount
[
j
]=
(
double
)
pixelsPSFCount
[
j
];
for
(
j
=
0
;
j
<
doublePixelsPSFCount
.
length
;
j
++)
doublePixelsPSFCount
[
j
]=
pixelsPSFCount
[
j
];
SDFA_INSTANCE
.
showArrays
(
doublePixelsPSFCount
,
title
+
"_PSF_bin_count"
);
SDFA_INSTANCE
.
showArrays
(
pixelsPSFWeight
,
title
+
"_PSF_bin_weight"
);
double
[]
doubleContrastCache
=
new
double
[
contrastCache
.
length
];
for
(
j
=
0
;
j
<
doubleContrastCache
.
length
;
j
++)
doubleContrastCache
[
j
]=(
double
)((
contrastCache
[
j
]>=
0.0
)?
contrastCache
[
j
]:-
0.00001
)
;
for
(
j
=
0
;
j
<
doubleContrastCache
.
length
;
j
++)
doubleContrastCache
[
j
]=(
contrastCache
[
j
]>=
0.0
)?
contrastCache
[
j
]:-
0.00001
;
SDFA_INSTANCE
.
showArrays
(
doubleContrastCache
,
title
+
"_ContrastCache"
);
}
return
pixelsPSF
;
...
...
@@ -4988,6 +4996,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
this
.
thresholdHigh
=
thresholdHigh
;
this
.
thresholdLow
=
thresholdLow
;
}
@Override
public
OTFFilterParameters
clone
()
{
return
new
OTFFilterParameters
(
this
.
deconvInvert
,
...
...
@@ -5076,6 +5085,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
}
@Override
public
PSFParameters
clone
(){
return
new
PSFParameters
(
this
.
minContrast
,
...
...
src/main/java/com/elphel/imagej/calibration/Goniometer.java
View file @
3f9c52b0
...
...
@@ -665,9 +665,12 @@ horizontal axis:
boolean
noMessageBoxes
=
true
;
int
numAbsolutePoints
=
matchSimulatedPattern
.
calculateDistortions
(
null
,
// LwirReaderParameters lwirReaderParameters, // null is OK
// allow more of grid around pointers?
distortionParameters
,
//
this
.
patternDetectParameters
,
// this.patternDetectParameters.minGridPeriod/2,
// this.patternDetectParameters.maxGridPeriod/2,
simulParameters
,
equalizeGreens
,
imp_eq
,
this
.
laserPointers
,
// null, //LASER_POINTERS, //
...
...
@@ -838,9 +841,12 @@ horizontal axis:
// matchSimulatedPatterns[numSensor].getChannel(images[numSensor])+" ");
int
numAbsolutePoints
=
this
.
matchSimulatedPatterns
[
numSensor
].
calculateDistortions
(
null
,
// LwirReaderParameters lwirReaderParameters, // null is OK
// allow more of grid around pointers?
distortionParameters
,
//
this
.
patternDetectParameters
,
// this.patternDetectParameters.minGridPeriod/2,
// this.patternDetectParameters.maxGridPeriod/2,
simulParameters
,
equalizeGreens
,
imp_eq
,
this
.
laserPointers
,
// null, //LASER_POINTERS, //
...
...
src/main/java/com/elphel/imagej/calibration/LensAdjustment.java
View file @
3f9c52b0
...
...
@@ -25,7 +25,6 @@ package com.elphel.imagej.calibration;
import
java.awt.Rectangle
;
import
java.util.Properties
;
import
com.elphel.imagej.calibration.SimulationPattern.SimulParameters
;
import
com.elphel.imagej.common.ShowDoubleFloatArrays
;
import
com.elphel.imagej.common.WindowTools
;
...
...
@@ -100,6 +99,7 @@ public class LensAdjustment {
ImagePlus
imp_eq
=
matchSimulatedPattern
.
applyFlatField
(
imp
);
// will throw if image size mismatch
if
(
updating
)
{
double
maxActualCorr
=
matchSimulatedPattern
.
refineDistortionCorrelation
(
null
,
// LwirReaderParameters lwirReaderParameters, // null is OK
distortionParameters
,
//
patternDetectParameters
,
simulParameters
,
...
...
@@ -133,9 +133,12 @@ public class LensAdjustment {
System
.
out
.
println
(
"updateFocusGrid(), number of already defined grid cells (before distortions()) = "
+
matchSimulatedPattern
.
numDefinedCells
());
}
matchSimulatedPattern
.
distortions
(
null
,
// is not used in update mode
null
,
//LwirReaderParameters lwirReaderParameters, // null is OK
null
,
// final boolean [] triedIndices, // is not used in update mode
distortionParameters
,
//
patternDetectParameters
,
patternDetectParameters
.
minGridPeriod
/
2
,
patternDetectParameters
.
maxGridPeriod
/
2
,
simulParameters
,
equalizeGreens
,
imp_eq
,
// image to process
...
...
@@ -156,8 +159,11 @@ public class LensAdjustment {
// matchSimulatedPattern.invalidateFlatFieldForGrid(); //Keep these!
// matchSimulatedPattern.invalidateFocusMask();
numAbsolutePoints
=
matchSimulatedPattern
.
calculateDistortions
(
// allow more of grid around pointers?
null
,
// LwirReaderParameters lwirReaderParameters, // null is OK
distortionParameters
,
//
patternDetectParameters
,
// patternDetectParameters.minGridPeriod/2,
// patternDetectParameters.maxGridPeriod/2,
simulParameters
,
equalizeGreens
,
imp_eq
,
...
...
@@ -806,6 +812,7 @@ public class LensAdjustment {
this
.
reportTemperature
=
reportTemperature
;
this
.
showLegacy
=
showLegacy
;
}
@Override
public
FocusMeasurementParameters
clone
(){
return
new
FocusMeasurementParameters
(
this
.
gridGeometryFile
,
...
...
src/main/java/com/elphel/imagej/calibration/MatchSimulatedPattern.java
View file @
3f9c52b0
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/calibration/SimulationPattern.java
View file @
3f9c52b0
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/common/DoubleFHT.java
View file @
3f9c52b0
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
View file @
3f9c52b0
...
...
@@ -112,6 +112,30 @@ import ij.process.ImageProcessor;
return
;
}
else
showArrays
(
pixels
,
width
,
height
,
titles
);
}
public
void
showComplex
(
double
[][][]
cpixels
,
String
title
)
{
int
height
=
cpixels
.
length
;
int
width
=
cpixels
[
0
].
length
;
double
[][]
pixels
=
new
double
[
height
*
width
][];
int
indx
=
0
;
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
pixels
[
indx
++]
=
cpixels
[
y
][
x
];
}
}
showComplex
(
pixels
,
width
,
title
);
}
public
void
showComplex
(
double
[][]
cpixels
,
int
width
,
String
title
)
{
int
height
=
cpixels
.
length
/
width
;
double
[][]
pixels
=
new
double
[
2
][
cpixels
.
length
];
for
(
int
i
=
0
;
i
<
cpixels
.
length
;
i
++)
{
pixels
[
0
][
i
]=
cpixels
[
i
][
0
];
pixels
[
1
][
i
]=
cpixels
[
i
][
1
];
}
String
[]
titles
=
{
"Re"
,
"Im"
};
showArrays
(
pixels
,
width
,
height
,
true
,
title
,
titles
);
}
public
void
showArrays
(
float
[][]
pixels
,
int
width
,
int
height
,
boolean
asStack
,
String
title
,
String
[]
titles
)
{
int
i
,
j
;
...
...
src/main/java/com/elphel/imagej/jp4/JP46_Reader_camera.java
View file @
3f9c52b0
...
...
@@ -1358,7 +1358,11 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
itr
=
set
.
iterator
();
while
(
itr
.
hasNext
())
{
str
=
(
String
)
itr
.
next
();
try
{
imp_dst
.
setProperty
(
str
,
prop
.
getProperty
(
str
));
}
catch
(
Exception
e
)
{
imp_dst
.
setProperty
(
str
,
""
);
}
}
}
}
...
...
@@ -1407,7 +1411,12 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
NodeList
allNodes
=
doc
.
getDocumentElement
().
getElementsByTagName
(
"*"
);
for
(
int
i
=
0
;
i
<
allNodes
.
getLength
();
i
++)
{
String
name
=
allNodes
.
item
(
i
).
getNodeName
();
String
value
=
allNodes
.
item
(
i
).
getFirstChild
().
getNodeValue
();
String
value
=
""
;
try
{
value
=
allNodes
.
item
(
i
).
getFirstChild
().
getNodeValue
();
}
catch
(
Exception
e
)
{
}
imp
.
setProperty
(
name
,
value
);
}
...
...
src/main/java/com/elphel/imagej/lwir/LwirReaderParameters.java
View file @
3f9c52b0
...
...
@@ -26,10 +26,15 @@
*/
package
com
.
elphel
.
imagej
.
lwir
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.util.Properties
;
import
com.elphel.imagej.common.GenericJTabbedDialog
;
import
ij.ImagePlus
;
import
ij.Prefs
;
public
class
LwirReaderParameters
{
private
boolean
parameters_updated
=
false
;
protected
int
avg_number
=
4
;
// number of measurements to average
...
...
@@ -49,6 +54,8 @@ public class LwirReaderParameters {
protected
double
vnir_gain_g
=
2.0
;
protected
double
vnir_gain_rg
=
0.7705
;
// 1.116; halogen/fluorescent
protected
double
vnir_gain_bg
=
2.401
;
// 1.476;
protected
boolean
[]
selected_channels
=
{
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
};
protected
int
max_lwir_width
=
1024
;
//
/*
protected double [] vnir_exp_corr = {1.0, 1.0, 1.0, 1.0};
...
...
@@ -73,11 +80,19 @@ public class LwirReaderParameters {
protected
int
debug_level
=
0
;
//-3: OFF, -2:Fatal, -1:ERROR, 0:WARN, 1:INFO,2:DEBUG
protected
boolean
show_images
=
false
;
// --- interface methods
public
boolean
is_LWIR
(
int
width
)
{
return
width
<=
max_lwir_width
;
}
public
boolean
is_LWIR
(
ImagePlus
imp
){
return
is_LWIR
(
imp
.
getWidth
());
}
public
int
getDebugLevel
()
{
return
this
.
debug_level
;
}
public
void
setDebugLevel
(
int
level
)
{
this
.
debug_level
=
level
;
}
...
...
@@ -110,9 +125,9 @@ public class LwirReaderParameters {
properties
.
setProperty
(
prefix
+
"max_mismatch_ms"
,
this
.
max_mismatch_ms
+
""
);
properties
.
setProperty
(
prefix
+
"max_frame_diff"
,
this
.
max_frame_diff
+
""
);
properties
.
setProperty
(
prefix
+
"debug_level"
,
this
.
debug_level
+
""
);
properties
.
setProperty
(
prefix
+
"selected_channels"
,
arr_to_str
(
this
.
selected_channels
));
properties
.
setProperty
(
prefix
+
"show_images"
,
this
.
show_images
+
""
);
}
public
void
getProperties
(
String
prefix
,
Properties
properties
){
...
...
@@ -140,8 +155,8 @@ public class LwirReaderParameters {
if
(
properties
.
getProperty
(
prefix
+
"max_mismatch_ms"
)!=
null
)
this
.
max_mismatch_ms
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"max_mismatch_ms"
));
if
(
properties
.
getProperty
(
prefix
+
"max_frame_diff"
)!=
null
)
this
.
max_frame_diff
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"max_frame_diff"
));
if
(
properties
.
getProperty
(
prefix
+
"debug_level"
)!=
null
)
this
.
debug_level
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"debug_level"
));
if
(
properties
.
getProperty
(
prefix
+
"selected_channels"
)!=
null
)
this
.
selected_channels
=
str_to_barr
(
properties
.
getProperty
(
prefix
+
"selected_channels"
));
if
(
properties
.
getProperty
(
prefix
+
"show_images"
)!=
null
)
this
.
show_images
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"show_images"
));
parameters_updated
=
true
;
}
@Override
...
...
@@ -171,6 +186,7 @@ public class LwirReaderParameters {
lrp
.
max_mismatch_ms
=
this
.
max_mismatch_ms
;
lrp
.
max_frame_diff
=
this
.
max_frame_diff
;
lrp
.
debug_level
=
this
.
debug_level
;
lrp
.
selected_channels
=
this
.
selected_channels
.
clone
();
lrp
.
show_images
=
this
.
show_images
;
return
lrp
;
}
...
...
@@ -208,6 +224,7 @@ public class LwirReaderParameters {
(
lrp
.
max_mismatch_ms
==
this
.
max_mismatch_ms
)
&&
(
lrp
.
max_frame_diff
==
this
.
max_frame_diff
)
&&
(
lrp
.
debug_level
==
this
.
debug_level
)
&&
(
java
.
util
.
Arrays
.
equals
(
lrp
.
selected_channels
,
this
.
selected_channels
))
&&
(
lrp
.
show_images
==
this
.
show_images
);
}
...
...
@@ -235,6 +252,7 @@ public class LwirReaderParameters {
result
=
prime
*
result
+
arr_to_str
(
vnir_exp_corr
).
hashCode
();
result
=
prime
*
result
+
arr_to_str
(
vnir_gcorr_rbgb
).
hashCode
();
result
=
prime
*
result
+
(
new
Integer
(
lwir_trig_dly
)).
hashCode
();
result
=
prime
*
result
+
arr_to_str
(
selected_channels
).
hashCode
();
// next are not needed to be programmed to the cameras
// result = prime * result + (new Integer(vnir_lag)).hashCode();
// result = prime * result + (new Double(max_mismatch_ms)).hashCode();
...
...
@@ -251,7 +269,7 @@ public class LwirReaderParameters {
gd
.
addStringField
(
"LWIR channels"
,
arr_to_str
(
this
.
lwir_channels
),
20
,
"Space-separated list of used LWIR camera channels, such as '0 1 2 3'"
);
gd
.
addStringField
(
"VNIR channels"
,
arr_to_str
(
this
.
vnir_channels
),
20
,
"Space-separated list of used visible range camera channels, such as '0 1 2 3'"
);
gd
.
addCheckbox
(
"LWIR telemetry"
,
this
.
lwir_telemetry
,
"Set LWIR sesnors to provide telemetry data in the last 2 lines (may become mandatory later)"
);
gd
.
addNumericField
(
"VNIR quality"
,
this
.
vnir_quality
,
3
,
6
,
"
ms
"
,
"Visible range camera JPEG compression quality (all channels)"
);
gd
.
addNumericField
(
"VNIR quality"
,
this
.
vnir_quality
,
3
,
6
,
"
%
"
,
"Visible range camera JPEG compression quality (all channels)"
);
gd
.
addCheckbox
(
"VNIR undo white balance"
,
this
.
vnir_scale
,
"Undo in-camera white balancing"
);
gd
.
addCheckbox
(
"VNIR autoexposure"
,
this
.
vnir_autoexp
,
"Enable autoexposure for the visible range camera"
);
gd
.
addNumericField
(
"VNIR vnir_max_autoexp_ms"
,
this
.
vnir_max_autoexp_ms
,
3
,
6
,
"ms"
,
"Visible range camera maximal exposure in autoexposure mode"
);
...
...
@@ -267,6 +285,7 @@ public class LwirReaderParameters {
gd
.
addNumericField
(
"Max mismatch"
,
this
.
max_mismatch_ms
,
3
,
6
,
"ms"
,
"Maximal mismatch between image timestamps. Larger mismatch requires LWIR sinsor reinitialization"
);
gd
.
addNumericField
(
"Max frame diff"
,
this
.
max_frame_diff
,
0
,
3
,
""
,
"Maximal difference in frames between simultaneously acquired channels as calculated from the timestamps"
);
gd
.
addNumericField
(
"Debug level"
,
this
.
debug_level
,
0
,
3
,
""
,
"Image acquisition log level: -3: OFF, -2:FATAL, -1:ERROR, 0:WARN, 1:INFO, 2:DEBUG"
);
gd
.
addStringField
(
"Selected channels"
,
arr_to_str
(
this
.
selected_channels
),
20
,
"Space-separated channel selection (1 - selected, 0 - unselected)"
);
gd
.
addCheckbox
(
"Show images"
,
this
.
show_images
,
"Show acquired images after averaging)"
);
}
...
...
@@ -295,8 +314,8 @@ public class LwirReaderParameters {
this
.
max_mismatch_ms
=
gd
.
getNextNumber
();
this
.
max_frame_diff
=
(
int
)
gd
.
getNextNumber
();
this
.
debug_level
=
(
int
)
gd
.
getNextNumber
();
this
.
selected_channels
=
str_to_barr
(
gd
.
getNextString
());
this
.
show_images
=
gd
.
getNextBoolean
();
parameters_updated
=
true
;
}
...
...
@@ -320,6 +339,80 @@ public class LwirReaderParameters {
parameters_updated
=
false
;
}
public
boolean
[]
getSelected
(){
return
selected_channels
;
}
public
boolean
[]
getSelectedLwir
(){
boolean
[]
sel
=
selected_channels
.
clone
();
for
(
int
i
=
lwir_channels
.
length
;
i
<
sel
.
length
;
i
++
)
{
sel
[
i
]
=
false
;
}
return
sel
;
}
public
boolean
[]
getSelectedVnir
(){
boolean
[]
sel
=
selected_channels
.
clone
();
for
(
int
i
=
0
;
i
<
lwir_channels
.
length
;
i
++
)
{
sel
[
i
]
=
false
;
}
return
sel
;
}
public
String
[]
getSourceFilesFlat
(
String
[]
sets
,
boolean
[]
channels
)
{
int
num_sel
=
0
;
for
(
boolean
s:
channels
)
if
(
s
)
num_sel
++;
String
[]
files
=
new
String
[
sets
.
length
*
num_sel
];
int
indx
=
0
;
for
(
String
set:
sets
)
{
for
(
int
i
=
0
;
i
<
channels
.
length
;
i
++)
if
(
channels
[
i
])
{
String
file_base
=
set
;
if
(
set
.
indexOf
(
Prefs
.
getFileSeparator
())
>=
0
)
{
file_base
=
set
.
substring
(
set
.
lastIndexOf
(
Prefs
.
getFileSeparator
())+
1
);
}
files
[
indx
++]
=
set
+
Prefs
.
getFileSeparator
()+
file_base
+
"_"
+
i
+
".tiff"
;
}
}
return
files
;
}
// Image set may have different timestamps, only lwir0 matches
public
String
[][]
getSourceFiles
(
String
[]
sets
,
boolean
[]
channels
)
{
String
[][]
files
=
new
String
[
sets
.
length
][
channels
.
length
];
for
(
int
nset
=
0
;
nset
<
sets
.
length
;
nset
++)
{
// read all files in the directory
File
set_dir
=
new
File
(
sets
[
nset
]);
File
[]
channel_files
=
set_dir
.
listFiles
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
current
,
String
name
)
{
if
(!(
new
File
(
current
,
name
).
isFile
())
||
!
name
.
endsWith
(
".tiff"
))
return
false
;
String
base
=
name
.
substring
(
0
,
name
.
lastIndexOf
(
".tiff"
));
int
undr
=
base
.
lastIndexOf
(
"_"
);
if
(
undr
<
0
)
return
false
;
int
chn
=
-
1
;
try
{
chn
=
Integer
.
parseInt
(
base
.
substring
(
undr
+
1
));
}
catch
(
Exception
e
)
{
}
return
chn
>=
0
;
}
});
for
(
File
f:
channel_files
)
{
String
base
=
f
.
getName
().
substring
(
0
,
f
.
getName
().
lastIndexOf
(
".tiff"
));
int
undr
=
base
.
lastIndexOf
(
"_"
);
int
chn
=
Integer
.
parseInt
(
base
.
substring
(
undr
+
1
));
if
((
chn
>=
0
)
&&
(
chn
<
channels
.
length
)
&&
channels
[
chn
])
{
files
[
nset
][
chn
]
=
f
.
getPath
();
}
}
}
return
files
;
}
// --- internal methods
private
String
arr_to_str
(
int
[]
arr
)
{
...
...
@@ -334,6 +427,23 @@ public class LwirReaderParameters {
return
s
.
trim
();
}
private
String
arr_to_str
(
boolean
[]
arr
)
{
String
s
=
""
;
for
(
boolean
c:
arr
)
s
+=
(
c
?
1
:
0
)+
" "
;
return
s
.
trim
();
}
private
boolean
[]
str_to_barr
(
String
s
)
{
int
[]
iarr
=
str_to_iarr
(
s
);
if
(
iarr
==
null
)
return
null
;
boolean
[]
barr
=
new
boolean
[
iarr
.
length
];
for
(
int
i
=
0
;
i
<
barr
.
length
;
i
++)
{
barr
[
i
]
=
iarr
[
i
]
!=
0
;
}
return
barr
;
}
private
int
[]
str_to_iarr
(
String
s
)
{
String
[]
sa
;
if
(
s
.
indexOf
(
","
)
>=
0
)
{
...
...
@@ -362,4 +472,22 @@ public class LwirReaderParameters {
return
darr
;
}
public
boolean
[]
selectSourceChannels
(){
return
selectSourceChannels
(
selected_channels
);
}
public
boolean
[]
selectSourceChannels
(
boolean
[]
sel
)
{
GenericJTabbedDialog
gd
=
new
GenericJTabbedDialog
(
"Set CLT parameters"
,
300
,
500
);
for
(
int
i
=
0
;
i
<
sel
.
length
;
i
++)
{
gd
.
addCheckbox
(
"Channel "
+
i
,
sel
[
i
],
"Enable processing camera channel "
+
i
);
}
gd
.
showDialog
();
if
(
gd
.
wasCanceled
())
return
null
;
for
(
int
i
=
0
;
i
<
sel
.
length
;
i
++)
{
sel
[
i
]
=
gd
.
getNextBoolean
();
}
return
sel
;
}
}
src/main/java/com/elphel/imagej/readers/EyesisTiff.java
View file @
3f9c52b0
...
...
@@ -640,7 +640,7 @@ the type of pixel data in this file getPixelType()
}
// copied from JP46_Reader_camera.java
public
ImagePlus
encodeProperiesToInfo
(
ImagePlus
imp
){
public
static
ImagePlus
encodeProperiesToInfo
(
ImagePlus
imp
){
String
info
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties>"
;
Set
<
Object
>
jp4_set
;
Properties
jp4_prop
;
...
...
@@ -661,7 +661,7 @@ the type of pixel data in this file getPixelType()
return
imp
;
}
public
boolean
decodeProperiesFromInfo
(
ImagePlus
imp
){
public
static
boolean
decodeProperiesFromInfo
(
ImagePlus
imp
){
if
(
imp
.
getProperty
(
"Info"
)==
null
)
return
false
;
String
xml
=
(
String
)
imp
.
getProperty
(
"Info"
);
...
...
@@ -684,11 +684,15 @@ the type of pixel data in this file getPixelType()
NodeList
allNodes
=
doc
.
getDocumentElement
().
getElementsByTagName
(
"*"
);
for
(
int
i
=
0
;
i
<
allNodes
.
getLength
();
i
++)
{
String
name
=
allNodes
.
item
(
i
).
getNodeName
();
String
value
=
allNodes
.
item
(
i
).
getFirstChild
().
getNodeValue
();
// System.out.print(name+" -> ");
String
value
=
""
;
try
{
value
=
allNodes
.
item
(
i
).
getFirstChild
().
getNodeValue
();
}
catch
(
Exception
e
)
{
}
// System.out.println(value);
imp
.
setProperty
(
name
,
value
);
}
return
true
;
}
...
...
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