13 #ifndef MLPACK_CORE_DATA_LOAD_IMAGE_IMPL_HPP 14 #define MLPACK_CORE_DATA_LOAD_IMAGE_IMPL_HPP 24 bool Load(
const std::string& filename,
25 arma::Mat<eT>& matrix,
33 arma::Mat<unsigned char> tempMatrix;
34 const bool result = LoadImage(filename, tempMatrix, info, fatal);
43 matrix = arma::conv_to<arma::Mat<eT>>::from(tempMatrix);
50 bool Load(
const std::vector<std::string>& files,
51 arma::Mat<eT>& matrix,
55 if (files.size() == 0)
57 std::ostringstream oss;
58 oss <<
"Load(): vector of image files is empty." << std::endl;
68 arma::Mat<unsigned char> img;
69 bool status = LoadImage(files[0], img, info, fatal);
75 arma::Mat<unsigned char> tmpMatrix(
77 tmpMatrix.col(0) = img;
79 for (
size_t i = 1; i < files.size() ; ++i)
81 arma::Mat<unsigned char> colImg(tmpMatrix.colptr(i), tmpMatrix.n_rows, 1,
83 status = LoadImage(files[i], colImg, info, fatal);
89 matrix = arma::conv_to<arma::Mat<eT>>::from(tmpMatrix);
const size_t & Channels() const
Get the image channels.
Definition: image_info.hpp:64
static void Start(const std::string &name)
Start the given timer.
Definition: timers.cpp:28
const size_t & Height() const
Get the image height.
Definition: image_info.hpp:59
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Definition: log.hpp:90
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
Implements meta-data of images required by data::Load and data::Save for loading and saving images in...
Definition: image_info.hpp:36
static MLPACK_EXPORT util::PrefixedOutStream Warn
Prints warning messages prefixed with [WARN ].
Definition: log.hpp:87
static void Stop(const std::string &name)
Stop the given timer.
Definition: timers.cpp:36
bool Load(const std::string &filename, arma::Mat< eT > &matrix, const bool fatal=false, const bool transpose=true, const arma::file_type inputLoadType=arma::auto_detect)
Loads a matrix from file, guessing the filetype from the extension.
Definition: load_impl.hpp:89
const size_t & Width() const
Get the image width.
Definition: image_info.hpp:54