vil_flip.h
Go to the documentation of this file.
1 // This is core/vil/vil_flip.h
2 #ifndef vil_flip_h_
3 #define vil_flip_h_
4 //:
5 // \file
6 // \author Ian Scott.
7 
9 #include <vil/vil_image_view.h>
10 
11 
12 //: Create a reflected view in which i -> ni-1-i.
13 // i.e. vil_flip_lr(view)(i,j,p) = view(ni-1-i,j,p)
14 // O(1).
15 // \relatesalso vil_image_view
16 template<class T>
18 {
19  return vil_image_view<T>(v.memory_chunk(),
20  v.top_left_ptr()+(v.ni()-1)*v.istep(),
21  v.ni(),v.nj(),v.nplanes(),
22  -v.istep(),v.jstep(),v.planestep());
23 }
24 
25 //: Create a reflected view in which y -> nj-1-j.
26 // i.e. vil_flip_ud(view)(i,j,p) = view(i,nj-1-j,p)
27 // O(1).
28 // \relatesalso vil_image_view
29 template<class T>
31 {
32  return vil_image_view<T>(v.memory_chunk(),
33  v.top_left_ptr()+(v.nj()-1)*v.jstep(),
34  v.ni(),v.nj(),v.nplanes(),
35  v.istep(),-v.jstep(),v.planestep());
36 }
37 
38 
39 //: Flip an image resource left to right.
40 // \relatesalso vil_image_resource
42 
43 
44 //: A generic_image adaptor that behaves like a flipped left to right version of its input
46 {
49  public:
50 
51  unsigned nplanes() const override { return src_->nplanes(); }
52  unsigned ni() const override { return src_->ni(); }
53  unsigned nj() const override { return src_->nj(); }
54 
55  enum vil_pixel_format pixel_format() const override { return src_->pixel_format(); }
56 
57 
58  vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
59  unsigned j0, unsigned nj) const override;
60 
61  vil_image_view_base_sptr get_view(unsigned i0, unsigned ni,
62  unsigned j0, unsigned nj) const override;
63 
64 
65  //: Put the data in this view back into the image source.
66  bool put_view(const vil_image_view_base& im, unsigned i0,
67  unsigned j0) override;
68 
69  //: Extra property information
70  bool get_property(char const* tag, void* property_value = nullptr) const override {
71  return src_->get_property(tag, property_value); }
72 
73 
74  protected:
75  //: Reference to underlying image source
77 };
78 
79 
80 //: Flip an image resource left to right.
81 // \relatesalso vil_image_resource
83 
84 
85 //: A generic_image adaptor that behaves like a flipped left to right version of its input
87 {
90  public:
91 
92  unsigned nplanes() const override { return src_->nplanes(); }
93  unsigned ni() const override { return src_->ni(); }
94  unsigned nj() const override { return src_->nj(); }
95 
96  enum vil_pixel_format pixel_format() const override { return src_->pixel_format(); }
97 
98 
99  vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
100  unsigned j0, unsigned nj) const override;
101 
102  vil_image_view_base_sptr get_view(unsigned i0, unsigned ni,
103  unsigned j0, unsigned nj) const override;
104 
105 
106  //: Put the data in this view back into the image source.
107  bool put_view(const vil_image_view_base& im, unsigned i0,
108  unsigned j0) override;
109 
110  //: Extra property information
111  bool get_property(char const* tag, void* property_value = nullptr) const override {
112  return src_->get_property(tag, property_value); }
113 
114  protected:
115  //: Reference to underlying image source
117 };
118 
119 #endif // vil_flip_h_
An abstract base class of smart pointers to actual image data in memory.
unsigned nplanes() const override
Dimensions: Planes x ni x nj.
Definition: vil_flip.h:92
vil_pixel_format
Describes the type of the concrete data.
unsigned nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_flip.h:53
friend vil_image_resource_sptr vil_flip_ud(const vil_image_resource_sptr &src)
Flip an image resource left to right.
Definition: vil_flip.cxx:121
vil_flip_ud_image_resource(vil_image_resource_sptr const &)
Definition: vil_flip.cxx:126
unsigned ni() const override
Dimensions: Planes x ni x nj.
Definition: vil_flip.h:52
bool get_property(char const *tag, void *property_value=nullptr) const override
Extra property information.
Definition: vil_flip.h:111
Concrete view of image data of type T held in memory.
Definition: vil_fwd.h:13
unsigned nplanes() const override
Dimensions: Planes x ni x nj.
Definition: vil_flip.h:51
unsigned ni() const override
Dimensions: Planes x ni x nj.
Definition: vil_flip.h:93
enum vil_pixel_format pixel_format() const override
Pixel Format.
Definition: vil_flip.h:55
bool get_property(char const *tag, void *property_value=nullptr) const override
Extra property information.
Definition: vil_flip.h:70
#define v
vil_flip_lr_image_resource(vil_image_resource_sptr const &)
Definition: vil_flip.cxx:19
vil_image_resource_sptr src_
Reference to underlying image source.
Definition: vil_flip.h:76
vil_image_view< T > vil_flip_ud(const vil_image_view< T > &v)
Create a reflected view in which y -> nj-1-j.
Definition: vil_flip.h:30
unsigned nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_flip.h:94
Abstract representation of an image source or image destination.
friend vil_image_resource_sptr vil_flip_lr(const vil_image_resource_sptr &src)
Flip an image resource left to right.
Definition: vil_flip.cxx:14
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
A base class reference-counting view of some image data.
bool put_view(const vil_image_view_base &im, unsigned i0, unsigned j0) override
Put the data in this view back into the image source.
Definition: vil_flip.cxx:91
enum vil_pixel_format pixel_format() const override
Pixel Format.
Definition: vil_flip.h:96
Representation of a generic image source or destination.
vil_image_view< T > vil_flip_lr(const vil_image_view< T > &v)
Create a reflected view in which i -> ni-1-i.
Definition: vil_flip.h:17
bool put_view(const vil_image_view_base &im, unsigned i0, unsigned j0) override
Put the data in this view back into the image source.
Definition: vil_flip.cxx:199
A generic_image adaptor that behaves like a flipped left to right version of its input.
Definition: vil_flip.h:45
vil_image_view_base_sptr get_view() const
Create a read/write view of all the data.
vil_image_resource_sptr src_
Reference to underlying image source.
Definition: vil_flip.h:116
A generic_image adaptor that behaves like a flipped left to right version of its input.
Definition: vil_flip.h:86