Commit e69ea295 authored by Luc Deschenaux's avatar Luc Deschenaux

Merge branch 'tiff_compression' of github.com:luxigo/imagej-elphel into tiff_compression

parents d07d5c28 2d359171
......@@ -61,6 +61,7 @@ public class EyesisCorrectionParameters {
public double outputRangeFP= 255.0; // 1.0 intensity will be saved as 255.0 (in float 32-bit mode)
public boolean imageJTags= false; // encode ImageJ info data to the TIFF output header
public String tiffCompression = "UNCOMPRESSED"; // tiff compression codec
public boolean jpeg = true; // convert to RGB and save JPEG (if save is true)
public boolean save = true;
public boolean save16 = false; // save 16-bit tiff also if the end result is 8 bit
......@@ -201,6 +202,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"equirectangularFormat")!=null) this.equirectangularFormat=Integer.parseInt(properties.getProperty(prefix+"equirectangularFormat"));
if (properties.getProperty(prefix+"outputRangeInt")!=null) this.outputRangeInt=Double.parseDouble(properties.getProperty(prefix+"outputRangeInt"));
if (properties.getProperty(prefix+"outputRangeFP")!=null) this.outputRangeFP=Double.parseDouble(properties.getProperty(prefix+"outputRangeFP"));
if (properties.getProperty(prefix+"tiffCompression")!=null) this.tiffCompression=properties.getProperty(prefix+"tiffCompression");
if (properties.getProperty(prefix+"imageJTags")!=null) this.imageJTags=Boolean.parseBoolean(properties.getProperty(prefix+"imageJTags"));
if (properties.getProperty(prefix+"jpeg")!=null) this.jpeg=Boolean.parseBoolean(properties.getProperty(prefix+"jpeg")); // convert to RGB and save jpeg (if save is true)
if (properties.getProperty(prefix+"save")!=null) this.save=Boolean.parseBoolean(properties.getProperty(prefix+"save"));
......@@ -283,6 +285,8 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Save chroma denoise mask (white - use hi-res, black - low-res)", this.saveChromaDenoiseMask);
gd.addCheckbox ("Rotate result image", this.rotate);
gd.addCheckbox ("Crop result image to the original size", this.crop);
String [] tiffCompressionChoices={"UNCOMPRESSED","LZW","JPEG_2000","ALT_JPEG2000"};
int tiffCompressionIndex=0;
String [] equirectangularFormatChoices={"RGBA 8-bit","RGBA 16-bit","RGBA 32-bit integer","RGBA 32-bit float","ImageJ stack"};
int [] equirectangularFormats={0,1,2,3,4};
int equirectangularFormatIndex=0;
......@@ -294,6 +298,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Map 1.0 intensity to this fraction of the full range 8/16/32-bit integer mode output", 100*this.outputRangeInt, 2,6,"%");
gd.addNumericField("Map 1.0 intensity to this value in 32-bit floating point output mode", this.outputRangeFP, 2,6,"");
gd.addCheckbox ("Encode ImageJ specific Info metadata to the output file TIFF header", this.imageJTags);
gd.addChoice("TIFF lossless compression codec",tiffCompressionChoices,tiffCompressionChoices[tiffCompressionIndex]);
gd.addCheckbox ("Convert to RGB48", this.toRGB);
gd.addCheckbox ("Convert to 8 bit RGB (and save JPEG if save is enabled)", this.jpeg);
......@@ -372,6 +377,7 @@ public class EyesisCorrectionParameters {
this.outputRangeInt=0.01*gd.getNextNumber();
this.outputRangeFP= gd.getNextNumber();
this.imageJTags= gd.getNextBoolean();
this.tiffCompression= tiffCompressionChoices[gd.getNextChoiceIndex()];
this.toRGB= gd.getNextBoolean();
this.jpeg= gd.getNextBoolean();
this.save= gd.getNextBoolean();
......
......@@ -472,7 +472,7 @@ public class EyesisCorrections {
this.defectsDiff[srcChannel]=this.pixelMapping.getDefectsDiff(srcChannel);
if (this.debugLevel>0){
if (this.defectsXY[srcChannel]==null){
System.out.println("No pixel defects info is availabele for channel "+srcChannel);
System.out.println("No pixel defects info is available for channel "+srcChannel);
} else {
System.out.println("Extracted "+this.defectsXY[srcChannel].length+" pixel outlayers for channel "+srcChannel+
" (x:y:difference");
......@@ -700,7 +700,7 @@ public class EyesisCorrections {
if (path!=null){
path+=Prefs.getFileSeparator()+imp.getTitle()+".tiff";
if (this.debugLevel>0) System.out.println("Saving equirectangular result to "+path);
(new EyesisTiff()).saveTiff(
(new EyesisTiff(correctionsParameters.tiffCompression)).saveTiff(
imp,
path,
correctionsParameters.equirectangularFormat,
......
......@@ -47,15 +47,25 @@ import loci.formats.tiff.IFDList;
import loci.formats.tiff.TiffParser;
import loci.formats.tiff.TiffRational;
import loci.formats.tiff.TiffSaver;
import loci.formats.tiff.TiffCompression;
public class EyesisTiff {
// private static org.apache.log4j.Logger log= Logger.getLogger(EyesisTiff.class);
private String codec="UNCOMPRESSED";
public EyesisTiff(){
// Please initialize the log4j system properly
}
public EyesisTiff(String codec){
// Please initialize the log4j system properly
this.codec=codec;
}
public void saveTiff(
ImagePlus imp,
String path,
......@@ -175,7 +185,7 @@ public EyesisTiff(){
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.COMPRESSION, TiffCompression.valueOf(codec).getCode());
ifd.putIFDValue(IFD.PHOTOMETRIC_INTERPRETATION,2); // RGB
ifd.putIFDValue(IFD.EXTRA_SAMPLES,2); // 0 = Unspecified data 1 = Associated alpha data (with pre-multiplied color) 2 = Unassociated alpha data
// int [] bpsArray={8,8,8,8};
......@@ -257,7 +267,7 @@ public EyesisTiff(){
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.COMPRESSION, TiffCompression.valueOf(codec).getCode());
ifd.putIFDValue(IFD.PHOTOMETRIC_INTERPRETATION,2); // RGB
ifd.putIFDValue(IFD.EXTRA_SAMPLES,2); // extra bytes (over 3) meaning Unassociated alpha data
......
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