elsa io¶
Table of Contents
General¶
-
template<typename
data_t
>
voidelsa::io
::
write
(DataContainer<data_t> x, std::string_view filename)¶ Write DataContainer to a file with given filename. Filename is expected to have a valid (i.e. supported) extension, else this function will throw.
- Parameters
x
: DataContainer to write to filefilename
: filename to write data to
-
template<typename
data_t
>
DataContainer<data_t>elsa::io
::
read
(std::string_view filename)¶ Read from filename and create a DataContainer. Filename is expected to have a valid (i.e. supported) extension, else this function will throw.
- Parameters
filename
: filename to read data from
EDF¶
-
class
elsa
::
EDF
¶ class to read and write EDF files.
Class to handle reading EDF files into DataContainers and writing of DataContainers to EDF files.
EDF files are non-standard files that include a 1024 Byte header containing textual meta data about the following raw data. It allows storing images of arbitrary dimensions in a low-overhead manner.
Please note: we assume little endian byte order.
- Author
Matthias Wieczorek - initial code
Maximilian Hornung - modularization
Tobias Lasser - modernization
David Frank - istream overloads, improved testability
Public Static Functions
-
template<typename
data_t
= real_t>
DataContainer<data_t>read
(std::string filename)¶ read from filename into a DataContainer
-
template<typename
data_t
= real_t>
DataContainer<data_t>read
(std::istream &input)¶ read from stream into a DataContainer
-
template<typename
data_t
= real_t>
voidwrite
(const DataContainer<data_t> &data, std::string filename)¶ write the DataContainer to the file named filename
-
template<typename
data_t
= real_t>
voidwrite
(const DataContainer<data_t> &data, std::ostream &output)¶ write the DataContainer to the file named filename
Private Static Functions
-
std::map<std::string, std::string>
readHeader
(std::istream &file)¶ read the EDF header into a property map
-
std::pair<std::unique_ptr<DataDescriptor>, DataUtils::DataType>
parseHeader
(const std::map<std::string, std::string> &properties)¶ parse the EDF header property map into a DataDescriptor and DataType
-
template<typename
data_t
>
voidwriteHeader
(std::ostream &file, const DataContainer<data_t> &data)¶ write the EDF header to file
-
template<typename
data_t
>
std::stringgetDataTypeName
(const DataContainer<data_t> &data)¶ return the EDF string for data type of DataContainer
MHD¶
-
class
elsa
::
MHD
¶ class to read and write MHD files. MHD files are compatible with ITK/VTK based applications.
Class to handle reading
MHD files into DataContainers and writing of DataContainers to MHD files.- Author
Matthias Wieczorek - initial code
- Author
Maximilian Hornung - modularization
- Author
Tobias Lasser - modernization
MHD files consist of two parts, a text file (ending in .mhd) containing meta data, and a raw file containing the image data (filename is referenced in meta data). It allows storing images of arbitrary dimensions in a low-overhead manner.
Please note: we assume little endian byte order.
Public Static Functions
-
template<typename
data_t
= real_t>
DataContainer<data_t>read
(std::string filename)¶ read from filename into a DataContainer
-
template<typename
data_t
= real_t>
voidwrite
(const DataContainer<data_t> &data, std::string metaFilename, std::string rawFilename)¶ write the DataContainer to the file named filename
Private Static Functions
-
std::map<std::string, std::string>
readHeader
(std::ifstream &metaFile)¶ read the MHD header into a property map
-
std::tuple<std::unique_ptr<DataDescriptor>, std::string, DataUtils::DataType>
parseHeader
(const std::map<std::string, std::string> &properties)¶ parse the MHD header property map into a DataDescriptor and DataType
-
template<typename
data_t
>
voidwriteHeader
(std::ofstream &metaFile, const DataContainer<data_t> &data, std::string rawFilename)¶ write the MHD header to file
-
template<typename
data_t
>
std::stringgetDataTypeName
(const DataContainer<data_t> &data)¶ return the MHD string for data type of DataContainer
PGM¶
-
class
elsa
::
PGM
¶ Class to handle writing PGM image files from DataContainers.
The “portable gray map” (PGM) fileformat is split into the header and the body (with image data). The header starts with a magic number, then width and height (in ASCII) are specified and the last part of the header is the maximum value of the colour component. The Magic number in our case is “P2” as we want to write a grey scale image. The width and height are taken from the
DataContainer
and the maximum value is 255 (values are scaled accordingly)An example of a header would be:
P2 100 50 # width height 255 # Max value, 1 byte
Then the body prints one value in each line
Note: This class currently only handles 2D
DataContainer
s.Reference: http://paulbourke.net/dataformats/ppm/
- Author
David Frank - initial code
Public Static Functions
-
template<typename
data_t
= real_t>
voidwrite
(const DataContainer<data_t> &data, const std::string &filename)¶ write the DataContainer to the file named filename. Currently we only handle 2D images
-
template<typename
data_t
= real_t>
voidwrite
(const DataContainer<data_t> &data, std::ostream &stream)¶ write the DataContainer to ostream with the specified format. Only 2D buffers are supported
IO Utilities¶
DataUtils¶
-
struct
elsa
::
DataUtils
¶ class providing utility functions for reading/writing data
- Author
Matthias Wieczorek - first version of code
- Author
Maximilian Hornung - modularization
- Author
Tobias Lasser - rewrite
Public Types
Public Static Functions
-
template<typename
data_t
>
std::vector<data_t>parseVector
(const std::string &str)¶ parse a vector of data_t values from a string
-
template<typename
raw_data_t
, typenamedata_t
>
voidparseRawData
(std::istream &file, DataContainer<data_t> &data)¶ read in raw data (of type raw_data_t) into a data container (of type data_t)
Public Static Attributes
-
const ByteOrder
DEFAULT_BYTE_ORDER
= ByteOrder::LOW_BYTE_FIRST¶ our default byte order is little endian (low byte first)