Volume Cartographer 2.27.0
|
IO Utilities for TIFF files. More...
#include <cstdint>
#include <opencv2/core.hpp>
#include "vc/core/filesystem.hpp"
#include "vc/core/util/MemMap.hpp"
Go to the source code of this file.
Namespaces | |
namespace | volcart |
Volume Cartographer library | |
Enumerations | |
enum class | volcart::tiffio::Compression : std::uint16_t { NONE = 1 , CCITTRLE = 2 , CCITTFAX3 = 3 , CCITT_T4 = 3 , CCITTFAX4 = 4 , CCITT_T6 = 4 , LZW = 5 , OJPEG = 6 , JPEG = 7 , ADOBE_DEFLATE = 8 , NEXT = 32766 , CCITTRLEW = 32771 , PACKBITS = 32773 , THUNDERSCAN = 32809 , IT8CTPAD = 32895 , IT8LW = 32896 , IT8MP = 32897 , IT8BL = 32898 , PIXARFILM = 32908 , PIXARLOG = 32909 , DEFLATE = 32946 , DCS = 32947 , JBIG = 34661 , SGILOG = 34676 , SGILOG24 = 34677 , JP2000 = 34712 } |
Functions | |
auto | volcart::tiffio::ReadTIFF (const filesystem::path &path, mmap_info *mmap_info=nullptr) -> cv::Mat |
Read a TIFF file. More... | |
void | volcart::tiffio::WriteTIFF (const filesystem::path &path, const cv::Mat &img, Compression compression=Compression::LZW) |
Write a TIFF image to file. More... | |
|
strong |
TIFF compression schemes
Definition at line 24 of file TIFFIO.hpp.
auto volcart::tiffio::ReadTIFF | ( | const filesystem::path & | path, |
mmap_info * | mmap_info = nullptr |
||
) | -> cv::Mat |
Read a TIFF file.
Reads Gray, Gray+Alpha, RGB, and RGBA TIFF images. Supports 8, 16, and 32-bit integer types as well as 32-bit float types. 3 and 4 channel images will be returned with a BGR channel order, except for 8-bit and 16-bit signed integer types which will be returned with an RGB channel order.
Only supports single image TIFF files with scanline encoding and a contiguous planar configuration (this matches the format written by WriteTIFF). Unless you need to read some obscure image type (e.g. 32-bit float or signed integer images), it's generally preferable to use cv::imread.
If mmap_info
is provided, this function will attempt to memory map the TIFF file rather than reading it into memory. If successful, mmap_info
will contain the address and size required to unmap the file with UnmapFile. If memory mapping fails for any reason, this function will fallback to loading the image into memory, and mmap_info
will be empty. This can be checked with mmap_info::operator bool()
:
path | Path to TIFF file |
mmap_info | mmap_info needed to unmap the file |
volcart::IOException | Unrecoverable read errors |
void volcart::tiffio::WriteTIFF | ( | const filesystem::path & | path, |
const cv::Mat & | img, | ||
Compression | compression = Compression::LZW |
||
) |
Write a TIFF image to file.
Writes Gray, Gray+Alpha, RGB, and RGBA TIFF images. Supports 8, 16, and 32-bit integer types as well as 32-bit float types. 3 and 4 channel images are assumed to have a BGR channel order, except for 8-bit and 16-bit signed integer types which are not supported.
If the raw size of the image (width x height x channels x bytes-per-sample) is >= 4GB, the TIFF will be written using the BigTIFF extension to the TIFF format.
volcart::IOException | All writing errors |