vil_blocked_image_resource.h
Go to the documentation of this file.
1 // This is core/vil/vil_blocked_image_resource.h
2 #ifndef vil_blocked_image_resource_h_
3 #define vil_blocked_image_resource_h_
4 //:
5 // \file
6 // \brief A blocked representation of the image_resource
7 // \author J. L. Mundy
8 #include <vector>
9 #ifdef _MSC_VER
10 # include <vcl_msvc_warnings.h>
11 #endif
12 #include <vil/vil_image_resource.h>
14 
15 //:cast to blocked resource if possible
18 
20 {
21 
22  public:
23 
25  ~vil_blocked_image_resource() override;
26 
27  unsigned nplanes() const override =0;
28  unsigned ni() const override = 0;
29  unsigned nj() const override = 0;
30 
31  //: Block size in columns
32  virtual unsigned size_block_i() const = 0;
33 
34  //: Block size in rows
35  virtual unsigned size_block_j() const = 0;
36 
37  //: Number of blocks in image width
38  virtual unsigned n_block_i() const;
39 
40  //: Number of blocks in image height
41  virtual unsigned n_block_j() const;
42 
43 
44  enum vil_pixel_format pixel_format() const override = 0;
45 
47  get_copy_view(unsigned i0, unsigned n_i, unsigned j0, unsigned n_j) const override;
48 
49  bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0) override = 0;
50 
51  //: Block access
52  virtual vil_image_view_base_sptr get_block( unsigned block_index_i,
53  unsigned block_index_j ) const = 0;
54 
55 
56  //: the multiple blocks are in col row order, i.e. blocks[i][j]
57  virtual bool get_blocks( unsigned start_block_i, unsigned end_block_i,
58  unsigned start_block_j, unsigned end_block_j,
59  std::vector< std::vector< vil_image_view_base_sptr > >& blocks ) const;
60 
61  //: put the block into the resource at the indicated location
62  virtual bool put_block(unsigned block_index_i,
63  unsigned block_index_j,
64  const vil_image_view_base& view) = 0;
65 
66 
67  //: put multiple blocks in raster order, i.e., blocks[i][j]
68  virtual bool put_blocks( unsigned start_block_i, unsigned end_block_i,
69  unsigned start_block_j, unsigned end_block_j,
70  std::vector< std::vector< vil_image_view_base_sptr > > const& blocks );
71 
72  //: Extra property information
73  bool get_property(char const* tag, void* property_value = nullptr) const override = 0;
74 
75  protected:
76  //Internal functions
77  vil_image_view_base_sptr fill_block(unsigned i0, unsigned icrop,
78  unsigned j0, unsigned jcrop,
79  vil_image_view_base_sptr& view) const;
80 
81  //: Get the offset from the start of the block row for pixel position i
82  bool block_i_offset(unsigned block_i, unsigned i,
83  unsigned& i_offset) const;
84 
85  //: Get the offset from the start of the block column for pixel position j
86  bool block_j_offset(unsigned block_j, unsigned j,
87  unsigned& j_offset) const;
88 
89  bool trim_border_blocks(unsigned i0, unsigned ni,
90  unsigned j0, unsigned nj,
91  unsigned start_block_i,
92  unsigned start_block_j,
93  std::vector< std::vector< vil_image_view_base_sptr > >& blocks) const;
94 
96  glue_blocks_together(const std::vector< std::vector< vil_image_view_base_sptr > >& blocks) const;
97 
98  protected:
100 };
101 
102 #endif // vil_blocked_image_resource_h_
unsigned ni() const override=0
Dimensions: Planes x ni x nj.
virtual vil_image_view_base_sptr get_block(unsigned block_index_i, unsigned block_index_j) const =0
Block access.
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
virtual unsigned size_block_i() const =0
Block size in columns.
A templated smart pointer class.
Definition: vil_fwd.h:16
bool put_view(const vil_image_view_base &im, unsigned i0, unsigned j0) override=0
Put the data in this view back into the image source.
bool block_i_offset(unsigned block_i, unsigned i, unsigned &i_offset) const
Get the offset from the start of the block row for pixel position i.
enum vil_pixel_format pixel_format() const override=0
Pixel Format.
virtual unsigned n_block_i() const
Number of blocks in image width.
bool block_j_offset(unsigned block_j, unsigned j, unsigned &j_offset) const
Get the offset from the start of the block column for pixel position j.
vil_blocked_image_resource_sptr blocked_image_resource(const vil_image_resource_sptr &ir)
cast to blocked resource if possible.
virtual bool get_blocks(unsigned start_block_i, unsigned end_block_i, unsigned start_block_j, unsigned end_block_j, std::vector< std::vector< vil_image_view_base_sptr > > &blocks) const
the multiple blocks are in col row order, i.e. blocks[i][j].
~vil_blocked_image_resource() override
unsigned nplanes() const override=0
Dimensions: Planes x ni x nj.
Abstract representation of an image source or image destination.
bool get_property(char const *tag, void *property_value=nullptr) const override=0
Extra property information.
unsigned nj() const override=0
Dimensions: Planes x ni x nj.
bool trim_border_blocks(unsigned i0, unsigned ni, unsigned j0, unsigned nj, unsigned start_block_i, unsigned start_block_j, std::vector< std::vector< vil_image_view_base_sptr > > &blocks) const
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
virtual unsigned size_block_j() const =0
Block size in rows.
vil_image_view_base_sptr fill_block(unsigned i0, unsigned icrop, unsigned j0, unsigned jcrop, vil_image_view_base_sptr &view) const
Smart pointer to an image resource.
Representation of a generic image source or destination.
virtual bool put_blocks(unsigned start_block_i, unsigned end_block_i, unsigned start_block_j, unsigned end_block_j, std::vector< std::vector< vil_image_view_base_sptr > > const &blocks)
put multiple blocks in raster order, i.e., blocks[i][j].
virtual bool put_block(unsigned block_index_i, unsigned block_index_j, const vil_image_view_base &view)=0
put the block into the resource at the indicated location.
virtual unsigned n_block_j() const
Number of blocks in image height.
vil_image_view_base_sptr glue_blocks_together(const std::vector< std::vector< vil_image_view_base_sptr > > &blocks) const