5#include <opencv2/core.hpp>
24auto ReadImage(
const filesystem::path& path) -> cv::Mat;
46 const filesystem::path& path,
const cv::Mat& img,
WriteImageOpts = {});
48template <
class Iterable>
49void WriteImageSequence(
50 const filesystem::path& path,
51 const Iterable& iterable,
52 const WriteImageOpts& opts = {})
63 if (fs::is_directory(path)) {
70 parent = path.parent_path();
71 ext = path.extension();
74 auto stem = path.stem().string();
75 std::tie(prefix, std::ignore, suffix) =
partition(stem,
"{}");
80 "Index placement separator \\{\\} not found in stem: {}", stem);
85 auto pad = std::to_string(std::size(iterable)).size();
86 pad = opts.padding.value_or(pad);
89 for (
const auto [i, image] :
enumerate(iterable)) {
91 auto filepath = (parent / name).replace_extension(ext);
auto enumerate(Iterable &&it)
Wrap an Iterable into a new one whose iterators return an [index, value] pair.
Alias for std::filesystem
Volume Cartographer library
auto Logger() -> std::shared_ptr< spdlog::logger >
Volume Cartographer global logger.
auto to_padded_string(Integer val, const int padding, const char fill='0') -> std::string
Convert an Integer to a padded string.
auto ReadImage(const filesystem::path &path) -> cv::Mat
Read an image from the specified path.
static auto partition(std::string_view s, std::string_view sep) -> std::tuple< std::string, std::string, std::string >
Partition a string by a separator substring.
void WriteImage(const filesystem::path &path, const cv::Mat &img, WriteImageOpts={})
Write image to the specified path.
std::optional< int > padding
std::optional< int > compression