Gradient Domain Fusion for Large EM Image Stacks (Version 1.0)
links
description
data layout
volume processing
usage
LINKS
Paper:
ArXiv 2015
Scripts:
Scripts (Perl)
Source:
Distributed Gradient Domain (C++),
Cross-Slice Smoothing (C++)
Executables:
Distributed Multi-Grid (Win64),
Cross-Slice Smoothing (Win64)
CODE DESCRIPTION
This distribution provides an implementation of our gradient domain fusion for color correction in large EM image stacks. The implementation proceeds in two phases.
- XSliceSmooth: First, an initial pass of smoothing is performed across the slices.
- DMG: Then, gradient domain fusion is performed for each (2D) slice in order to generate new slices that have inter-slice coherence while preserving the intra-slice detail.
These executables are tied together using a Perl script which is invoked from the command line.
DATA LAYOUT
The input/output data is a 3D image of size W×H×D.
Each image is represented by as a set of D slices -- each of which is a 2D image of size W×H.
Each slice is futher partitioned into a grid of C×R tiles -- sub-images all of the same resolution (except for the tiles in the last column/row of a slice, which may be smaller).
There are two ways in which the data can be layed out on disk:
- Flat: In this representation, all tiles for all (input and output) slices are contained in the same directory:
<in_dir>/<in_tile_name>.<tile_extension>
<tmp_dir>/<tmp_tile_name>.<tile_extension>
<out_dir>/<out_tile_name>.<tile_extension>
For this represenation, the --slices parameter (see below) gives the number of different slices.
- Sliced: In this representation, the tiles for each slice are stored in separate directories:
<in_dir>/<in_slice_dir>/<in_tile_name>.<tile_extension>
<tmp_dir>/<out_slice_dir>/<out_tile_name>.<tile_extension>
<out_dir>/<out_slice_dir>/<out_tile_name>.<tile_extension>
For this represenation, the --slices parameter (see below) gives the name of the file containg the list of slice directories. Each slice directory is assumed to be stored on a separate line and the total number of (non-empty) lines defines the number of slices.
For technical reasons, the <out_slice_dir>
string is obtained by replacing all instances of the file separator character ("/" on Linux, "\" on Windows) in <in_slice_dir>
with the character "_". (i.e. Collapsing a multi-level directory structure down to one directory.)
VOLUME PROCESSING
- SCRIPTS
Executing the scripts is done in two steps.
- parameters.pl: This script must be edited to indicate the location of the executables and the data. Specifically, the user must modify/set the following variables and functions:
- $X_SLICE_SMOOTH: The location of the executable performing the cross-slice smoothing,
- $GRADIENT_DOMAIN_SERVER: The location of the distributed multigrid server executable,
- $GRADIENT_DOMAIN_CLIENT: The location of the distributed multigrid client executable,
- input_name: This function takes in indices of the tile (column, row, depth) and returns the name of the correponding input tile.
This corresponds to the <in_tile_name>
string described in the DATA LAYOUT section above.
- output_name: This function takes in the indices of the tile (column, row, depth) and returns the name of the corresponding output tile.
This corresponds to the <out_tile_name>
string described in the DATA LAYOUT section above.
- gdf.pl: This script uses the information in parameters.pl to invoke the cross-slice smoothing and gradient domain fusion code.
This script takes the following parameters (the first five are required, the remainder are optional):
- --params <parameters.pl file>
- This required string specifies the location of the parameters file described above.
- --slices <slice directory count/slice directory list>
- This required parameter can be used either to specify the number of z-slices in the 3D dataset (the integer D) or the file enumberating the directories containing the slice tiles (the strings
<in_slice_dir>
).
For more details, see the DATA LAYOUT section above.
- --columns <columns per slice>
- This required integer values specifies the number columns in the tile-grid representing each slice (C).
- --rows <rows per slice>
- This required integer values specifies the number rows in the tile-grid representing each slice (R).
- --ext <extension>
- This required string specifies the file extension used to represent the tile images in the input/output.
This corresponds to the <tile_extension>
string described in the DATA LAYOUT section above.
The code currently supports JPEG, PNG, and TIFF formats.
- [--inDir <input directory>]
- This optional string specifies the (base) directory from which the input tiles are to be read.
The default value for this parameter is ".".
This corresponds to the <in_dir>
string described in the DATA LAYOUT section above.
- [--tempDir <temporary directory>]
- This optional string specifies the (base) directory to/from which the temporary tiles are to be written/read.
The default value for this parameter is ".".
This corresponds to the <tmp_dir>
string described in the DATA LAYOUT section above.
- [--outDir <output directory>]
- This optional string specifies the (base) directory to which the output tiles are to be written.
The default value for this parameter is ".".
This corresponds to the <out_dir>
string described in the DATA LAYOUT section above.
- [--xySigma <xy sigma>]
- This optional floating point value specifies the standard deviation (in pixels) of the Gaussian filter used for smoothing within each slice.
The default value for this parameter is 1.
- [--zSigma <z sigma>]
- This optional floating point value specifies the standard deviation (in pixels) of the Gaussian filter used for smoothing across each slice.
The default value for this parameter is 3.
- [--blockSize <tile block size>]
- This optional integer value specifies the width/height (in pixels) of the output tiles.
The default value for this parameter is 2048.
- [--iWeight <tile block size>]
- This optional floating point value specifies the interpolation weight used for the gradient domain fusion. (Larger values mean less cross-slice smoothing.)
The default value for this parameter is 0.001.
- [--port <dmg connection port>]
- This optional integer value specifies the port over which the distributed multigrid client/server communicate.
On Windows, the default value for this parameter is 3672. On Linux it is 45674.
- [--threads <parallelization threads>]
- This optional integer value specifies the number of threads to be used for parallelization.
The default value for this parameter is 4.
- [--color]
- This optional parameter indicates that the input tiles contain color values.
By default, the input is assumed to be gray-scale.
- [--progress]
- This optional parameter indicates that the progress of the gradient domain fusion should be output to STDOUT.
- EXECUTABLES
Though the executables are invoked by the Perl script and do not need to be called directly by the user, their parameters are provided for completeness:
- XSliceSmooth
- --in <input image file>
- This required string is the name of the file containing the list of the tiles in the input 3D volume. The first three lines contain the width/height/depth of the tile grid, followed by a list of the tile names.
- [--out <output image file>]
- This optional string is the name of the file containing the list of the tiles in the output 3D volume. The first three lines contain the width/height/depth of the tile grid, followed by a list of the tile names.
- [--header <output file header>]
- This optional string specifies the header to prepended to the output tile names.
- [--ext] <output file extension>]
- This optional string specifies the file extension to be used for the output tiles.
The default value for this parameter is "tiff".
- [--scratchHeader] <scratch header extension>
- This optional string specifies the header to prepended to the temporary tile names.
- [--xySigma <xy sigma>]
- This optional floating point value specifies the standard deviation (in pixels) of the Gaussian filter used for smoothing within each slice.
The default value for this parameter is 0.
- [--zSigma <z sigma>]
- This optional floating point value specifies the standard deviation (in pixels) of the Gaussian filter used for smoothing across each slice.
The default value for this parameter is 0.
- [--threads <parallelization threads>]
- This optional integer value specifies the number of threads to be used for parallelization.
The default value for this parameter is 1.
- [--channels <color channels>]
- This optional integer value specifies the number of channels used for representing a pixel's color.
The default value for this parameter is 1.
- [--verbose]
- This optional parameter indicates that the state of the cross-slice smoother should be output to STDOUT.
- [--progress]
- This optional parameter indicates that the more detailed progress of the gradient domain fusion should be output to STDOUT.
- DMG
Parameters for the distributed gradient domain executables can be found here.
USAGE
As a simple example, consider the case when the volume is comprised of 100 slices, each reprsented by a grid of 32×16 image tiles.
Furthermore, assume that the input tiles are named {in.x1.y1.z1.jpg, ..., in.x32.y1.z1.jpg, ..., in.x32.y16.z1.jpg, ..., in.x32.y16.z100.jpg} and are each of size 1024×1024 (except, perhaps, for the tiles in the last column/row).
To run the processing we first modify the parameters.pl file to specify the locations of the executables and define the functions returning the input/output file-names:
$X_SLICE_SMOOTH = ...;
$GRADIENT_DOMAIN_SERVER = ...;
$GRADIENT_DOMAIN_CLIENT = ...;
sub input_name
{
my( $i , $j , $k ) = @_;
return "in" . ".x" . ($i+1) . ".y" . ($j+1) . ".z" . ($k+1);
}
sub output_name
{
my( $i , $j , $k ) = @_;
return "out" . ".x" . ($i+1) . ".y" . ($j+1) . ".z" . ($k+1);
}
(By default, indexing starts at 0, not 1.)
Then we invoke the gdf.pl script to perform the smoothing and fusion (using the --blockSize parameter to obtain output tiles which partition the slices in the same way as the input):
% perl gdf.pl --params parameters.pl --columns 32 --rows 16 --slices 100 --ext jpg --blockSize 1024
HOME