vil_openjpeg.h
Go to the documentation of this file.
1 //==========
2 // Kitware (c) 2010
3 //
4 // Restrictions applicable to use by the US Government:
5 //
6 // UNLIMITED RIGHTS
7 //
8 // Restrictions applicable for all other users:
9 //
10 // This software and all information and expression are the property of Kitware, Inc. All Rights Reserved.
11 //==========
12 //:
13 // \file
14 // \brief Image I/O for JPEG2000 imagery using OpenJPEG
15 // \author Chuck Atkins
16 
17 #ifndef vil_openjpeg_h_
18 #define vil_openjpeg_h_
19 
20 #include <vil/vil_fwd.h>
21 #include <vil/vil_file_format.h>
22 #include <vil/vil_image_resource.h>
23 
24 //: OpenJPEG Codec
26 {
30 };
31 
32 
33 //: Derived class for JPEG2000 imagery using OpenJPEG
35 {
36  public:
38  vil_openjpeg_format opjfmt);
40  unsigned int ni,
41  unsigned int nj,
42  unsigned int nplanes,
43  vil_pixel_format format,
44  vil_openjpeg_format opjfmt);
45 };
46 
49 {
50  public:
51  const char * tag() const override { return "jp2"; }
52 
54  {
55  return static_cast<vil_openjpeg_file_format*>(this)->
57  }
58 
60  unsigned int ni,
61  unsigned int nj,
62  unsigned int nplanes,
63  vil_pixel_format format) override
64  {
65  return static_cast<vil_openjpeg_file_format*>(this)->
66  make_output_image(vs, ni, nj, nplanes, format, VIL_OPENJPEG_JP2);
67  }
68 };
69 
70 #if 0
71 class vil_openjpeg_jpt_file_format : public vil_file_format,
73 {
74  public:
75  virtual const char * tag() const { return "jpt"; }
76 
78  {
79  return static_cast<vil_openjpeg_file_format*>(this)->
81  }
82 
84  unsigned int ni,
85  unsigned int nj,
86  unsigned int nplanes,
87  vil_pixel_format format)
88  {
89  return static_cast<vil_openjpeg_file_format*>(this)->
90  make_output_image(vs, ni, nj, nplanes, format, VIL_OPENJPEG_JPT);
91  }
92 };
93 #endif // 0
94 
97 {
98  public:
99  const char * tag() const override { return "j2k"; }
100 
102  {
103  return static_cast<vil_openjpeg_file_format*>(this)->
105  }
106 
108  unsigned int ni,
109  unsigned int nj,
110  unsigned int nplanes,
111  vil_pixel_format format) override
112  {
113  return static_cast<vil_openjpeg_file_format*>(this)->
114  make_output_image(vs, ni, nj, nplanes, format, VIL_OPENJPEG_J2K);
115  }
116 };
117 
119 
120 //: Derived image resource for JPEG2000 imagery using OpenJPEG
122 {
123  public:
125  unsigned int ni, unsigned int nj, unsigned int nplanes,
126  vil_pixel_format format, vil_openjpeg_format opjfmt);
128  ~vil_openjpeg_image(void) override;
129 
130  bool is_valid(void) const;
131 
132  // Inherit the documentation from vil_image_resource
133 
134  unsigned int nplanes() const override;
135  unsigned int ni() const override;
136  unsigned int nj() const override;
137  enum vil_pixel_format pixel_format() const override;
138  const char * file_format() const override;
139 
140  //: Reductions.
141  // An image may supply lower resolutions.
142  // This will return the number of reductions available.
143  // 0 means only the full size image is available.
144  virtual unsigned int nreductions() const;
145 
147  unsigned int i0, unsigned int ni, unsigned int j0, unsigned int nj) const override;
148 
149  //: Create a read/write view of a copy of this data.
150  // This is similar to get_copy_view, except that a reduction level may
151  // be specified. On success, the returned data is reduced by 2^reduction.
152  // Coordinates should be specified relative to the full-sized image.
153  // \return 0 if the reduction is not available, or for any reason that
154  // get_copy_view would return 0.
156  unsigned i0, unsigned ni, unsigned j0, unsigned nj,
157  unsigned reduction) const;
158 
159  bool put_view(const vil_image_view_base& im,
160  unsigned int i0, unsigned int j0) override;
161 
162  bool get_property(char const* tag, void* property_value = nullptr) const override;
163 
164  private:
165  bool validate_format();
166 
167  int maxbpp(void) const;
168 
169  template<typename PIXEL_TYPE>
171  void *opj_view,
172  unsigned int i0, unsigned int ni, unsigned int j0, unsigned int nji) const;
173 // vil_memory_chunk_sptr image_mem_ptr);
174 
176 };
177 
178 #endif
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
~vil_openjpeg_image(void) override
vil_image_resource_sptr make_input_image(vil_stream *vs) override
Attempt to make a generic_image which will read from vil_stream vs.
Definition: vil_openjpeg.h:53
vil_openjpeg_image(vil_stream *is, unsigned int ni, unsigned int nj, unsigned int nplanes, vil_pixel_format format, vil_openjpeg_format opjfmt)
vil_image_resource_sptr make_input_image(vil_stream *vs, vil_openjpeg_format opjfmt)
unsigned int nplanes() const override
Dimensions: Planes x ni x nj.
virtual vil_image_resource_sptr make_input_image(vil_stream *vs)=0
Attempt to make a generic_image which will read from vil_stream vs.
vil_image_view_base_sptr opj2vil(void *opj_view, unsigned int i0, unsigned int ni, unsigned int j0, unsigned int nji) const
const char * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_openjpeg.h:99
virtual unsigned int nreductions() const
Reductions.
bool get_property(char const *tag, void *property_value=nullptr) const override
Extra property information.
vil_openjpeg_image_impl * impl_
Definition: vil_openjpeg.h:175
Base class for image formats.
vil_image_resource_sptr make_output_image(vil_stream *vs, unsigned int ni, unsigned int nj, unsigned int nplanes, vil_pixel_format format) override
Definition: vil_openjpeg.h:59
bool is_valid(void) const
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
enum vil_pixel_format pixel_format() const override
Pixel Format.
vil_image_resource_sptr make_output_image(vil_stream *vs, unsigned int ni, unsigned int nj, unsigned int nplanes, vil_pixel_format format, vil_openjpeg_format opjfmt)
Abstract representation of an image source or image destination.
unsigned int nj() const override
Dimensions: Planes x ni x nj.
vil_openjpeg_format
OpenJPEG Codec.
Definition: vil_openjpeg.h:25
virtual char const * tag() const =0
Return a character string which uniquely identifies this format.
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
vil_image_resource_sptr make_input_image(vil_stream *vs) override
Attempt to make a generic_image which will read from vil_stream vs.
Definition: vil_openjpeg.h:101
vil_image_resource_sptr make_output_image(vil_stream *vs, unsigned int ni, unsigned int nj, unsigned int nplanes, vil_pixel_format format) override
Definition: vil_openjpeg.h:107
virtual vil_image_view_base_sptr get_copy_view_reduced(unsigned i0, unsigned ni, unsigned j0, unsigned nj, unsigned reduction) const
Create a read/write view of a copy of this data.
unsigned int ni() const override
Dimensions: Planes x ni x nj.
bool put_view(const vil_image_view_base &im, unsigned int i0, unsigned int j0) override
const char * file_format() const override
Return a string describing the file format.
const char * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_openjpeg.h:51
Representation of a generic image source or destination.
Derived image resource for JPEG2000 imagery using OpenJPEG.
Definition: vil_openjpeg.h:121
Base class for image formats.
Derived class for JPEG2000 imagery using OpenJPEG.
Definition: vil_openjpeg.h:34
int maxbpp(void) const
virtual vil_image_resource_sptr make_output_image(vil_stream *, unsigned, unsigned, unsigned, enum vil_pixel_format)=0
Make a "generic_image" on which put_section may be applied.