core/vil/file_formats/vil_j2k_nitf2_pyramid_image_resource.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_j2k_nitf2_pyramid_image_resource.h
00002 #ifndef vil_j2k_nitf2_pyramid_image_resource_h_
00003 #define vil_j2k_nitf2_pyramid_image_resource_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Representation of a pyramid resolution hierarchy based on JPEG2000 NITF image
00010 //
00011 // \author J. L. Mundy
00012 // \date April 9 2009
00013 // Do not remove the following notice
00014 // Approved for public Release, distribution unlimited
00015 // DISTAR Case 14074
00016 //
00017 #include <vcl_vector.h>
00018 #include <vil/vil_pyramid_image_resource.h>
00019 #include <vil/file_formats/vil_nitf2_image.h>
00020 
00021 //: Representation of a pyramid resolution hierarchy; mostly pure virtual methods
00022 //
00023 // The pyramid consists of a set of scaled (lower resolution) copies of the base
00024 // image.  A typical case is where the copies are each a factor of two smaller
00025 // than the next lower image in the pyramid. However, there is no intrinsic
00026 // assumption about the scale difference between copies at different levels.
00027 //
00028 // All image positions and sizes are expressed in the coordinate system of
00029 // the base image. The transformation from base image coordinates to one
00030 // of the copy images is given by:  ic = ib*scale, jc = jb*scale. Thus the
00031 // base image is considered to have scale = 1.0.
00032 // The copies all have scale<1.0.
00033 
00034 class vil_j2k_nitf2_pyramid_image_resource : public vil_pyramid_image_resource
00035 {
00036  public:
00037   vil_j2k_nitf2_pyramid_image_resource(vil_image_resource_sptr const& nitf2);
00038   virtual ~vil_j2k_nitf2_pyramid_image_resource(){}
00039 
00040   //: The number of planes (or components) in the image.
00041   // Dimensions:  Planes x ni x nj.
00042   // This method refers to the base (max resolution) image
00043   // This concept is treated as a synonym to components.
00044   virtual unsigned nplanes() const;
00045 
00046   //: The number of pixels in each row.
00047   // Dimensions:  Planes x ni x nj.
00048   // This method refers to the base (max resolution) image
00049   virtual unsigned ni() const;
00050 
00051   //: The number of pixels in each column.
00052   // Dimensions:  Planes x ni x nj.
00053   // This method refers to the base (max resolution) image
00054   virtual unsigned nj() const;
00055 
00056   //: Pixel Format.
00057   virtual enum vil_pixel_format pixel_format() const;
00058 
00059   //: Put the data in this view back into the base image.
00060   // Pyramid is readonly.
00061   // This is essentially (although not formally) a pure virtual function.
00062   virtual bool put_view(vil_image_view_base const& /*im*/, unsigned /*i0*/, unsigned /*j0*/)
00063   { return false; }
00064 
00065   //: Return a string describing the file format.
00066   // Only file images have a format, others return 0
00067   virtual char const* file_format() const;
00068 
00069   // === Methods particular to pyramid resource ===
00070 
00071   //: Number of pyramid levels.
00072   // In principle, the number of levels is
00073   // undefined since the j2k decoder can decompress to any window size.
00074   // A reasonable strategy is to define the number of levels so that
00075   // the lowest scale produces a smallest image dimension of 1K pixels
00076   virtual unsigned nlevels() const;
00077 
00078   //: Get a partial view from the image from a specified pyramid level
00079   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
00080                                                  unsigned j0, unsigned n_j,
00081                                                  unsigned level) const;
00082 
00083   //: Get a complete view from a specified pyramid level.
00084   // This method needs no specialisation.
00085   virtual vil_image_view_base_sptr get_copy_view(unsigned level) const
00086   { return get_copy_view(0, ni(), 0, nj(), level); }
00087 
00088   //: Get a partial view from the image in the pyramid closest to scale.
00089   // The origin and size parameters are in the coordinate system of the base image.
00090   // The scale factor is with respect to the base image (base scale = 1.0).
00091   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
00092                                                  unsigned j0, unsigned n_j,
00093                                                  const float scale,
00094                                                  float& actual_scale) const;
00095 
00096   //: Get a complete view from the image in the pyramid closest to the specified scale.
00097   // The scale factor is with respect to the base image (base scale = 1.0).
00098   // This method needs no specialisation.
00099   virtual vil_image_view_base_sptr get_copy_view(const float scale, float& actual_scale) const
00100   { return get_copy_view(0, ni(), 0, nj(), scale, actual_scale); }
00101 
00102   //: Copy a resource into the pyramid, level is determined by resource scale
00103   virtual bool put_resource(vil_image_resource_sptr const& resc)
00104     {return false;}
00105 
00106   //: Get an image resource from the pyramid at the specified level
00107   virtual vil_image_resource_sptr get_resource(const unsigned level) const;
00108 
00109   //: for debug purposes
00110   virtual void print(const unsigned level);
00111 
00112  protected:
00113   vil_j2k_nitf2_pyramid_image_resource();
00114   vil_image_resource_sptr nitf2_sptr_;
00115   vil_nitf2_image* ptr_;
00116 };
00117 
00118 #endif // vil_j2k_nitf2_pyramid_image_resource_h_