vil_j2k_nitf2_pyramid_image_resource.h
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_j2k_nitf2_pyramid_image_resource.h
2 #ifndef vil_j2k_nitf2_pyramid_image_resource_h_
3 #define vil_j2k_nitf2_pyramid_image_resource_h_
4 //:
5 // \file
6 // \brief Representation of a pyramid resolution hierarchy based on JPEG2000 NITF image
7 //
8 // \author J. L. Mundy
9 // \date April 9 2009
10 // Do not remove the following notice
11 // Approved for public Release, distribution unlimited
12 // DISTAR Case 14074
13 //
14 #include <vector>
15 #ifdef _MSC_VER
16 # include <vcl_msvc_warnings.h>
17 #endif
20 
21 //: Representation of a pyramid resolution hierarchy; mostly pure virtual methods
22 //
23 // The pyramid consists of a set of scaled (lower resolution) copies of the base
24 // image. A typical case is where the copies are each a factor of two smaller
25 // than the next lower image in the pyramid. However, there is no intrinsic
26 // assumption about the scale difference between copies at different levels.
27 //
28 // All image positions and sizes are expressed in the coordinate system of
29 // the base image. The transformation from base image coordinates to one
30 // of the copy images is given by: ic = ib*scale, jc = jb*scale. Thus the
31 // base image is considered to have scale = 1.0.
32 // The copies all have scale<1.0.
33 
35 {
36  public:
39 
40  //: The number of planes (or components) in the image.
41  // Dimensions: Planes x ni x nj.
42  // This method refers to the base (max resolution) image
43  // This concept is treated as a synonym to components.
44  virtual unsigned nplanes() const;
45 
46  //: The number of pixels in each row.
47  // Dimensions: Planes x ni x nj.
48  // This method refers to the base (max resolution) image
49  virtual unsigned ni() const;
50 
51  //: The number of pixels in each column.
52  // Dimensions: Planes x ni x nj.
53  // This method refers to the base (max resolution) image
54  virtual unsigned nj() const;
55 
56  //: Pixel Format.
57  virtual enum vil_pixel_format pixel_format() const;
58 
59  //: Put the data in this view back into the base image.
60  // Pyramid is readonly.
61  // This is essentially (although not formally) a pure virtual function.
62  virtual bool put_view(vil_image_view_base const& /*im*/, unsigned /*i0*/, unsigned /*j0*/)
63  { return false; }
64 
65  //: Return a string describing the file format.
66  // Only file images have a format, others return 0
67  virtual char const* file_format() const;
68 
69  // === Methods particular to pyramid resource ===
70 
71  //: Number of pyramid levels.
72  // In principle, the number of levels is
73  // undefined since the j2k decoder can decompress to any window size.
74  // A reasonable strategy is to define the number of levels so that
75  // the lowest scale produces a smallest image dimension of 1K pixels
76  virtual unsigned nlevels() const;
77 
78  //: Get a partial view from the image from a specified pyramid level
79  virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
80  unsigned j0, unsigned n_j,
81  unsigned level) const;
82 
83  //: Get a complete view from a specified pyramid level.
84  // This method needs no specialisation.
85  virtual vil_image_view_base_sptr get_copy_view(unsigned level) const
86  { return get_copy_view(0, ni(), 0, nj(), level); }
87 
88  //: Get a partial view from the image in the pyramid closest to scale.
89  // The origin and size parameters are in the coordinate system of the base image.
90  // The scale factor is with respect to the base image (base scale = 1.0).
91  virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
92  unsigned j0, unsigned n_j,
93  const float scale,
94  float& actual_scale) const;
95 
96  //: Get a complete view from the image in the pyramid closest to the specified scale.
97  // The scale factor is with respect to the base image (base scale = 1.0).
98  // This method needs no specialisation.
99  virtual vil_image_view_base_sptr get_copy_view(const float scale, float& actual_scale) const
100  { return get_copy_view(0, ni(), 0, nj(), scale, actual_scale); }
101 
102  //: Copy a resource into the pyramid, level is determined by resource scale
103  virtual bool put_resource(vil_image_resource_sptr const& resc)
104  {return false;}
105 
106  //: Get an image resource from the pyramid at the specified level
107  virtual vil_image_resource_sptr get_resource(const unsigned level) const;
108 
109  //: for debug purposes
110  virtual void print(const unsigned level);
111 
112  protected:
116 };
117 
118 #endif // vil_j2k_nitf2_pyramid_image_resource_h_
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
virtual vil_image_view_base_sptr get_copy_view(const float scale, float &actual_scale) const
Get a complete view from the image in the pyramid closest to the specified scale.
virtual void print(const unsigned level)
for debug purposes.
virtual vil_image_view_base_sptr get_copy_view(unsigned level) const
Get a complete view from a specified pyramid level.
Representation of a pyramid resolution hierarchy; mostly pure virtual methods.
virtual unsigned nplanes() const
The number of planes (or components) in the image.
vil_nitf2: Written by Rob Radtke (rob@) and Harry Voorhees (hlv@) of Stellar Science Ltd.
Class for reading NITF 2.1 imagery files.
Representation of a pyramid resolution hierarchy; mostly pure virtual methods.
Representation of a pyramid resolution hierarchy.
virtual unsigned nlevels() const
Number of pyramid levels.
virtual char const * file_format() const
Return a string describing the file format.
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
virtual vil_image_resource_sptr get_resource(const unsigned level) const
Get an image resource from the pyramid at the specified level.
virtual enum vil_pixel_format pixel_format() const
Pixel Format.
virtual bool put_view(vil_image_view_base const &, unsigned, unsigned)
Put the data in this view back into the base image.
virtual unsigned nj() const
The number of pixels in each column.
virtual unsigned ni() const
The number of pixels in each row.
virtual bool put_resource(vil_image_resource_sptr const &resc)
Copy a resource into the pyramid, level is determined by resource scale.