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
632eb62e
Commit
632eb62e
authored
May 23, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set default directory, averaging to multithreaded
parent
50de1233
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
41 deletions
+104
-41
Aberration_Calibration.java
...com/elphel/imagej/calibration/Aberration_Calibration.java
+19
-17
Eyesis_Correction.java
.../java/com/elphel/imagej/correction/Eyesis_Correction.java
+18
-16
LwirReader.java
src/main/java/com/elphel/imagej/lwir/LwirReader.java
+50
-7
LwirReaderParameters.java
...ain/java/com/elphel/imagej/lwir/LwirReaderParameters.java
+17
-1
No files found.
src/main/java/com/elphel/imagej/calibration/Aberration_Calibration.java
View file @
632eb62e
...
...
@@ -1102,10 +1102,10 @@ if (MORE_BUTTONS) {
Runtime runtime = Runtime.getRuntime();
runtime.gc();
if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
if (label==null) return;
if (LWIR_PARAMETERS !=null) {
String LOG_LEVEL;
switch (MASTER_DEBUG_LEVEL
) {
switch (LWIR_PARAMETERS.getDebugLevel()
) {
case -2: LOG_LEVEL = "FATAL"; break;
case -1: LOG_LEVEL = "ERROR"; break;
case 0: LOG_LEVEL = "WARN"; break;
...
...
@@ -1118,8 +1118,9 @@ if (MORE_BUTTONS) {
if (!LOG_LEVEL_SET) { // only first time true
loci.common.DebugTools.setRootLevel(LOG_LEVEL);
}
System.out.println("DEBUG_LEVEL = "+DEBUG_LEVEL+", MASTER_DEBUG_LEVEL = "+MASTER_DEBUG_LEVEL
+
System.out.println("DEBUG_LEVEL = "+DEBUG_LEVEL+", LWIR_PARAMETERS.getDebugLevel() = "+LWIR_PARAMETERS.getDebugLevel()
+
" LOG_LEVEL="+LOG_LEVEL+"LOG_LEVEL_SET="+LOG_LEVEL_SET);
}
if (FOCUSING_FIELD!=null) FOCUSING_FIELD.setThreads(THREADS_MAX);
/* ======================================================================== */
...
...
@@ -9441,7 +9442,8 @@ if (MORE_BUTTONS) {
if (LWIR_READER == null) {
LWIR_READER = new LwirReader(LWIR_PARAMETERS);
}
ImagePlus [] imps = LWIR_READER.acquire("/data_ssd/imagej-elphel/attic/camera_img/test-calib"); // directory to save
// ImagePlus [] imps = LWIR_READER.acquire(DISTORTION_PROCESS_CONFIGURATION.sourceDirectory); // directory to save
ImagePlus [] imps = LWIR_READER.acquire("attic/lwir_test_images"); // directory to save
if (imps != null) {
// for (ImagePlus imp: imps) {
// imp.show();
src/main/java/com/elphel/imagej/correction/Eyesis_Correction.java
View file @
632eb62e
...
...
@@ -897,8 +897,9 @@ private Panel panel1,
if
(
DEBUG_LEVEL
>
0
)
System
.
out
.
println
(
"--- Free memory="
+
runtime
.
freeMemory
()+
" (of "
+
runtime
.
totalMemory
()+
")"
);
CLT_PARAMETERS
.
batch_run
=
false
;
if
(
label
==
null
)
return
;
if
((
CLT_PARAMETERS
!=
null
)
&&
(
CLT_PARAMETERS
.
lwir
!=
null
))
{
String
LOG_LEVEL
;
switch
(
MASTER_DEBUG_LEVEL
)
{
switch
(
CLT_PARAMETERS
.
lwir
.
getDebugLevel
()
)
{
case
-
2
:
LOG_LEVEL
=
"FATAL"
;
break
;
case
-
1
:
LOG_LEVEL
=
"ERROR"
;
break
;
case
0
:
LOG_LEVEL
=
"WARN"
;
break
;
...
...
@@ -911,8 +912,9 @@ private Panel panel1,
if
(!
LOG_LEVEL_SET
)
{
// only first time true
loci
.
common
.
DebugTools
.
setRootLevel
(
LOG_LEVEL
);
}
System
.
out
.
println
(
"DEBUG_LEVEL = "
+
DEBUG_LEVEL
+
", MASTER_DEBUG_LEVEL = "
+
MASTER_DEBUG_LEVEL
+
System
.
out
.
println
(
"DEBUG_LEVEL = "
+
DEBUG_LEVEL
+
", CLT_PARAMETERS.lwir.getDebugLevel() = "
+
CLT_PARAMETERS
.
lwir
.
getDebugLevel
()
+
" LOG_LEVEL="
+
LOG_LEVEL
+
"LOG_LEVEL_SET="
+
LOG_LEVEL_SET
);
}
/* ======================================================================== */
if
(
label
.
equals
(
"Configure spilt"
))
{
...
...
@@ -4873,7 +4875,7 @@ private Panel panel1,
if
(
LWIR_READER
==
null
)
{
LWIR_READER
=
new
LwirReader
(
CLT_PARAMETERS
.
lwir
);
}
ImagePlus
[]
imps
=
LWIR_READER
.
acquire
(
"
/data_ssd/imagej-elphel/attic/camera_img/test
"
);
// directory to save
ImagePlus
[]
imps
=
LWIR_READER
.
acquire
(
"
attic/lwir_test_images
"
);
// directory to save
if
(
imps
!=
null
)
{
for
(
ImagePlus
imp:
imps
)
{
// imp.show();
...
...
src/main/java/com/elphel/imagej/lwir/LwirReader.java
View file @
632eb62e
...
...
@@ -208,12 +208,54 @@ public class LwirReader {
return
imps
;
}
public
ImagePlus
[]
averageMultiFrames
(
ImagePlus
[][]
sets
)
{
//TODO: convert to multithreaded !
int
num_frames
=
sets
.
length
;
int
num_channels
=
sets
[
0
].
length
;
ImagePlus
[]
imps_avg
=
new
ImagePlus
[
num_channels
];
public
ImagePlus
[]
averageMultiFrames
(
final
ImagePlus
[][]
sets
)
{
final
int
num_frames
=
sets
.
length
;
final
int
num_channels
=
sets
[
0
].
length
;
final
ImagePlus
[]
imps_avg
=
new
ImagePlus
[
num_channels
];
final
Thread
[]
threads
=
newThreadArray
(
MAX_THREADS
);
final
AtomicInteger
indxAtomic
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
@Override
public
void
run
()
{
for
(
int
chn
=
indxAtomic
.
getAndIncrement
();
chn
<
num_channels
;
chn
=
indxAtomic
.
getAndIncrement
())
{
int
width
=
sets
[
0
][
chn
].
getWidth
();
int
height
=
sets
[
0
][
chn
].
getHeight
();
String
title
=
sets
[
0
][
chn
].
getTitle
()+
"_average"
+
num_frames
;
float
[]
pixels_avg
=
(
float
[])
sets
[
0
][
chn
].
getProcessor
().
getPixels
();
//null pointer
for
(
int
n
=
1
;
n
<
num_frames
;
n
++)
{
float
[]
pixels
=
(
float
[])
sets
[
n
][
chn
].
getProcessor
().
getPixels
();
for
(
int
i
=
0
;
i
<
pixels_avg
.
length
;
i
++)
{
pixels_avg
[
i
]
+=
pixels
[
i
];
}
}
double
scale
=
1.0
/
num_frames
;
for
(
int
i
=
0
;
i
<
pixels_avg
.
length
;
i
++)
{
pixels_avg
[
i
]
*=
scale
;
}
ImageProcessor
ip
=
new
FloatProcessor
(
width
,
height
);
ip
.
setPixels
(
pixels_avg
);
ip
.
resetMinAndMax
();
imps_avg
[
chn
]=
new
ImagePlus
(
title
,
ip
);
Properties
properties0
=
sets
[
0
][
chn
].
getProperties
();
for
(
String
key:
properties0
.
stringPropertyNames
())
{
imps_avg
[
chn
].
setProperty
(
key
,
properties0
.
getProperty
(
key
));
}
imps_avg
[
chn
].
setProperty
(
"average"
,
""
+
num_frames
);
if
(
motorsPosition
!=
null
)
for
(
int
m
=
0
;
m
<
motorsPosition
.
length
;
m
++
)
{
imps_avg
[
chn
].
setProperty
(
"MOTOR"
+(
m
+
1
),
""
+
motorsPosition
[
m
]);
}
ImagejJp4Tiff
.
encodeProperiesToInfo
(
imps_avg
[
chn
]);
}
}
};
}
startAndJoin
(
threads
);
/*
for (int chn = 0; chn < num_channels; chn++) {
int width = sets[0][chn].getWidth();
int height = sets[0][chn].getHeight();
...
...
@@ -244,7 +286,7 @@ public class LwirReader {
ImagejJp4Tiff.encodeProperiesToInfo(imps_avg[chn]);
// TODO: Overwrite some properties?
}
*/
return
imps_avg
;
}
...
...
@@ -513,13 +555,14 @@ public class LwirReader {
String
set_path
=
dirpath
+
Prefs
.
getFileSeparator
()+
set_name
;
File
set_dir
=
new
File
(
set_path
);
set_dir
.
mkdirs
();
// including parent
LOGGER
.
warn
(
"Saving image set to: "
+
set_dir
.
getAbsolutePath
());
for
(
ImagePlus
imp:
imps_avg
)
{
String
fname
=
imp
.
getTitle
();
fname
=
fname
.
substring
(
0
,
fname
.
lastIndexOf
(
'_'
))
+
".tiff"
;
// remove _average
FileSaver
fs
=
new
FileSaver
(
imp
);
String
path
=
set_path
+
Prefs
.
getFileSeparator
()+
fname
;
IJ
.
showStatus
(
"Saving "
+
path
);
LOGGER
.
debug
(
"LWIR_ACQUIRE: 'Saving "
+
path
+
" (and other with the same timestamp)"
);
LOGGER
.
info
(
"LWIR_ACQUIRE: 'Saving "
+
path
);
fs
.
saveAsTiff
(
path
);
}
}
...
...
src/main/java/com/elphel/imagej/lwir/LwirReaderParameters.java
View file @
632eb62e
...
...
@@ -49,6 +49,7 @@ 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 double [] vnir_exp_corr = {1.0, 1.0, 1.0, 1.0};
protected double [] vnir_gcorr_rbgb = {
...
...
@@ -69,9 +70,17 @@ public class LwirReaderParameters {
protected
int
vnir_lag
=
1
;
// frames
protected
double
max_mismatch_ms
=
0.05
;
protected
int
max_frame_diff
=
1
;
// 2;
protected
int
debug_level
=
0
;
//-3: OFF, -2:Fatal, -1:ERROR, 0:WARN, 1:INFO,2:DEBUG
// --- interface methods
public
int
getDebugLevel
()
{
return
this
.
debug_level
;
}
public
void
setDebugLevel
(
int
level
)
{
this
.
debug_level
=
level
;
}
public
void
setProperties
(
String
prefix
,
Properties
properties
){
properties
.
setProperty
(
prefix
+
"avg_number"
,
this
.
avg_number
+
""
);
properties
.
setProperty
(
prefix
+
"lwir_ffc"
,
this
.
lwir_ffc
+
""
);
...
...
@@ -96,6 +105,8 @@ public class LwirReaderParameters {
properties
.
setProperty
(
prefix
+
"vnir_lag"
,
this
.
vnir_lag
+
""
);
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
+
""
);
}
public
void
getProperties
(
String
prefix
,
Properties
properties
){
...
...
@@ -122,6 +133,7 @@ public class LwirReaderParameters {
if
(
properties
.
getProperty
(
prefix
+
"vnir_lag"
)!=
null
)
this
.
vnir_lag
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"vnir_lag"
));
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"
));
parameters_updated
=
true
;
}
@Override
...
...
@@ -150,6 +162,7 @@ public class LwirReaderParameters {
lrp
.
vnir_lag
=
this
.
vnir_lag
;
lrp
.
max_mismatch_ms
=
this
.
max_mismatch_ms
;
lrp
.
max_frame_diff
=
this
.
max_frame_diff
;
lrp
.
debug_level
=
this
.
debug_level
;
return
lrp
;
}
...
...
@@ -184,7 +197,8 @@ public class LwirReaderParameters {
(
lrp
.
lwir_trig_dly
==
this
.
lwir_trig_dly
)
&&
(
lrp
.
vnir_lag
==
this
.
vnir_lag
)
&&
(
lrp
.
max_mismatch_ms
==
this
.
max_mismatch_ms
)
&&
(
lrp
.
max_frame_diff
==
this
.
max_frame_diff
);
(
lrp
.
max_frame_diff
==
this
.
max_frame_diff
)
&&
(
lrp
.
debug_level
==
this
.
debug_level
);
}
@Override
...
...
@@ -242,6 +256,7 @@ public class LwirReaderParameters {
gd
.
addNumericField
(
"VNIR lag"
,
this
.
vnir_lag
,
0
,
3
,
""
,
"Visible camera lag (in frames) relative to LWIR one"
);
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"
);
}
public
void
dialogAnswers
(
GenericJTabbedDialog
gd
)
{
...
...
@@ -268,6 +283,7 @@ public class LwirReaderParameters {
this
.
vnir_lag
=
(
int
)
gd
.
getNextNumber
();
this
.
max_mismatch_ms
=
gd
.
getNextNumber
();
this
.
max_frame_diff
=
(
int
)
gd
.
getNextNumber
();
this
.
debug_level
=
(
int
)
gd
.
getNextNumber
();
parameters_updated
=
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