Commit b6b0e4d8 authored by Andrey Filippov's avatar Andrey Filippov

Implemented 8bpp mode for ML output

parent a520cd7b
......@@ -80,6 +80,7 @@ public class BiQuadParameters {
public boolean ml_keep_hor_vert = true; // include combined horizontal and vertical pairs data in the ML output
public boolean ml_keep_debug= true; // include debug layer(s) data in the ML output
public boolean ml_8bit= true; // output in 8-bit format (default - 32-bit TIFF
public double ml_limit_extrim = 0.00001; // ignore lowest and highest values when converting to 8 bpp
public boolean ml_show_ml = true; // show each generated MLoutput file
......@@ -185,6 +186,8 @@ public class BiQuadParameters {
"Keep additional (debug) layers that may change for different file versions");
gd.addCheckbox ("Use 8 bpp TIFF (default - 32 bpp)", this.ml_8bit,
"Reduce file size by lowering bpp");
gd.addNumericField("When converting to 8bpp, limit fraction of extreme values", 1E6 * this.ml_limit_extrim, 1,8,"ppm",
"Use values histogram to find min/max values, ignoring(limiting) this fraction (parts per million) of pixels at both extremes");
gd.addCheckbox ("Show each generated ML file", this.ml_show_ml,
"Use only for small number of generated files to reduce memory usage");
......@@ -241,6 +244,7 @@ public class BiQuadParameters {
this.ml_keep_hor_vert= gd.getNextBoolean();
this.ml_keep_debug= gd.getNextBoolean();
this.ml_8bit= gd.getNextBoolean();
this.ml_limit_extrim= gd.getNextNumber() * 1E-6;
this.ml_show_ml= gd.getNextBoolean();
}
......@@ -298,6 +302,7 @@ public class BiQuadParameters {
properties.setProperty(prefix+"ml_keep_hor_vert", this.ml_keep_hor_vert+"");
properties.setProperty(prefix+"ml_keep_debug", this.ml_keep_debug+"");
properties.setProperty(prefix+"ml_8bit", this.ml_8bit+"");
properties.setProperty(prefix+"ml_limit_extrim", this.ml_limit_extrim+"");
properties.setProperty(prefix+"ml_show_ml", this.ml_show_ml+"");
......@@ -353,6 +358,7 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"ml_keep_hor_vert")!=null) this.ml_keep_hor_vert=Boolean.parseBoolean(properties.getProperty(prefix+"ml_keep_hor_vert"));
if (properties.getProperty(prefix+"ml_keep_debug")!=null) this.ml_keep_debug=Boolean.parseBoolean(properties.getProperty(prefix+"ml_keep_debug"));
if (properties.getProperty(prefix+"ml_8bit")!=null) this.ml_8bit=Boolean.parseBoolean(properties.getProperty(prefix+"ml_8bit"));
if (properties.getProperty(prefix+"ml_limit_extrim")!=null) this.ml_limit_extrim=Double.parseDouble(properties.getProperty(prefix+"ml_limit_extrim"));
if (properties.getProperty(prefix+"ml_show_ml")!=null) this.ml_show_ml=Boolean.parseBoolean(properties.getProperty(prefix+"ml_show_ml"));
}
@Override
......@@ -408,9 +414,8 @@ public class BiQuadParameters {
bqp.ml_keep_hor_vert= this.ml_keep_hor_vert;
bqp.ml_keep_debug= this.ml_keep_debug;
bqp.ml_8bit= this.ml_8bit;
bqp.ml_limit_extrim= this.ml_limit_extrim;
bqp.ml_show_ml= this.ml_show_ml;
return bqp;
}
}
......@@ -1162,7 +1162,54 @@ public class Correlation2d {
int oindex = tileY *tile_width * full_width + tileX * tile_width + (ml_index/tile_width)*full_width + (ml_index%tile_width) ;
ml_data[ml_layer][oindex] = ml_value;
}
/**
* Get a single value from the combined multi-layer ML array, viewable as an image
* @param tileX horizontal tile index
* @param tileY vertical tile index
* @param ml_hwidth half-width of the preserved 2d correlation (0 - single point, 1 -> 3x3, 2 -> 5x5, 7 - all data)
* @param ml_data multi-layer array, each layer matches an image of ((2 * ml_hwidth + 1) * tilesX) by ((2 * ml_hwidth + 1) * tilesY) in scanline order
* Each tile corresponds to (2 * ml_hwidth + 1) * (2 * ml_hwidth + 1) square in the image. Only selected tiles will be updated, so it is good to initialize array
* with all Double.NaN values
* @param ml_layer layer to save tile data
* @param ml_index data index within tile
* @param tilesX image width in tiles
* @return value indexed by tileX, tileY, ml_layer and ml_index
*/
public double restoreMlTilePixel(
int tileX,
int tileY,
int ml_hwidth,
double [][] ml_data,
int ml_layer,
int ml_index,
int tilesX) {
int tile_width = 2 * ml_hwidth + 1;
int full_width = tile_width * tilesX;
int oindex = tileY *tile_width * full_width + tileX * tile_width + (ml_index/tile_width)*full_width + (ml_index%tile_width) ;
return ml_data[ml_layer][oindex];
}
/**
* Get an index of the selected tile+index in a ML array layer
* @param tileX horizontal tile index
* @param tileY vertical tile index
* @param ml_hwidth half-width of the preserved 2d correlation (0 - single point, 1 -> 3x3, 2 -> 5x5, 7 - all data)
* @param ml_index data index within tile
* @param tilesX image width in tiles
* @return index of teh selected pixel in thye whole image (specified by tileX, tileY, and ml_index)
*/
public int getMlTilePixelIndex(
int tileX,
int tileY,
int ml_hwidth,
int ml_index,
int tilesX) {
int tile_width = 2 * ml_hwidth + 1;
int full_width = tile_width * tilesX;
int oindex = tileY *tile_width * full_width + tileX * tile_width + (ml_index/tile_width)*full_width + (ml_index%tile_width) ;
return oindex;
}
......
This diff is collapsed.
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