Commit 86efce83 authored by Andrey Filippov's avatar Andrey Filippov

Extracting radial pattern

parent 8667ae4b
......@@ -67,6 +67,20 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
"/media/elphel/NVME/lwir16-proc/ortho_videos/kernel_50_100.tiff"
};
public static String pattern_dir= "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/debug/mines/pattern_25m_zoom1/synthetic/";
public static String [] pattern_files=
{"patterns_50m_zoom1_200x200.tiff",
"patterns_50m_evening_zoom1_200x200.tiff",
"patterns_50m_evening_01_zoom1_200x200_00.tiff",
"patterns_50m_evening_02_zoom1_200x200_00.tiff",
"patterns_50m_evening_03_zoom1_200x200_00.tiff",
"patterns_50m_evening_04_zoom1_200x200_00.tiff",
"patterns_50m_evening_05_zoom1_200x200_00.tiff",
"mine1_zoom0.tiff",
"mine2_zoom0.tiff",
"mine3_zoom0.tiff",
"mine4_zoom0.tiff",
"mine6_zoom0.tiff"};
public static final String ALT_SUFFIX = "-ALT";
......@@ -1095,9 +1109,12 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
* @return square kernel as a 1-d double array or null
*/
public static double [] getConvolutionKernel() {
return getConvolutionKernel(kernel_paths.length-1);
}
public static double [] getConvolutionKernel(int choice) {
String kernel_path = null;
GenericJTabbedDialog gds = new GenericJTabbedDialog("Select kernel path",1200,400);
gds.addChoice("Kernel path:", kernel_paths, kernel_paths[kernel_paths.length-1]);
gds.addChoice("Kernel path:", kernel_paths, kernel_paths[choice]);
gds.showDialog();
if (gds.wasCanceled()) return null;
int kernel_index = gds.getNextChoiceIndex();
......@@ -3038,6 +3055,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
double [] wnd_in,
double phaseCoeff) {
// phaseCoeff = 0.5;
boolean dbg=false;
double [] data = data_in.clone();
double [] pattern = pattern_in.clone();
double [] wnd = wnd_in.clone();
......@@ -3047,7 +3065,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
for (int i = 0; i < data.length; i++) {
data[i] *= wnd[i];
}
{
if (dbg) {
String [] rslt_titles= {"original","window","windowed","pattern"};
ShowDoubleFloatArrays.showArrays(
new double[][] {data_orig, wnd, data, pattern},
......@@ -3096,7 +3114,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
}
{
if (dbg) {
String [] rslt_titles= {"corr", "original","window","windowed","pattern"};
ShowDoubleFloatArrays.showArrays(
new double[][] {corr_out, data_orig, wnd, data_orig2, pattern_orig},
......@@ -3106,7 +3124,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
convolve?"output_conv":("output_corr"+phaseCoeff),
rslt_titles);
}
System.out.println("testPhaseCorr() done");
if (dbg) System.out.println("testPhaseCorr() done");
return corr_out;
}
......@@ -3192,8 +3210,8 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public static void testPatternCorrelate(
ImagePlus imp_src) {
/*
String pattern_dir= "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/debug/mines/pattern_25m_zoom1/synthetic/";
// String pattern_file= "patterns_50m_zoom1_200x200.tiff";
String [] pattern_files=
{"patterns_50m_zoom1_200x200.tiff",
"patterns_50m_evening_zoom1_200x200.tiff",
......@@ -3202,6 +3220,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
"patterns_50m_evening_03_zoom1_200x200_00.tiff",
"patterns_50m_evening_04_zoom1_200x200_00.tiff",
"patterns_50m_evening_05_zoom1_200x200_00.tiff"};
*/
int zoomout = 2; // 1;
int corr_size = 128; // 256;
double phaseCoeff = 0.5;
......@@ -3297,7 +3316,6 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
double [][] corrs_out = new double[patterns.length][];
double [][] convolve_out = new double[patterns.length][];
// double [][] lim_corr = new double[patterns.length][];
double [][] corr_patterns = new double[patterns.length][];
for (int n = 0; n < patterns.length; n++) {
corr_patterns[n] = patternZoomCropPad(
......@@ -3331,6 +3349,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
height,
removeKnownExtension(imp_src.getTitle())+"-PATTERN_CORRS",
patt_titles); // test_titles,
if (src_marks != null) {
PointRoi roi = new PointRoi();
roi.setOptions("label");
......@@ -3881,40 +3904,16 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public static void testPatternGenerate() {
int half_size = 100;
boolean half_pix = false; // center between pixels
boolean evening_mode = false; // glare around object, use radius
double radius_out= 42;
double edge_out = 6;
double scale_out = 1.5;
boolean evening_mode = true; // false; // glare around object, use radius
double radius = 30; // 32; // 32;
double edge= 15; // 4;
double radius_in= 15; // if 0 - skip
double edge_in = 8;
double scale_in = -0.05;
double radius_out= 42;
double edge_out = 6;
double scale_out = 1.5;
double scale = -200; // black 200
if (evening_mode) {
radius_out= 42;
edge_out = 8;
scale_out =-1.5; // relative to scale
radius = 30; // 32; // 32;
edge= 15; // 4;
radius_in= 10; // if 0 - skip
edge_in = 8;
scale_in = -0.7;
scale = -40; // black 200
} else {
radius_out= 42;
edge_out = 6;
scale_out =.08;
radius = 30; // 32; // 32;
edge= 15; // 4;
radius_in= 15; // if 0 - skip
edge_in = 8;
scale_in = -0.05;
scale = -170; // black 200
}
boolean normalize = false;
int halves_number = 8; // hidden mines - number of diameter cuts
......@@ -3930,15 +3929,15 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
if (gd0.wasCanceled()) return;
evening_mode= gd0.getNextBoolean();
if (evening_mode) {
radius_out= 62; // 42;
edge_out = 40; // 8;
scale_out =-1.5; // relative to scale
radius = 30; // 32; // 32;
edge= 24; // 8; // 4;
edge= 8; // 8; // 4;
radius_in= 10; // if 0 - skip
edge_in = 8;
scale_in = -0.1; // 7;
scale = -40; // black 200
scale_in = 0; // -0.1; // 7;
radius_out= 45; // 42;
edge_out = 30; // 8;
scale_out =-1.0; // relative to scale
scale = -60; // black 200
} else {
radius_out= 42;
edge_out = 6;
......
......@@ -396,6 +396,64 @@ public class OrthoMapsCollection implements Serializable{
return bounds;
}
/**
* Use object coordinates (now metric) on the composite image to
* determine corresponding pixel coordinates of the source images
* @param objects ArrayList of objects with the scene name and xy coordinates
* in the composite image. Will fill in pixel coordinates of the objects
* @param zoom_level zoom level of the composite image
*/
public void reverseRender(
ArrayList<ObjectLocation> objects,
int zoom_level){
int [][] bounds = getBoundsPixels( // should be for rectified, {-bounds[0][0], -bounds[0][1]} - exact center
zoom_level,
null);
int width = bounds[0][1] - bounds[0][0]; // bounds[x][0] - negative
int height = bounds[1][1] - bounds[1][0];
/*
int [] indices = new int [ortho_maps.length]; //maybe will get rid of
for (int i = 0; i < indices.length; i++) {
indices[i] = i;
}
*/
final int reference_index = 0;
for (ObjectLocation ol: objects) {
int nmap =getIndex(ol.getName());
final double scale = 1.0/OrthoMap.getPixelSizeMeters(zoom_level);
final double src_scale = 1.0/OrthoMap.getPixelSizeMeters(ortho_maps[nmap].orig_zoom_level); // pix per meter
double [][] mbounds = ortho_maps[nmap].getBoundsMeters(true); // keep original bounds
double [] enu_offset = ortho_maps[reference_index].enuOffsetTo(ortho_maps[nmap]);
double [] scaled_out_center = { // xy center to apply affine to
-bounds[0][0] + scale * enu_offset[0],
-bounds[1][0] - scale * enu_offset[1]};
double [] metric_center = { // back to meters to match objects
scaled_out_center[0]/scale,
scaled_out_center[1]/scale};
double dX = ol.getMetric()[0]-metric_center[0]; // matching dX, dY in renderMulti()
double dY = ol.getMetric()[1]-metric_center[1];
// final int [][] obounds = new int [2][2]; // output (rectified, combined) image bounds, relative to thje top-left
// for (int n = 0; n< 2; n++) {
// obounds[n][0] = (int) Math.floor(scaled_out_center[n] + scale*mbounds[n][0]);
// obounds[n][1] = (int) Math.ceil (scaled_out_center[n] + scale*mbounds[n][1]);
// }
// Output window size (keep original affine - OK if will not exactly fit)
// final int ownd_width = obounds[0][1] - obounds[0][0];
// final int ownd_height = obounds[1][1] - obounds[1][0];
// final int ownd_len = ownd_width * ownd_height;
double [][] src_bounds=ortho_maps[nmap].getBoundsMeters (true); // using original affines
final double [] src_center = {-src_bounds[0][0],-src_bounds[1][0]}; // x,y center offset in the source image
final double [][] affine = ortho_maps[nmap].affine; // only here use provided
// final int src_width = ortho_maps[nmap].getImageData().width;
// final int src_height = ortho_maps[nmap].getImageData().height;
// final float [] src_img = ortho_maps[nmap].getImageData().data; // FIXME: will not use
double [] xy_src = { // pixels of the source image
src_scale * (affine[0][0]*dX + affine[0][1]*dY + affine[0][2] + src_center[0]),
src_scale * (affine[1][0]*dX + affine[1][1]*dY + affine[1][2] + src_center[1])};
ol.setPixels(xy_src);
}
}
public ImagePlus renderMulti (
......
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