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 
17 #include <mlpack/prereqs.hpp>
18 
19 #include "extension.hpp"
20 
21 #ifdef HAS_STB // Compile this only if stb is present.
22 
23 #define STB_IMAGE_STATIC
24 #define STB_IMAGE_IMPLEMENTATION
25 #include <stb_image.h>
26 
27 #define STB_IMAGE_WRITE_STATIC
28 #define STB_IMAGE_WRITE_IMPLEMENTATION
29 #include <stb_image_write.h>
30 
31 #endif
32 
33 namespace mlpack {
34 namespace data {
35 
36 #ifdef HAS_STB // Compile this only if stb is present.
37 
44 inline bool ImageFormatSupported(const std::string& fileName,
45  const bool save = false);
46 
47 #endif
48 
53 class ImageInfo
54 {
55  public:
65  ImageInfo(const size_t width = 0,
66  const size_t height = 0,
67  const size_t channels = 3,
68  const size_t quality = 90);
69 
71  const size_t& Width() const { return width; }
73  size_t& Width() { return width; }
75 
76  const size_t& Height() const { return height; }
78  size_t& Height() { return height; }
79 
81  const size_t& Channels() const { return channels; }
83  size_t& Channels() { return channels; }
84 
86  const size_t& Quality() const { return quality; }
88  size_t& Quality() { return quality; }
89 
90  private:
91  // To store the image width.
92  size_t width;
93 
94  // To store the image height.
95  size_t height;
96 
97  // To store the number of channels in the image.
98  size_t channels;
99 
100  // Compression of the image if saved as jpg (0 - 100).
101  size_t quality;
102 };
103 
104 } // namespace data
105 } // namespace mlpack
106 
107 // Include implementation of Image.
108 #include "image_info_impl.hpp"
109 
110 #endif
size_t & Channels()
Modify the image channels.
Definition: image_info.hpp:83
strip_type.hpp
Definition: add_to_po.hpp:21
size_t & Width()
Modify the image width.
Definition: image_info.hpp:73
Implements meta-data of images required by data::Load and data::Save for loading and saving images in...
Definition: image_info.hpp:53
size_t & Height()
Modify the image height.
Definition: image_info.hpp:78
The core includes that mlpack expects; standard C++ includes and Armadillo.
const size_t & Width() const
Get the image width.
Definition: image_info.hpp:71
const size_t & Height() const
Get the image height.
Definition: image_info.hpp:76
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:88
const size_t & Quality() const
Get the image quality.
Definition: image_info.hpp:86
const size_t & Channels() const
Get the image channels.
Definition: image_info.hpp:81