Commit 4bdd4cd8 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Cleaning up

parent 064ff7ca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1221,7 +1221,7 @@ public class PixelMapping {
    		if (saveTiff){
    			String outPath=((resultDirectory.length()<1)?"":(resultDirectory+Prefs.getFileSeparator()))+impOverlap.getTitle()+".tiff";
    			try {
    				(new EyesisTiff()).saveTiff(
    				EyesisTiff.saveTiff(
    						impOverlap,
    						outPath,
    						3, // float32
+1 −1
Original line number Diff line number Diff line
@@ -2743,7 +2743,7 @@ public class EyesisCorrections {
					try {
						(new EyesisTiff()).saveTiffARGB32(
								imp,
								path, // +".tiff",
								path+".tiff", //path, // +".tiff",
								false, // correctionsParameters.imageJTags,
								debugLevel);
					} catch (IOException e) {
+17 −29
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ the type of pixel data in this file getPixelType()



	public void saveTiff(
	public static void saveTiff(
			ImagePlus imp,
			String path,
			int mode,     // 0 - 8-bit, 1 - 16-bit, 2 - 32-bit unsigned, 3 - 32FP (only if source image is a 4-stack of FP)
@@ -316,7 +316,7 @@ the type of pixel data in this file getPixelType()
		IJ.showMessage("Not yet implemented for this image type");
	}

	public void saveTiffARGB(
	public static void saveTiffARGB(
			ImagePlus imp,
			String path,
			int mode,     // 0 - 8-bit, 1 - 16-bit, 2 - 32-bit unsigned, 3 - 32FP (only if source image is a 4-stack of FP)
@@ -428,12 +428,14 @@ the type of pixel data in this file getPixelType()
			return;
		}
		//        System.out.println("saveTiffARGBFloat32(): mode="+mode+" pixelType="+pixelType+" bw="+bw);
//		ExifGPSTagSet gps_set = new ExifGPSTagSet();
//		EXIFGPSTagSet gps_set = new EXIFGPSTagSet();
		IFD ifd=new IFD();
		ifd.put(new Integer(IFD.LITTLE_ENDIAN), new Boolean(false));
		ifd.put(IFD.LITTLE_ENDIAN, false);
		//        ifd.put(new Integer(IFD.LITTLE_ENDIAN), new Boolean(true));
		ifd.put(new Integer(IFD.IMAGE_WIDTH), imp.getWidth());
		ifd.put(new Integer(IFD.IMAGE_LENGTH), imp.getHeight());
		ifd.put(new Integer(IFD.SAMPLES_PER_PIXEL), 4);
		ifd.put(IFD.IMAGE_WIDTH, imp.getWidth());
		ifd.put(IFD.IMAGE_LENGTH, imp.getHeight());
		ifd.put(IFD.SAMPLES_PER_PIXEL, 4);
		ifd.putIFDValue(IFD.SOFTWARE, "Elphel Eyesis");
		ifd.putIFDValue(IFD.IMAGE_DESCRIPTION, description);
		// copy some other data?
@@ -484,7 +486,7 @@ the type of pixel data in this file getPixelType()
				true); // boolean last)
	}

	public void saveTiffARGB32(
	public static void saveTiffARGB32(
			ImagePlus imp,
			String path,
			boolean imageJTags,
@@ -511,18 +513,19 @@ the type of pixel data in this file getPixelType()
			bytes[pIndex++]=(byte) ((iPixels[i]>>24)& 0xff); // alpha
		}
		IFD ifd=new IFD();
		ifd.put(new Integer(IFD.LITTLE_ENDIAN), new Boolean(false));
		ifd.put(IFD.LITTLE_ENDIAN, false);
		//        ifd.put(new Integer(IFD.LITTLE_ENDIAN), new Boolean(true));
		ifd.put(new Integer(IFD.IMAGE_WIDTH), imp.getWidth());
		ifd.put(new Integer(IFD.IMAGE_LENGTH), imp.getHeight());
		ifd.put(new Integer(IFD.SAMPLES_PER_PIXEL), 4);
		ifd.put(IFD.IMAGE_WIDTH, imp.getWidth());
		ifd.put(IFD.IMAGE_LENGTH, imp.getHeight());
		ifd.put(IFD.SAMPLES_PER_PIXEL, 4);
		ifd.putIFDValue(IFD.SOFTWARE, "Elphel Eyesis");
		ifd.putIFDValue(IFD.IMAGE_DESCRIPTION, description);
		// copy some other data?
		ifd.putIFDValue(IFD.COMPRESSION, 1); //TiffCompression.UNCOMPRESSED);
		ifd.putIFDValue(IFD.PHOTOMETRIC_INTERPRETATION,2); // RGB
		ifd.putIFDValue(IFD.EXTRA_SAMPLES,2); // extra bytes (over 3) meaning Unassociated alpha data

//		ifd.putIFDValue(IFD.EXTRA_SAMPLES,2); // extra bytes (over 3) meaning Unassociated alpha data
		ifd.putIFDValue(IFD.EXTRA_SAMPLES,1); // extra bytes (over 3) meaning Unassociated alpha data
		ifd.putIFDValue(IFD.SAMPLE_FORMAT,1); // 
		//        int [] bpsArray={8,8,8,8};
		//        ifd.putIFDValue(IFD.BITS_PER_SAMPLE, bpsArray); // will be done automatically
		if (imp.getProperty("XPosition")!=null) {
@@ -548,24 +551,9 @@ the type of pixel data in this file getPixelType()
			int index=0;
			for (int i=0;i<ImageJInfoMagic.length;i++) bInfo[index++]=ImageJInfoMagic[i];
			for (int i=skipFirstBytes;i<bInfoBody.length;      i++) bInfo[index++]=bInfoBody[i]; // first 2 bytes {-2, -1} ???
			/*
        	StringBuffer sb=new StringBuffer("bInfo: ");
        	for (int i=0;i<bInfo.length;i++) sb.append(bInfo[i]+" ");
        	System.out.println(sb.toString());
        	sb=new StringBuffer("ImageJInfoMagic: ");
        	for (int i=0;i<ImageJInfoMagic.length;i++) sb.append(ImageJInfoMagic[i]+" ");
        	System.out.println(sb.toString());
        	sb=new StringBuffer("bInfoBody: ");
        	for (int i=0;i<bInfoBody.length;i++) sb.append(bInfoBody[i]+" ");
        	System.out.println(sb.toString());
        	System.out.println("info[0]="+info.charAt(0));
        	System.out.println("info[1]="+info.charAt(1));
        	System.out.println("info[2]="+info.charAt(2));
			 */
			long [] imageJcounts={12, bInfoBody.length-skipFirstBytes};
			ifd.putIFDValue(IFDImageJByteCounts, imageJcounts);
			ifd.putIFDValue(IFDImageJInfo, bInfo);

		}
		(new File(path)).delete(); // Otherwise TiffSaver appends!
		TiffSaver tiffSaver = new TiffSaver(path);
@@ -584,7 +572,7 @@ the type of pixel data in this file getPixelType()



	public void propertiesTiff(ImagePlus imp){
	public static void propertiesTiff(ImagePlus imp){
		FileInfo fi = imp.getOriginalFileInfo();
		if ((fi==null) ||(fi.directory==null) ||  (fi.fileFormat!=FileInfo.TIFF)) {
			IJ.error("TIFF Dumper", "File path not available or not TIFF file");
+80 −19
Original line number Diff line number Diff line
@@ -51,11 +51,19 @@ public class IntersceneMatchParameters {
	public  double  sfm_same_weight =    0.8;    // correction weight when new SfM gain is the same as the old one
	public  int     sfm_shrink =         2;      // shrink sfm gain area before applying sfm_fade_sigma
    public  double  sfm_fade_sigma =     3.0;    // fade SfM gains at the edges 
	public  double  sfm_min_str =        0.4;    // update if correction strength exceeds
	public  double  sfm_min_str1 =       0.2;    // update if correction strength exceeds
	public  double  sfm_min_str16 =      0.4;    // update if correction strength exceeds (for >=16 pairs)
	public  boolean sfm_use_neibs =      true;   // use neighbors if individual corr is too weak
	public  double  sfm_neib_too_str=    0.4;    // do not count neighbors stronger than that
	public  double  sfm_neib_str=        0.5;    // update if no-individual and neibs correction strength exceeds 
	public  double  sfm_neib_too_str1=   0.3;    // do not count neighbors stronger than that
	public  double  sfm_neib_too_str16=  0.4;    // do not count neighbors stronger than that  (for >=16 pairs)
	public  double  sfm_neib_str1=       0.2;    // update if no-individual and neibs correction strength exceeds 
	public  double  sfm_neib_str16=      0.5;    // update if no-individual and neibs correction strength exceeds  (for >=16 pairs) 
	public  int     sfm_extrap_steps =   5;      // extrapolate disparity this number over undefined by SfM area
	public  int     sfm_extrap_radius =  5;      // find tilt for extrapolation using this radius circle around the new tile
	
	public boolean  sfm_average_neibs = false;   // Average neighbors disparity among them  
	public boolean  sfm_fill_weak =     false;   // Fill too weak tiles from nearest neighbors
	public boolean  sfm_extrapolate =   false;   // Extrapolate tiles with no SfM data (near edges)
	
	public double [] getImsMountATR() {
		return new double [] {
@@ -469,14 +477,31 @@ public class IntersceneMatchParameters {
				"Shrink sfm gain area before applying sfm_fade_sigmas.");
		gd.addNumericField("Fade SfM area sigma",                    this.sfm_fade_sigma, 5,8,"",
				"Fade SfM gains at the edges.");
		gd.addNumericField("Minimal correlation strength",           this.sfm_min_str, 5,8,"",
		gd.addNumericField("Minimal correlation strength",           this.sfm_min_str1, 5,8,"",
				"Update if correction strength of individual tiles exceeds.");
		gd.addNumericField("Minimal correlation strength >= 16 pairs", this.sfm_min_str16, 5,8,"",
				"Update if correction strength of individual tiles exceeds (for >=16 pairs).");
		gd.addCheckbox ("Use neighbors",                             this.sfm_use_neibs,
				"Use neighbors if individual corr is too weak.");
		gd.addNumericField("Too strong neighbors",                   this.sfm_neib_too_str, 5,8,"",
		gd.addNumericField("Too strong neighbors >= 16 pairs",       this.sfm_neib_too_str1, 5,8,"",
				"Do not accumulate neighbors stronger than that.");
		gd.addNumericField("Minimal neighbors strength",             this.sfm_neib_str, 5,8,"",
		gd.addNumericField("Too strong neighbors",                   this.sfm_neib_too_str16, 5,8,"",
				"Do not accumulate neighbors stronger than that (for >=16 pairs).");
		gd.addNumericField("Minimal neighbors strength",             this.sfm_neib_str1, 5,8,"",
				"Update if no-individual and neighbors correction strength exceeds this.");
		gd.addNumericField("Minimal neighbors strength >=16 pairs",  this.sfm_neib_str16, 5,8,"",
				"Update if no-individual and neighbors correction strength exceeds this (for >=16 pairs).");
		gd.addNumericField("Extrapolation steps",                    this.sfm_extrap_steps, 0,3,"",
				"Extrapolate disparity this number of times over the undefined by SfM area.");
		gd.addNumericField("Extrapolation radius",                   this.sfm_extrap_radius, 0,3,"",
				"Find tilt for extrapolation using this radius circle around the new tile.");
		gd.addCheckbox ("Average neighbors",                         this.sfm_average_neibs,
				"Average neighbors disparity among them.");
		gd.addCheckbox ("Fill too weak tiles",                       this.sfm_fill_weak,
				"Fill too weak tiles from nearest neighbors.");
		gd.addCheckbox ("Extrapolate no SfM data",                   this.sfm_extrapolate,
				"Extrapolate tiles with no SfM data (near edges).");
		
		
		gd.addTab         ("Scene Series", "Processing series of scenes and multi-series sets");
		gd.addMessage  ("Build series options");
@@ -1156,10 +1181,19 @@ public class IntersceneMatchParameters {
        this.sfm_same_weight =                gd.getNextNumber();
        this.sfm_shrink =               (int) gd.getNextNumber();
        this.sfm_fade_sigma =                 gd.getNextNumber(); 
        this.sfm_min_str =                    gd.getNextNumber(); 
        this.sfm_min_str1 =                   gd.getNextNumber(); 
        this.sfm_min_str16 =                  gd.getNextNumber(); 
        this.sfm_use_neibs =                  gd.getNextBoolean(); 
        this.sfm_neib_too_str =               gd.getNextNumber(); 
        this.sfm_neib_str =	                  gd.getNextNumber(); 
        this.sfm_neib_too_str1 =              gd.getNextNumber(); 
        this.sfm_neib_too_str16 =             gd.getNextNumber(); 
        this.sfm_neib_str1 =	              gd.getNextNumber(); 
        this.sfm_neib_str16 =	              gd.getNextNumber(); 
        this.sfm_extrap_steps =         (int) gd.getNextNumber();
        this.sfm_extrap_radius =        (int) gd.getNextNumber();
		this.sfm_average_neibs =              gd.getNextBoolean();
		this.sfm_fill_weak =                  gd.getNextBoolean();
		this.sfm_extrapolate =                gd.getNextBoolean();
        
		this.center_reference =               gd.getNextBoolean();
		this.force_ref_dsi =                  gd.getNextBoolean();
		this.force_orientations =             gd.getNextBoolean();
@@ -1522,10 +1556,19 @@ public class IntersceneMatchParameters {
		properties.setProperty(prefix+"sfm_same_weight",               this.sfm_same_weight+"");               // double
		properties.setProperty(prefix+"sfm_shrink",                    this.sfm_shrink+"");                    // int
		properties.setProperty(prefix+"sfm_fade_sigma",                this.sfm_fade_sigma+"");                // double
		properties.setProperty(prefix+"sfm_min_str",                   this.sfm_min_str+"");                   // double
		properties.setProperty(prefix+"sfm_min_str1",                  this.sfm_min_str1+"");                  // double
		properties.setProperty(prefix+"sfm_min_str16",                 this.sfm_min_str16+"");                 // double
		properties.setProperty(prefix+"sfm_use_neibs",                 this.sfm_use_neibs+"");                 // boolean
		properties.setProperty(prefix+"sfm_neib_too_str",              this.sfm_neib_too_str+"");              // double
		properties.setProperty(prefix+"sfm_neib_str",                  this.sfm_neib_str +"");                 // double
		properties.setProperty(prefix+"sfm_neib_too_str1",             this.sfm_neib_too_str1+"");             // double
		properties.setProperty(prefix+"sfm_neib_too_str16",            this.sfm_neib_too_str16+"");            // double
		properties.setProperty(prefix+"sfm_neib_str1",                 this.sfm_neib_str1 +"");                // double
		properties.setProperty(prefix+"sfm_neib_str16",                this.sfm_neib_str16 +"");               // double
		properties.setProperty(prefix+"sfm_extrap_steps",              this.sfm_extrap_steps+"");              // int
		properties.setProperty(prefix+"sfm_extrap_radius",             this.sfm_extrap_radius+"");             // int
		properties.setProperty(prefix+"sfm_average_neibs",             this.sfm_average_neibs + "");           // boolean
		properties.setProperty(prefix+"sfm_fill_weak",                 this.sfm_fill_weak + "");               // boolean
		properties.setProperty(prefix+"sfm_extrapolate",               this.sfm_extrapolate + "");             // boolean

		properties.setProperty(prefix+"center_reference",              this.center_reference + "");            // boolean
		properties.setProperty(prefix+"force_ref_dsi",                 this.force_ref_dsi + "");               // boolean
		properties.setProperty(prefix+"force_orientations",            this.force_orientations + "");          // boolean
@@ -1848,10 +1891,19 @@ public class IntersceneMatchParameters {
		if (properties.getProperty(prefix+"sfm_same_weight")!=null)    this.sfm_same_weight=Double.parseDouble(properties.getProperty(prefix+"sfm_same_weight"));
		if (properties.getProperty(prefix+"sfm_shrink")!=null)         this.sfm_shrink=Integer.parseInt(properties.getProperty(prefix+"sfm_shrink"));
		if (properties.getProperty(prefix+"sfm_fade_sigma")!=null)     this.sfm_fade_sigma=Double.parseDouble(properties.getProperty(prefix+"sfm_fade_sigma"));
		if (properties.getProperty(prefix+"sfm_min_str")!=null)        this.sfm_min_str=Double.parseDouble(properties.getProperty(prefix+"sfm_min_str"));
		if (properties.getProperty(prefix+"sfm_min_str1")!=null)       this.sfm_min_str1=Double.parseDouble(properties.getProperty(prefix+"sfm_min_str1"));
		if (properties.getProperty(prefix+"sfm_min_str16")!=null)      this.sfm_min_str16=Double.parseDouble(properties.getProperty(prefix+"sfm_min_str16"));
		if (properties.getProperty(prefix+"sfm_use_neibs")!=null)      this.sfm_use_neibs=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_use_neibs"));
		if (properties.getProperty(prefix+"sfm_neib_too_str")!=null)   this.sfm_neib_too_str=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_too_str"));
		if (properties.getProperty(prefix+"sfm_neib_str")!=null)       this.sfm_neib_str=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_str"));
		if (properties.getProperty(prefix+"sfm_neib_too_str1")!=null)  this.sfm_neib_too_str1=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_too_str1"));
		if (properties.getProperty(prefix+"sfm_neib_too_str16")!=null) this.sfm_neib_too_str16=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_too_str16"));
		if (properties.getProperty(prefix+"sfm_neib_str1")!=null)      this.sfm_neib_str1=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_str1"));
		if (properties.getProperty(prefix+"sfm_neib_str16")!=null)     this.sfm_neib_str16=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_str16"));
		if (properties.getProperty(prefix+"sfm_extrap_steps")!=null)   this.sfm_extrap_steps=Integer.parseInt(properties.getProperty(prefix+"sfm_extrap_steps"));
		if (properties.getProperty(prefix+"sfm_extrap_radius")!=null)  this.sfm_extrap_radius=Integer.parseInt(properties.getProperty(prefix+"sfm_extrap_radius"));
		if (properties.getProperty(prefix+"sfm_average_neibs")!=null)  this.sfm_average_neibs=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_average_neibs"));		
		if (properties.getProperty(prefix+"sfm_fill_weak")!=null)      this.sfm_fill_weak=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_fill_weak"));		
		if (properties.getProperty(prefix+"sfm_extrapolate")!=null)    this.sfm_extrapolate=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_extrapolate"));		
		
		if (properties.getProperty(prefix+"center_reference")!=null)              this.center_reference=Boolean.parseBoolean(properties.getProperty(prefix+"center_reference"));		
		if (properties.getProperty(prefix+"force_ref_dsi")!=null)                 this.force_ref_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"force_ref_dsi"));		
		if (properties.getProperty(prefix+"force_orientations")!=null)            this.force_orientations=Boolean.parseBoolean(properties.getProperty(prefix+"force_orientations"));		
@@ -2201,10 +2253,19 @@ public class IntersceneMatchParameters {
 		imp.sfm_same_weight               = this.sfm_same_weight;
 		imp.sfm_shrink                    = this.sfm_shrink;
 		imp.sfm_fade_sigma	              = this.sfm_fade_sigma;
 		imp.sfm_min_str   	              = this.sfm_min_str;
 		imp.sfm_min_str1   	              = this.sfm_min_str1;
 		imp.sfm_min_str16   	          = this.sfm_min_str16;
 		imp.sfm_use_neibs 	              = this.sfm_use_neibs;
 		imp.sfm_neib_too_str              = this.sfm_neib_too_str;
 		imp.sfm_neib_str   	              = this.sfm_neib_str;
 		imp.sfm_neib_too_str1              = this.sfm_neib_too_str1;
 		imp.sfm_neib_too_str16            = this.sfm_neib_too_str16;
 		imp.sfm_neib_str1   	          = this.sfm_neib_str1;
 		imp.sfm_neib_str16                = this.sfm_neib_str16;
		imp.sfm_extrap_steps              = this.sfm_extrap_steps;
		imp.sfm_extrap_radius             = this.sfm_extrap_radius;
		imp.sfm_average_neibs             = this.sfm_average_neibs;
		imp.sfm_fill_weak                 = this.sfm_fill_weak;
		imp.sfm_extrapolate               = this.sfm_extrapolate;

		imp.center_reference              = this.center_reference;
		imp.force_ref_dsi                 = this.force_ref_dsi;
		imp.force_orientations            = this.force_orientations;
+1 −1
Original line number Diff line number Diff line
@@ -3070,7 +3070,7 @@ public class TexturedModel {
							hdr_whs[0],    // int     width,
							wh,            // int []  wh, // should be initialized to int [2]
							full_render);  // double [][] img_src) 
					if (img_cropped != null) {
					if (img_cropped != null) { // has NaN and alpha 0-1
						scenes[ref_index].saveDoubleArrayInModelDirectory(
								suffix+"-CROP", // String      suffix,
								null,           // String []   labels, // or null
Loading