mlpack  3.1.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
19 namespace mlpack {
20 namespace data {
21 
28 inline bool ImageFormatSupported(const std::string& fileName,
29  const bool save = false);
30 
35 class ImageInfo
36 {
37  public:
47  ImageInfo(const size_t width = 0,
48  const size_t height = 0,
49  const size_t channels = 3,
50  const size_t quality = 90);
51 
53  const size_t& Width() const { return width; }
55  size_t& Width() { return width; }
57 
58  const size_t& Height() const { return height; }
60  size_t& Height() { return height; }
61 
63  const size_t& Channels() const { return channels; }
65  size_t& Channels() { return channels; }
66 
68  const size_t& Quality() const { return quality; }
70  size_t& Quality() { return quality; }
71 
72  template<typename Archive>
73  void serialize(Archive& ar, const unsigned int /* version */)
74  {
75  ar & BOOST_SERIALIZATION_NVP(width);
76  ar & BOOST_SERIALIZATION_NVP(channels);
77  ar & BOOST_SERIALIZATION_NVP(height);
78  ar & BOOST_SERIALIZATION_NVP(quality);
79  }
80 
81  private:
82  // To store the image width.
83  size_t width;
84 
85  // To store the image height.
86  size_t height;
87 
88  // To store the number of channels in the image.
89  size_t channels;
90 
91  // Compression of the image if saved as jpg (0 - 100).
92  size_t quality;
93 };
94 
95 } // namespace data
96 } // namespace mlpack
97 
98 // Include implementation of Image.
99 #include "image_info_impl.hpp"
100 
101 #endif
const size_t & Width() const
Get the image width.
Definition: image_info.hpp:53
size_t & Channels()
Modify the image channels.
Definition: image_info.hpp:65
size_t & Width()
Modify the image width.
Definition: image_info.hpp:55
Implements meta-data of images required by data::Load and data::Save for loading and saving images in...
Definition: image_info.hpp:35
size_t & Height()
Modify the image height.
Definition: image_info.hpp:60
const size_t & Channels() const
Get the image channels.
Definition: image_info.hpp:63
The core includes that mlpack expects; standard C++ includes and Armadillo.
void serialize(Archive &ar, const unsigned int)
Definition: image_info.hpp:73
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...
size_t & Quality()
Modify the image quality.
Definition: image_info.hpp:70
bool ImageFormatSupported(const std::string &fileName, const bool save=false)
Checks if the given image filename is supported.
const size_t & Quality() const
Get the image quality.
Definition: image_info.hpp:68
string(REGEX REPLACE".*#define MLPACK_VERSION_MINOR ([0-9]+).*""\\1"MLPACK_VERSION_MINOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* "\\1" MLPACK_VERSION_PATCH "$
Definition: CMakeLists.txt:35
const size_t & Height() const
Get the image height.
Definition: image_info.hpp:58