Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vil_j2k_image Class Reference

#include <vil_j2k_image.h>

Inheritance diagram for vil_j2k_image:

Inheritance graph
[legend]
List of all members.

Detailed Description

Class capable of reading JPEG2000 Part I files and ECW (ER Mapper's proprietary format) image files.

They can either be local or hosted on an Image Web Server. Either way, you just pass in the file path or url (eg. "ecwp://www.earthetc.com/images/australia/Sydney.ecw") to the ctor. The call get_copy_view() to get the image data that you want. The class efficiently handles reading large images (Terrabytes) -- and can read image portions without loading the whole file into memory.

Because the source image can be really big, it is possible (through the get_copy_view() API) to ask for more data than you can handle in memory -- or more than you download for the remote case. That is why the setMaxImageDimension() guard is in place. You can set a max image dimension for both remote and local files (different values for each). Then if you call get_copy_view() asking for an image that is too big, get_copy_view() will scale down the image to the max dimension you specified. It does this silently -- perhaps we could/should change this?

Writing not currently supported.

Note that, in order to use this class, you need to use cmake to cofigure VXL to link against Er Mapper's freely available ECW JPEG 2000 SDK (http://ermapper.com/downloads/sdks.aspx#16).

Definition at line 47 of file vil_j2k_image.h.

Public Member Functions

 vil_j2k_image (const vcl_string &fileOrUrl)
 vil_j2k_image (vil_stream *is)
 Read a jpeg 2000 image from a stream containing either a raw j2k codestream or a jp2 file stream.
 ~vil_j2k_image ()
virtual unsigned nplanes () const
 Dimensions: planes x width x height x components.
virtual unsigned ni () const
 Dimensions: Planes x ni x nj.
virtual unsigned nj () const
 Dimensions: Planes x ni x nj.
virtual enum vil_pixel_format pixel_format () const
 Pixel Format.
virtual bool get_property (char const *, void *=0) const
 Extra property information.
virtual bool put_view (const vil_image_view_base &, unsigned, unsigned)
 Put the data in this view back into the image source.
virtual vil_image_view_base_sptr get_copy_view (unsigned i0, unsigned ni, unsigned j0, unsigned nj) const
 Create a read/write view of a copy of this data.
virtual vil_image_view_base_sptr get_copy_view_decimated (unsigned i0, unsigned ni, unsigned j0, unsigned nj, double i_factor, double j_factor) const
virtual vil_image_view_base_sptr get_copy_view_decimated_by_size (unsigned i0, unsigned ni, unsigned j0, unsigned nj, unsigned int output_width, unsigned int output_height) const
vil_image_view_base_sptr get_copy_view () const
 Create a read/write view of a copy of all the data.
bool is_valid () const
 Call this after construction to see if you can get valid data from me.
void setMaxImageDimension (unsigned int widthOrHeight, bool remote=false)
 When calling get_copy_view(), the function will scale down the output image_view so that neither dimension (x or y) is greater than widthOrHeight.
void unsetMaxImageDimension (bool remote=false)
 Call this if you don't want get_copy_view() to do size checking.
virtual vil_image_view_base_sptr get_view (unsigned i0, unsigned n_i, unsigned j0, unsigned n_j) const
 Create a read/write view of the data.
vil_image_view_base_sptr get_view () const
 Create a read/write view of all the data.
bool put_view (const vil_image_view_base &im)
 Put the data in this view back into the image source at the origin.
virtual bool view_fits (const vil_image_view_base &im, unsigned i0, unsigned j0)
 Check that a view will fit into the data at the given offset.
virtual char const * file_format () const
 Return a string describing the file format.

Static Public Member Functions

static vil_image_view_base_sptr s_decode_jpeg_2000 (vil_stream *vs, unsigned i0, unsigned ni, unsigned j0, unsigned nj, double i_factor, double j_factor)
 Static function that can be used to decode a JPEG2000 codestream or file (jp2 file).
static vil_image_view_base_sptr s_decode_jpeg_2000_by_size (vil_stream *vs, unsigned i0, unsigned ni, unsigned j0, unsigned nj, unsigned int output_width, unsigned int output_height)

Protected Member Functions

void ref ()
void unref ()

Protected Attributes

CNCSFile * mFileResource
unsigned int mMaxLocalDimension
unsigned int mMaxRemoteDimension
 Same as.
bool mRemoteFile
 file is remote
int reference_count_

Friends

class vil_smart_ptr< vil_image_resource >

Related Functions

(Note that these are not member functions.)

template<class destT, class kernelT, class accumT>
vil_image_resource_sptr vil_convolve_1d (const vil_image_resource_sptr &src_im, const destT, const kernelT *kernel, int k_lo, int k_hi, const accumT, vil_convolve_boundary_option start_option, vil_convolve_boundary_option end_option)
 Create an image_resource object which convolve kernel[x] x in [k_lo,k_hi] with srcT.
template<class destT, class kernelT, class accumT>
vil_image_resource_sptr vil_correlate_1d (const vil_image_resource_sptr &src_im, const destT, const kernelT *kernel, vcl_ptrdiff_t k_lo, vcl_ptrdiff_t k_hi, const accumT, vil_convolve_boundary_option start_option, vil_convolve_boundary_option end_option)
 Create an image_resource object which correlate kernel[x] x in [k_lo,k_hi] with srcT.
bool vil_copy_deep (const vil_image_resource_sptr &src, vil_image_resource_sptr &dest)
 Copy src to dest.
vil_image_resource_sptr vil_crop (const vil_image_resource_sptr &src, unsigned i0, unsigned n_i, unsigned j0, unsigned n_j)
 Crop to a region of src.
vil_image_resource_sptr vil_decimate (const vil_image_resource_sptr &src, unsigned i_factor, unsigned j_factor=0)
 decimate to a region of src.
vil_image_resource_sptr vil_load_image_resource (char const *filename)
 Load an image resource object from a file.
vil_image_resource_sptr vil_new_image_resource (unsigned ni, unsigned nj, vil_image_resource_sptr const &prototype)
 Make a new image, similar format to the prototype.
vil_image_resource_sptr vil_new_image_resource (vil_stream *os, unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format, char const *file_format)
 Make a new image.
vil_image_resource_sptr vil_new_image_resource (char const *filename, unsigned ni, unsigned nj, vil_image_resource_sptr const &prototype, char const *file_format)
 Make a new vil_image_resource, writing to file "filename", size ni x nj, copying pixel format etc from "prototype".
vil_image_resource_sptr vil_new_image_resource (char const *filename, unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format, char const *file_format)
 Make a new image.
vil_image_resource_sptr vil_new_image_resource (vil_stream *os, unsigned ni, unsigned nj, vil_image_resource_sptr const &prototype, char const *file_format)
 Make a new vil_image_resource, writing to stream "os", size ni x nj, copying pixel format etc from "prototype".
vil_image_resource_sptr vil_new_image_resource (char const *filename, unsigned ni, unsigned nj, unsigned nplanes, vil_image_resource_sptr const &prototype, char const *format=0)
 Make a new vil_image_resource, writing to file "filename", size ni x nj, copying pixel format etc from "prototype".
vil_image_resource_sptr vil_new_image_resource (vil_stream *os, unsigned ni, unsigned nj, unsigned nplanes, vil_image_resource_sptr const &prototype, char const *file_format=0)
 Make a new vil_image_resource, writing to stream "os", size ni x nj, copying pixel format etc from "prototype".
bool vil_save_image_resource (const vil_image_resource_sptr &ir, char const *filename, char const *file_format)
 Send vil_image_resource to disk.
bool vil_save_image_resource (const vil_image_resource_sptr &ir, char const *filename)
 Save vil_image_resource to file, deducing format from filename.


Constructor & Destructor Documentation

vil_j2k_image::vil_j2k_image const vcl_string &  fileOrUrl  ) 
 

Parameters:
filelOrUrl,: can either be a local file (eg. /home/beavis/file1.jp2) or it can be a url to a file hosted on an Image Web Server (eg. ecwp://www.earthetc.com/images/australia/Sydney.ecw or ecwp://www.earthetc.com/images/usa/1metercalif.ecw

Definition at line 96 of file vil_j2k_image.cxx.

vil_j2k_image::vil_j2k_image vil_stream is  ) 
 

Read a jpeg 2000 image from a stream containing either a raw j2k codestream or a jp2 file stream.

is' current position needs to be pointing at the beginning of one of these two things. In other words, the beginning of the stream must contain one of the two signatures:

  • Hex( FF 4F ) -- (codestream)
  • Hex( 00 00 00 0C 6A 50 20 20 0D 0A 87 0A ) -- jp2 file

Note that some references state that jp2 files start with ( 00 00 00 0C 6A 50 1A 1A 0D 0A 87 0A ) [note the 1A 1A difference]. I believe this was changed between the last draft and the final version of ISO/IEC 155444-1 (JPEG standard). I have never seen a real jp2 file with this old signature (including the official jpeg conformance test files)

also note: Don't use is while I'm trying to use it... it'll screw us both up.

Definition at line 115 of file vil_j2k_image.cxx.

vil_j2k_image::~vil_j2k_image  ) 
 

Definition at line 132 of file vil_j2k_image.cxx.


Member Function Documentation

virtual char const* vil_image_resource::file_format  )  const [inline, virtual, inherited]
 

Return a string describing the file format.

Only file images have a format, others return 0

Reimplemented in vil_bmp_image, vil_dicom_image, vil_iris_generic_image, vil_jpeg_image, vil_mit_image, vil_nitf2_image, vil_png_image, vil_pnm_image, vil_pyramid_image_list, vil_ras_image, vil_tiff_image, vil_tiff_pyramid_resource, vil_viff_image, and vil_pyramid_image_resource.

Definition at line 100 of file vil_image_resource.h.

vil_image_view_base_sptr vil_j2k_image::get_copy_view  )  const [inline]
 

Create a read/write view of a copy of all the data.

Reimplemented from vil_image_resource.

Definition at line 99 of file vil_j2k_image.h.

vil_image_view_base_sptr vil_j2k_image::get_copy_view unsigned  i0,
unsigned  ni,
unsigned  j0,
unsigned  nj
const [virtual]
 

Create a read/write view of a copy of this data.

Returns:
0 if unable to get view of correct size.

Implements vil_image_resource.

Definition at line 278 of file vil_j2k_image.cxx.

vil_image_view_base_sptr vil_j2k_image::get_copy_view_decimated unsigned  i0,
unsigned  ni,
unsigned  j0,
unsigned  nj,
double  i_factor,
double  j_factor
const [virtual]
 

Definition at line 164 of file vil_j2k_image.cxx.

vil_image_view_base_sptr vil_j2k_image::get_copy_view_decimated_by_size unsigned  i0,
unsigned  ni,
unsigned  j0,
unsigned  nj,
unsigned int  output_width,
unsigned int  output_height
const [virtual]
 

Definition at line 180 of file vil_j2k_image.cxx.

virtual bool vil_j2k_image::get_property char const *  ,
void *  = 0
const [inline, virtual]
 

Extra property information.

Implements vil_image_resource.

Definition at line 79 of file vil_j2k_image.h.

vil_image_view_base_sptr vil_image_resource::get_view  )  const [inline, inherited]
 

Create a read/write view of all the data.

Definition at line 68 of file vil_image_resource.h.

virtual vil_image_view_base_sptr vil_image_resource::get_view unsigned  i0,
unsigned  n_i,
unsigned  j0,
unsigned  n_j
const [inline, virtual, inherited]
 

Create a read/write view of the data.

Modifying this view might modify the actual data. If you want to modify this data in place, call put_view after you done, and it should work efficiently. This function will always return a multi-plane scalar-pixel view of the data.

Returns:
0 if unable to get view of correct size, or if resource is write-only.
If you want to fill an existing view (e.g. a window onto some other image), then use
   vil_reformat(data->get_view(..), window);
  

Reimplemented in vil_dicom_image, vil_clamp_image_resource, vil_crop_image_resource, vil_decimate_image_resource, vil_flip_lr_image_resource, vil_flip_ud_image_resource, vil_memory_image, vil_plane_image_resource, and vil_transpose_image_resource.

Definition at line 63 of file vil_image_resource.h.

bool vil_j2k_image::is_valid  )  const [inline]
 

Call this after construction to see if you can get valid data from me.

If this returns false, then this image is of no use to you

Definition at line 105 of file vil_j2k_image.h.

unsigned vil_j2k_image::ni  )  const [virtual]
 

Dimensions: Planes x ni x nj.

The number of pixels in each row.

Implements vil_image_resource.

Definition at line 145 of file vil_j2k_image.cxx.

unsigned vil_j2k_image::nj  )  const [virtual]
 

Dimensions: Planes x ni x nj.

The number of pixels in each column.

Implements vil_image_resource.

Definition at line 151 of file vil_j2k_image.cxx.

unsigned vil_j2k_image::nplanes  )  const [virtual]
 

Dimensions: planes x width x height x components.

Implements vil_image_resource.

Definition at line 139 of file vil_j2k_image.cxx.

enum vil_pixel_format vil_j2k_image::pixel_format  )  const [virtual]
 

Pixel Format.

A standard RGB RGB RGB of chars image has pixel_format() == VIL_PIXEL_FORMAT_BYTE

Implements vil_image_resource.

Definition at line 157 of file vil_j2k_image.cxx.

bool vil_image_resource::put_view const vil_image_view_base im  )  [inline, inherited]
 

Put the data in this view back into the image source at the origin.

Definition at line 91 of file vil_image_resource.h.

virtual bool vil_j2k_image::put_view const vil_image_view_base ,
unsigned  ,
unsigned 
[inline, virtual]
 

Put the data in this view back into the image source.

The view must be of scalar components. Assign your view to a scalar-component view if this is not the case.

Returns:
false if failed, because e.g. resource is read-only, format of view is not correct (if it is a compound pixel type, try assigning it to a multi-plane scalar pixel view.)

Implements vil_image_resource.

Definition at line 81 of file vil_j2k_image.h.

void vil_image_resource::ref  )  [inline, protected, inherited]
 

Definition at line 109 of file vil_image_resource.h.

vil_image_view_base_sptr vil_j2k_image::s_decode_jpeg_2000 vil_stream vs,
unsigned  i0,
unsigned  ni,
unsigned  j0,
unsigned  nj,
double  i_factor,
double  j_factor
[static]
 

Static function that can be used to decode a JPEG2000 codestream or file (jp2 file).

The stream must start at vs' current position.

Definition at line 301 of file vil_j2k_image.cxx.

vil_image_view_base_sptr vil_j2k_image::s_decode_jpeg_2000_by_size vil_stream vs,
unsigned  i0,
unsigned  ni,
unsigned  j0,
unsigned  nj,
unsigned int  output_width,
unsigned int  output_height
[static]
 

Definition at line 313 of file vil_j2k_image.cxx.

void vil_j2k_image::setMaxImageDimension unsigned int  widthOrHeight,
bool  remote = false
 

When calling get_copy_view(), the function will scale down the output image_view so that neither dimension (x or y) is greater than widthOrHeight.

This feature is here to protect you in the case that your code asks for an excessively large image that will crash your program. You can turn this checking off with

See also:
unsetMaxImageDimension() By default, this value is set to 5000.

Definition at line 292 of file vil_j2k_image.cxx.

void vil_image_resource::unref  )  [inline, protected, inherited]
 

Definition at line 110 of file vil_image_resource.h.

void vil_j2k_image::unsetMaxImageDimension bool  remote = false  ) 
 

Call this if you don't want get_copy_view() to do size checking.

Be warned that jpeg 2000 codestreams can be really big, so you could cause a program crash.

Definition at line 286 of file vil_j2k_image.cxx.

bool vil_image_resource::view_fits const vil_image_view_base im,
unsigned  i0,
unsigned  j0
[virtual, inherited]
 

Check that a view will fit into the data at the given offset.

This includes checking that the pixel type is scalar.

Definition at line 30 of file vil_image_resource.cxx.


Friends And Related Function Documentation

template<class destT, class kernelT, class accumT>
vil_image_resource_sptr vil_convolve_1d const vil_image_resource_sptr src_im,
const destT  ,
const kernelT *  kernel,
int  k_lo,
int  k_hi,
const accumT  ,
vil_convolve_boundary_option  start_option,
vil_convolve_boundary_option  end_option
[related, inherited]
 

Create an image_resource object which convolve kernel[x] x in [k_lo,k_hi] with srcT.

Note:
This function reverses the kernel. If you don't want the kernel reversed, use vil_correlate_1d instead.
Parameters:
kernel should point to tap 0.

Definition at line 404 of file vil_convolve_1d.h.

bool vil_copy_deep const vil_image_resource_sptr src,
vil_image_resource_sptr dest
[related, inherited]
 

Copy src to dest.

This is useful if you want to copy on image into a window on another image. src and dest must have identical sizes, and pixel-types. Returns false if the copy failed. O(size).

Definition at line 44 of file vil_copy.cxx.

template<class destT, class kernelT, class accumT>
vil_image_resource_sptr vil_correlate_1d const vil_image_resource_sptr src_im,
const destT  ,
const kernelT *  kernel,
vcl_ptrdiff_t  k_lo,
vcl_ptrdiff_t  k_hi,
const accumT  ,
vil_convolve_boundary_option  start_option,
vil_convolve_boundary_option  end_option
[related, inherited]
 

Create an image_resource object which correlate kernel[x] x in [k_lo,k_hi] with srcT.

Note:
This function does not reverse the kernel. If you want the kernel reversed, use vil_convolve_1d instead.
Parameters:
kernel should point to tap 0.

Definition at line 214 of file vil_correlate_1d.h.

vil_image_resource_sptr vil_crop const vil_image_resource_sptr src,
unsigned  i0,
unsigned  n_i,
unsigned  j0,
unsigned  n_j
[related, inherited]
 

Crop to a region of src.

Definition at line 14 of file vil_crop.cxx.

vil_image_resource_sptr vil_decimate const vil_image_resource_sptr src,
unsigned  i_factor,
unsigned  j_factor = 0
[related, inherited]
 

decimate to a region of src.

vil_image_resource_sptr vil_load_image_resource char const *  filename  )  [related, inherited]
 

Load an image resource object from a file.

Definition at line 52 of file vil_load.cxx.

vil_image_resource_sptr vil_new_image_resource vil_stream os,
unsigned  ni,
unsigned  nj,
unsigned  nplanes,
vil_image_resource_sptr const &  prototype,
char const *  file_format = 0
[related, inherited]
 

Make a new vil_image_resource, writing to stream "os", size ni x nj, copying pixel format etc from "prototype".

vil_image_resource_sptr vil_new_image_resource char const *  filename,
unsigned  ni,
unsigned  nj,
unsigned  nplanes,
vil_image_resource_sptr const &  prototype,
char const *  format = 0
[related, inherited]
 

Make a new vil_image_resource, writing to file "filename", size ni x nj, copying pixel format etc from "prototype".

vil_image_resource_sptr vil_new_image_resource vil_stream os,
unsigned  ni,
unsigned  nj,
vil_image_resource_sptr const &  prototype,
char const *  file_format
[related, inherited]
 

Make a new vil_image_resource, writing to stream "os", size ni x nj, copying pixel format etc from "prototype".

Definition at line 141 of file vil_new.cxx.

vil_image_resource_sptr vil_new_image_resource char const *  filename,
unsigned  ni,
unsigned  nj,
unsigned  nplanes,
vil_pixel_format  format,
char const *  file_format
[related, inherited]
 

Make a new image.

Definition at line 122 of file vil_new.cxx.

vil_image_resource_sptr vil_new_image_resource char const *  filename,
unsigned  ni,
unsigned  nj,
vil_image_resource_sptr const &  prototype,
char const *  file_format
[related, inherited]
 

Make a new vil_image_resource, writing to file "filename", size ni x nj, copying pixel format etc from "prototype".

Definition at line 103 of file vil_new.cxx.

vil_image_resource_sptr vil_new_image_resource vil_stream os,
unsigned  ni,
unsigned  nj,
unsigned  nplanes,
vil_pixel_format  format,
char const *  file_format
[related, inherited]
 

Make a new image.

Definition at line 76 of file vil_new.cxx.

vil_image_resource_sptr vil_new_image_resource unsigned  ni,
unsigned  nj,
vil_image_resource_sptr const &  prototype
[related, inherited]
 

Make a new image, similar format to the prototype.

Definition at line 68 of file vil_new.cxx.

bool vil_save_image_resource const vil_image_resource_sptr ir,
char const *  filename
[related, inherited]
 

Save vil_image_resource to file, deducing format from filename.

bool vil_save_image_resource const vil_image_resource_sptr ir,
char const *  filename,
char const *  file_format
[related, inherited]
 

Send vil_image_resource to disk.

friend class vil_smart_ptr< vil_image_resource > [friend, inherited]
 

Definition at line 108 of file vil_image_resource.h.


Member Data Documentation

CNCSFile* vil_j2k_image::mFileResource [protected]
 

Definition at line 135 of file vil_j2k_image.h.

unsigned int vil_j2k_image::mMaxLocalDimension [protected]
 

See also:
setMaxImageDimension and

unsetMaxImageDimension

if this equals vcl_numeric_limits<unsigned int>::max(), then this feature is turned off Of course I'm ignored if mRemoteFile is true

Definition at line 141 of file vil_j2k_image.h.

unsigned int vil_j2k_image::mMaxRemoteDimension [protected]
 

Same as.

See also:
mMaxLocalDimension but applies to remote files. This is typically a smaller number because of the speed concerns of downloading a very largeimage

Definition at line 146 of file vil_j2k_image.h.

bool vil_j2k_image::mRemoteFile [protected]
 

file is remote

Definition at line 148 of file vil_j2k_image.h.

int vil_image_resource::reference_count_ [protected, inherited]
 

Definition at line 113 of file vil_image_resource.h.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 14:40:08 2008 for core/vil by  doxygen 1.4.4