mlpack 3.4.2
image_info.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_CORE_DATA_IMAGE_INFO_HPP
14#define MLPACK_CORE_DATA_IMAGE_INFO_HPP
15
16#include <mlpack/prereqs.hpp>
17#include "extension.hpp"
18
19namespace mlpack {
20namespace data {
21
29inline bool ImageFormatSupported(const std::string& fileName,
30 const bool save = false);
31
37{
38 public:
48 ImageInfo(const size_t width = 0,
49 const size_t height = 0,
50 const size_t channels = 3,
51 const size_t quality = 90);
52
54 const size_t& Width() const { return width; }
56 size_t& Width() { return width; }
58
59 const size_t& Height() const { return height; }
61 size_t& Height() { return height; }
62
64 const size_t& Channels() const { return channels; }
66 size_t& Channels() { return channels; }
67
69 const size_t& Quality() const { return quality; }
71 size_t& Quality() { return quality; }
72
73 template<typename Archive>
74 void serialize(Archive& ar, const unsigned int /* version */)
75 {
76 ar & BOOST_SERIALIZATION_NVP(width);
77 ar & BOOST_SERIALIZATION_NVP(channels);
78 ar & BOOST_SERIALIZATION_NVP(height);
79 ar & BOOST_SERIALIZATION_NVP(quality);
80 }
81
82 private:
83 // To store the image width.
84 size_t width;
85
86 // To store the image height.
87 size_t height;
88
89 // To store the number of channels in the image.
90 size_t channels;
91
92 // Compression of the image if saved as jpg (0 - 100).
93 size_t quality;
94};
95
96} // namespace data
97} // namespace mlpack
98
99// Include implementation of Image.
100#include "image_info_impl.hpp"
101
102#endif
Implements meta-data of images required by data::Load and data::Save for loading and saving images in...
Definition: image_info.hpp:37
const size_t & Channels() const
Get the image channels.
Definition: image_info.hpp:64
ImageInfo(const size_t width=0, const size_t height=0, const size_t channels=3, const size_t quality=90)
Instantiate the ImageInfo object with the given image width, height, number of channels and quality p...
const size_t & Height() const
Get the image height.
Definition: image_info.hpp:59
const size_t & Quality() const
Get the image quality.
Definition: image_info.hpp:69
size_t & Quality()
Modify the image quality.
Definition: image_info.hpp:71
size_t & Height()
Modify the image height.
Definition: image_info.hpp:61
const size_t & Width() const
Get the image width.
Definition: image_info.hpp:54
size_t & Width()
Modify the image width.
Definition: image_info.hpp:56
size_t & Channels()
Modify the image channels.
Definition: image_info.hpp:66
void serialize(Archive &ar, const unsigned int)
Definition: image_info.hpp:74
bool ImageFormatSupported(const std::string &fileName, const bool save=false)
Checks if the given image filename is supported.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.