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 
29 inline bool ImageFormatSupported(const std::string& fileName,
30  const bool save = false);
31 
36 class ImageInfo
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 uint32_t /* version */)
75  {
76  ar(CEREAL_NVP(width));
77  ar(CEREAL_NVP(channels));
78  ar(CEREAL_NVP(height));
79  ar(CEREAL_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
void serialize(Archive &ar, const uint32_t)
Definition: image_info.hpp:74
size_t & Channels()
Modify the image channels.
Definition: image_info.hpp:66
Linear algebra utility functions, generally performed on matrices or vectors.
size_t & Width()
Modify the image width.
Definition: image_info.hpp:56
Implements meta-data of images required by data::Load and data::Save for loading and saving images in...
Definition: image_info.hpp:36
size_t & Height()
Modify the image height.
Definition: image_info.hpp:61
The core includes that mlpack expects; standard C++ includes and Armadillo.
const size_t & Width() const
Get the image width.
Definition: image_info.hpp:54
const size_t & Height() const
Get the image height.
Definition: image_info.hpp:59
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:71
const size_t & Quality() const
Get the image quality.
Definition: image_info.hpp:69
const size_t & Channels() const
Get the image channels.
Definition: image_info.hpp:64
bool ImageFormatSupported(const std::string &fileName, const bool save=false)
Checks if the given image filename is supported.