core/vil/file_formats/vil_openjpeg_pyramid_image_resource.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_openjpeg_pyramid_image_resource.h
00002 #ifndef vil_openjpeg_pyramid_image_resource_h_
00003 #define vil_openjpeg_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 openjpeg_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_openjpeg.h>
00020 
00021 class vil_openjpeg_pyramid_image_resource : public vil_pyramid_image_resource
00022 {
00023  public:
00024   vil_openjpeg_pyramid_image_resource(vil_image_resource_sptr const& openjpeg);
00025   virtual ~vil_openjpeg_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   virtual unsigned nlevels() const;
00060 
00061   //: Get a partial view from the image from a specified pyramid level
00062   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00063                                                  unsigned j0, unsigned nj,
00064                                                  unsigned level) const;
00065 
00066   //: Get a complete view from a specified pyramid level.
00067   // This method needs no specialization.
00068   virtual vil_image_view_base_sptr get_copy_view(unsigned level) const
00069   { return get_copy_view(0, ni(), 0, nj(), level); }
00070 
00071   //: Get a partial view from the image in the pyramid closest to scale.
00072   // The origin and size parameters are in the coordinate system of the base image.
00073   // The scale factor is with respect to the base image (base scale = 1.0).
00074   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00075                                                  unsigned j0, unsigned nj,
00076                                                  const float scale,
00077                                                  float& actual_scale) const;
00078 
00079   //: Get a complete view from the image in the pyramid closest to the specified scale.
00080   // The scale factor is with respect to the base image (base scale = 1.0).
00081   // This method needs no specialization.
00082   virtual vil_image_view_base_sptr get_copy_view(const float scale, float& actual_scale) const
00083   { return get_copy_view(0, ni(), 0, nj(), scale, actual_scale); }
00084 
00085   //: Copy a resource into the pyramid, level is determined by resource scale
00086   virtual bool put_resource(vil_image_resource_sptr const& resc)
00087     {return false;}
00088 
00089   //: Get an image resource from the pyramid at the specified level
00090   virtual vil_image_resource_sptr get_resource(const unsigned level) const;
00091 
00092   //: for debug purposes
00093   virtual void print(const unsigned level);
00094 
00095  protected:
00096   vil_openjpeg_pyramid_image_resource();
00097   vil_image_resource_sptr openjpeg_sptr_;
00098   vil_openjpeg_image* ptr_;
00099 };
00100 
00101 
00102 #endif // vil_openjpeg_pyramid_image_resource_h_