Commit f97f3155 authored by Andrey Filippov's avatar Andrey Filippov

Implemented OrthoMapCollection class and possibility to save maps state

w/o images
parent 624f1144
......@@ -109,7 +109,7 @@ import com.elphel.imagej.ims.EventLogger;
import com.elphel.imagej.ims.Imx5;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.orthomosaic.ComboMap;
import com.elphel.imagej.orthomosaic.OrthoMap;
import com.elphel.imagej.orthomosaic.ComboMatch;
import com.elphel.imagej.readers.ChangeImageResolution;
import com.elphel.imagej.readers.DumpImageMetadata;
......@@ -5732,7 +5732,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
IJ.showMessage("Error", "No images selected");
return;
}
ComboMap.testVideo(imp_sel);
OrthoMap.testVideo(imp_sel);
}
}
......
......@@ -45,7 +45,8 @@ public class ComboMatch {
GPU_TILE_PROCESSOR = gpu_tile_processor;
// find -L /media/elphel/SSD3-4GB/lwir16-proc/berdich3/linked/linked_1697875868-1697879449-b/ -type f -name "*-GCORR-GEO.tiff" | sort > GCORR-GEO.list
String files_list_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_berdich2.list";
String files_list_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_03_short.list";
String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/ortho_maps_collection.data";
double [][][] image_enuatr = {{{0,0,0},{0,0,0}},{{0,0,0},{0,0,0}}};
int gpu_width= clt_parameters.imp.rln_gpu_width; // 3008;
......@@ -53,8 +54,13 @@ public class ComboMatch {
int zoom_lev = -4; // 0; // +1 - zoom in twice, -1 - zoom out twice
boolean use_alt = false;
boolean show_centers = true;
boolean use_saved_collection = false;
boolean save_collection = true;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,800);
gd.addStringField ("Image list full path ", files_list_path, 180, "Image listfull path.");
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.addCheckbox ("Use saved maps collection", use_saved_collection, "If false - use files list.");
gd.addCheckbox ("Save maps collection", save_collection, "If false - use files list.");
// 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");
// }
......@@ -81,11 +87,11 @@ public class ComboMatch {
gd.showDialog();
if (gd.wasCanceled()) return false;
files_list_path = gd.getNextString();
// for (int n = 0; n < image_paths_pre.length; n++) {
// image_paths_pre[n] = gd.getNextString();
// }
// image_paths_pre[0] = gd.getNextString();
// image_paths_pre[1] = gd.getNextString();
orthoMapsCollection_path = gd.getNextString();
use_saved_collection = gd.getNextBoolean();
save_collection = 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();
......@@ -98,58 +104,71 @@ public class ComboMatch {
gpu_width = (int) gd.getNextNumber();
gpu_height = (int) gd.getNextNumber();
ComboMap.setGPUWidthHeight(gpu_width,gpu_height);
OrthoMap.setGPUWidthHeight(gpu_width,gpu_height);
show_centers = gd.getNextBoolean();
use_alt = gd.getNextBoolean();
// ComboMap[] combo_maps = ComboMap.initializeComboMaps(
// full_paths); // String [] image_paths);
ComboMap[] combo_maps = ComboMap.initializeComboMaps(
files_list_path); // String [] image_paths);
String [] map_names = ComboMap.getNames(combo_maps);
OrthoMapsCollection maps_collection=null;
if (use_saved_collection) {
try {
maps_collection = OrthoMapsCollection.readOrthoMapsCollection (orthoMapsCollection_path);
} catch (ClassNotFoundException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
maps_collection = new OrthoMapsCollection(files_list_path); // should have ".list" extensiohn
}
String [] names = maps_collection.getNames();
// which pair to compare
int [] gpu_pair = {1,2};
String [] gpu_spair = {names[gpu_pair[0]],names[gpu_pair[1]]};
int [] origin = new int[2];
ImagePlus imp_img = ComboMap.renderMulti (
ImagePlus imp_img = maps_collection.renderMulti (
"multi_"+zoom_lev, // String title,
false, // boolean use_alt,
show_centers, // boolean show_centers,
combo_maps, // ComboMap [] maps,
zoom_lev, // int zoom_level,
origin); // int [] origin){
imp_img.show();
ImagePlus imp_alt = null;
if (use_alt) {
imp_alt =ComboMap.renderMulti (
imp_alt =maps_collection.renderMulti (
"multi_alt_"+zoom_lev, // String title,
true, // boolean use_alt,
show_centers, // boolean show_centers,
combo_maps, // ComboMap [] maps,
zoom_lev, // int zoom_level,
origin); // int [] origin){
imp_alt.show();
}
// which pair to compare
int [] gpu_pair = {1,2};
float [][] gpu_pair_img = new float [2][];
for (int n = 0; n < gpu_pair.length; n++) {
gpu_pair_img[n] = combo_maps[gpu_pair[n]].getPaddedGPU (
zoom_lev, // int zoom_level,
gpu_width, // int gpu_width,
gpu_height); // int gpu_height)
}
float [][] gpu_pair_img = maps_collection.getPaddedPairGPU(
gpu_spair, // String [] spair,
zoom_lev); // int zoom_lev);
ShowDoubleFloatArrays.showArrays(
gpu_pair_img,
gpu_width,
gpu_height,
true,
"gpu_pair-zoom"+zoom_lev+"-"+combo_maps[gpu_pair[0]].getName()+"-"+combo_maps[gpu_pair[1]].getName(),
map_names);
"gpu_pair-zoom"+zoom_lev+"-"+gpu_spair[0]+"-"+gpu_spair[1],
gpu_spair);
if (save_collection) {
try {
maps_collection.writeOrthoMapsCollection(orthoMapsCollection_path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (debugLevel <1000) {
return true;
}
/* */
OrthoMap [] ortho_maps = maps_collection.getMaps(); // just temporarily
int [] widths = new int[imp_src.length];
int [] heights = new int[imp_src.length];
for (int n = 0; n < imp_src.length; n++) {
......@@ -178,8 +197,8 @@ public class ComboMatch {
}
/* */
if (show_centers) {
for (int n = 0; n < combo_maps.length; n++) {
combo_maps[n].getOriginalImage(true);
for (int n = 0; n < ortho_maps.length; n++) {
ortho_maps[n].getOriginalImage(true);
}
}
/*
......@@ -187,11 +206,12 @@ public class ComboMatch {
imp_src[n].show();
}
*/
if (combo_maps[0].orig_zoom_level != combo_maps[1].orig_zoom_level) {
if (ortho_maps[0].orig_zoom_level != ortho_maps[1].orig_zoom_level) {
System.out.println("openTestPairGps() does not yet handle different scales, aborting");
return false;
}
double [] enu_diff = combo_maps[0].enuOffsetTo(combo_maps[0]);
double [] enu_diff = ortho_maps[0].enuOffsetTo(ortho_maps[0]);
double pix_size1 = ElphelTiffReader.getPixelSize(imp_prop[0])[0];
double [] pix_shift = {enu_diff[0]/pix_size1, -enu_diff[1]/pix_size1}; // E->X, N->-Y
......
package com.elphel.imagej.orthomosaic;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class PairwiseOrthoMatch implements Serializable {
public PairwiseOrthoMatch(double [][] affine, double [][] jtj) {
this.affine = affine;
this.jtj = jtj;
}
private static final long serialVersionUID = 1L;
public double [][] affine = new double[2][3];
public transient double [][] jtj = new double [6][6];
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
for (int i = 0; i < jtj.length; i++) {
for (int j = i; j < jtj[i].length; j++) {
oos.writeObject(jtj[i][j]);
}
}
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
for (int i = 0; i < jtj.length; i++) {
for (int j = i; j < jtj[i].length; j++) {
jtj[i][j] = (Double) ois.readObject();
if (j > i) {
jtj[j][i] = jtj[i][j];
}
}
}
}
//private void readObjectNoData() throws ObjectStreamException; // used to modify default values
}
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