Loading src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java +17 −0 Original line number Diff line number Diff line Loading @@ -861,4 +861,21 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ } return true; } public static double [][] combineAffine( double [][] ref_affine, double [][] other_affine){ Matrix m_ref = new Matrix(ref_affine); Matrix m_other = new Matrix(other_affine); Matrix A1 = m_ref.getMatrix(0,1,0,1); Matrix A2 =m_other.getMatrix(0,1,0,1); Matrix B1 = m_ref.getMatrix(0,1,2,2); Matrix B2 =m_other.getMatrix(0,1,2,2); Matrix A = A2.times(A1); Matrix B = A2.times(B1).plus(B2); double [][] affine = { {A.get(0,0),A.get(0,1),B.get(0,0)}, {A.get(1,0),A.get(1,1),B.get(1,0)}}; return affine; } } src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java +98 −69 Original line number Diff line number Diff line Loading @@ -533,6 +533,10 @@ public class OrthoMapsCollection implements Serializable{ // uses fixed_size gpu image size // TDCorrTile [] td_corr_tiles = TpTask [][] tp_tasks = new TpTask [2][]; int num_tries = 5; double prev_rms = Double.NaN; double rel_improve = 1E-3; for (int ntry = 0; ntry < num_tries; ntry++) { double [][][] vector_field = ComboMatch.rectilinearVectorField(//rectilinearCorrelate_TD( // scene0/scene1 clt_parameters, // final CLTParameters clt_parameters, Loading Loading @@ -601,7 +605,32 @@ public class OrthoMapsCollection implements Serializable{ num_iter, // int num_iter, // 20 last_run, // boolean last_run, debugLevel); // int debug_level) if (debugLevel > -1) { System.out.println("LMA result = "+lma_rslt); } if (lma_rslt < 0) { System.out.println("LMA failed, result="+lma_rslt); return null; } double rms = orthoPairLMA.getRms(); if (rms > prev_rms) { if (debugLevel > -3) { System.out.println("LMA RMSE worsened: new"+rms+" ("+ orthoPairLMA.getInitialRms()+"), prev="+prev_rms); } break; } affines_gpu[1]=OrthoMap.combineAffine(affines_gpu[1], orthoPairLMA.getAffine()); double [][] jtj = orthoPairLMA.getLastJtJ(); if ((prev_rms - rms)/prev_rms < rel_improve) { if (debugLevel > -2) { System.out.println("LMA relative RMSE improvement = "+((prev_rms - rms)/prev_rms)+" < "+rel_improve+", exiting."); } break; } prev_rms=rms; } // for (int ntry = 0; ntry < num_tries; ntry++) { // analyze result, re-run correlation /* Loading Loading @@ -637,7 +666,7 @@ public class OrthoMapsCollection implements Serializable{ } */ if (debugLevel > 1) { if (debugLevel > 1) {// show result here String [] map_names = {ortho_maps[gpu_pair[0]].getName(),ortho_maps[gpu_pair[1]].getName()}; ShowDoubleFloatArrays.showArrays( gpu_pair_img, Loading src/main/java/com/elphel/imagej/orthomosaic/OrthoPairLMA.java +24 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,30 @@ public class OrthoPairLMA { } public double [][] getAffine(){ return new double [][] { {parameters_vector[0],parameters_vector[1],parameters_vector[4]}, {parameters_vector[2],parameters_vector[3],parameters_vector[5]}}; } public double getRms() { return last_rms[0]; } public double getInitialRms() { return initial_rms[0]; } public double getWeight() { return weight; } public double [][] getLastJtJ(){ return getWJtJlambda( 0.0, // lambda, // *10, // temporary this.last_jt); } //getWJtJlambda( // lambda, // *10, // temporary // this.last_jt) private void setSamplesWeightsYCenters( final double [][] vector_XYS, final double [] weights_extra, // null or additional weights (such as elevation-based) Loading Loading
src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java +17 −0 Original line number Diff line number Diff line Loading @@ -861,4 +861,21 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ } return true; } public static double [][] combineAffine( double [][] ref_affine, double [][] other_affine){ Matrix m_ref = new Matrix(ref_affine); Matrix m_other = new Matrix(other_affine); Matrix A1 = m_ref.getMatrix(0,1,0,1); Matrix A2 =m_other.getMatrix(0,1,0,1); Matrix B1 = m_ref.getMatrix(0,1,2,2); Matrix B2 =m_other.getMatrix(0,1,2,2); Matrix A = A2.times(A1); Matrix B = A2.times(B1).plus(B2); double [][] affine = { {A.get(0,0),A.get(0,1),B.get(0,0)}, {A.get(1,0),A.get(1,1),B.get(1,0)}}; return affine; } }
src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java +98 −69 Original line number Diff line number Diff line Loading @@ -533,6 +533,10 @@ public class OrthoMapsCollection implements Serializable{ // uses fixed_size gpu image size // TDCorrTile [] td_corr_tiles = TpTask [][] tp_tasks = new TpTask [2][]; int num_tries = 5; double prev_rms = Double.NaN; double rel_improve = 1E-3; for (int ntry = 0; ntry < num_tries; ntry++) { double [][][] vector_field = ComboMatch.rectilinearVectorField(//rectilinearCorrelate_TD( // scene0/scene1 clt_parameters, // final CLTParameters clt_parameters, Loading Loading @@ -601,7 +605,32 @@ public class OrthoMapsCollection implements Serializable{ num_iter, // int num_iter, // 20 last_run, // boolean last_run, debugLevel); // int debug_level) if (debugLevel > -1) { System.out.println("LMA result = "+lma_rslt); } if (lma_rslt < 0) { System.out.println("LMA failed, result="+lma_rslt); return null; } double rms = orthoPairLMA.getRms(); if (rms > prev_rms) { if (debugLevel > -3) { System.out.println("LMA RMSE worsened: new"+rms+" ("+ orthoPairLMA.getInitialRms()+"), prev="+prev_rms); } break; } affines_gpu[1]=OrthoMap.combineAffine(affines_gpu[1], orthoPairLMA.getAffine()); double [][] jtj = orthoPairLMA.getLastJtJ(); if ((prev_rms - rms)/prev_rms < rel_improve) { if (debugLevel > -2) { System.out.println("LMA relative RMSE improvement = "+((prev_rms - rms)/prev_rms)+" < "+rel_improve+", exiting."); } break; } prev_rms=rms; } // for (int ntry = 0; ntry < num_tries; ntry++) { // analyze result, re-run correlation /* Loading Loading @@ -637,7 +666,7 @@ public class OrthoMapsCollection implements Serializable{ } */ if (debugLevel > 1) { if (debugLevel > 1) {// show result here String [] map_names = {ortho_maps[gpu_pair[0]].getName(),ortho_maps[gpu_pair[1]].getName()}; ShowDoubleFloatArrays.showArrays( gpu_pair_img, Loading
src/main/java/com/elphel/imagej/orthomosaic/OrthoPairLMA.java +24 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,30 @@ public class OrthoPairLMA { } public double [][] getAffine(){ return new double [][] { {parameters_vector[0],parameters_vector[1],parameters_vector[4]}, {parameters_vector[2],parameters_vector[3],parameters_vector[5]}}; } public double getRms() { return last_rms[0]; } public double getInitialRms() { return initial_rms[0]; } public double getWeight() { return weight; } public double [][] getLastJtJ(){ return getWJtJlambda( 0.0, // lambda, // *10, // temporary this.last_jt); } //getWJtJlambda( // lambda, // *10, // temporary // this.last_jt) private void setSamplesWeightsYCenters( final double [][] vector_XYS, final double [] weights_extra, // null or additional weights (such as elevation-based) Loading