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
3fd21c81
Commit
3fd21c81
authored
Jun 18, 2021
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing bugs for variable images per set (e.g. eo only)
parent
9c63f90b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
270 additions
and
72 deletions
+270
-72
Aberration_Calibration.java
...com/elphel/imagej/calibration/Aberration_Calibration.java
+141
-24
DistortionCalibrationData.java
.../elphel/imagej/calibration/DistortionCalibrationData.java
+74
-24
Distortions.java
src/main/java/com/elphel/imagej/calibration/Distortions.java
+40
-20
FittingStrategy.java
...n/java/com/elphel/imagej/calibration/FittingStrategy.java
+5
-2
LwirReaderParameters.java
...ain/java/com/elphel/imagej/lwir/LwirReaderParameters.java
+10
-2
No files found.
src/main/java/com/elphel/imagej/calibration/Aberration_Calibration.java
View file @
3fd21c81
...
...
@@ -615,6 +615,12 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
public static double [][][][] PSF_KERNEL_MAP=null; // remove?
public static String [] COMPONENT_COLOR_NAMES={"green1","red","blue","green2", "greens (diagonal)", "greens (checker)"};
public static String [] STACK_COLOR_NAMES={"red","green","blue"};
// last used values for dialogs to suggest next time
public int LASTUSED_RECALIB_SET = -1;
public int LASTUSED_RECALIB_CHN = -1;
public int LASTUSED_MAN_HINT = -1;
/**
* DIST_ARRAY:
* [v][u][0][0] - pixel x of the grid node u,v
...
...
@@ -9379,12 +9385,12 @@ if (MORE_BUTTONS) {
}
LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL;
GenericDialog gd=new GenericDialog("Select grid image to add manual hint");
gd.addNumericField("Grid Image index",
0
,0);
gd.addNumericField("Grid Image index",
LASTUSED_MAN_HINT
,0);
gd.showDialog();
if (gd.wasCanceled()) return;
int numGridImage= (int) gd.getNextNumber();
LASTUSED_MAN_HINT = numGridImage;
LENS_DISTORTIONS.manualGridHint(numGridImage);
return;
}
...
...
@@ -9552,13 +9558,32 @@ if (MORE_BUTTONS) {
public boolean recalibrateSet() {
int imageSetNumber = LASTUSED_RECALIB_SET;
int sel_chn = LASTUSED_RECALIB_CHN;
boolean reEstimate= true;
boolean use_eo = true;
boolean use_lwir = true;
// double grid_mismatch = 0.1;
GenericDialog gd=new GenericDialog ("Select image set to re-calibrate");
gd.addNumericField("Image set number", 0, 0);
gd.addCheckbox ("Set image set parameters from closest, (re-)estimate orientation", true);
gd.addNumericField("Image set number", imageSetNumber, 0);
gd.addCheckbox ("Set image set parameters from closest, (re-)estimate orientation", reEstimate);
gd.addCheckbox ("Use RGB grids for matching", use_eo);
gd.addCheckbox ("Use LWIR grids for matching", use_lwir);
gd.addNumericField("Use single channel (<0 - use all unfiltered)", sel_chn, 0);
// TODO: distribute results to unselected images
// gd.addNumericField("Remove outlier channels if relative grid mismatch is above ", grid_mismatch, 2,6,"");
gd.showDialog();
if (gd.wasCanceled()) return false;
int imageSetNumber=(int) gd.getNextNumber();
boolean reEstimate=gd.getNextBoolean();
imageSetNumber=(int) gd.getNextNumber();
reEstimate=gd.getNextBoolean();
use_eo = gd.getNextBoolean();
use_lwir = gd.getNextBoolean();
sel_chn =(int) gd.getNextNumber();
LASTUSED_RECALIB_SET = imageSetNumber;
LASTUSED_RECALIB_CHN = sel_chn;
// grid_mismatch = gd.getNextNumber();
if (imageSetNumber<0) return false;
if (reEstimate){
// boolean OK=
...
...
@@ -9617,12 +9642,25 @@ if (MORE_BUTTONS) {
useSetsData= gd.getNextBoolean();
processAllImages= gd.getNextBoolean();
// Find channel with most weight
// Find channel with most weight
???
LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.gIS[imageSetNumber].goniometerTilt=tiltCenter;
LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.gIS[imageSetNumber].goniometerAxial=axialCenter;
LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.gIS[imageSetNumber].interAxisAngle=interCenter;
// Run once with center position or Goniometer angles to determine average derivatives
int [][] imageSets=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.listImages(!processAllImages);
int tmask = (use_eo ? 1 : 0) + (use_lwir ? 2 : 0);
int [] type_map = LWIR_PARAMETERS.getTypeMap(); // 0 - eo, 1 -0 lwir
boolean [] chn_sel = new boolean [type_map.length];
if (sel_chn >= 0) {
chn_sel[sel_chn] = true;
} else {
for (int chn = 0; chn < chn_sel.length; chn++) {
chn_sel[chn] = (tmask & ( 1 << type_map[chn])) != 0;
}
}
int [][] imageSets=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.listImages(
!processAllImages,
chn_sel
);
int [] imageSet=imageSets[imageSetNumber];
if (imageSet==null){
IJ.showMessage("Image set #"+imageSetNumber+" is empty");
...
...
@@ -9727,7 +9765,9 @@ if (MORE_BUTTONS) {
" Initial tilt=" + tilt0+
" Initial axial=" + axial0+
" Initial inter=" + interCenter);
imageSets=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.listImages(!processAllImages);
imageSets=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.listImages(
!processAllImages,
chn_sel);
imageSet=imageSets[imageSetNumber];
if (imageSet==null){
IJ.showMessage("Image set #"+imageSetNumber+" is empty");
...
...
@@ -9806,7 +9846,9 @@ if (MORE_BUTTONS) {
" Initial axial="+best_axial+
" Initial inter="+best_inter
);
imageSets=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.listImages(!processAllImages);
imageSets=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.listImages(
!processAllImages,
chn_sel);
imageSet=imageSets[imageSetNumber];
if (imageSet==null){
IJ.showMessage("Image set #"+imageSetNumber+" is empty");
...
...
@@ -10172,21 +10214,34 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested);
// Maybe wrong ! Use folders that have at least all EO channels?
int min_files = lwirReaderParameters.getNumChannels();// 8; // use folders that have all 8 files
// int min_files = lwirReaderParameters.getNumChannels();// 8; // use folders that have all 8 files
int [] type_map = lwirReaderParameters.getTypeMap(); // 0 - eo, 1 -0 lwir
int lwir_chn0 = lwirReaderParameters.getLwirChn0();
int eo_chn0 = lwirReaderParameters.getEoChn0();
int numStations = 3;
boolean allornone_all = false;
boolean allornone_eo = true;
boolean allornone_lwir = true;
GenericDialog gd = new GenericDialog("Setup Goniometer/Camera Stations");
gd.addMessage("Setting up calibration that includes multiple camera tripod or goniometer positions.");
gd.addMessage("File selection dialog will open for each station separateley.");
gd.addMessage
("Setting up calibration that includes multiple camera tripod or goniometer positions.");
gd.addMessage
("File selection dialog will open for each station separateley.");
gd.addNumericField("Number of goniometer/camera stations", numStations,0);
gd.addMessage("lwir_chn0 = "+lwir_chn0);
gd.addMessage("eo_chn0 = "+eo_chn0);
gd.addMessage("min_files = "+min_files);
gd.addMessage ("lwir_chn0 = "+lwir_chn0);
gd.addMessage ("eo_chn0 = "+eo_chn0);
// gd.addMessage ("min_files = "+min_files);
gd.addCheckbox ("Process only sets with all channels present", allornone_all);
gd.addCheckbox ("Process eo channels in a set only if all eo channels are present", allornone_eo);
gd.addCheckbox ("Process lwir channels in a set only if all lwir channels are present", allornone_lwir);
gd.showDialog();
if (gd.wasCanceled()) return false;
numStations= (int) gd.getNextNumber();
allornone_all = gd.getNextBoolean();
allornone_eo = gd.getNextBoolean();
allornone_lwir = gd.getNextBoolean();
// String [] grid_extensions={".tif",".tiff"};
// String [] src_extensions={".tif",".tiff"};
String [] grid_extensions={".tiff"};
...
...
@@ -10200,12 +10255,14 @@ if (MORE_BUTTONS) {
// new CalibrationFileManagement.DirectoryContentsFilter (gridFilter, min_files, 0, null);
String [][] gridFileDirs= new String [numStations][];
// int [][] gridUseTypes = new int [numStations][]; // +1 - use eo channels,+2 - use lwir channels (in pointed set)
boolean [][][] gridUseChn = new boolean [numStations][][]; // channels to use in each scene
String [] sourceStationDirs = new String [numStations]; // directories of the source files per station
for (int numStation=0;numStation<numStations;numStation++){
DirectoryChoser dc = new DirectoryChoser(
gridFilter,
min_files, // not actually used
type_map.length, //
min_files, // not actually used
0,
null);
dc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
...
...
@@ -10219,11 +10276,56 @@ if (MORE_BUTTONS) {
dc.setCurrentDirectory(cur_dir);
int returnVal = dc.showOpenDialog(IJ.getInstance());
if (returnVal!=JFileChooser.APPROVE_OPTION) return false;
File [] files = dc.getSelectedFiles();
File [] files = dc.getSelectedFiles();
// set directory nome
if (files.length<1) return false;
// Can not make it work correctly with multiple selection, giving up for now
ArrayList<File> filelist = new ArrayList<File>();
for (int nFile=0;nFile<files.length;nFile++) {
class ScenePathChnFilter{
File file;
boolean [] channels;
ScenePathChnFilter(File file, boolean [] channels){
this.file=file;
this.channels = channels; // clone?
}
}
// ArrayList<File> setlist = new ArrayList<File>();
// ArrayList<Integer> settypes = new ArrayList<Integer>();
ArrayList<ScenePathChnFilter> setlist = new ArrayList<ScenePathChnFilter>();
for (int nSet=0;nSet<files.length;nSet++) { // nfile - scene number
String [] sfiles = files[nSet].list(gridFilter);
boolean [] avail_chn = new boolean[type_map.length];
for (String sfile: sfiles) {
avail_chn[DistortionCalibrationData.pathToChannel(sfile)] = true;
}
boolean [] all_type = {true, true};
boolean [] some_type = {false, false};
for (int i = 0; i < avail_chn.length; i++) {
if (avail_chn[i]) {
some_type[type_map[i]] = true;
} else {
all_type[type_map[i]] = false;
}
}
if (allornone_all && !(all_type[0] && all_type[1])) {
some_type[0] = false;
some_type[1] = false;
}
if (allornone_eo) some_type[0] = all_type[0];
if (allornone_lwir) some_type[1] = all_type[1];
if (some_type[0] || some_type[1]) {
for (int i = 0; i < avail_chn.length; i++) {
avail_chn[i] &= some_type[type_map[i]];
}
setlist.add(new ScenePathChnFilter(files[nSet], avail_chn));
// setlist.add(files[nSet]);
// settypes.add((some_type[0]?1:0)+(some_type[1]?2:0));
}
/*
// for (int nFile=0;nFile<files.length;nFile++) {
int num_match = files[nFile].list(gridFilter).length;
if (num_match >= min_files) {
filelist.add(files[nFile]);
...
...
@@ -10235,11 +10337,20 @@ if (MORE_BUTTONS) {
// }
// System.out.println("");
}
*/
}
/*
int chn = pathToChannel(path);
gridFileDirs[numStation]=new String[filelist.size()];
for (int nFile=0;nFile<gridFileDirs[numStation].length;nFile++) {
gridFileDirs[numStation][nFile]= filelist.get(nFile).getPath();
*/
gridFileDirs[numStation]=new String[setlist.size()];
gridUseChn[numStation]=new boolean [gridFileDirs[numStation].length][];
for (int nSet=0;nSet<gridFileDirs[numStation].length;nSet++) {
ScenePathChnFilter scene = setlist.get(nSet);
gridFileDirs[numStation][nSet]= scene.file.getPath();
gridUseChn[numStation][nSet] = scene.channels;
// gridFileDirs[numStation][nSet]= setlist.get(nSet).getPath();
// gridUseTypes[numStation][nSet]=settypes.get(nSet);
}
if ((gridFileDirs[numStation]==null) || (gridFileDirs[numStation].length==0)) {
if (!IJ.showMessageWithCancel("No files selected","Retry? (Cancel will abort the command)")) return false;
...
...
@@ -10279,6 +10390,8 @@ if (MORE_BUTTONS) {
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // new way for LWIR - initialize from dirs
gridFileDirs,
gridUseChn, //
// gridUseTypes, //int [][] gridUseTypes, // per station, per set - a bitbmask of channels to use (+1 - eo, +2 - lwir)
sourceStationDirs,
gridFilter,
sourceFilter,
...
...
@@ -10476,12 +10589,16 @@ if (MORE_BUTTONS) {
IJ.d2s(0.000000001*(System.nanoTime()-startFileTime),3)+"s )\n");
//
if (this.SYNC_COMMAND.stopRequested.get()
>
0) {
if (this.SYNC_COMMAND.stopRequested.get()
>
0) {
System.out.println("User requested stop");
break;
}
saved_file++;
}
if (this.SYNC_COMMAND.stopRequested.get() > 0) {
System.out.println("User requested stop2");
break;
}
}
if (DEBUG_LEVEL>0) System.out.println(((this.SYNC_COMMAND.stopRequested.get()>0)?"Partial (interrupted by user) set of grids":"All")+ " grids calculation done at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
return;
src/main/java/com/elphel/imagej/calibration/DistortionCalibrationData.java
View file @
3fd21c81
...
...
@@ -92,6 +92,18 @@ import ij.text.TextWindow;
public
boolean
updateStatus
=
true
;
public
int
debugLevel
=
2
;
private
ShowDoubleFloatArrays
SDFA_INSTANCE
=
null
;
// just for debugging
public
static
int
pathToChannel
(
String
path
)
{
int
last_dash
=
path
.
lastIndexOf
(
'-'
);
int
last
=
path
.
lastIndexOf
(
'_'
);
if
(
last_dash
>
last
)
last
=
last_dash
;
int
last_dot
=
path
.
lastIndexOf
(
'.'
);
if
(
last_dot
<
0
)
{
last_dot
=
path
.
length
();
}
return
Integer
.
parseInt
(
path
.
substring
(
last
+
1
,
last_dot
));
}
public
int
getNumStations
(){
return
(
eyesisCameraParameters
==
null
)?
0
:
eyesisCameraParameters
.
getNumStations
();
}
...
...
@@ -838,20 +850,24 @@ import ij.text.TextWindow;
}
public
DistortionCalibrationData
(
String
[][]
stationFilenames
,
String
[]
source_dirs
,
// directories of the source files per station
MultipleExtensionsFileFilter
gridFilter
,
MultipleExtensionsFileFilter
sourceFilter
,
PatternParameters
patternParameters
,
EyesisCameraParameters
eyesisCameraParameters
,
LaserPointer
laserPointers
,
// as a backup if data is not available in the file
Goniometer
.
GoniometerParameters
goniometerParameters
,
boolean
read_grids
,
int
debugLevel
String
[][]
stationFilenames
,
boolean
[][][]
gridUseChn
,
// per station, per set - a bmask of permitted channels
// int [][] gridUseTypes, // per station, per set - a bitbmask of channels to use (+1 - eo, +2 - lwir)
String
[]
source_dirs
,
// directories of the source files per station
MultipleExtensionsFileFilter
gridFilter
,
MultipleExtensionsFileFilter
sourceFilter
,
PatternParameters
patternParameters
,
EyesisCameraParameters
eyesisCameraParameters
,
LaserPointer
laserPointers
,
// as a backup if data is not available in the file
Goniometer
.
GoniometerParameters
goniometerParameters
,
boolean
read_grids
,
int
debugLevel
)
{
this
.
debugLevel
=
debugLevel
;
setupDirDistortionCalibrationData
(
stationFilenames
,
gridUseChn
,
// per station, per set - a bmask of permitted channels
// gridUseTypes, // per station, per set - a bitbmask of channels to use (+1 - eo, +2 - lwir)
source_dirs
,
// directories of the source files per station
gridFilter
,
sourceFilter
,
...
...
@@ -933,6 +949,7 @@ import ij.text.TextWindow;
// from data organized as image sets
public
static
int
getChannelFromPath
(
String
path
)
{
// int indexSuffix=path.length()-suffix.length();
if
(
path
==
null
)
return
-
1
;
int
indexSuffix
=
path
.
lastIndexOf
(
"."
);
int
indexLastDash
=
indexSuffix
-
1
;
while
((
indexLastDash
>
0
)
&&
...
...
@@ -950,15 +967,17 @@ import ij.text.TextWindow;
}
public
void
setupDirDistortionCalibrationData
(
String
[][]
stationFilenames
,
// per-station List of image set directories
String
[]
source_dirs
,
// directories of the source files per station
MultipleExtensionsFileFilter
gridFilter
,
MultipleExtensionsFileFilter
sourceFilter
,
PatternParameters
patternParameters
,
EyesisCameraParameters
eyesisCameraParameters
,
LaserPointer
laserPointers
,
// as a backup if data is not available in the file
String
[][]
stationFilenames
,
// per-station List of image set directories
boolean
[][][]
gridUseChn
,
// per station, per set - a bmask of permitted channels
// int [][] gridUseTypes, // per station, per set - a bitbmask of channels to use (+1 - eo, +2 - lwir)
String
[]
source_dirs
,
// directories of the source files per station
MultipleExtensionsFileFilter
gridFilter
,
MultipleExtensionsFileFilter
sourceFilter
,
PatternParameters
patternParameters
,
EyesisCameraParameters
eyesisCameraParameters
,
LaserPointer
laserPointers
,
// as a backup if data is not available in the file
Goniometer
.
GoniometerParameters
goniometerParameters
,
boolean
read_grids
boolean
read_grids
)
{
class
DirTs
{
int
station
;
...
...
@@ -971,6 +990,7 @@ import ij.text.TextWindow;
String
[]
getSourcePaths
()
{
return
spaths
;}
// may not be null
DirTs
(
int
station
,
String
dir
,
// grid image set directory that contains channel files (may be different timestamps)
boolean
[]
permitted_channels
,
// bitmask of permitted channels (lwir/eo), or null - use nay
String
sdir
,
// source super directory that contains image set directories with files
int
num_chn
,
MultipleExtensionsFileFilter
gridFilter
,
...
...
@@ -993,6 +1013,7 @@ import ij.text.TextWindow;
String
[]
files
=
(
new
File
(
dir
)).
list
(
gridFilter
);
// are these full files?
paths
=
new
String
[
num_chn
];
for
(
String
path:
files
)
{
/*
int last_dash = path.lastIndexOf('-');
int last = path.lastIndexOf('_');
if (last_dash >last) last = last_dash;
...
...
@@ -1001,7 +1022,11 @@ import ij.text.TextWindow;
last_dot = path.length();
}
int chn = Integer.parseInt(path.substring(last+1, last_dot));
paths
[
chn
]
=
(
new
File
(
dir
,
path
)).
getPath
();
*/
int
chn
=
pathToChannel
(
path
);
if
((
permitted_channels
==
null
)
||
(
permitted_channels
[
chn
]))
{
paths
[
chn
]
=
(
new
File
(
dir
,
path
)).
getPath
();
}
//grid-elphelimg_1559195695_507621_4.tiff
}
spaths
=
new
String
[
num_chn
];
...
...
@@ -1014,6 +1039,7 @@ import ij.text.TextWindow;
System
.
out
.
println
(
"sfiles == null"
);
}
for
(
String
spath:
sfiles
)
{
/*
int last_dash = spath.lastIndexOf('-');
int last = spath.lastIndexOf('_');
if (last_dash >last) last = last_dash;
...
...
@@ -1022,6 +1048,8 @@ import ij.text.TextWindow;
last_dot = spath.length();
}
int chn = Integer.parseInt(spath.substring(last+1, last_dot));
*/
int
chn
=
pathToChannel
(
spath
);
spaths
[
chn
]
=
(
new
File
(
set_dir
,
spath
)).
getPath
();
}
}
...
...
@@ -1040,6 +1068,7 @@ import ij.text.TextWindow;
dirTsList
.
add
(
new
DirTs
(
numStation
,
stationFilenames
[
numStation
][
is
],
// String dir,
gridUseChn
[
numStation
][
is
],
//
source_dirs
[
numStation
],
numSubCameras
,
// int num_chn,
gridFilter
,
...
...
@@ -1297,7 +1326,8 @@ import ij.text.TextWindow;
// boolean invert_color = ((base_channel ^ nc) & 4) != 0;
boolean
invert_color
=
invertColor
(
base_channel
)
^
invertColor
(
nc
);
// eyesisCameraParameters.isLWIR(main_channel);
if
((
this
.
gIS
[
nis
].
imageSet
[
nc
].
matchedPointers
<=
0
)
&&
(
nc
!=
base_channel
))
{
// Later add non-laser conditions
if
(
(
this
.
gIS
[
nis
].
imageSet
[
nc
]
!=
null
)
&&
(
this
.
gIS
[
nis
].
imageSet
[
nc
].
matchedPointers
<=
0
)
&&
(
nc
!=
base_channel
))
{
// Later add non-laser conditions
int
imgNum
=
this
.
gIS
[
nis
].
imageSet
[
nc
].
imgNumber
;
// with_pointers - base_channel + nc;
if
(
this
.
updateStatus
)
IJ
.
showStatus
(
"Re-reading grid file "
+(
imgNum
+
1
)+
" (of "
+(
numFiles
)+
"): "
+
this
.
gIP
[
imgNum
].
path
);
if
(
this
.
debugLevel
>-
1
)
System
.
out
.
print
(
imgNum
+
"*("
+
this
.
gIP
[
imgNum
].
getStationNumber
()+
...
...
@@ -2442,16 +2472,36 @@ import ij.text.TextWindow;
* create list of image indices per image set
* @return array of image indices for each image set
*/
public
int
[][]
listImages
(
boolean
enabledOnly
){
public
int
[][]
listImages
(
boolean
enabledOnly
,
//int type_mask // 0 - all, otherwise +1 - eo, +2 - lwir
boolean
[]
chn_sel
// selected channels or null
){
int
[][]
imageSets
=
new
int
[
this
.
gIS
.
length
][];
for
(
int
i
=
0
;
i
<
this
.
gIS
.
length
;
i
++){
int
setSize
=
0
;
for
(
int
n
=
0
;
n
<
this
.
gIS
[
i
].
imageSet
.
length
;
n
++)
if
((
this
.
gIS
[
i
].
imageSet
[
n
]!=
null
)
&&
(
this
.
gIS
[
i
].
imageSet
[
n
].
imgNumber
>=
0
)
&&
(!
enabledOnly
||
this
.
gIS
[
i
].
imageSet
[
n
].
enabled
))
setSize
++;
for
(
int
n
=
0
;
n
<
this
.
gIS
[
i
].
imageSet
.
length
;
n
++)
{
if
(
(
this
.
gIS
[
i
].
imageSet
[
n
]!=
null
)
&&
(
this
.
gIS
[
i
].
imageSet
[
n
].
imgNumber
>=
0
)
&&
(!
enabledOnly
||
this
.
gIS
[
i
].
imageSet
[
n
].
enabled
))
{
if
((
chn_sel
==
null
)
||
(
chn_sel
[
this
.
gIS
[
i
].
imageSet
[
n
].
getChannel
()])){
setSize
++;
}
}
}
imageSets
[
i
]=
new
int
[
setSize
];
}
for
(
int
i
=
0
;
i
<
this
.
gIS
.
length
;
i
++){
int
index
=
0
;
for
(
int
n
=
0
;
n
<
this
.
gIS
[
i
].
imageSet
.
length
;
n
++)
if
((
this
.
gIS
[
i
].
imageSet
[
n
]!=
null
)
&&
(
this
.
gIS
[
i
].
imageSet
[
n
].
imgNumber
>=
0
)
&&
(!
enabledOnly
||
this
.
gIS
[
i
].
imageSet
[
n
].
enabled
))
imageSets
[
i
][
index
++]=
this
.
gIS
[
i
].
imageSet
[
n
].
imgNumber
;
for
(
int
n
=
0
;
n
<
this
.
gIS
[
i
].
imageSet
.
length
;
n
++)
{
if
(
(
this
.
gIS
[
i
].
imageSet
[
n
]!=
null
)
&&
(
this
.
gIS
[
i
].
imageSet
[
n
].
imgNumber
>=
0
)
&&
(!
enabledOnly
||
this
.
gIS
[
i
].
imageSet
[
n
].
enabled
))
{
if
((
chn_sel
==
null
)
||
(
chn_sel
[
this
.
gIS
[
i
].
imageSet
[
n
].
getChannel
()])){
imageSets
[
i
][
index
++]=
this
.
gIS
[
i
].
imageSet
[
n
].
imgNumber
;
}
}
}
}
return
imageSets
;
}
...
...
@@ -4466,7 +4516,7 @@ import ij.text.TextWindow;
}
return
small_sensors
;
}
public
boolean
isSmallSensor
(
int
numImg
)
{
public
boolean
isSmallSensor
(
int
numImg
)
{
// number of image, not a channel!!!
boolean
[]
ss
=
getSmallSensors
();
if
((
this
.
gIP
!=
null
)
&&
(
numImg
>=
0
)
&&
(
numImg
<
this
.
gIP
.
length
)){
return
ss
[
this
.
gIP
[
numImg
].
getChannel
()];
...
...
src/main/java/com/elphel/imagej/calibration/Distortions.java
View file @
3fd21c81
...
...
@@ -854,7 +854,9 @@ public class Distortions {
double
[]
errors
=
calcErrors
(
calcYminusFx
(
this
.
currentfX
));
int
[]
numPairs
=
calcNumPairs
();
int
[][]
imageSets
=
this
.
fittingStrategy
.
distortionCalibrationData
.
listImages
(
false
);
// true - only enabled images
int
[][]
imageSets
=
this
.
fittingStrategy
.
distortionCalibrationData
.
listImages
(
false
,
// true - only enabled images
null
);
// do not filter eo, lwir
boolean
hasLWIR
=
this
.
fittingStrategy
.
distortionCalibrationData
.
hasSmallSensors
();
int
[]
numSetPoints
=
new
int
[
imageSets
.
length
*(
hasLWIR
?
2
:
1
)];
...
...
@@ -870,12 +872,13 @@ public class Distortions {
int
[]
numInSet
=
{
0
,
0
};
hasNaNInSet
[
2
*
setNum
]=
false
;
hasNaNInSet
[
2
*
setNum
+
1
]=
false
;
for
(
int
imgInSet
=
0
;
imgInSet
<
imageSets
[
setNum
].
length
;
imgInSet
++)
{
int
imgNum
=
imageSets
[
setNum
][
imgInSet
];
int
isLwir
=
this
.
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
imgNum
)?
1
:
0
;
for
(
int
imgInSet
=
0
;
imgInSet
<
imageSets
[
setNum
].
length
;
imgInSet
++)
{
// upper limit depends (now 4/20)
int
imgNum
=
imageSets
[
setNum
][
imgInSet
];
// image number
int
chn
=
fittingStrategy
.
distortionCalibrationData
.
gIP
[
imgNum
].
getChannel
();
int
isLwir
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
imgNum
)?
1
:
0
;
int
num
=
numPairs
[
imgNum
];
rmsPerImg
[
setNum
][
imgInSet
]
=
errors
[
imgNum
];
numImgPoints
[
setNum
][
imgInSet
]
=
num
;
rmsPerImg
[
setNum
][
chn
]
=
errors
[
imgNum
];
numImgPoints
[
setNum
][
chn
]
=
num
;
if
(
Double
.
isNaN
(
errors
[
imgNum
])){
hasNaNInSet
[
2
*
setNum
+
isLwir
]=
true
;
}
else
{
...
...
@@ -896,9 +899,10 @@ public class Distortions {
hasNaNInSet
[
setNum
]=
false
;
for
(
int
imgInSet
=
0
;
imgInSet
<
imageSets
[
setNum
].
length
;
imgInSet
++)
{
int
imgNum
=
imageSets
[
setNum
][
imgInSet
];
int
chn
=
fittingStrategy
.
distortionCalibrationData
.
gIP
[
imgNum
].
getChannel
();
int
num
=
numPairs
[
imgNum
];
rmsPerImg
[
setNum
][
imgInSet
]
=
errors
[
imgNum
];
numImgPoints
[
setNum
][
imgInSet
]
=
num
;
rmsPerImg
[
setNum
][
chn
]
=
errors
[
imgNum
];
numImgPoints
[
setNum
][
chn
]
=
num
;
if
(
Double
.
isNaN
(
errors
[
imgNum
])){
hasNaNInSet
[
setNum
]=
true
;
}
else
{
...
...
@@ -1040,9 +1044,10 @@ public class Distortions {
debugLevel
);
String
[]
titles
={
"X-corr(pix)"
,
"Y-corr(pix)"
,
"weight"
,
"Red"
,
"Green"
,
"Blue"
};
for
(
int
numChn
=
0
;
numChn
<
sensorXYRGBCorr
.
length
;
numChn
++)
if
(
sensorXYRGBCorr
[
numChn
]!=
null
){
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
numChn
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(numChn);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
numChn
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
int
decimate
=
getDecimateMasks
(
numChn
);
int
decimate
=
getDecimateMasks
(
numChn
);
// Reduce for LWIR? Make form sensor width?
int
sWidth
=
(
getSensorWidth
(
numChn
)-
1
)/
decimate
+
1
;
if
(
rp
.
showUnfilteredCorrection
&&
enableShow
)
{
// && this.refineParameters.showUnfilteredCorrection) {
showWithRadialTangential
(
...
...
@@ -1750,7 +1755,9 @@ public class Distortions {
){
if
(
this
.
pixelCorrection
==
null
)
return
;
// no modifications are needed
for
(
int
i
=
0
;
i
<
sensorXYCorr
.
length
;
i
++)
if
((
sensorXYCorr
[
i
]!=
null
)
&&
(
this
.
pixelCorrection
[
i
]!=
null
))
{
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
i
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(i);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
i
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
// if (rp.sensorExtrapolateDiff ^ invert) { // add current correction AFTER extrapolationg/bluring
double
scale
=
rp
.
correctionScale
;
...
...
@@ -1990,7 +1997,8 @@ public class Distortions {
for
(
int
imgNum
=
imageNumberAtomic
.
getAndIncrement
();
(
imgNum
<
selectedImages
.
length
)
&&
!
interruptedAtomic
.
get
();
imgNum
=
imageNumberAtomic
.
getAndIncrement
()){
if
(
selectedImages
[
imgNum
]){
int
chnNum
=
fittingStrategy
.
distortionCalibrationData
.
gIP
[
imgNum
].
channel
;
// number of sub-camera
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
chnNum
);
//boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(chnNum);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
chnNum
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
boolean
showIndividual
=
si
&&
rp
.
showPerImage
;
int
showIndividualNumber
=
rp
.
showIndividualNumber
;
...
...
@@ -2077,7 +2085,8 @@ public class Distortions {
// if (shrinkBlurComboSigma>0.0) gb=new DoubleGaussianBlur();
gb
=
new
DoubleGaussianBlur
();
for
(
int
sensorNum
=
sensorNumberAtomic
.
getAndIncrement
();
(
sensorNum
<
gridPCorr
.
length
)
&&
!
interruptedAtomic
.
get
();
sensorNum
=
sensorNumberAtomic
.
getAndIncrement
()){
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
sensorNum
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(sensorNum);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
sensorNum
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
if
(
rp
.
extrapolate
)
{
int
sensorWidth
=
fittingStrategy
.
distortionCalibrationData
.
eyesisCameraParameters
.
getSensorWidth
(
sensorNum
);
...
...
@@ -4945,7 +4954,10 @@ List calibration
boolean
[]
selectedImages
=
fittingStrategy
.
selectedImages
(
this
.
seriesNumber
);
// int [] numPairs=calcNumPairs();
int
[][]
imageSets
=
this
.
fittingStrategy
.
distortionCalibrationData
.
listImages
(
false
);
// true - only enabled images
int
[][]
imageSets
=
this
.
fittingStrategy
.
distortionCalibrationData
.
listImages
(
false
,
// true - only enabled images
null
);
// do not filter eo, lwir
int
[]
numSetPoints
=
new
int
[
imageSets
.
length
];
double
[]
rmsPerSet
=
new
double
[
imageSets
.
length
];
boolean
[]
hasNaNInSet
=
new
boolean
[
imageSets
.
length
];
...
...
@@ -6188,6 +6200,10 @@ List calibration
JtByJmod
[
i
][
i
]+=
lambda
*
JtByJmod
[
i
][
i
];
//Marquardt mod
}
// M*Ma=Mb
System
.
out
.
println
(
"JtByJmod.length="
+
JtByJmod
.
length
+
" numPars="
+
numPars
);
if
(
numPars
==
0
)
{
return
null
;
}
Matrix
M
=
new
Matrix
(
JtByJmod
);
// public Matrix (double vals[], int m) {
...
...
@@ -6896,7 +6912,8 @@ List calibration
this
.
pathNames
=
tmpPaths
;
}
for
(
int
i
=
0
;
i
<
sensorXYCorr
.
length
;
i
++)
if
(
sensorXYCorr
[
i
]!=
null
){
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
i
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(i);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
i
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
boolean
update
=
rp
.
applyCorrection
;
boolean
updateFlatField
=
rp
.
applyFlatField
;
...
...
@@ -7524,9 +7541,9 @@ List calibration
// For each sensor separately accumulate grid intensity using current sensor flat field calibration
for
(
int
numImg
=
0
;
numImg
<
fittingStrategy
.
distortionCalibrationData
.
gIP
.
length
;
numImg
++)
if
(
selectedImages
[
numImg
])
{
int
channel
=
fittingStrategy
.
distortionCalibrationData
.
gIP
[
numImg
].
channel
;
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
channel
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(channel);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
channel
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
double
minContrast
=
rp
.
flatFieldMinimalContrast
;
// double threshold = rp.flatFieldMinimalContrast;
boolean
interpolate
=
rp
.
flatFieldUseInterpolate
;
...
...
@@ -7658,7 +7675,8 @@ List calibration
}
for
(
int
station
=
0
;
station
<
sensorGrids
.
length
;
station
++){
for
(
int
channel
=
0
;
channel
<
sensorGrids
[
station
].
length
;
channel
++)
if
(
sensorGrids
[
station
][
channel
]!=
null
){
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
channel
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(channel);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
channel
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
double
threshold
=
rp
.
flatFieldMinimalContrast
;
if
(
this
.
pixelCorrection
[
channel
]==
null
)
{
...
...
@@ -8229,7 +8247,8 @@ List calibration
double
[][]
masks
=
new
double
[
this
.
pixelCorrection
.
length
][];
int
maskIndex
=
2
;
for
(
int
numSensor
=
0
;
numSensor
<
masks
.
length
;
numSensor
++){
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
numSensor
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(numSensor);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
numSensor
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
if
(
this
.
pixelCorrection
[
numSensor
]==
null
)
masks
[
numSensor
]
=
null
;
...
...
@@ -8258,7 +8277,8 @@ List calibration
double
[][]
masks
=
new
double
[
this
.
pixelCorrection
.
length
][];
int
maskIndex
=
2
;
for
(
int
numSensor
=
0
;
numSensor
<
masks
.
length
;
numSensor
++){
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
isSmallSensor
(
numSensor
);
// boolean small_sensor = fittingStrategy.distortionCalibrationData.isSmallSensor(numSensor);
boolean
small_sensor
=
fittingStrategy
.
distortionCalibrationData
.
getSmallSensors
()[
numSensor
];
RefineParameters
rp
=
small_sensor
?
refineParameters
.
refineParametersSmall
:
refineParameters
;
double
shrink
=
rp
.
flatFieldShrink
;
...
...
src/main/java/com/elphel/imagej/calibration/FittingStrategy.java
View file @
3fd21c81
...
...
@@ -1583,7 +1583,10 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
System
.
out
.
println
(
"BUG: selectIndividualImages(): selection.length!=enabled.length!"
);
return
false
;
}
int
[][]
imageSets
=
this
.
distortionCalibrationData
.
listImages
(!
allImages
);
// true - only enabled images
int
[][]
imageSets
=
this
.
distortionCalibrationData
.
listImages
(
!
allImages
,
// true - only enabled images
null
);
// do not filter by eo/lwir?
boolean
[]
enabledSets
=
new
boolean
[
imageSets
.
length
];
boolean
[]
selectedSets
=
new
boolean
[
imageSets
.
length
];
// at least one image selected in the series
for
(
int
i
=
0
;
i
<
imageSets
.
length
;
i
++){
...
...
@@ -2483,7 +2486,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
this
.
selectedImages
[
numSeries
][
i
]=
selectAllImages
||
((
i
==
0
)
&&
removeAllImages
);
// invalidate - all, regardless of .enabled
this
.
selectedImages
[
numSeries
][
i
]
&=
constrainByStation
[
this
.
distortionCalibrationData
.
gIP
[
i
].
getStationNumber
()];
if
(
selectHiLowRes
!=
null
)
{
int
small_01
=
this
.
distortionCalibrationData
.
isSmallSensor
(
i
)?
1
:
0
;
int
small_01
=
this
.
distortionCalibrationData
.
isSmallSensor
(
i
)?
1
:
0
;
//OK, i here is image number, not channel number
// System.out.println(i+":"+small_01);
this
.
selectedImages
[
numSeries
][
i
]
&=
selectHiLowRes
[
small_01
];
}
...
...
src/main/java/com/elphel/imagej/lwir/LwirReaderParameters.java
View file @
3fd21c81
...
...
@@ -142,9 +142,17 @@ public class LwirReaderParameters {
}
public
int
getNumChannels
()
{
return
20
;
return
isLwir16
()?
20
:
8
;
}
public
int
[]
getTypeMap
()
{
// eo - 0, lwir - 1
int
[]
types
=
new
int
[
getNumChannels
()];
for
(
int
i
=
0
;
i
<
types
.
length
;
i
++)
{
types
[
i
]
=
(
i
>=
getEoChn0
())?
0
:
1
;
}
return
types
;
}
public
static
boolean
is_LWIR
(
int
width
)
{
return
width
<=
MAX_LWIR_WIDTH
;
}
...
...
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