Loading src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java +4 −8 Original line number Diff line number Diff line Loading @@ -1078,10 +1078,8 @@ public class OrthoMapsCollection implements Serializable{ double [][] tlo_rect_metric = new double [2][2]; // top-left of overlap referenced to it's own vertical point (subtract!) tlo_rect_metric[0][0] = bounds_overlap_meters[0][0]; // relative to ref vert_meters tlo_rect_metric[0][1] = bounds_overlap_meters[1][0]; // vert_meters tlo_rect_metric[1][0] = bounds_overlap_meters[0][0] // relative to other vert_meters - rd[0]; // + ortho_maps[gpu_pair[1]].vert_meters[0]- ortho_maps[gpu_pair[0]].vert_meters[0]; tlo_rect_metric[1][1] = bounds_overlap_meters[1][0] - rd[1]; // + ortho_maps[gpu_pair[1]].vert_meters[1]- ortho_maps[gpu_pair[0]].vert_meters[1]; tlo_rect_metric[1][0] = bounds_overlap_meters[0][0] - rd[0]; // relative to other vert_meters tlo_rect_metric[1][1] = bounds_overlap_meters[1][0] - rd[1]; double [][] tlo_src_metric = new double[tlo_rect_metric.length][2]; // relative to it's own vert_meters for (int n=0; n <tlo_src_metric.length; n++) { Loading Loading @@ -1227,7 +1225,6 @@ public class OrthoMapsCollection implements Serializable{ } } // Rectangle tile_woi = scaleRectangle (woi, GPUTileProcessor.DTT_SIZE); double max_err= 7.0; int num_bins = 1000; boolean ignore_strength = false; Loading Loading @@ -1260,7 +1257,6 @@ public class OrthoMapsCollection implements Serializable{ // TODO: use crop, keep (0,0) (woi.x+woi.width, woi.y+woi.height if (vector_field_bkp != null) { // show_vector_field) { // double [][] dbg_vf = new double [8 * vector_field.length][tilesX * tilesY]; int dbg_width = tile_woi.x+tile_woi.width; int dbg_height = tile_woi.y+tile_woi.height; double [][][][] vf_all = {vector_field_bkp,vector_field}; Loading Loading @@ -1350,9 +1346,9 @@ public class OrthoMapsCollection implements Serializable{ System.out.println("correlateOrthoPair(): before LMA, ntry="+ntry); } } boolean origin_center = true; // false - old mode OrthoPairLMA orthoPairLMA = new OrthoPairLMA(); OrthoPairLMA orthoPairLMA = new OrthoPairLMA(origin_center); // vector_field[1] - neighbors double lambda = 0.1; double lambda_scale_good = 0.5; Loading src/main/java/com/elphel/imagej/orthomosaic/OrthoPairLMA.java +19 −14 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ package com.elphel.imagej.orthomosaic; import java.awt.Rectangle; import java.util.concurrent.atomic.AtomicInteger; import com.elphel.imagej.gpu.GPUTileProcessor; import com.elphel.imagej.tileprocessor.ImageDtt; import com.elphel.imagej.tileprocessor.QuadCLT; Loading @@ -51,7 +52,11 @@ public class OrthoPairLMA { // private double pure_weight; // weight of samples only private double [] last_ymfx = null; private double [][] last_jt = null; private boolean origin_center = false; // true - origin in overlap center, false - top left corner (as it was) private double [] origin = null; // either {0,0} for top-left or center of the woi public OrthoPairLMA (boolean origin_center) { this.origin_center = origin_center; } public void prepareLMA( // will always calculate relative affine, starting with unity int width, // tilesX Loading @@ -73,6 +78,12 @@ public class OrthoPairLMA { if (tileY > max_y) max_y = tileY; } woi = new Rectangle (min_x, min_y, max_x - min_x + 1, max_y - min_y + 1); origin = new double[2]; if (origin_center) { origin = new double [] { woi.x + 0.5 * woi.width * GPUTileProcessor.DTT_SIZE, woi.y + 0.5 * woi.height * GPUTileProcessor.DTT_SIZE}; } N = woi.width * woi.height; parameters_vector = new double [] {1,0,0,1,0,0}; setSamplesWeightsYCenters( Loading @@ -83,26 +94,20 @@ public class OrthoPairLMA { if (debug_level > 1) { System.out.println("prepareLMA() 1"); } // tile_centers = new double [N]; last_rms = new double [2]; // double [] fx = getFxDerivs( // parameters_vector, // double [] vector, // last_jt, // final double [][] jt, // should be null or initialized with [vector.length][] // debug_level); // final int debug_level) // last_ymfx = getYminusFxWeighted( // fx, // final double [] fx, // last_rms); // final double [] rms_fp // null or [2] initial_rms = last_rms.clone(); good_or_bad_rms = this.last_rms.clone(); } public double [][] getAffine(){ return new double [][] { double [][] affine= new double [][] { {parameters_vector[0],parameters_vector[1],parameters_vector[4]}, {parameters_vector[2],parameters_vector[3],parameters_vector[5]}}; affine[0][2] -= (affine[0][0] -1) * origin[0] + affine[0][1]*origin[1]; affine[1][2] -= affine[1][0]*origin[0] + (affine[1][1] - 1) * origin[1]; return affine; } public double getRms() { return last_rms[0]; Loading Loading @@ -470,8 +475,8 @@ public class OrthoPairLMA { threads[ithread] = new Thread() { public void run() { for (int iTile = ai.getAndIncrement(); iTile < N; iTile = ai.getAndIncrement()) if (tile_centers[iTile] !=null) { double x = tile_centers[iTile][0]; double y = tile_centers[iTile][1]; double x = tile_centers[iTile][0] - origin[0]; double y = tile_centers[iTile][1] - origin[0]; double vx = (vector[0] - 1.0) * x + vector[1] * y + vector[4]; double vy = vector[2] * x + (vector[3] - 1.0) * y + vector[5]; fx[2 * iTile + 0] = vx; Loading Loading
src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java +4 −8 Original line number Diff line number Diff line Loading @@ -1078,10 +1078,8 @@ public class OrthoMapsCollection implements Serializable{ double [][] tlo_rect_metric = new double [2][2]; // top-left of overlap referenced to it's own vertical point (subtract!) tlo_rect_metric[0][0] = bounds_overlap_meters[0][0]; // relative to ref vert_meters tlo_rect_metric[0][1] = bounds_overlap_meters[1][0]; // vert_meters tlo_rect_metric[1][0] = bounds_overlap_meters[0][0] // relative to other vert_meters - rd[0]; // + ortho_maps[gpu_pair[1]].vert_meters[0]- ortho_maps[gpu_pair[0]].vert_meters[0]; tlo_rect_metric[1][1] = bounds_overlap_meters[1][0] - rd[1]; // + ortho_maps[gpu_pair[1]].vert_meters[1]- ortho_maps[gpu_pair[0]].vert_meters[1]; tlo_rect_metric[1][0] = bounds_overlap_meters[0][0] - rd[0]; // relative to other vert_meters tlo_rect_metric[1][1] = bounds_overlap_meters[1][0] - rd[1]; double [][] tlo_src_metric = new double[tlo_rect_metric.length][2]; // relative to it's own vert_meters for (int n=0; n <tlo_src_metric.length; n++) { Loading Loading @@ -1227,7 +1225,6 @@ public class OrthoMapsCollection implements Serializable{ } } // Rectangle tile_woi = scaleRectangle (woi, GPUTileProcessor.DTT_SIZE); double max_err= 7.0; int num_bins = 1000; boolean ignore_strength = false; Loading Loading @@ -1260,7 +1257,6 @@ public class OrthoMapsCollection implements Serializable{ // TODO: use crop, keep (0,0) (woi.x+woi.width, woi.y+woi.height if (vector_field_bkp != null) { // show_vector_field) { // double [][] dbg_vf = new double [8 * vector_field.length][tilesX * tilesY]; int dbg_width = tile_woi.x+tile_woi.width; int dbg_height = tile_woi.y+tile_woi.height; double [][][][] vf_all = {vector_field_bkp,vector_field}; Loading Loading @@ -1350,9 +1346,9 @@ public class OrthoMapsCollection implements Serializable{ System.out.println("correlateOrthoPair(): before LMA, ntry="+ntry); } } boolean origin_center = true; // false - old mode OrthoPairLMA orthoPairLMA = new OrthoPairLMA(); OrthoPairLMA orthoPairLMA = new OrthoPairLMA(origin_center); // vector_field[1] - neighbors double lambda = 0.1; double lambda_scale_good = 0.5; Loading
src/main/java/com/elphel/imagej/orthomosaic/OrthoPairLMA.java +19 −14 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ package com.elphel.imagej.orthomosaic; import java.awt.Rectangle; import java.util.concurrent.atomic.AtomicInteger; import com.elphel.imagej.gpu.GPUTileProcessor; import com.elphel.imagej.tileprocessor.ImageDtt; import com.elphel.imagej.tileprocessor.QuadCLT; Loading @@ -51,7 +52,11 @@ public class OrthoPairLMA { // private double pure_weight; // weight of samples only private double [] last_ymfx = null; private double [][] last_jt = null; private boolean origin_center = false; // true - origin in overlap center, false - top left corner (as it was) private double [] origin = null; // either {0,0} for top-left or center of the woi public OrthoPairLMA (boolean origin_center) { this.origin_center = origin_center; } public void prepareLMA( // will always calculate relative affine, starting with unity int width, // tilesX Loading @@ -73,6 +78,12 @@ public class OrthoPairLMA { if (tileY > max_y) max_y = tileY; } woi = new Rectangle (min_x, min_y, max_x - min_x + 1, max_y - min_y + 1); origin = new double[2]; if (origin_center) { origin = new double [] { woi.x + 0.5 * woi.width * GPUTileProcessor.DTT_SIZE, woi.y + 0.5 * woi.height * GPUTileProcessor.DTT_SIZE}; } N = woi.width * woi.height; parameters_vector = new double [] {1,0,0,1,0,0}; setSamplesWeightsYCenters( Loading @@ -83,26 +94,20 @@ public class OrthoPairLMA { if (debug_level > 1) { System.out.println("prepareLMA() 1"); } // tile_centers = new double [N]; last_rms = new double [2]; // double [] fx = getFxDerivs( // parameters_vector, // double [] vector, // last_jt, // final double [][] jt, // should be null or initialized with [vector.length][] // debug_level); // final int debug_level) // last_ymfx = getYminusFxWeighted( // fx, // final double [] fx, // last_rms); // final double [] rms_fp // null or [2] initial_rms = last_rms.clone(); good_or_bad_rms = this.last_rms.clone(); } public double [][] getAffine(){ return new double [][] { double [][] affine= new double [][] { {parameters_vector[0],parameters_vector[1],parameters_vector[4]}, {parameters_vector[2],parameters_vector[3],parameters_vector[5]}}; affine[0][2] -= (affine[0][0] -1) * origin[0] + affine[0][1]*origin[1]; affine[1][2] -= affine[1][0]*origin[0] + (affine[1][1] - 1) * origin[1]; return affine; } public double getRms() { return last_rms[0]; Loading Loading @@ -470,8 +475,8 @@ public class OrthoPairLMA { threads[ithread] = new Thread() { public void run() { for (int iTile = ai.getAndIncrement(); iTile < N; iTile = ai.getAndIncrement()) if (tile_centers[iTile] !=null) { double x = tile_centers[iTile][0]; double y = tile_centers[iTile][1]; double x = tile_centers[iTile][0] - origin[0]; double y = tile_centers[iTile][1] - origin[0]; double vx = (vector[0] - 1.0) * x + vector[1] * y + vector[4]; double vy = vector[2] * x + (vector[3] - 1.0) * y + vector[5]; fx[2 * iTile + 0] = vx; Loading