IOFormat 1.12.0
Loading...
Searching...
No Matches
ioformat::StackWriter Class Reference

#include <ioformat/StackWriter.h>

Public Member Functions

 StackWriter ()=delete
 

Static Public Member Functions

static void writeFromPattern (std::shared_ptr< iolink::MultiImageView > multi, const std::string &outputFilePathPattern)
 
static void writeFromPattern (std::shared_ptr< iolink::ImageView > stack, const std::string &outputFilePathPattern)
 
static void writeFromUriPattern (std::shared_ptr< iolink::MultiImageView > multi, const std::string &outputUriPattern, const ioformat::GeneralOptions &options={})
 
static void writeFromUriPattern (std::shared_ptr< iolink::ImageView > stack, const std::string &outputUriPattern, const ioformat::GeneralOptions &options={})
 

Detailed Description

A factory to save stacks of images.

Constructor & Destructor Documentation

◆ StackWriter()

ioformat::StackWriter::StackWriter ( )
delete

Remove constructor, as this class is a static factory.

Member Function Documentation

◆ writeFromPattern() [1/2]

static void ioformat::StackWriter::writeFromPattern ( std::shared_ptr< iolink::ImageView >  stack,
const std::string &  outputFilePathPattern 
)
static

Write a stack of images to many files using a pattern to generate indexed filenames.

N-dimension image will be written as many N-1-dimension images. Last dimension (N) is used as the stack dimension.

e.g. a 3D image of size (10, 20, 30) will be written as 30 images of size (10, 20).

Parameters
stackThe stack of images to write as separated files.
outputFilePathPatternThe pattern for the output file path. The pattern must contain one group of consecutive '%' characters, which will be replaced by the image index.

The count of '%' characters sets the minimum count of digits for printing the image index, but the printed index may include additional digits.

e.g.

  • outputFilePattern = "output%%%%.png" will create files named output0000.png, output0001.png, ...,outut0010.png, outut0011.png,etc.
  • outputFilePattern = "output%%.png" will create files named output00.png, output01.png, ..., output10.png, ..., output100.png, output101.png, etc.
  • outputFilePattern = "output%.png" will create files named output0.png, output1.png, ..., output10.png, output11.png, etc.
Exceptions
InvalidArgumentIf the output file pattern is invalid.
UnsupportedOperationIf the input image cannot be written as a stack.
ErrorIf an error occurs while writing the images.

◆ writeFromPattern() [2/2]

static void ioformat::StackWriter::writeFromPattern ( std::shared_ptr< iolink::MultiImageView >  multi,
const std::string &  outputFilePathPattern 
)
static

Write a list of images to many files using a pattern to generate indexed filenames.

Each frame of the input MultiImageView will be written as a separate file.

Parameters
multiThe list of images to write as separated files.
outputFilePathPatternThe pattern for the output file path. The pattern must contain one group of consecutive '%' characters, which will be replaced by the image index.

The count of '%' characters sets the minimum count of digits for printing the image index, but the printed index may include additional digits.

e.g.

  • outputFilePattern = "output%%%%.png" will create files named output0000.png, output0001.png, ...,outut0010.png, outut0011.png,etc.
  • outputFilePattern = "output%%.png" will create files named output00.png, output01.png, ..., output10.png, ..., output100.png, output101.png, etc.
  • outputFilePattern = "output%.png" will create files named output0.png, output1.png, ..., output10.png, output11.png, etc.
Exceptions
InvalidArgumentIf the output file pattern is invalid.
ErrorIf an error occurs while writing the images.

◆ writeFromUriPattern() [1/2]

static void ioformat::StackWriter::writeFromUriPattern ( std::shared_ptr< iolink::ImageView >  stack,
const std::string &  outputUriPattern,
const ioformat::GeneralOptions options = {} 
)
static

Write a stack of images to many files using a URI pattern to generate indexed filenames.

N-dimension image will be written as many N-1-dimension images. Last dimension (N) is used as the stack dimension.

e.g. a 3D image of size (10, 20, 30) will be written as 30 images of size (10, 20).

Parameters
stackThe stack of images to write as separated files.
outputUriPatternThe pattern for the output URI. The pattern must contain one group of consecutive '%' characters, which will be replaced by the image index.
optionsGeneral options for the output, such as compression or metadata handling.

The count of '%' characters sets the minimum count of digits for printing the image index, but the printed index may include additional digits.

e.g.

  • outputUriPattern = "file:///output%%%%.png" will create files named output0000.png, output0001.png, ...,outut0010.png, outut0011.png,etc.
  • outputUriPattern = "file:///output%%.png" will create files named output00.png, output01.png, ..., output10.png, ..., output100.png, output101.png, etc.
  • outputUriPattern = "file:///output%.png" will create files named output0.png, output1.png, ..., output10.png, output11.png, etc.
Exceptions
InvalidArgumentIf the input image cannot be written as a stack.
InvalidArgumentif the output URI pattern is not well-formed
InvalidArgumentif the URI cannot be parsed.
InvalidArgumentif the URI does not contain any scheme
InvalidArgumentif the URI does not contain a valid extension
ErrorWhen at least one ImageView cannot be written into the destination URI.

◆ writeFromUriPattern() [2/2]

static void ioformat::StackWriter::writeFromUriPattern ( std::shared_ptr< iolink::MultiImageView >  multi,
const std::string &  outputUriPattern,
const ioformat::GeneralOptions options = {} 
)
static

Write a MultiImageView to many files using a URI pattern to generate indexed filenames.

Each frame of the input MultiImageView will be written as a separate file.

Parameters
multiThe list of images to write as separated files.
outputUriPatternThe pattern for the output URI. The pattern must contain one group of consecutive '%' characters, which will be replaced by the image index.
optionsGeneral options for the output, such as compression or metadata handling.

The count of '%' characters sets the minimum count of digits for printing the image index, but the printed index may include additional digits.

e.g.

  • outputUriPattern = "file:///output%%%%.png" will create files named output0000.png, output0001.png, ...,outut0010.png, outut0011.png,etc.
  • outputUriPattern = "file:///output%%.png" will create files named output00.png, output01.png, ..., output10.png, ..., output100.png, output101.png, etc.
  • outputUriPattern = "file:///output%.png" will create files named output0.png, output1.png, ..., output10.png, output11.png, etc.
Exceptions
InvalidArgumentif the output URI pattern is not well-formed
InvalidArgumentif the URI cannot be parsed.
InvalidArgumentif the URI does not contain any scheme
InvalidArgumentif the URI does not contain a valid extension
ErrorWhen at least one ImageView cannot be written into the destination URI.

The documentation for this class was generated from the following file: