Commit d3389b58 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

More on quaternions - affines

parent 0abd52b8
Loading
Loading
Loading
Loading
+63 −8
Original line number Original line Diff line number Diff line
@@ -177,7 +177,7 @@ public class ComboMatch {
		
		
		
		
		boolean use_saved_collection = true; // false;
		boolean use_saved_collection = true; // false;
		boolean save_collection =     true;
		boolean save_collection =     false; // true;
		boolean process_correlation = true; // use false to save new version of data
		boolean process_correlation = true; // use false to save new version of data
		int     num_tries_fit =       10;
		int     num_tries_fit =       10;
		boolean update_match =        true; // use false to save new version of data
		boolean update_match =        true; // use false to save new version of data
@@ -210,7 +210,7 @@ public class ComboMatch {
			pattern_match = false;
			pattern_match = false;
		}
		}
		
		
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,800);
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,900);
//		gd.addChoice      ("Files list/data path (w/o extension):", FILES_LISTS_PATHS, FILES_LISTS_PATHS[default_list_choice]);
//		gd.addChoice      ("Files list/data path (w/o extension):", FILES_LISTS_PATHS, FILES_LISTS_PATHS[default_list_choice]);
		gd.addChoice      ("Files list/data path (w/o extension):", FILES_LISTS_PATHS, omtch_img_set);
		gd.addChoice      ("Files list/data path (w/o extension):", FILES_LISTS_PATHS, omtch_img_set);
		gd.addCheckbox    ("Use saved maps collection ", use_saved_collection, " (if available). If false - use files list.");
		gd.addCheckbox    ("Use saved maps collection ", use_saved_collection, " (if available). If false - use files list.");
@@ -433,7 +433,7 @@ public class ComboMatch {
					};
					};
			
			
			
			
			GenericJTabbedDialog gdo = new GenericJTabbedDialog("Set image pair",1200,900);
			GenericJTabbedDialog gdo = new GenericJTabbedDialog("Set image pair",1200,1000);
			gdo.addNumericField("Correlation size",          corr_size,       0,4,"",
			gdo.addNumericField("Correlation size",          corr_size,       0,4,"",
					"Correlation size, power of 2");
					"Correlation size, power of 2");
			gdo.addNumericField("Extracted size",            extr_size,  0,4,"",
			gdo.addNumericField("Extracted size",            extr_size,  0,4,"",
@@ -858,6 +858,12 @@ public class ComboMatch {
		}
		}
        if (process_correlation || render_match || pattern_match || test_multi_lma) {
        if (process_correlation || render_match || pattern_match || test_multi_lma) {
//        	int [] gpu_pair;
//        	int [] gpu_pair;
			boolean removeTilt =   false;
			boolean removeRot =    false;
			boolean removeScale =  false;
			boolean removeOffset = false;
			boolean max_is_scale = false;

        	if (gpu_spair == null) {
        	if (gpu_spair == null) {
        		ArrayList<Point> pairs_list = new ArrayList<Point>(); 
        		ArrayList<Point> pairs_list = new ArrayList<Point>(); 
        		for (OrthoMap map : maps_collection.ortho_maps) {
        		for (OrthoMap map : maps_collection.ortho_maps) {
@@ -905,7 +911,7 @@ public class ComboMatch {
        		boolean flt_show_alt =       clt_parameters.imp.flt_show_alt;      //  true;
        		boolean flt_show_alt =       clt_parameters.imp.flt_show_alt;      //  true;
        		boolean flt_update_config = false;
        		boolean flt_update_config = false;
        		String  flt_extra_line =    "--- select a single image ---";
        		String  flt_extra_line =    "--- select a single image ---";
				GenericJTabbedDialog gdf = new GenericJTabbedDialog("Select pairs filter/display",800,500);
				GenericJTabbedDialog gdf = new GenericJTabbedDialog("Select pairs filter/display",800,600);
				gdf.addCheckbox    ("Filter pairs",                flt_list, "Filter available pairs.");
				gdf.addCheckbox    ("Filter pairs",                flt_list, "Filter available pairs.");
				gdf.addCheckbox    ("Keep undefined pairs only",   flt_undef_only, "Keep only undefined pairs (affines== null).");
				gdf.addCheckbox    ("Keep undefined pairs only",   flt_undef_only, "Keep only undefined pairs (affines== null).");
				gdf.addNumericField("Minimal scene overlap (0..1)",flt_min_overlap,  3,7,"", "Minimal overlap of the scenes to keep (0-no overlap, 1.0 - smaller scene is inside the parger one.");
				gdf.addNumericField("Minimal scene overlap (0..1)",flt_min_overlap,  3,7,"", "Minimal overlap of the scenes to keep (0-no overlap, 1.0 - smaller scene is inside the parger one.");
@@ -999,15 +1005,27 @@ public class ComboMatch {
						false,             // boolean          use_tab,
						false,             // boolean          use_tab,
						flt_extra_line);   // String           extra_line)
						flt_extra_line);   // String           extra_line)
				
				
				GenericJTabbedDialog gdc = new GenericJTabbedDialog("Select image pair",1200,100);
				GenericJTabbedDialog gdc = new GenericJTabbedDialog("Select image pair",1200,300);
				int num_choice_lines = 50;
				int num_choice_lines = 50;
				gdc.addChoice("Image pair:",
				gdc.addChoice("Image pair:",
						choices_all,
						choices_all,
						choices_all[choices_all.length - 1], // -1],
						choices_all[choices_all.length - 1], // -1],
						"Select processed image pair or request a single image selection", num_choice_lines);
						"Select processed image pair or request a single image selection", num_choice_lines);
				gdc.addCheckbox    ("Remove tilt",             removeTilt,   "Remove tilts from the pairwise affine transform.");
				gdc.addCheckbox    ("Remove Rotation",         removeRot,    "Remove rotation from the pairwise affine transform.");
				gdc.addCheckbox    ("Remove Scale",            removeScale,  "Remove scale from the pairwise affine transform.");
				gdc.addCheckbox    ("Remove Translation",      removeOffset, "Remove translation from the pairwise affine transform.");
				gdc.addCheckbox    ("Max eigenvalue is scale", max_is_scale, "Maximal eigenvalue is scale (false - minimal is).");
				//        			boolean max_is_scale = false;

				gdc.showDialog();
				gdc.showDialog();
				if (gdc.wasCanceled()) return false;
				if (gdc.wasCanceled()) return false;
				int pair=      gdc.getNextChoiceIndex();
				int pair=      gdc.getNextChoiceIndex();
				removeTilt =   gdc.getNextBoolean();
				removeRot =    gdc.getNextBoolean();
				removeScale =  gdc.getNextBoolean();
				removeOffset = gdc.getNextBoolean();
				max_is_scale = gdc.getNextBoolean();
				if (pair >= (choices_all.length -1)) {
				if (pair >= (choices_all.length -1)) {
					int default_choice = 0;
					int default_choice = 0;
					int num_scene_lines = 50;
					int num_scene_lines = 50;
@@ -1118,7 +1136,36 @@ public class ComboMatch {
        			
        			
        			
        			
        		} else {
        		} else {
        			affine1 = pairwiseOrthoMatch.getAffine();
        			affine1 = pairwiseOrthoMatch.getAffine().clone();
        			if (debugLevel > -4) {
            			System.out.println("removeTilt="+  removeTilt);
            			System.out.println("removeRot="+   removeRot);
            			System.out.println("removeScale="+ removeScale);
            			System.out.println("removeOffset="+removeOffset);
            			System.out.println("max_is_scale="+max_is_scale);
            			if (removeTilt || removeRot || removeScale || removeOffset) {
                			SingularValueDecomposition svd_affine_pair =  SingularValueDecomposition.singularValueDecomposeScaleTiltGamma(affine1, true); // y_down_ccw); // boolean y_down_ccw)
                			System.out.println("Full (original) affine transform:");
            	        	System.out.println(QuatUtils.affinesToString(affine1, "full_affine"));
            	        	System.out.println("full_affine_svd" + svd_affine_pair.toString(true)); // use_degrees));
            			}
        			}
        			affine1 = SingularValueDecomposition.removeTiltRotScale(
        					affine1,       // double [][] A,
        					removeTilt,    // boolean removeTilt,
        					removeRot,     // boolean removeRot,
        					removeScale,   // boolean removeScale,
        					removeOffset,  // boolean removeOffset)
        					max_is_scale); //boolean max_is_scale)
        			if (debugLevel > -4) {
            			if (removeTilt || removeRot || removeScale || removeOffset) {
                			SingularValueDecomposition svd_affine_pair =  SingularValueDecomposition.singularValueDecomposeScaleTiltGamma(affine1, true); // y_down_ccw); // boolean y_down_ccw)
                			System.out.println("Final differential affine transform:");
            	        	System.out.println(QuatUtils.affinesToString(affine1, "affine1    "));
            	        	System.out.println("affine1_svd    " + svd_affine_pair.toString(true)); // use_degrees));
            			}
        			}
        			
        			double [][][] affines = {affine0,affine1};
        			double [][][] affines = {affine0,affine1};
        			int [] zooms = {initial_zoom, min_zoom_lev, 1000,1000}; // make automatic
        			int [] zooms = {initial_zoom, min_zoom_lev, 1000,1000}; // make automatic
//        			double scale = 2.0; // scale vectors when warping;
//        			double scale = 2.0; // scale vectors when warping;
@@ -1239,6 +1286,14 @@ public class ComboMatch {
        				}
        				}
        				if (render_match) {
        				if (render_match) {
        					String title=String.format("multi_%03d-%03d_%s-%s_zoom%d_%d",gpu_pair[0],gpu_pair[1],gpu_spair[0],gpu_spair[1],min_zoom_lev,zoom_lev);
        					String title=String.format("multi_%03d-%03d_%s-%s_zoom%d_%d",gpu_pair[0],gpu_pair[1],gpu_spair[0],gpu_spair[1],min_zoom_lev,zoom_lev);
        					if (removeTilt || removeRot || removeScale || removeOffset) {
        						title += "_no-";
        						if (removeTilt)   title += "T";
        						if (removeRot)    title += "R";
        						if (removeScale)  title += "S";
        						if (removeOffset) title += "O";
        						if (max_is_scale) title += "X"; 
        					}
        					// Avoid renderMulti() - it duplicates code renderMultiDouble()
        					// Avoid renderMulti() - it duplicates code renderMultiDouble()
        					int eq_mode = 2; // calculate
        					int eq_mode = 2; // calculate
        					ImagePlus imp_img_pair = 	maps_collection.renderMulti (
        					ImagePlus imp_img_pair = 	maps_collection.renderMulti (
@@ -2077,7 +2132,7 @@ adjusted affines[1] for a pair: 1694564291_293695/1694564778_589341
					{2139.833, 1474.5},
					{2139.833, 1474.5},
					{ 461.5,   1493.5}}};
					{ 461.5,   1493.5}}};
		boolean set_coords = true; // false;
		boolean set_coords = true; // false;
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1090,900);
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Select processing moder",1090,900);
		gd.addStringField ("First image path",  image_paths[0], 120, "First image full path");		
		gd.addStringField ("First image path",  image_paths[0], 120, "First image full path");		
		gd.addStringField ("Second image path", image_paths[1], 120, "Second image full path");		
		gd.addStringField ("Second image path", image_paths[1], 120, "Second image full path");		
		gd.addCheckbox    ("Set image markers to following coordinates", set_coords, "Delete markers and set them according to data.");
		gd.addCheckbox    ("Set image markers to following coordinates", set_coords, "Delete markers and set them according to data.");
Loading