Commit 81c431ad authored by Andrey Filippov's avatar Andrey Filippov

DATI and pattern matching

parent 1c62dfa5
......@@ -418,7 +418,54 @@ public class DoubleFHT {
return first;
}
/**
* Transform pattern once, and then use FD of the pattern for each overlapping image tile
* @param second pattern to be transform
* @return transformed pattern ( the original is also modified)
*/
public double [] transformPattern ( // new
double [] second ){ //null-OK
updateMaxN(second);
swapQuadrants(second);
if (!transform(second,false)) return null; // direct FHT
return second;
}
/**
* Phase correlate with pattern, that is transformed separately with transformPattern()
* @param first square array to be phase-correlated, modified but not with result!
* @param secondFD pattern already transformed to FD
* @param phaseCoeff 0 - regular correlation, 1.0 - pure phase correlation
* @param filter frequency filter or null
* @param first_save null or array to accommodate FD of the first array before updating it with correlation
* @return phase correlation, first still contains original transformed!
*/
public double [] phaseCorrelatePattern ( // new
double [] first,
double [] secondFD,
double phaseCoeff,
double [] filter, // high/low pass filtering
double [] first_save ){ //null-OK
if (first.length!=secondFD.length) {
IJ.showMessage("Error","Correlation arrays should be the same size");
return null;
}
updateMaxN(first);
swapQuadrants(first);
if (!transform(first,false)) return null; // direct FHT
if (first_save != null) System.arraycopy(first, 0, first_save, 0, first.length);
first= phaseMultiplyNorm(first, secondFD, phaseCoeff); // correlation, not convolution
if (filter!=null) multiplyByReal(first, filter);
transform(first,true) ; // inverse transform
swapQuadrants(first);
return first;
}
//
public double [] applyFreqFilter(
......
......@@ -847,9 +847,12 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addButton("Set pair", panelLWIRWorld, color_process);
addButton("Warp pair", panelLWIRWorld, color_process);
addButton("Read Tiff", panelLWIRWorld, color_process);
addButton("Set pair GPS", panelLWIRWorld, color_process);
addButton("Test video", panelLWIRWorld, color_process);
addButton("Deconvolve Slices", panelLWIRWorld, color_process);
addButton("Ortho Pairs", panelLWIRWorld, color_process);
addButton("Mismatched resolutions", panelLWIRWorld, color_process);
addButton("Generate DATI", panelLWIRWorld, color_process);
addButton("Create mine", panelLWIRWorld, color_process);
addButton("Pattern correlate", panelLWIRWorld, color_process);
plugInFrame.add(panelLWIRWorld);
}
......@@ -5705,7 +5708,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
e.printStackTrace();
}
// ComboMatch.testReadTiff();
} else if (label.equals("Set pair GPS")) {
} else if (label.equals("Ortho Pairs")) {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (GPU_TILE_PROCESSOR == null) {
......@@ -5734,24 +5737,44 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return;
}
OrthoMap.testVideo(imp_sel);
} else if (label.equals("Deconvolve Slices")) {
} else if (label.equals("Mismatched resolutions")) {
ImagePlus imp_sel = WindowManager.getCurrentImage();
if (imp_sel == null) {
IJ.showMessage("Error", "No images selected");
return;
}
OrthoMap.testDeconvolveSlices(
OrthoMap.createMismatchedResolutionKernel(
imp_sel, // ImagePlus imp,
512, // int [] slices,
new int [] {1,2}, // int [] slices, deconvolve slice 2 with slice1
4, // int kernel_radius,
6, // 4, // int kernel_radius,
true, // boolean hor_sym,
true, // boolean vert_sym,
true, // false, // boolean all_sym,
DEBUG_LEVEL); // int debugLevel) { // >0
} else if (label.equals("Generate DATI")) {
ImagePlus imp_sel = WindowManager.getCurrentImage();
if (imp_sel == null) {
IJ.showMessage("Error", "No images selected");
return;
}
OrthoMap.generateDATI(
imp_sel, // ImagePlus imp,
512, // int [] slices,
new int [] {1,2}, // int [] slices, deconvolve slice 2 with slice1
DEBUG_LEVEL); // int debugLevel) { // >0
} else if (label.equals("Create mine")) {
OrthoMap.testPatternGenerate();
} else if (label.equals("Pattern correlate")) {
ImagePlus imp_sel = WindowManager.getCurrentImage();
if (imp_sel == null) {
IJ.showMessage("Error", "No images selected");
return;
}
OrthoMap.testPatternCorrelate(imp_sel);
}
}
//
public boolean debugInitOneScene() {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
if (EYESIS_CORRECTIONS_AUX == null) {
......
......@@ -82,8 +82,15 @@ public class ComboMatch {
// String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_08_november.data";
// String files_list_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_10_short.list";
// String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_10_short.data";
String files_list_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.list";
String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.data";
// String files_list_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.list";
// String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.data";
String [] files_lists_paths = {
"/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m",
"/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_nov3_50-75"};
String files_list_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_nov3_50-75.list";
String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_nov3_50-75.data";
//maps_nov3_50-75
//maps_19_sep13.list
//maps_09_short.list
//maps_08_november.list
......@@ -129,26 +136,20 @@ public class ComboMatch {
boolean restore_temp = true;
double frac_remove = 0.15;
double metric_error = 0.05; // 0.02;// 2 cm
boolean update_lla = false; // re-read file metadata
if (!use_marked_image) {
process_correlation=false; // use already adjusted by defualt
process_correlation=false; // use already adjusted by default
}
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,900);
gd.addStringField ("Image list full path", files_list_path, 180, "Image list full path.");
gd.addStringField ("Maps collection save path", orthoMapsCollection_path, 180, "Save path for serialized map collection data.");
gd.addChoice ("Files list/data path (w/o extension):", files_lists_paths, files_lists_paths[files_lists_paths.length-1]);
gd.addCheckbox ("Use saved maps collection", use_saved_collection, "If false - use files list.");
gd.addCheckbox ("Save maps collection", save_collection, "Save maps collection to be able to restore.");
gd.addCheckbox ("Process correlations", process_correlation, "false to skip to just regenerate new save file.");
gd.addCheckbox ("Update match if calculated", update_match, "Will update correlation match for a pair if found.");
gd.addCheckbox ("Render match", render_match, "Render a pair of matched images.");
//
// for (int n = 0; n < image_paths_pre.length; n++) {
// gd.addStringField ("Image path "+n, image_paths_pre[n], 180, "Image "+n+" full path w/o ext");
// }
// gd.addStringField ("First image path", image_paths_pre[0], 180, "First image full path w/o ext");
// gd.addStringField ("Second image path", image_paths_pre[1], 180, "Second image full path w/o ext");
/*
for (int n = 0; n < image_enuatr.length; n++) {
gd.addMessage("image["+n+"] pose");
gd.addNumericField("East", image_enuatr[n][0][0], 3,7,"m", "Move image "+n+" East.");
......@@ -158,6 +159,7 @@ public class ComboMatch {
gd.addNumericField("Tilt", image_enuatr[n][1][1], 3,7,"deg", "Rotate image "+n+" around East.");
gd.addNumericField("Roll", image_enuatr[n][1][2], 3,7,"deg", "Rotate image "+n+" around North.");
}
*/
gd.addNumericField("Zoom level", zoom_lev, 0,4,"",
"Zoom level: +1 - zoom in twice, -1 - zoom out twice");
gd.addNumericField("GPU image width", gpu_width, 0,4,"",
......@@ -167,23 +169,24 @@ public class ComboMatch {
gd.addCheckbox ("Show transformation centers", show_centers, "Mark verticals from the UAS on the ground.");
gd.addCheckbox ("Show combo image map", show_combo_map, "Load and process altitude maps.");
gd.addCheckbox ("Show altitude combo image", use_alt, "Load and process altitude maps.");
// gd.addStringField ("First matching timestamp", gpu_spair[0], 20, "First GPU-matching timestamp with '_' for decimal point.");
// gd.addStringField ("Second matching timestamp", gpu_spair[1], 20, "First GPU-matching timestamp with '_' for decimal point.");
gd.addNumericField("Remove fraction of worst matches", frac_remove, 3,7,"", "When fitting scenes remove this fraction of worst match.");
gd.addNumericField("Maximal metric error", metric_error, 3,7,"m", "Maximal tolerable fitting error caused by elevation variations.");
if (use_marked_image ) {
gd.addCheckbox ("Use marked image data", true, "Use markes from the selected image");
}
gd.addCheckbox ("Update files metadata", update_lla, "Re-read files metadata (ifd it was modified)");
gd.showDialog();
if (gd.wasCanceled()) return false;
files_list_path = gd.getNextString();
orthoMapsCollection_path = gd.getNextString();
int choice_index = gd.getNextChoiceIndex();
files_list_path = files_lists_paths[choice_index]+".list";
orthoMapsCollection_path =files_lists_paths[choice_index]+".data";
use_saved_collection = gd.getNextBoolean();
save_collection = gd.getNextBoolean();
process_correlation= gd.getNextBoolean();
update_match= gd.getNextBoolean();
render_match= gd.getNextBoolean();
/*
for (int n = 0; n < image_enuatr.length; n++) {
image_enuatr[n][0][0] = gd.getNextNumber();
image_enuatr[n][0][1] = gd.getNextNumber();
......@@ -192,6 +195,7 @@ public class ComboMatch {
image_enuatr[n][1][1] = gd.getNextNumber();
image_enuatr[n][1][2] = gd.getNextNumber();
}
*/
zoom_lev = (int) gd.getNextNumber();
gpu_width = (int) gd.getNextNumber();
gpu_height = (int) gd.getNextNumber();
......@@ -209,6 +213,7 @@ public class ComboMatch {
if (use_marked_image ) { // will only be used if found and asked
use_marked_image= gd.getNextBoolean();
}
update_lla= gd.getNextBoolean();
OrthoMapsCollection maps_collection=null;
if (use_saved_collection) {
try {
......@@ -245,8 +250,11 @@ public class ComboMatch {
//getTemperature()
// get all temperatures
maps_collection. getAllTemperatures();
maps_collection.getAllTemperatures();
if (update_lla) {
System.out.println("Updating map files metadata");
maps_collection.updateLLa();
}
// which pair to compare
// String [] gpu_spair = {names[gpu_ipair[0]],names[gpu_ipair[1]]};
......@@ -310,7 +318,7 @@ public class ComboMatch {
int max_zoom_lev = Math.max(
maps_collection.ortho_maps[gpu_pair[0]].getOriginalZoomLevel(),
maps_collection.ortho_maps[gpu_pair[1]].getOriginalZoomLevel());
int initial_zoom = max_zoom_lev - 3; // another algorithm?
int initial_zoom = max_zoom_lev - 4; // another algorithm?
System.out.println("Setting up GPU");
......
......@@ -60,8 +60,8 @@ public class OrthoMapsCollection implements Serializable{
ortho_maps = new OrthoMap[paths.length];
for (int n = 0; n < ortho_maps.length; n++) {
String name = OrthoMap.getNameFromPath(paths[n]);
String scene_path = getSceneDir(scenes_path, name);
ortho_maps[n] = new OrthoMap(paths[n], scene_path);
// String scene_path = getSceneDir(scenes_path, name);
ortho_maps[n] = new OrthoMap(paths[n]); // , scene_path);
ortho_maps[n].setAffine(affine);
}
}
......@@ -117,9 +117,15 @@ public class OrthoMapsCollection implements Serializable{
public void getAllTemperatures() {
for (int n = 0; n < ortho_maps.length; n++) {
ortho_maps[n].getTemperature();
ortho_maps[n].getTemperatureAndTelemetry();
}
}
public void updateLLa() { // make automatic by saving/testing file modification stamp?
for (int n = 0; n < ortho_maps.length; n++) {
ortho_maps[n].updateLLA();
}
}
public static String[] getPathsFromSorceList(
String files_list) {
......@@ -683,6 +689,12 @@ public class OrthoMapsCollection implements Serializable{
}
gpu_pair_img[n] = ortho_maps[gpu_pair[n]].getPaddedGPU (zoom_lev); // int zoom_level,
}
boolean invert_second = (debugLevel > 1000);
if (invert_second) {
for (int i = 0; i < gpu_pair_img[1].length; i++) {
gpu_pair_img[1][i]= -gpu_pair_img[1][i];
}
}
if (show_gpu_img) {
String [] dbg_titles = {ortho_maps[gpu_pair[0]].getName(),ortho_maps[gpu_pair[1]].getName()};
ShowDoubleFloatArrays.showArrays(
......@@ -1271,7 +1283,7 @@ public class OrthoMapsCollection implements Serializable{
num_passes, // int num_passes,
max_diff, // double max_diff,
ImageDtt.THREADS_MAX, // int threadsMax,
debugLevel); // int debug_level)
debugLevel-1); // int debug_level)
}
if (debugLevel > 0) {
String [] dbg_titles = {"x-raw","x_filled","y-raw","y_filled"};
......
package com.elphel.imagej.orthomosaic;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class SensorTemperatureData implements Serializable {
private static final long serialVersionUID = 1L;
double averagePixelValue;
double TLM_FPA_KELV;
double TLM_FFC_KELV;
double TLM_CORE_TEMP;
int TLM_FRAME_FFC;
int TLM_FRAME;
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
}
}
......@@ -100,10 +100,10 @@ public class TileNeibs{
int getY(int indx) {return indx / sizeX;};
int getSizeX() {
public int getSizeX() {
return sizeX;
}
int getSizeY() {
public int getSizeY() {
return sizeY;
}
......
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