Commit 0da53711 authored by Andrey Filippov's avatar Andrey Filippov

When matching a pair of image rotation is around the center of

overlapping area
parent c325ea24
...@@ -1078,10 +1078,8 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -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!) 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][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[0][1] = bounds_overlap_meters[1][0]; // vert_meters
tlo_rect_metric[1][0] = bounds_overlap_meters[0][0] // relative to other vert_meters tlo_rect_metric[1][0] = bounds_overlap_meters[0][0] - rd[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];
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];
double [][] tlo_src_metric = new double[tlo_rect_metric.length][2]; // relative to it's own vert_meters 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++) { for (int n=0; n <tlo_src_metric.length; n++) {
...@@ -1227,7 +1225,6 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -1227,7 +1225,6 @@ public class OrthoMapsCollection implements Serializable{
} }
} }
// Rectangle tile_woi = scaleRectangle (woi, GPUTileProcessor.DTT_SIZE);
double max_err= 7.0; double max_err= 7.0;
int num_bins = 1000; int num_bins = 1000;
boolean ignore_strength = false; boolean ignore_strength = false;
...@@ -1260,7 +1257,6 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -1260,7 +1257,6 @@ public class OrthoMapsCollection implements Serializable{
// TODO: use crop, keep (0,0) (woi.x+woi.width, woi.y+woi.height // TODO: use crop, keep (0,0) (woi.x+woi.width, woi.y+woi.height
if (vector_field_bkp != null) { // show_vector_field) { 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_width = tile_woi.x+tile_woi.width;
int dbg_height = tile_woi.y+tile_woi.height; int dbg_height = tile_woi.y+tile_woi.height;
double [][][][] vf_all = {vector_field_bkp,vector_field}; double [][][][] vf_all = {vector_field_bkp,vector_field};
...@@ -1350,9 +1346,9 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -1350,9 +1346,9 @@ public class OrthoMapsCollection implements Serializable{
System.out.println("correlateOrthoPair(): before LMA, ntry="+ntry); System.out.println("correlateOrthoPair(): before LMA, ntry="+ntry);
} }
} }
boolean origin_center = true; // false - old mode
OrthoPairLMA orthoPairLMA = new OrthoPairLMA(origin_center);
OrthoPairLMA orthoPairLMA = new OrthoPairLMA();
// vector_field[1] - neighbors // vector_field[1] - neighbors
double lambda = 0.1; double lambda = 0.1;
double lambda_scale_good = 0.5; double lambda_scale_good = 0.5;
......
...@@ -29,6 +29,7 @@ package com.elphel.imagej.orthomosaic; ...@@ -29,6 +29,7 @@ package com.elphel.imagej.orthomosaic;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.tileprocessor.ImageDtt; import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.QuadCLT; import com.elphel.imagej.tileprocessor.QuadCLT;
...@@ -51,7 +52,11 @@ public class OrthoPairLMA { ...@@ -51,7 +52,11 @@ public class OrthoPairLMA {
// private double pure_weight; // weight of samples only // private double pure_weight; // weight of samples only
private double [] last_ymfx = null; private double [] last_ymfx = null;
private double [][] last_jt = 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( public void prepareLMA(
// will always calculate relative affine, starting with unity // will always calculate relative affine, starting with unity
int width, // tilesX int width, // tilesX
...@@ -73,7 +78,13 @@ public class OrthoPairLMA { ...@@ -73,7 +78,13 @@ public class OrthoPairLMA {
if (tileY > max_y) max_y = tileY; if (tileY > max_y) max_y = tileY;
} }
woi = new Rectangle (min_x, min_y, max_x - min_x + 1, max_y - min_y + 1); woi = new Rectangle (min_x, min_y, max_x - min_x + 1, max_y - min_y + 1);
N = woi.width*woi.height; 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}; parameters_vector = new double [] {1,0,0,1,0,0};
setSamplesWeightsYCenters( setSamplesWeightsYCenters(
vector_XYS, vector_XYS,
...@@ -83,26 +94,20 @@ public class OrthoPairLMA { ...@@ -83,26 +94,20 @@ public class OrthoPairLMA {
if (debug_level > 1) { if (debug_level > 1) {
System.out.println("prepareLMA() 1"); System.out.println("prepareLMA() 1");
} }
// tile_centers = new double [N];
last_rms = new double [2]; 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(); initial_rms = last_rms.clone();
good_or_bad_rms = this.last_rms.clone(); good_or_bad_rms = this.last_rms.clone();
} }
public double [][] getAffine(){ public double [][] getAffine(){
return new double [][] { double [][] affine= new double [][] {
{parameters_vector[0],parameters_vector[1],parameters_vector[4]}, {parameters_vector[0],parameters_vector[1],parameters_vector[4]},
{parameters_vector[2],parameters_vector[3],parameters_vector[5]}}; {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() { public double getRms() {
return last_rms[0]; return last_rms[0];
...@@ -470,8 +475,8 @@ public class OrthoPairLMA { ...@@ -470,8 +475,8 @@ public class OrthoPairLMA {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
for (int iTile = ai.getAndIncrement(); iTile < N; iTile = ai.getAndIncrement()) if (tile_centers[iTile] !=null) { for (int iTile = ai.getAndIncrement(); iTile < N; iTile = ai.getAndIncrement()) if (tile_centers[iTile] !=null) {
double x = tile_centers[iTile][0]; double x = tile_centers[iTile][0] - origin[0];
double y = tile_centers[iTile][1]; double y = tile_centers[iTile][1] - origin[0];
double vx = (vector[0] - 1.0) * x + vector[1] * y + vector[4]; double vx = (vector[0] - 1.0) * x + vector[1] * y + vector[4];
double vy = vector[2] * x + (vector[3] - 1.0) * y + vector[5]; double vy = vector[2] * x + (vector[3] - 1.0) * y + vector[5];
fx[2 * iTile + 0] = vx; fx[2 * iTile + 0] = vx;
......
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