core/vil/file_formats/vil_j2k_pyramid_image_resource.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_j2k_pyramid_image_resource.h
00002 #ifndef vil_j2k_pyramid_image_resource_h_
00003 #define vil_j2k_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 the j2k_image
00010 //
00011 // \author J. L. Mundy
00012 // \date April 22, 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_j2k_image.h>
00020 
00021 class vil_j2k_pyramid_image_resource : public vil_pyramid_image_resource
00022 {
00023  public:
00024   vil_j2k_pyramid_image_resource(vil_image_resource_sptr const& j2k);
00025   virtual ~vil_j2k_pyramid_image_resource(){}
00026 
00027   //: The number of planes (or components) in the image.
00028   // Dimensions:  Planes x ni x nj.
00029   // This method refers to the base (max resolution) image
00030   // This concept is treated as a synonym to components.
00031   virtual unsigned nplanes() const;
00032 
00033   //: The number of pixels in each row.
00034   // Dimensions:  Planes x ni x nj.
00035   // This method refers to the base (max resolution) image
00036   virtual unsigned ni() const;
00037 
00038   //: The number of pixels in each column.
00039   // Dimensions:  Planes x ni x nj.
00040   // This method refers to the base (max resolution) image
00041   virtual unsigned nj() const;
00042 
00043   //: Pixel Format.
00044   virtual enum vil_pixel_format pixel_format() const;
00045 
00046   //: Put the data in this view back into the base image.
00047   // Pyramid is readonly.
00048   // This is essentially (although not formally) a pure virtual function.
00049   virtual bool put_view(vil_image_view_base const& /*im*/, unsigned /*i0*/, unsigned /*j0*/)
00050   { return false; }
00051 
00052   //: Return a string describing the file format.
00053   // Only file images have a format, others return 0
00054   virtual char const* file_format() const;
00055 
00056   // === Methods particular to pyramid resource ===
00057 
00058   //: Number of pyramid levels.
00059   // In principle, the number of levels is
00060   // undefined since the j2k decoder can decompress to any window size.
00061   // A reasonable strategy is to define the number of levels so that
00062   // the lowest scale produces a smallest image dimension of 1K pixels
00063   virtual unsigned nlevels() const;
00064 
00065   //: Get a partial view from the image from a specified pyramid level
00066   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
00067                                                  unsigned j0, unsigned n_j,
00068                                                  unsigned level) const;
00069 
00070   //: Get a complete view from a specified pyramid level.
00071   // This method needs no specialisation.
00072   virtual vil_image_view_base_sptr get_copy_view(unsigned level) const
00073   { return get_copy_view(0, ni(), 0, nj(), level); }
00074 
00075   //: Get a partial view from the image in the pyramid closest to scale.
00076   // The origin and size parameters are in the coordinate system of the base image.
00077   // The scale factor is with respect to the base image (base scale = 1.0).
00078   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
00079                                                  unsigned j0, unsigned n_j,
00080                                                  const float scale,
00081                                                  float& actual_scale) const;
00082 
00083   //: Get a complete view from the image in the pyramid closest to the specified scale.
00084   // The scale factor is with respect to the base image (base scale = 1.0).
00085   // This method needs no specialisation.
00086   virtual vil_image_view_base_sptr get_copy_view(const float scale, float& actual_scale) const
00087   { return get_copy_view(0, ni(), 0, nj(), scale, actual_scale); }
00088 
00089   //: Copy a resource into the pyramid, level is determined by resource scale
00090   virtual bool put_resource(vil_image_resource_sptr const& resc)
00091     {return false;}
00092 
00093   //: Get an image resource from the pyramid at the specified level
00094   virtual vil_image_resource_sptr get_resource(const unsigned level) const;
00095 
00096   //: for debug purposes
00097   virtual void print(const unsigned level);
00098 
00099  protected:
00100   vil_j2k_pyramid_image_resource();
00101   vil_image_resource_sptr j2k_sptr_;
00102   vil_j2k_image* ptr_;
00103 };
00104 
00105 
00106 #endif // vil_j2k_pyramid_image_resource_h_