Interface ImageExporter
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumAllowed export formats. -
Method Summary
Modifier and TypeMethodDescriptionvoidexport()Run the export process.Add a new "inner loop" to the export parameters.voidReset the current export loop parameters to empty.voidsetDisplay(DisplayWindow display) Set the display to use for image exporting.default voidsetFfmpegPath(String ffmpegPath) Set the path to the ffmpeg executable.voidsetImageJName(String imageJName) Sets the name to be used for the ImageJ Stack Window (if this was used as the output format).voidSet the output format to use.voidsetOutputQuality(int quality) Set the image quality.voidsetSaveInfo(String path, String prefix) Set the path to save images to, and the filename prefix to use when saving images.voidsetUseLabel(boolean label) Whether to use labels indicating position, channel, time point and z position (where) appropriate or to sequentially number output files.voidBlock until a prior call to export() returns.
-
Method Details
-
setDisplay
Set the display to use for image exporting. The same ImageExporter may be re-used for multiple displays, if desired.- Parameters:
display- Display to use for exporting images.
-
setOutputFormat
Set the output format to use.- Parameters:
format- The format to output in.
-
setUseLabel
void setUseLabel(boolean label) Whether to use labels indicating position, channel, time point and z position (where) appropriate or to sequentially number output files.- Parameters:
label- When true, filename will include position, channel, time point and z position labels (where appropriate).
-
setOutputQuality
void setOutputQuality(int quality) Set the image quality. This is currently only relevant if the output format is OUTPUT_JPG or OUTPUT_MOVIE.- Parameters:
quality- An integer quality ranging from 1 through 100. The default value is 90.
-
setFfmpegPath
Set the path to the ffmpeg executable. Required when the output format is OUTPUT_MOVIE. Ignored for other formats.This method has a default no-op implementation so that existing implementations of this interface remain source- and binary-compatible.
- Parameters:
ffmpegPath- Absolute path to the ffmpeg binary.
-
setSaveInfo
Set the path to save images to, and the filename prefix to use when saving images. These values are ignored if the output format is set to OUTPUT_IMAGEJ.- Parameters:
path- Directory in which images will be placedprefix- String to place at beginning of each output image's name.- Throws:
IllegalArgumentException- if the directory does not exist.IOException
-
setImageJName
Sets the name to be used for the ImageJ Stack Window (if this was used as the output format). Only used when output format is set to OUTPUT_IMAGEJ- Parameters:
imageJName- Name to be used in ImageJ
-
loop
Add a new "inner loop" to the export parameters. This determines what order the images will be output in. For example: exporter.loop(Coords.Z, 0, 10).loop(Coords.CHANNEL, 0, 2) This will cause the channel axis to be the "inner loop", changing most frequently, and the Z axis to be the "outer loop", changing least frequently.- Parameters:
axis- Axis name, like Coords.CHANNEL, Coords.Z, etc.start- Axis index to start exporting from, inclusive.stop- Axis index to stop exporting from, exclusive (i.e. one more than the index of the last image you want to export).- Returns:
- This instance, allowing calls to be chained together.
-
resetLoops
void resetLoops()Reset the current export loop parameters to empty. -
export
Run the export process. This will generate the image sequence as configured previously by calling setOutputFormat, setSaveInfo, and loop. Only one export is allowed to run at a time; if a second export is started, it will block until the first has finished. Otherwise, this method will return immediately. If you want to wait for exporting to finish, call the waitForExport() method.NOTE: the exporter will silently ignore the following "configuration errors": - Setting a save path when using the OUTPUT_IMAGEJ format - Loops over axes that are not used by any images in the display's datastore - Loops that have invalid start/end boundary conditions (starting or ending index is greater than largest index in the datastore). In the latter two cases, image coordinates that do not refer to a valid image will be ignored (for example, trying to access a Z coordinate of 1 in a dataset that is two-dimensional). It is therefore possible that this method will not actually do anything, if none of the loops encompass valid image coordinates.
- Throws:
IOException- if the export process would attempt to write to a file that already existsIllegalArgumentException- if no output format has been set, or OUTPUT_PNG or OUTPUT_JPG formats are used but no save information has been set, or if no loops have been configured, or if no display has been set.
-
waitForExport
Block until a prior call to export() returns. Returns immediately if no export is currently running.- Throws:
InterruptedException- if the thread was interrupted while waiting.
-