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
96038858
Commit
96038858
authored
Jan 14, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed normalization of DCT kernels
parent
4ec177ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+5
-0
EyesisDCT.java
src/main/java/EyesisDCT.java
+28
-2
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
96038858
...
@@ -1798,6 +1798,7 @@ public class EyesisCorrectionParameters {
...
@@ -1798,6 +1798,7 @@ public class EyesisCorrectionParameters {
public
boolean
subtract_dc
=
false
;
//subtract/restore dc
public
boolean
subtract_dc
=
false
;
//subtract/restore dc
public
int
kernel_chn
=
-
1
;
// camera channel calibration to use for aberration correction ( < 0 - no correction)
public
int
kernel_chn
=
-
1
;
// camera channel calibration to use for aberration correction ( < 0 - no correction)
public
boolean
normalize
=
true
;
//normalize both sym and asym kernels (asym to have sum==1, sym to have sum = dct_size
public
boolean
normalize
=
true
;
//normalize both sym and asym kernels (asym to have sum==1, sym to have sum = dct_size
public
boolean
normalize_sym
=
true
;
//normalize sym kernels separately
public
boolean
skip_sym
=
false
;
// do not apply symmetrical correction
public
boolean
skip_sym
=
false
;
// do not apply symmetrical correction
public
boolean
convolve_direct
=
false
;
// do not apply symmetrical correction
public
boolean
convolve_direct
=
false
;
// do not apply symmetrical correction
...
@@ -1873,6 +1874,7 @@ public class EyesisCorrectionParameters {
...
@@ -1873,6 +1874,7 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"subtract_dc"
,
this
.
subtract_dc
+
""
);
properties
.
setProperty
(
prefix
+
"subtract_dc"
,
this
.
subtract_dc
+
""
);
properties
.
setProperty
(
prefix
+
"kernel_chn"
,
this
.
kernel_chn
+
""
);
properties
.
setProperty
(
prefix
+
"kernel_chn"
,
this
.
kernel_chn
+
""
);
properties
.
setProperty
(
prefix
+
"normalize"
,
this
.
normalize
+
""
);
properties
.
setProperty
(
prefix
+
"normalize"
,
this
.
normalize
+
""
);
properties
.
setProperty
(
prefix
+
"normalize_sym"
,
this
.
normalize_sym
+
""
);
properties
.
setProperty
(
prefix
+
"skip_sym"
,
this
.
skip_sym
+
""
);
properties
.
setProperty
(
prefix
+
"skip_sym"
,
this
.
skip_sym
+
""
);
properties
.
setProperty
(
prefix
+
"convolve_direct"
,
this
.
convolve_direct
+
""
);
properties
.
setProperty
(
prefix
+
"convolve_direct"
,
this
.
convolve_direct
+
""
);
properties
.
setProperty
(
prefix
+
"vignetting_max"
,
this
.
vignetting_max
+
""
);
properties
.
setProperty
(
prefix
+
"vignetting_max"
,
this
.
vignetting_max
+
""
);
...
@@ -1930,6 +1932,7 @@ public class EyesisCorrectionParameters {
...
@@ -1930,6 +1932,7 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"subtract_dc"
)!=
null
)
this
.
subtract_dc
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"subtract_dc"
));
if
(
properties
.
getProperty
(
prefix
+
"subtract_dc"
)!=
null
)
this
.
subtract_dc
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"subtract_dc"
));
if
(
properties
.
getProperty
(
prefix
+
"kernel_chn"
)!=
null
)
this
.
kernel_chn
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"kernel_chn"
));
if
(
properties
.
getProperty
(
prefix
+
"kernel_chn"
)!=
null
)
this
.
kernel_chn
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"kernel_chn"
));
if
(
properties
.
getProperty
(
prefix
+
"normalize"
)!=
null
)
this
.
normalize
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"normalize"
));
if
(
properties
.
getProperty
(
prefix
+
"normalize"
)!=
null
)
this
.
normalize
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"normalize"
));
if
(
properties
.
getProperty
(
prefix
+
"normalize_sym"
)!=
null
)
this
.
normalize_sym
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"normalize_sym"
));
if
(
properties
.
getProperty
(
prefix
+
"skip_sym"
)!=
null
)
this
.
skip_sym
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"skip_sym"
));
if
(
properties
.
getProperty
(
prefix
+
"skip_sym"
)!=
null
)
this
.
skip_sym
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"skip_sym"
));
if
(
properties
.
getProperty
(
prefix
+
"convolve_direct"
)!=
null
)
this
.
convolve_direct
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"convolve_direct"
));
if
(
properties
.
getProperty
(
prefix
+
"convolve_direct"
)!=
null
)
this
.
convolve_direct
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"convolve_direct"
));
if
(
properties
.
getProperty
(
prefix
+
"vignetting_max"
)!=
null
)
this
.
vignetting_max
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"vignetting_max"
));
if
(
properties
.
getProperty
(
prefix
+
"vignetting_max"
)!=
null
)
this
.
vignetting_max
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"vignetting_max"
));
...
@@ -1986,6 +1989,7 @@ public class EyesisCorrectionParameters {
...
@@ -1986,6 +1989,7 @@ public class EyesisCorrectionParameters {
gd
.
addCheckbox
(
"Subtract avarege before dct, restore after idct"
,
this
.
subtract_dc
);
gd
.
addCheckbox
(
"Subtract avarege before dct, restore after idct"
,
this
.
subtract_dc
);
gd
.
addNumericField
(
"Calibration channel to use for aberration ( <0 - no correction)"
,
this
.
kernel_chn
,
0
);
gd
.
addNumericField
(
"Calibration channel to use for aberration ( <0 - no correction)"
,
this
.
kernel_chn
,
0
);
gd
.
addCheckbox
(
"Normalize both sym and asym kernels "
,
this
.
normalize
);
gd
.
addCheckbox
(
"Normalize both sym and asym kernels "
,
this
.
normalize
);
gd
.
addCheckbox
(
"Normalize sym kernels separately"
,
this
.
normalize_sym
);
gd
.
addCheckbox
(
"Do not apply symmetrical (DCT) correction "
,
this
.
skip_sym
);
gd
.
addCheckbox
(
"Do not apply symmetrical (DCT) correction "
,
this
.
skip_sym
);
gd
.
addCheckbox
(
"Convolve directly with symmetrical kernel (debug feature) "
,
this
.
convolve_direct
);
gd
.
addCheckbox
(
"Convolve directly with symmetrical kernel (debug feature) "
,
this
.
convolve_direct
);
gd
.
addNumericField
(
"Value (max) in vignetting data to correspond to 1x in the kernel"
,
this
.
vignetting_max
,
3
);
gd
.
addNumericField
(
"Value (max) in vignetting data to correspond to 1x in the kernel"
,
this
.
vignetting_max
,
3
);
...
@@ -2042,6 +2046,7 @@ public class EyesisCorrectionParameters {
...
@@ -2042,6 +2046,7 @@ public class EyesisCorrectionParameters {
this
.
subtract_dc
=
gd
.
getNextBoolean
();
this
.
subtract_dc
=
gd
.
getNextBoolean
();
this
.
kernel_chn
=
(
int
)
gd
.
getNextNumber
();
this
.
kernel_chn
=
(
int
)
gd
.
getNextNumber
();
this
.
normalize
=
gd
.
getNextBoolean
();
this
.
normalize
=
gd
.
getNextBoolean
();
this
.
normalize_sym
=
gd
.
getNextBoolean
();
this
.
skip_sym
=
gd
.
getNextBoolean
();
this
.
skip_sym
=
gd
.
getNextBoolean
();
this
.
convolve_direct
=
gd
.
getNextBoolean
();
this
.
convolve_direct
=
gd
.
getNextBoolean
();
this
.
vignetting_max
=
gd
.
getNextNumber
();
this
.
vignetting_max
=
gd
.
getNextNumber
();
...
...
src/main/java/EyesisDCT.java
View file @
96038858
...
@@ -631,6 +631,8 @@ public class EyesisDCT {
...
@@ -631,6 +631,8 @@ public class EyesisDCT {
kernels
[
chn
]
=
null
;
kernels
[
chn
]
=
null
;
}
}
}
}
showDoubleFloatArrays
sdfa_instance
=
new
showDoubleFloatArrays
();
// just for debugging?
showDoubleFloatArrays
sdfa_instance
=
new
showDoubleFloatArrays
();
// just for debugging?
DttRad2
dtt
=
new
DttRad2
(
dct_parameters
.
dct_size
);
DttRad2
dtt
=
new
DttRad2
(
dct_parameters
.
dct_size
);
...
@@ -695,6 +697,16 @@ public class EyesisDCT {
...
@@ -695,6 +697,16 @@ public class EyesisDCT {
kernels
[
chn
].
asym_indx
=
new
int
[
nColors
][
numVert
][
numHor
][
asym_nonzero
];
kernels
[
chn
].
asym_indx
=
new
int
[
nColors
][
numVert
][
numHor
][
asym_nonzero
];
int
sym_kernel_inc_index
=
numHor
*
dct_size
;
int
sym_kernel_inc_index
=
numHor
*
dct_size
;
int
asym_kernel_inc_index
=
numHor
*
asym_size
;
int
asym_kernel_inc_index
=
numHor
*
asym_size
;
double
[]
norm_sym_weights
=
new
double
[
dct_size
*
dct_size
];
for
(
int
i
=
0
;
i
<
dct_size
;
i
++){
for
(
int
j
=
0
;
j
<
dct_size
;
j
++){
double
d
=
Math
.
cos
(
Math
.
PI
*
i
/(
2
*
dct_size
))*
Math
.
cos
(
Math
.
PI
*
j
/(
2
*
dct_size
));
if
(
i
>
0
)
d
*=
2.0
;
if
(
j
>
0
)
d
*=
2.0
;
norm_sym_weights
[
i
*
dct_size
+
j
]
=
d
;
}
}
if
(
debugLevel
>
0
)
{
if
(
debugLevel
>
0
)
{
System
.
out
.
println
(
"readDCTKernels() debugLevel = "
+
debugLevel
+
System
.
out
.
println
(
"readDCTKernels() debugLevel = "
+
debugLevel
+
" kernels["
+
chn
+
"].size = "
+
kernels
[
chn
].
size
+
" kernels["
+
chn
+
"].size = "
+
kernels
[
chn
].
size
+
...
@@ -771,8 +783,16 @@ public class EyesisDCT {
...
@@ -771,8 +783,16 @@ public class EyesisDCT {
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
][
i
]
*=
scale_asym
;
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
][
i
]
*=
scale_asym
;
}
}
}
}
if
(
dct_parameters
.
dbg_mode
==
0
){
// normalize sym kernel regardless of asym:
// +++++++++++++++++++++++++++++++++++++++++
if
(
dct_parameters
.
normalize_sym
){
// normalize sym kernel regardless of asym:
double
scale_sym
=
0.0
;
double
scale_sym
=
0.0
;
for
(
int
i
=
0
;
i
<
norm_sym_weights
.
length
;
i
++){
scale_sym
+=
norm_sym_weights
[
i
]*
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
][
i
];
}
/*
for (int i = 0; i< dct_size; i++){
for (int i = 0; i< dct_size; i++){
for (int j = 0; j< dct_size; j++){
for (int j = 0; j< dct_size; j++){
double d = kernels[chn].st_kernels[nc][tileY][tileX][i*dct_size+j];
double d = kernels[chn].st_kernels[nc][tileY][tileX][i*dct_size+j];
...
@@ -781,9 +801,14 @@ public class EyesisDCT {
...
@@ -781,9 +801,14 @@ public class EyesisDCT {
scale_sym +=d;
scale_sym +=d;
}
}
}
}
*/
for
(
int
i
=
0
;
i
<
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
].
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
].
length
;
i
++)
{
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
][
i
]
/=
scale_sym
;
kernels
[
chn
].
st_kernels
[
nc
][
tileY
][
tileX
][
i
]
/=
scale_sym
;
}
}
if
((
debugLevel
>
0
)
&&
(
tileY
==
dct_parameters
.
tileY
)
&&
(
tileX
==
dct_parameters
.
tileX
))
{
System
.
out
.
println
(
"chn="
+
chn
+
" tileY="
+
tileY
+
", tileX"
+
tileY
+
" scale_sym="
+
scale_sym
);
}
}
}
// Make a copy of direct kernels (debug feature, may be removed later)
// Make a copy of direct kernels (debug feature, may be removed later)
for
(
int
i
=
0
;
i
<
dct_size
;
i
++){
for
(
int
i
=
0
;
i
<
dct_size
;
i
++){
...
@@ -1660,7 +1685,8 @@ public class EyesisDCT {
...
@@ -1660,7 +1685,8 @@ public class EyesisDCT {
if
(
nonlin_max_y
!=
0
){
if
(
nonlin_max_y
!=
0
){
double
sum
=
0
;
double
sum
=
0
;
for
(
int
i
=
0
;
i
<
kern_y
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
kern_y
.
length
;
i
++){
sum
+=
Math
.
abs
(
kern_y
[
i
]);
// (i != 4) just increases denoise maximal value
if
(
i
!=
4
)
sum
+=
Math
.
abs
(
kern_y
[
i
]);
}
}
if
(
sum
>
nonlin_max_y
){
if
(
sum
>
nonlin_max_y
){
sum
=
nonlin_max_y
/
sum
;
sum
=
nonlin_max_y
/
sum
;
...
...
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