core/vil/vil_new.h

Go to the documentation of this file.
00001 // This is core/vil/vil_new.h
00002 #ifndef vil_new_h_
00003 #define vil_new_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Make a new image.
00010 //
00011 // If it's very big, it might make a disk image, with a temporary name in which
00012 // case "prototype" will be consulted about issues such as file format etc.  If
00013 // you want more control over the exact disk format, use one of the routines
00014 // with more than 4 arguments.
00015 //
00016 // \author awf@robots.ox.ac.uk
00017 // \date 26 Feb 00
00018 //
00019 // \verbatim
00020 //  Modifications
00021 //   16 Feb 2000 AWF - Initial version.
00022 //   25 Sep 2002 Ian Scott - convert to vil.
00023 //   30 Mar 2007 Peter Vanroose- Removed deprecated vil_new_image_view_j_i_plane
00024 // \endverbatim
00025 
00026 #include <vil/vil_fwd.h>
00027 #include <vil/vil_image_resource.h>
00028 #include <vil/vil_blocked_image_resource.h>
00029 #include <vil/vil_pyramid_image_resource.h>
00030 #include <vil/vil_image_view.h>
00031 
00032 //: Make a new image of given format.
00033 // If the format is not scalar, the number of planes must be 1. When you create
00034 // a multi-component image in this way, the vil_image_resource API will treat
00035 // it as a scalar pixel image with multiple planes. (This doesn't affect the
00036 // underlying data storage.)
00037 // \relates vil_image_resource
00038 vil_image_resource_sptr vil_new_image_resource(unsigned ni, unsigned nj, unsigned nplanes,
00039                                                vil_pixel_format format);
00040 
00041 //: Make a new image of given format with interleaved planes.
00042 // The format must be scalar. 
00043 // \relates vil_image_resource
00044 vil_image_resource_sptr vil_new_image_resource_interleaved(unsigned ni, unsigned nj,
00045                                                            unsigned nplanes,
00046                                                            vil_pixel_format format);
00047 
00048 //: Make a new image resource that is a wrapper on an existing view's data.
00049 // \note The output will be a shallow copy of the input, so changing the pixel values
00050 // of one may change the pixel value of the other. Thanks to the magic of smart pointers,
00051 // the output will remain valid even if you destroy the input. When you wrap
00052 // a multi-component image in this way, the vil_image_resource API will treat
00053 // it as a scalar pixel image with multiple planes. (This doesn't affect the
00054 // underlying data storage.)
00055 // \relates vil_image_resource
00056 vil_image_resource_sptr vil_new_image_resource_of_view(vil_image_view_base const& view);
00057 
00058 
00059 //: Make a new image, similar format to the prototype.
00060 // \relates vil_image_resource
00061 vil_image_resource_sptr vil_new_image_resource(unsigned ni, unsigned nj,
00062                                                vil_image_resource_sptr const& prototype);
00063 
00064 //: Make a new image.
00065 // \relates vil_image_resource
00066 vil_image_resource_sptr vil_new_image_resource(vil_stream* os,
00067                                                unsigned ni, unsigned nj,
00068                                                unsigned nplanes,
00069                                                vil_pixel_format format,
00070                                                char const* file_format = 0);
00071 
00072 //: Make a new image.
00073 // \relates vil_image_resource
00074 vil_image_resource_sptr vil_new_image_resource(char const* filename,
00075                                                unsigned ni, unsigned nj,
00076                                                unsigned nplanes,
00077                                                vil_pixel_format format,
00078                                                char const* file_format = 0);
00079 
00080 //: Make a new vil_image_resource, writing to file "filename", size ni x nj, copying pixel format etc from "prototype".
00081 // \relates vil_image_resource
00082 vil_image_resource_sptr vil_new_image_resource(char const* filename,
00083                                                unsigned ni, unsigned nj,
00084                                                unsigned nplanes,
00085                                                vil_image_resource_sptr const &prototype,
00086                                                char const* format = 0);
00087 
00088 //: Make a new vil_image_resource, writing to stream "os", size ni x nj, copying pixel format etc from "prototype".
00089 // \relates vil_image_resource
00090 vil_image_resource_sptr vil_new_image_resource(vil_stream* os,
00091                                                unsigned ni, unsigned nj,
00092                                                unsigned nplanes,
00093                                                vil_image_resource_sptr const& prototype,
00094                                                char const* file_format = 0);
00095 //: Make a new blocked resource file
00096 vil_blocked_image_resource_sptr
00097 vil_new_blocked_image_resource(vil_stream* os, unsigned ni, unsigned nj,
00098                                unsigned nplanes, vil_pixel_format format,
00099                                unsigned size_block_i, unsigned size_block_j,
00100                                char const* file_format = 0);
00101 
00102 //: Make a new blocked resource file
00103 vil_blocked_image_resource_sptr
00104 vil_new_blocked_image_resource(char const* filename, unsigned ni, unsigned nj,
00105                                unsigned nplanes, vil_pixel_format format,
00106                                unsigned size_block_i, unsigned size_block_j,
00107                                char const* file_format = 0);
00108 
00109 //: create a blocked interface around any image resource
00110 // For zero size blocks, appropriate default blocking is created
00111 vil_blocked_image_resource_sptr
00112 vil_new_blocked_image_facade(const vil_image_resource_sptr& src,
00113                              const unsigned size_block_i=0,
00114                              const unsigned size_block_j=0);
00115 //: Make a new cached resource
00116 vil_blocked_image_resource_sptr
00117 vil_new_cached_image_resource(const vil_blocked_image_resource_sptr& bir,
00118                               const unsigned cache_size = 100);
00119 
00120 
00121 //: Make a new pyramid image resource for writing.
00122 //  Any number of pyramid layers can be inserted and with any scale.
00123 //  Image resources that duplicate existing scales are not inserted.
00124 vil_pyramid_image_resource_sptr
00125 vil_new_pyramid_image_resource(char const* file_or_directory,
00126                                char const* file_format);
00127 
00128 //: Construct a pyramid image resource from a base image.
00129 //  All levels are stored in the same resource file. Each level has the same
00130 //  scale ratio (0.5) to the preceeding level. Level 0 is the original
00131 //  base image. The resource is returned open for reading.
00132 //  The temporary directory is for storing intermediate image
00133 //  resources during the construction of the pyramid. Files are
00134 //  be removed from the directory after completion.  If temp_dir is 0
00135 //  then the intermediate resources are created in memory.
00136 vil_pyramid_image_resource_sptr
00137 vil_new_pyramid_image_from_base(char const* filename,
00138                                 vil_image_resource_sptr const& base_image,
00139                                 unsigned nlevels,
00140                                 char const* file_format,
00141                                 char const* temp_dir);
00142 
00143 //: Construct a new pyramid image resource from a base image
00144 //  The result is a directory containing separate images for each
00145 //  pyramid level. Each level has the same scale ratio (0.5) to the
00146 //  preceeding level and is created using level_file_format.
00147 //  Level 0 is the original base image. If copy_base is false, then Level 0
00148 //  is already present in the directory and is used without modification.
00149 //  Each pyramid file in the directory is
00150 //   named filename + "level_index", e.g. R0, R1, ... Rn.
00151 vil_pyramid_image_resource_sptr
00152 vil_new_pyramid_image_list_from_base(char const* directory,
00153                                      vil_image_resource_sptr const& base_image,
00154                                      unsigned nlevels,
00155                                      bool copy_base,
00156                                      char const* level_file_format,
00157                                      char const* filename);
00158 
00159 #if 0 // deprecated
00160 //: Create a new image view whose plane step is 1.
00161 //  Pixel data type is the type of the last (dummy) argument.
00162 //  i_step will be nplanes, j_step will be nplanes x ni.
00163 // \deprecated in favour of vil_image_view constructor
00164 template <class T>
00165 vil_image_view<T> vil_new_image_view_j_i_plane(unsigned ni, unsigned nj, unsigned nplanes, T /*dummy*/)
00166 {
00167   VXL_DEPRECATED("vil_new_image_view_j_i_plane");
00168   vil_pixel_format fmt = vil_pixel_format_of(T());
00169   vil_memory_chunk_sptr chunk = new vil_memory_chunk(ni*nj*nplanes*sizeof(T),
00170                                                      vil_pixel_format_component_format(fmt));
00171   return vil_image_view<T>(chunk, reinterpret_cast<T*>(chunk->data()), ni, nj, nplanes, nplanes, nplanes*ni, 1);
00172 }
00173 #endif // 0
00174 
00175 //: Create a new image view whose j_step is 1.
00176 //  Pixel data type is the type of the last (dummy) argument.
00177 //  i_step will be nj, planestep will be ni x nj.
00178 template <class T>
00179 vil_image_view<T> vil_new_image_view_plane_i_j(unsigned ni, unsigned nj, unsigned nplanes, T /*dummy*/)
00180 {
00181   vil_pixel_format fmt = vil_pixel_format_of(T());
00182   vil_memory_chunk_sptr chunk = new vil_memory_chunk(ni*nj*nplanes*sizeof(T),
00183                                                      vil_pixel_format_component_format(fmt));
00184   return vil_image_view<T>(chunk, reinterpret_cast<T*>(chunk->data()), ni, nj, nplanes, nj, 1, nj*ni);
00185 }
00186 
00187 //: Create a new image view whose plane step is 1 and whose j_step is nplanes.
00188 //  Pixel data type is the type of the last (dummy) argument.
00189 //  i_step will be nplanes x nj.
00190 template <class T>
00191 vil_image_view<T> vil_new_image_view_i_j_plane(unsigned ni, unsigned nj, unsigned nplanes, T /*dummy*/)
00192 {
00193   vil_pixel_format fmt = vil_pixel_format_of(T());
00194   vil_memory_chunk_sptr chunk = new vil_memory_chunk(ni*nj*nplanes*sizeof(T),
00195                                                      vil_pixel_format_component_format(fmt));
00196   return vil_image_view<T>(chunk, reinterpret_cast<T*>(chunk->data()), ni, nj, nplanes, nplanes*nj, nplanes, 1);
00197 }
00198 
00199 //: Create a shallow copy of an image and wrap it in a vil_image_view_base_sptr
00200 // \note vil_image_view_base_sptr almost certainly doesn't behave as
00201 // you would expect, and this function should really only be used by experts.
00202 vil_image_view_base_sptr vil_new_image_view_base_sptr(const vil_image_view_base&);
00203 
00204 #endif // vil_new_h_

Generated on Mon Oct 13 05:07:42 2008 for core/vil by  doxygen 1.5.1