Commit 3fd21c81 authored by Andrey Filippov's avatar Andrey Filippov

fixing bugs for variable images per set (e.g. eo only)

parent 9c63f90b
...@@ -92,6 +92,18 @@ import ij.text.TextWindow; ...@@ -92,6 +92,18 @@ import ij.text.TextWindow;
public boolean updateStatus=true; public boolean updateStatus=true;
public int debugLevel=2; public int debugLevel=2;
private ShowDoubleFloatArrays SDFA_INSTANCE=null; // just for debugging 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(){ public int getNumStations(){
return (eyesisCameraParameters==null)?0:eyesisCameraParameters.getNumStations(); return (eyesisCameraParameters==null)?0:eyesisCameraParameters.getNumStations();
} }
...@@ -839,6 +851,8 @@ import ij.text.TextWindow; ...@@ -839,6 +851,8 @@ import ij.text.TextWindow;
public DistortionCalibrationData ( public DistortionCalibrationData (
String [][] stationFilenames, 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 String [] source_dirs, // directories of the source files per station
MultipleExtensionsFileFilter gridFilter, MultipleExtensionsFileFilter gridFilter,
MultipleExtensionsFileFilter sourceFilter, MultipleExtensionsFileFilter sourceFilter,
...@@ -852,6 +866,8 @@ import ij.text.TextWindow; ...@@ -852,6 +866,8 @@ import ij.text.TextWindow;
this.debugLevel=debugLevel; this.debugLevel=debugLevel;
setupDirDistortionCalibrationData( setupDirDistortionCalibrationData(
stationFilenames, 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 source_dirs, // directories of the source files per station
gridFilter, gridFilter,
sourceFilter, sourceFilter,
...@@ -933,6 +949,7 @@ import ij.text.TextWindow; ...@@ -933,6 +949,7 @@ import ij.text.TextWindow;
// from data organized as image sets // from data organized as image sets
public static int getChannelFromPath(String path) { public static int getChannelFromPath(String path) {
// int indexSuffix=path.length()-suffix.length(); // int indexSuffix=path.length()-suffix.length();
if (path == null) return -1;
int indexSuffix = path.lastIndexOf("."); int indexSuffix = path.lastIndexOf(".");
int indexLastDash=indexSuffix-1; int indexLastDash=indexSuffix-1;
while ((indexLastDash>0) && while ((indexLastDash>0) &&
...@@ -951,6 +968,8 @@ import ij.text.TextWindow; ...@@ -951,6 +968,8 @@ import ij.text.TextWindow;
public void setupDirDistortionCalibrationData ( public void setupDirDistortionCalibrationData (
String [][] stationFilenames, // per-station List of image set directories 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 String [] source_dirs, // directories of the source files per station
MultipleExtensionsFileFilter gridFilter, MultipleExtensionsFileFilter gridFilter,
MultipleExtensionsFileFilter sourceFilter, MultipleExtensionsFileFilter sourceFilter,
...@@ -971,6 +990,7 @@ import ij.text.TextWindow; ...@@ -971,6 +990,7 @@ import ij.text.TextWindow;
String [] getSourcePaths() {return spaths;} // may not be null String [] getSourcePaths() {return spaths;} // may not be null
DirTs(int station, DirTs(int station,
String dir, // grid image set directory that contains channel files (may be different timestamps) 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 String sdir, // source super directory that contains image set directories with files
int num_chn, int num_chn,
MultipleExtensionsFileFilter gridFilter, MultipleExtensionsFileFilter gridFilter,
...@@ -993,6 +1013,7 @@ import ij.text.TextWindow; ...@@ -993,6 +1013,7 @@ import ij.text.TextWindow;
String [] files = (new File(dir)).list(gridFilter); // are these full files? String [] files = (new File(dir)).list(gridFilter); // are these full files?
paths = new String[num_chn]; paths = new String[num_chn];
for (String path:files) { for (String path:files) {
/*
int last_dash = path.lastIndexOf('-'); int last_dash = path.lastIndexOf('-');
int last = path.lastIndexOf('_'); int last = path.lastIndexOf('_');
if (last_dash >last) last = last_dash; if (last_dash >last) last = last_dash;
...@@ -1001,7 +1022,11 @@ import ij.text.TextWindow; ...@@ -1001,7 +1022,11 @@ import ij.text.TextWindow;
last_dot = path.length(); last_dot = path.length();
} }
int chn = Integer.parseInt(path.substring(last+1, last_dot)); int chn = Integer.parseInt(path.substring(last+1, last_dot));
*/
int chn = pathToChannel(path);
if ((permitted_channels == null) || (permitted_channels[chn])) {
paths[chn] = (new File(dir,path)).getPath(); paths[chn] = (new File(dir,path)).getPath();
}
//grid-elphelimg_1559195695_507621_4.tiff //grid-elphelimg_1559195695_507621_4.tiff
} }
spaths = new String[num_chn]; spaths = new String[num_chn];
...@@ -1014,6 +1039,7 @@ import ij.text.TextWindow; ...@@ -1014,6 +1039,7 @@ import ij.text.TextWindow;
System.out.println("sfiles == null"); System.out.println("sfiles == null");
} }
for (String spath:sfiles) { for (String spath:sfiles) {
/*
int last_dash = spath.lastIndexOf('-'); int last_dash = spath.lastIndexOf('-');
int last = spath.lastIndexOf('_'); int last = spath.lastIndexOf('_');
if (last_dash >last) last = last_dash; if (last_dash >last) last = last_dash;
...@@ -1022,6 +1048,8 @@ import ij.text.TextWindow; ...@@ -1022,6 +1048,8 @@ import ij.text.TextWindow;
last_dot = spath.length(); last_dot = spath.length();
} }
int chn = Integer.parseInt(spath.substring(last+1, last_dot)); int chn = Integer.parseInt(spath.substring(last+1, last_dot));
*/
int chn = pathToChannel(spath);
spaths[chn] = (new File(set_dir,spath)).getPath(); spaths[chn] = (new File(set_dir,spath)).getPath();
} }
} }
...@@ -1040,6 +1068,7 @@ import ij.text.TextWindow; ...@@ -1040,6 +1068,7 @@ import ij.text.TextWindow;
dirTsList.add(new DirTs( dirTsList.add(new DirTs(
numStation, numStation,
stationFilenames[numStation][is], // String dir, stationFilenames[numStation][is], // String dir,
gridUseChn[numStation][is], //
source_dirs[numStation], source_dirs[numStation],
numSubCameras, // int num_chn, numSubCameras, // int num_chn,
gridFilter, gridFilter,
...@@ -1297,7 +1326,8 @@ import ij.text.TextWindow; ...@@ -1297,7 +1326,8 @@ import ij.text.TextWindow;
// boolean invert_color = ((base_channel ^ nc) & 4) != 0; // boolean invert_color = ((base_channel ^ nc) & 4) != 0;
boolean invert_color = invertColor(base_channel) ^ invertColor(nc); // eyesisCameraParameters.isLWIR(main_channel); 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; 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.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()+ if (this.debugLevel>-1) System.out.print(imgNum+"*("+this.gIP[imgNum].getStationNumber()+
...@@ -2442,16 +2472,36 @@ import ij.text.TextWindow; ...@@ -2442,16 +2472,36 @@ import ij.text.TextWindow;
* create list of image indices per image set * create list of image indices per image set
* @return array of image indices for each 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][]; int [][] imageSets = new int [this.gIS.length][];
for (int i=0;i<this.gIS.length;i++){ for (int i=0;i<this.gIS.length;i++){
int setSize=0; 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]; imageSets[i]=new int [setSize];
} }
for (int i=0;i<this.gIS.length;i++){ for (int i=0;i<this.gIS.length;i++){
int index=0; 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; return imageSets;
} }
...@@ -4466,7 +4516,7 @@ import ij.text.TextWindow; ...@@ -4466,7 +4516,7 @@ import ij.text.TextWindow;
} }
return small_sensors; return small_sensors;
} }
public boolean isSmallSensor(int numImg) { public boolean isSmallSensor(int numImg) { // number of image, not a channel!!!
boolean [] ss = getSmallSensors(); boolean [] ss = getSmallSensors();
if ((this.gIP != null) && (numImg >= 0) && (numImg < this.gIP.length)){ if ((this.gIP != null) && (numImg >= 0) && (numImg < this.gIP.length)){
return ss[this.gIP[numImg].getChannel()]; return ss[this.gIP[numImg].getChannel()];
......
...@@ -1583,7 +1583,10 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -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!"); System.out.println("BUG: selectIndividualImages(): selection.length!=enabled.length!");
return false; 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 [] enabledSets=new boolean [imageSets.length];
boolean [] selectedSets=new boolean [imageSets.length]; // at least one image selected in the series boolean [] selectedSets=new boolean [imageSets.length]; // at least one image selected in the series
for (int i=0;i<imageSets.length;i++){ 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 ...@@ -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]=selectAllImages || ((i==0) && removeAllImages); // invalidate - all, regardless of .enabled
this.selectedImages[numSeries][i] &= constrainByStation[this.distortionCalibrationData.gIP[i].getStationNumber()]; this.selectedImages[numSeries][i] &= constrainByStation[this.distortionCalibrationData.gIP[i].getStationNumber()];
if (selectHiLowRes != null) { 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); // System.out.println(i+":"+small_01);
this.selectedImages[numSeries][i] &= selectHiLowRes[small_01]; this.selectedImages[numSeries][i] &= selectHiLowRes[small_01];
} }
......
...@@ -142,7 +142,15 @@ public class LwirReaderParameters { ...@@ -142,7 +142,15 @@ public class LwirReaderParameters {
} }
public int getNumChannels() { 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) { public static boolean is_LWIR(int width) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment