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
2e50bfb7
Commit
2e50bfb7
authored
Feb 08, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converting kernels
parent
4ca23a78
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
962 additions
and
130 deletions
+962
-130
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+109
-5
EyesisDCT.java
src/main/java/EyesisDCT.java
+644
-102
Eyesis_Correction.java
src/main/java/Eyesis_Correction.java
+101
-22
ImageDtt.java
src/main/java/ImageDtt.java
+108
-1
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
2e50bfb7
This diff is collapsed.
Click to expand it.
src/main/java/EyesisDCT.java
View file @
2e50bfb7
This diff is collapsed.
Click to expand it.
src/main/java/Eyesis_Correction.java
View file @
2e50bfb7
...
@@ -490,9 +490,10 @@ private Panel panel1,
...
@@ -490,9 +490,10 @@ private Panel panel1,
addButton
(
"CLT stack"
,
panelClt1
,
color_process
);
addButton
(
"CLT stack"
,
panelClt1
,
color_process
);
addButton
(
"Select second CLT image"
,
panelClt1
,
color_configure
);
addButton
(
"Select second CLT image"
,
panelClt1
,
color_configure
);
addButton
(
"CLT correlate"
,
panelClt1
,
color_process
);
addButton
(
"CLT correlate"
,
panelClt1
,
color_process
);
addButton
(
"CLT test 2"
,
panelClt1
,
color_process
);
addButton
(
"Create CLT kernels"
,
panelClt1
,
color_process
);
addButton
(
"CLT test 3"
,
panelClt1
,
color_process
);
addButton
(
"Read CLT kernels"
,
panelClt1
,
color_process
);
addButton
(
"CLT test 4"
,
panelClt1
,
color_process
);
addButton
(
"Reset CLT kernels"
,
panelClt1
,
color_stop
);
addButton
(
"CLT process files"
,
panelClt1
,
color_process
);
add
(
panelClt1
);
add
(
panelClt1
);
}
}
pack
();
pack
();
...
@@ -4044,29 +4045,107 @@ private Panel panel1,
...
@@ -4044,29 +4045,107 @@ private Panel panel1,
DBG_IMP
.
getTitle
()+
"-C"
+
suffix
,
titles_rbg
);
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"
double [][] iclt_data = new double [clt_data.length][];
}
else
if
(
label
.
equals
(
"Reset CLT kernels"
))
{
for (int chn=0; chn<iclt_data.length;chn++){
if
(
EYESIS_DCT
!=
null
){
iclt_data[chn] = image_dtt.iclt_2d(
EYESIS_DCT
.
resetCLTKernels
();
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)
}
}
SDFA_INSTANCE.showArrays(
}
else
if
(
label
.
equals
(
"Read CLT kernels"
))
{
iclt_data,
if
(!
CLT_PARAMETERS
.
showDialog
())
return
;
(tilesX + 1) * CLT_PARAMETERS.transform_size,
if
(
EYESIS_DCT
==
null
){
(tilesY + 1) * CLT_PARAMETERS.transform_size,
EYESIS_DCT
=
new
EyesisDCT
(
true,
EYESIS_CORRECTIONS
,
DBG_IMP.getTitle()+"-ICLT-"+CLT_PARAMETERS.iclt_mask);
CORRECTION_PARAMETERS
,
*/
DCT_PARAMETERS
);
return
;
}
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
;
// End of buttons code
// End of buttons code
}
}
...
...
src/main/java/ImageDtt.java
View file @
2e50bfb7
...
@@ -929,7 +929,7 @@ public class ImageDtt {
...
@@ -929,7 +929,7 @@ public class ImageDtt {
System
.
out
.
println
(
"clt_shift():tilesX= "
+
tilesX
);
System
.
out
.
println
(
"clt_shift():tilesX= "
+
tilesX
);
System
.
out
.
println
(
"clt_shift():tilesY= "
+
tilesY
);
System
.
out
.
println
(
"clt_shift():tilesY= "
+
tilesY
);
}
}
/*
/*
Direct matrix Z1: X2 ~= Z1 * Shift
* {{+cc -sc -cs +ss},
* {{+cc -sc -cs +ss},
* {+sc +cc -ss -cs},
* {+sc +cc -ss -cs},
* {+cs -ss +cc -sc},
* {+cs -ss +cc -sc},
...
@@ -1328,6 +1328,113 @@ public class ImageDtt {
...
@@ -1328,6 +1328,113 @@ public class ImageDtt {
startAndJoin
(
threads
);
startAndJoin
(
threads
);
return
dct_data_out
;
return
dct_data_out
;
}
}
void
clt_convert_double_kernel
(
// converts double resolution kernel
double
[]
src_kernel
,
//
double
[]
dst_kernel
,
// should be (2*dtt_size-1) * (2*dtt_size-1) +2 size - kernel and dx, dy to the nearest 1/2 pixels
int
src_size
,
// 64
int
dtt_size
)
// 8
{
int
[]
indices
=
{
0
,-
src_size
,-
1
,
1
,
src_size
,-
src_size
-
1
,-
src_size
+
1
,
src_size
-
1
,
src_size
+
1
};
double
[]
weights
=
{
0.25
,
0.125
,
0.125
,
0.125
,
0.125
,
0.0625
,
0.0625
,
0.0625
,
0.0625
};
int
src_center
=
src_size
/
2
;
// 32
// Find center
double
sx
=
0.0
,
sy
=
0.0
,
s
=
0.0
;
int
indx
=
0
;
for
(
int
i
=
-
src_center
;
i
<
src_center
;
i
++){
for
(
int
j
=
-
src_center
;
j
<
src_center
;
j
++){
double
d
=
src_kernel
[
indx
++];
sx
+=
j
*
d
;
sy
+=
i
*
d
;
s
+=
d
;
}
}
int
src_x
=
(
int
)
Math
.
round
(
sx
/
s
)
+
src_center
;
int
src_y
=
(
int
)
Math
.
round
(
sy
/
s
)
+
src_center
;
// make sure selected area (2*dst_size-1) * (2*dst_size-1) fits into src_kernel, move center if not
if
(
src_x
<
2
*
dtt_size
)
src_x
=
2
*
dtt_size
-
1
;
// 15
else
if
(
src_x
>
(
src_size
-
2
*
dtt_size
))
src_x
=
src_size
-
2
*
dtt_size
;
if
(
src_y
<
2
*
dtt_size
)
src_y
=
2
*
dtt_size
-
1
;
// 15
else
if
(
src_y
>
(
src_size
-
2
*
dtt_size
))
src_y
=
src_size
-
2
*
dtt_size
;
indx
=
0
;
// downscale, copy
for
(
int
i
=
-
dtt_size
+
1
;
i
<
dtt_size
;
i
++){
int
src_i
=
(
src_y
+
2
*
i
)
*
src_size
+
src_x
;
for
(
int
j
=
-
dtt_size
+
1
;
j
<
dtt_size
;
j
++){
double
d
=
0.0
;
for
(
int
k
=
0
;
k
<
indices
.
length
;
k
++){
d
+=
weights
[
k
]*
src_kernel
[
src_i
+
2
*
j
+
indices
[
k
]];
}
dst_kernel
[
indx
++]
=
d
;
}
}
dst_kernel
[
indx
++]
=
0.5
*(
src_x
-
src_center
);
dst_kernel
[
indx
++]
=
0.5
*(
src_y
-
src_center
);
}
void
clt_normalize_kernel
(
//
double
[]
kernel
,
// should be (2*dtt_size-1) * (2*dtt_size-1) +2 size (last 2 are not modified)
double
[]
window
,
// normalizes result kernel * window to have sum of elements == 1.0
final
int
dtt_size
)
// 8
{
double
s
=
0.0
;
int
indx
=
0
;
for
(
int
i
=
-
dtt_size
+
1
;
i
<
dtt_size
;
i
++){
int
ai
=
(
i
<
0
)?
-
i:
i
;
for
(
int
j
=
-
dtt_size
+
1
;
j
<
dtt_size
;
j
++){
int
aj
=
(
j
<
0
)?
-
j:
j
;
s
+=
kernel
[
indx
++]
*
window
[
ai
*
dtt_size
+
aj
];
}
}
s
=
1.0
/
s
;
indx
=
0
;
for
(
int
i
=
0
;
i
<
(
dtt_size
*
dtt_size
);
i
++)
{
kernel
[
indx
++]
*=
s
;
}
}
void
clt_symmetrize_kernel
(
//
double
[]
kernel
,
// should be (2*dtt_size-1) * (2*dtt_size-1) +2 size (last 2 are not modified)
double
[][]
sym_kernels
,
// set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift
final
int
dtt_size
)
// 8
{
int
in_size
=
2
*
dtt_size
-
1
;
int
dtt_size_m1
=
dtt_size
-
1
;
int
center
=
dtt_size_m1
*
in_size
+
dtt_size_m1
;
for
(
int
i
=
0
;
i
<
dtt_size
;
i
++){
for
(
int
j
=
0
;
j
<
dtt_size
;
j
++){
int
indx0
=
center
-
i
*
in_size
-
j
;
int
indx1
=
center
-
i
*
in_size
+
j
;
int
indx2
=
center
+
i
*
in_size
-
j
;
int
indx3
=
center
+
i
*
in_size
+
j
;
sym_kernels
[
0
][
i
*
dtt_size
+
j
]
=
0.25
*(
kernel
[
indx0
]
+
kernel
[
indx1
]
+
kernel
[
indx2
]
+
kernel
[
indx3
]);
if
(
j
>
0
)
sym_kernels
[
1
][
i
*
dtt_size
+
j
-
1
]
=
0.25
*(-
kernel
[
indx0
]
+
kernel
[
indx1
]
-
kernel
[
indx2
]
+
kernel
[
indx3
]);
if
(
i
>
0
)
sym_kernels
[
2
][(
i
-
1
)*
dtt_size
+
j
]
=
0.25
*(-
kernel
[
indx0
]
-
kernel
[
indx1
]
+
kernel
[
indx2
]
+
kernel
[
indx3
]);
if
((
i
>
0
)
&&
(
j
>
0
))
sym_kernels
[
3
][
i
*
dtt_size
+
j
]
=
0.25
*(-
kernel
[
indx0
]
+
kernel
[
indx1
]
-
kernel
[
indx2
]
+
kernel
[
indx3
]);
}
sym_kernels
[
1
][
i
*
dtt_size
+
dtt_size_m1
]
=
0.0
;
sym_kernels
[
2
][
dtt_size_m1
*
dtt_size
+
i
]
=
0.0
;
sym_kernels
[
3
][
i
*
dtt_size
+
dtt_size_m1
]
=
0.0
;
sym_kernels
[
3
][
dtt_size_m1
*
dtt_size
+
i
]
=
0.0
;
}
}
void
clt_dtt3_kernel
(
//
double
[][]
kernels
,
// set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift
final
int
dtt_size
,
// 8
DttRad2
dtt
)
{
if
(
dtt
==
null
)
dtt
=
new
DttRad2
(
dtt_size
);
for
(
int
quad
=
0
;
quad
<
4
;
quad
++){
kernels
[
quad
]
=
dtt
.
dttt_iiie
(
kernels
[
quad
],
quad
,
dtt_size
);
}
}
public
double
[][][][]
mdctScale
(
public
double
[][][][]
mdctScale
(
final
ImageStack
imageStack
,
final
ImageStack
imageStack
,
...
...
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