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
271830ae
Commit
271830ae
authored
Jan 13, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added saving dct kernel files
parent
46faeae7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
51 deletions
+69
-51
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+22
-22
EyesisDCT.java
src/main/java/EyesisDCT.java
+47
-29
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
271830ae
...
...
@@ -1767,36 +1767,36 @@ public class EyesisCorrectionParameters {
}
}
public
static
class
DCTParameters
{
public
int
dct_size
=
32
;
//
public
int
asym_size
=
6
;
//
public
int
asym_pixels
=
10
;
// maximal number of non-zero pixels in direct convolution kernel
public
int
asym_distance
=
2
;
// how far to try a new asym kernel pixel from existing ones
public
int
dct_size
=
8
;
//
public
int
asym_size
=
15
;
//
public
int
asym_pixels
=
4
;
// maximal number of non-zero pixels in direct convolution kernel
public
int
asym_distance
=
1
;
// how far to try a new asym kernel pixel from existing ones
public
int
dct_window
=
1
;
// currently only 3 types of windows - 0 (none), 1 and 2
public
int
LMA_steps
=
100
;
public
double
fact_precision
=
0.003
;
// stop iterations if error rms less than this part of target kernel rms
public
double
compactness
=
0.02
;
public
double
sym_compactness
=
0.01
;
public
double
dc_weight
=
10
;
// importance of dc realtive to rms_pure
public
int
asym_tax_free
=
5
;
// "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free
public
int
seed_size
=
8
;
// number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells)
public
double
asym_random
;
// initialize asym_kernel with random numbers
public
double
dbg_x
=
0
;
public
double
dbg_y
=
0
;
public
double
dbg_x1
=
0
;
public
double
dbg_y1
=
0
;
public
double
dbg_sigma
=
2.0
;
public
double
fact_precision
=
0.003
;
// stop iterations if error rms less than this part of target kernel rms
public
double
compactness
=
0.0
;
public
double
sym_compactness
=
0.5
;
public
double
dc_weight
=
1.0
;
// importance of dc realtive to rms_pure
public
int
asym_tax_free
=
0
;
// "compactness" does not apply to pixels with |x|<=asym_tax_free and |y| <= asym_tax_free
public
int
seed_size
=
1
;
// number of initial cells in asym_kernel - should be 4*b + 1 (X around center cell) or 4*n + 0 (X around between cells)
public
double
asym_random
=
-
1
;
// initialize asym_kernel with random numbers
public
double
dbg_x
=
2.7
;
public
double
dbg_y
=
0.
0
;
public
double
dbg_x1
=
-
1.3
;
public
double
dbg_y1
=
2.
0
;
public
double
dbg_sigma
=
0.8
;
public
String
dbg_mask
=
".........:::::::::.........:::::::::......*..:::::*:::.........:::::::::........."
;
public
int
dbg_mode
=
1
;
// 0 - old LMA, 1 - new LMA - *** not used anymore ***
public
int
dbg_window_mode
=
2
;
// 0 - none, 1 - square, 2 - sin 3 - sin^2
public
int
dbg_window_mode
=
1
;
// 0 - none, 1 - square, 2 - sin 3 - sin^2 Now _should_ be square !!!
public
boolean
centerWindowToTarget
=
true
;
// parameters to extract a kernel from the kernel image file
public
int
color_channel
=
2
;
// green (<0 - use simulated kernel, also will use simulated if kernels are not set)
public
int
decimation
=
2
;
// decimate original kernel this much in each direction
public
double
decimateSigma
=
0.4
;
// what is the optimal value for each decimation?
public
double
decimateSigma
=
-
1.0
;
// special mode for 2:1 deciamtion
public
int
tileX
=
82
;
// number of kernel tile (0..163)
public
int
tileY
=
62
;
// number of kernel tile (0..122)
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
skip_sym
=
false
;
// do not apply symmetrical correction
public
boolean
convolve_direct
=
false
;
// do not apply symmetrical correction
...
...
src/main/java/EyesisDCT.java
View file @
271830ae
...
...
@@ -29,6 +29,7 @@ import ij.IJ;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.Prefs
;
import
ij.io.FileSaver
;
import
ij.process.FloatProcessor
;
import
ij.process.ImageProcessor
;
...
...
@@ -107,31 +108,10 @@ public class EyesisDCT {
}
}
showDoubleFloatArrays
sdfa_instance
=
new
showDoubleFloatArrays
();
// just for debugging?
// String [] sensor_files = correctionsParameters.selectSensorFiles(eyesisCorrections.debugLevel);
for
(
int
chn
=
0
;
chn
<
eyesisCorrections
.
usedChannels
.
length
;
chn
++){
if
(
eyesisCorrections
.
usedChannels
[
chn
]
&&
(
sharpKernelPaths
[
chn
]!=
null
)
&&
(
kernels
[
chn
]==
null
)){
// if ((sensor_files!= null) && (sensor_files.length > chn) && (sensor_files[chn]!=null)){
/*
double [][] vignetting = null;
int vign_width = 0;
int vign_height = 0;
int vign_decimation = 1;
if ((pixelMapping != null) &&
(pixelMapping.sensors != null) &&
(pixelMapping.sensors[chn] != null) &&
(pixelMapping.sensors[chn].pixelCorrection != null) &&
(pixelMapping.sensors[chn].pixelCorrection.length >=6)){
vignetting = new double[3][];
vignetting[0] = pixelMapping.sensors[chn].pixelCorrection[3]; // red
vignetting[2] = pixelMapping.sensors[chn].pixelCorrection[4]; // green
vignetting[1] = pixelMapping.sensors[chn].pixelCorrection[5]; // blue
vign_width = pixelMapping.sensors[chn].pixelCorrectionWidth;
vign_height = pixelMapping.sensors[chn].pixelCorrectionHeight;
vign_decimation = pixelMapping.sensors[chn].pixelCorrectionDecimation;
}
*/
ImagePlus
imp_kernel_sharp
=
new
ImagePlus
(
sharpKernelPaths
[
chn
]);
if
(
imp_kernel_sharp
.
getStackSize
()<
3
)
{
System
.
out
.
println
(
"Need a 3-layer stack with kernels"
);
...
...
@@ -145,22 +125,60 @@ public class EyesisDCT {
kernel_sharp_stack
,
// final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
srcKernelSize
,
// final int kernelSize, // 64
dct_parameters
,
// final double blurSigma,
/*
vignetting,
vign_width,
vign_height,
vign_decimation,
*/
threadsMax
,
// maximal number of threads to launch
updateStatus
,
debugLevel
);
// update status info
int
sym_width
=
kernels
.
numHor
*
kernels
.
dct_size
;
int
sym_height
=
kernels
.
sym_kernels
[
0
].
length
/
sym_width
;
sdfa_instance
.
showArrays
(
kernels
.
sym_kernels
,
sym_width
,
sym_height
,
true
,
imp_kernel_sharp
.
getTitle
()+
"-sym"
);
// save files
String
[]
symNames
=
{
"red_sym"
,
"blue_sym"
,
"green_sym"
};
String
[]
asymNames
=
{
"red_asym"
,
"blue_asym"
,
"green_asym"
};
ImageStack
symStack
=
sdfa_instance
.
makeStack
(
kernels
.
sym_kernels
,
sym_width
,
sym_height
,
symNames
);
String
symPath
=
correctionsParameters
.
dctKernelDirectory
+
Prefs
.
getFileSeparator
()+
correctionsParameters
.
dctKernelPrefix
+
String
.
format
(
"%02d"
,
chn
)+
correctionsParameters
.
dctSymSuffix
;
String
msg
=
"Saving symmetrical convolution kernels to "
+
symPath
;
IJ
.
showStatus
(
msg
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
msg
);
ImagePlus
imp_sym
=
new
ImagePlus
(
imp_kernel_sharp
.
getTitle
()+
"-sym"
,
symStack
);
if
(
debugLevel
>
1
)
{
imp_sym
.
getProcessor
().
resetMinAndMax
();
imp_sym
.
show
();
}
FileSaver
fs
=
new
FileSaver
(
imp_sym
);
fs
.
saveAsTiffStack
(
symPath
);
// sdfa_instance.showArrays(kernels.sym_kernels, sym_width, sym_height, true, imp_kernel_sharp.getTitle()+"-sym");
int
asym_width
=
kernels
.
numHor
*
kernels
.
asym_size
;
int
asym_height
=
kernels
.
asym_kernels
[
0
].
length
/
asym_width
;
sdfa_instance
.
showArrays
(
kernels
.
asym_kernels
,
asym_width
,
asym_height
,
true
,
imp_kernel_sharp
.
getTitle
()+
"-asym"
);
ImageStack
asymStack
=
sdfa_instance
.
makeStack
(
kernels
.
asym_kernels
,
asym_width
,
asym_height
,
asymNames
);
String
asymPath
=
correctionsParameters
.
dctKernelDirectory
+
Prefs
.
getFileSeparator
()+
correctionsParameters
.
dctKernelPrefix
+
String
.
format
(
"%02d"
,
chn
)+
correctionsParameters
.
dctAsymSuffix
;
msg
=
"Saving asymmetrical convolution kernels "
+
asymPath
;
IJ
.
showStatus
(
msg
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
msg
);
ImagePlus
imp_asym
=
new
ImagePlus
(
imp_kernel_sharp
.
getTitle
()+
"-asym"
,
asymStack
);
if
(
debugLevel
>
1
)
{
imp_asym
.
getProcessor
().
resetMinAndMax
();
imp_asym
.
show
();
}
fs
=
new
FileSaver
(
imp_asym
);
fs
.
saveAsTiffStack
(
asymPath
);
// sdfa_instance.showArrays(kernels.asym_kernels, asym_width, asym_height, true, imp_kernel_sharp.getTitle()+"-asym");
}
}
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