save_image.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_DATA_SAVE_IMAGE_HPP
13 #define MLPACK_CORE_DATA_SAVE_IMAGE_HPP
14 
15 #include "image_info.hpp"
16 
17 #ifdef HAS_STB
18 
19 #define STB_IMAGE_WRITE_STATIC
20 #define STB_IMAGE_WRITE_IMPLEMENTATION
21 #include <stb_image_write.h>
22 
23 #endif // HAS_STB
24 
25 namespace mlpack {
26 namespace data {
27 
37 template<typename eT>
38 bool Save(const std::string& filename,
39  arma::Mat<eT>& matrix,
40  ImageInfo& info,
41  const bool fatal = false);
42 
52 template<typename eT>
53 bool Save(const std::vector<std::string>& files,
54  arma::Mat<eT>& matrix,
55  ImageInfo& info,
56  const bool fatal = false);
57 
61 inline bool SaveImage(const std::string& filename,
62  arma::Mat<unsigned char>& image,
63  ImageInfo& info,
64  const bool fatal = false);
65 
66 } //namespace data
67 } //namespace mlpack
68 
69 // Include implementation of Save() for images.
70 #include "save_image_impl.hpp"
71 
72 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
bool SaveImage(const std::string &filename, arma::Mat< unsigned char > &image, ImageInfo &info, const bool fatal=false)
Helper function to save files.
constexpr auto data(Container const &container) noexcept -> decltype(container.data())
Definition: iterator.hpp:79
bool Save(const std::string &filename, const arma::Mat< eT > &matrix, const bool fatal=false, bool transpose=true, FileType inputSaveType=FileType::AutoDetect)
Saves a matrix to file, guessing the filetype from the extension.