mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
image.h
Go to the documentation of this file.
1 #ifndef MF_IMAGE_H_
2 #define MF_IMAGE_H_
3 
4 #include "../ndarray/ndarray_view.h"
5 #include "../opencv.h"
6 #include "../masked_elem.h"
7 #include <type_traits>
8 
9 namespace mf {
10 
12 
13 template<typename Pixel>
14 class image {
15 public:
16  using pixel_type = Pixel;
18  using cv_mat_type = cv::Mat_<unmasked_type<pixel_type>>;
19 
20 private:
21  view_type view_;
22  cv_mat_type mat_;
23 
24 public:
25  image(const view_type& vw);
26 
27  const view_type& view() noexcept { return view_; }
28  const cv_mat_type& cv_mat() { return mat_; }
29 
30  virtual void update_cv_mat();
31  virtual void commit_cv_mat();
32 };
33 
34 
36 
37 template<typename Pixel>
38 class masked_image : public image<masked_elem<Pixel>> {
40 
41 public:
42  using pixel_type = typename base::pixel_type;
44  using view_type = typename base::view_type;
45  using cv_mat_type = typename base::cv_mat_type;
46  using cv_mask_mat_type = cv::Mat_<bool>;
47 
48 private:
49  cv_mask_mat_type mask_mat_;
50 
51 public:
52  masked_image(const view_type& vw);
53 
54  const cv_mask_mat_type& cv_mask_mat() { return mask_mat_; }
55 
56  void update_cv_mat();
57  void commit_cv_mat();
58 };
59 
60 
61 
63 template<typename Pixel>
65  return image<Pixel>(vw);
66 }
67 
68 template<typename Pixel>
70  return masked_image<Pixel>(vw);
71 }
72 
73 
74 }
75 
76 #include "image.tcc"
77 
78 #endif
virtual void update_cv_mat()
Definition: image.tcc:13
typename base::pixel_type pixel_type
Definition: image.h:42
const cv_mask_mat_type & cv_mask_mat()
Definition: image.h:54
void update_cv_mat()
Definition: image.tcc:34
const view_type & view() noexcept
Definition: image.h:27
masked_image(const view_type &vw)
Definition: image.tcc:29
const cv_mat_type & cv_mat()
Definition: image.h:28
image< Pixel > to_image(const ndarray_view< 2, Pixel > &vw)
Create image for given ndarray_view.
Definition: image.h:64
Nullable wrapper for elem type which adds mask.
Definition: masked_elem.h:15
virtual void commit_cv_mat()
Definition: image.tcc:18
image(const view_type &vw)
Definition: image.tcc:7
void commit_cv_mat()
Definition: image.tcc:44
cv::Mat_< unmasked_type< pixel_type >> cv_mat_type
Definition: image.h:18
typename base::view_type view_type
Definition: image.h:44
Pixel pixel_type
Definition: image.h:16
ndarray_view< 2, pixel_type > view_type
Definition: image.h:17
Two-dimensional image with given pixel type.
Definition: image.h:14
cv::Mat_< bool > cv_mask_mat_type
Definition: image.h:46
typename base::cv_mat_type cv_mat_type
Definition: image.h:45
Two-dimensional masked image with given pixel type.
Definition: image.h:38