Image loading and saving, and format conversion


Detailed Description

Functions to support saving and loading of BasicImage and Image to and from streams.

Supports a few common file formats (autodetecting on loading). Also functions for perfoming type conversion as necessary.


Functions

template<>
void CVD::convert_image (const BasicImage< bayer > &from, BasicImage< byte > &to)
template<>
void CVD::convert_image (const BasicImage< bayer > &from, BasicImage< Rgb< byte > > &to)
template<>
void CVD::convert_image (const BasicImage< yuv411 > &from, BasicImage< Rgb< byte > > &to)
template<>
void CVD::convert_image (const BasicImage< yuv411 > &from, BasicImage< byte > &to)
template<>
void CVD::convert_image (const BasicImage< yuv422 > &from, BasicImage< Rgb< byte > > &to)
template<>
void CVD::convert_image (const BasicImage< yuv422 > &from, BasicImage< byte > &to)
template<>
std::pair< Image
< byte >, Image< Rgb
< byte > > > 
CVD::convert_image_pair (const BasicImage< yuv411 > &from)
template<>
void CVD::convert_image (const BasicImage< vuy422 > &from, BasicImage< Rgb< byte > > &to)
template<>
void CVD::convert_image (const BasicImage< vuy422 > &from, BasicImage< byte > &to)
template<class D, class Conv, class C>
Image< D > CVD::convert_image (const SubImage< C > &from)
template<class D, class C>
Image< D > CVD::convert_image (const BasicImage< C > &from)
template<class D1, class D2, class C>
std::pair< Image< D1 >,
Image< D2 > > 
CVD::convert_image_pair (const BasicImage< C > &from)
template<class C>
Image< C > CVD::img_load (std::istream &i)
template<class C>
Image< C > CVD::img_load (std::string &i)
template<class I>
void CVD::img_load (Image< I > &im, std::istream &i)
template<class PixelType>
void CVD::img_save (const BasicImage< PixelType > &im, std::ostream &o, ImageType::ImageType t)
template<class PixelType>
void CVD::pnm_save (const BasicImage< PixelType > &im, std::ostream &o)
template<class PixelType>
void CVD::pnm_load (Image< PixelType > &im, std::istream &i)
void CVD::output_eps_footer (std::ostream &o)
void CVD::output_eps_header (std::ostream &o, int xs, int ys)
void CVD::output_eps_header (std::ostream &o, const ImageRef &s)
template<class PixelType>
void CVD::output_eps_header (std::ostream &o, const BasicImage< PixelType > &im)
template<class S, class T>
void CVD::copy (const BasicImage< S > &in, BasicImage< T > &out, ImageRef size=ImageRef(-1,-1), ImageRef begin=ImageRef(), ImageRef dst=ImageRef())


Function Documentation

template<>
void CVD::convert_image ( const BasicImage< bayer > &  from,
BasicImage< byte > &  to 
) [inline]

Convert Bayer pattern of the form ??? to greyscale data.

Parameters:
from The input data
to The output data

Referenced by CVD::convert_image(), and CVD::convert_image_pair().

template<>
void CVD::convert_image ( const BasicImage< bayer > &  from,
BasicImage< Rgb< byte > > &  to 
) [inline]

Convert Bayer pattern of the form ??? to rgb444 data.

Parameters:
from The input data
to The output data

template<>
void CVD::convert_image ( const BasicImage< yuv411 > &  from,
BasicImage< Rgb< byte > > &  to 
) [inline]

Convert YUV 411 pixel data to RGB.

Parameters:
from The input data
to The output data

template<>
void CVD::convert_image ( const BasicImage< yuv411 > &  from,
BasicImage< byte > &  to 
) [inline]

Convert YUV 411 pixel data to Y only.

Parameters:
from The input data
to The output data

template<>
void CVD::convert_image ( const BasicImage< yuv422 > &  from,
BasicImage< Rgb< byte > > &  to 
) [inline]

Convert YUV 422 pixel data to RGB.

Parameters:
from The input data
to The output data

template<>
void CVD::convert_image ( const BasicImage< yuv422 > &  from,
BasicImage< byte > &  to 
) [inline]

Convert YUV 422 pixel data to Y only.

Parameters:
from The input data
to The output data

template<>
std::pair<Image<byte>,Image<Rgb<byte> > > CVD::convert_image_pair ( const BasicImage< yuv411 > &  from  )  [inline]

Convert YUV 411 pixel data to both Y and RGB.

Parameters:
from The input data

template<>
void CVD::convert_image ( const BasicImage< vuy422 > &  from,
BasicImage< Rgb< byte > > &  to 
) [inline]

Convert VUY 422 pixel data to RGB.

Parameters:
from The input data
to The output data

template<>
void CVD::convert_image ( const BasicImage< vuy422 > &  from,
BasicImage< byte > &  to 
) [inline]

Convert VUY 422 pixel data to Y only.

Parameters:
from The input data
to The output data

template<class D, class Conv, class C>
Image< D > CVD::convert_image ( const SubImage< C > &  from  )  [inline]

Convert an image from one type to another using a specified conversion.

Convert an image from one type to another using the default.

Parameters:
D The destination image pixel type
C The source image pixel type
Conv The conversion to use
from The image to convert from
D The destination image pixel type
C The source image pixel type
from The image to convert from

Definition at line 86 of file image_convert.h.

References CVD::SubImage< T >::size().

template<class D, class C>
Image< D > CVD::convert_image ( const BasicImage< C > &  from  )  [inline]

Convert an image from one type to another using the default.

Parameters:
D The destination image pixel type
C The source image pixel type
from The image to convert from
Type deduction is automatic, and D does not need to be specified. The following usage will work:

 Image<byte> a;
 Image<byte> b;
 ...
 b = convert_image(a);
Note that this is performed using lazy evaluation, so convertion happens on evaluation of assignment.
Parameters:
D The destination image pixel type
C The source image pixel type
from The image to convert from
Returns:
The converted image

Definition at line 117 of file image_convert.h.

References CVD::convert_image(), and CVD::SubImage< T >::size().

template<class D1, class D2, class C>
std::pair<Image<D1>, Image<D2> > CVD::convert_image_pair ( const BasicImage< C > &  from  )  [inline]

Convert an image from one type to another using the default, returning a pair of images.

Parameters:
D1 The first destination image pixel type
D2 The second destination image pixel type
C The source image pixel type
from The image to convert from

Definition at line 133 of file image_convert.h.

References CVD::convert_image(), and CVD::SubImage< T >::size().

template<class C>
Image<C> CVD::img_load ( std::istream &  i  )  [inline]

Load an image from an istream, and return the image.

The template type is deduced automatically, and must not be specified.

The type deduction is performed using lazy evaluation, so the load operation is only performed if an image is assigned from this.

Parameters:
i The istream to load from

Referenced by CVD::DiskBuffer2< T >::DiskBuffer2(), CVD::DiskBuffer2< T >::get_frame(), CVD::img_load(), and CVD::pnm_load().

template<class C>
Image<C> CVD::img_load ( std::string &  i  )  [inline]

Load an image from a file, and return the image.

The template type is deduced automatically, and must not be specified.

The type deduction is performed using lazy evaluation, so the load operation is only performed if an image is assigned from this.

Parameters:
i The istream to load from

template<class I>
void CVD::img_load ( Image< I > &  im,
std::istream &  i 
) [inline]

Load an image from a stream.

This function resizes the Image as necessary. It will also perform image type conversion (e.g. colour to greyscale) according the Pixel:CIE conversion.

Parameters:
I The pixel type of the image
im The image to receive the loaded image data
i The stream

Definition at line 208 of file image_io.h.

template<class PixelType>
void CVD::img_save ( const BasicImage< PixelType > &  im,
std::ostream &  o,
ImageType::ImageType  t 
) [inline]

Save an image to a stream.

This function will convert types if necessary.

Parameters:
PixelType The pixel type of the image
Conversion The conversion class to use
im The image to save
o The stream
t The image file format to use (see ImageType::ImageType for a list of supported formats)

Definition at line 279 of file image_io.h.

References CVD::ImageType::Automatic, CVD::ImageType::BMP, CVD::ImageType::EPS, CVD::ImageType::JPEG, CVD::ImageType::PNG, CVD::ImageType::PNM, CVD::ImageType::PS, CVD::ImageType::TIFF, CVD::ImageType::TXT, and CVD::ImageType::Unknown.

Referenced by CVD::img_save(), and CVD::pnm_save().

template<class PixelType>
void CVD::pnm_save ( const BasicImage< PixelType > &  im,
std::ostream &  o 
) [inline]

Save an image to a stream as a PNM.

Deprecated Use img_save() instead, i.e. img_save(im, o, ImageType::PNM);

Parameters:
PixelType The pixel type of the image
im The image
o The stream

Definition at line 335 of file image_io.h.

References CVD::img_save(), and CVD::ImageType::PNM.

template<class PixelType>
void CVD::pnm_load ( Image< PixelType > &  im,
std::istream &  i 
) [inline]

Load a PNM image from a stream.

Deprecated Use img_load(Image<I>& im, std::istream& i) instead. This can handle and automatically detect other file formats as well.

Loading is simplistic, and automatic conversions of values are performed. So, for instance bytes are assumed to be in the range 0--255 and floats in the range 0--1, so loading bytes in to an Image<float> will result in an image with floats in the range 0--1. In the reverse direction, floats falling outside the range 0--1, will wrap when converted to bytes.

The image loader ignores the data range given by the file, if it is given.

Parameters:
PixelType The pixel type of the image
im The image
i The stream

Definition at line 356 of file image_io.h.

References CVD::img_load().

void CVD::output_eps_footer ( std::ostream &  o  ) 

Outputs an EPS footer to an ostream.

Parameters:
o the ostream

void CVD::output_eps_header ( std::ostream &  o,
int  xs,
int  ys 
)

Outputs an EPS header to an ostream.

Typical use is to output the header, save a raw PS image, output some other PS (eg annotations) and the output the EPS footer.

Parameters:
o the ostream
xs the width of the image
ys the height of the image

Referenced by CVD::output_eps_header().

void CVD::output_eps_header ( std::ostream &  o,
const ImageRef &  s 
)

Outputs an EPS header to an ostream.

Typical use is to output the header, save a raw PS image, output some other PS (eg annotations) and the output the EPS footer.

Parameters:
o the ostream
s size of the image

template<class PixelType>
void CVD::output_eps_header ( std::ostream &  o,
const BasicImage< PixelType > &  im 
) [inline]

Outputs an EPS header to an ostream.

Typical use is to output the header, save a raw PS image, output some other PS (eg annotations) and the output the EPS footer.

Parameters:
o the ostream
im the image

Definition at line 395 of file image_io.h.

References CVD::output_eps_header(), and CVD::SubImage< T >::size().

template<class S, class T>
void CVD::copy ( const BasicImage< S > &  in,
BasicImage< T > &  out,
ImageRef  size = ImageRef(-1,-1),
ImageRef  begin = ImageRef(),
ImageRef  dst = ImageRef() 
) [inline]

Generic image copy function for copying sub rectangles of images into other images.

This performs pixel type conversion if the input and output images are different pixel types.

Parameters:
in input image to copy from
out output image to copy into
size size of the area to copy. By default this is the entirty of the input image
begin upper left corner of the area to copy, by default the upper left corner of the input image
dst upper left corner of the destination in the output image, by default the upper left corner of the output image
Exceptions:
ImageRefNotInImage if either begin is not in the input image or dst not in the output image

Definition at line 26 of file utility.h.

References CVD::SubImage< T >::data(), CVD::SubImage< T >::in_image(), CVD::SubImage< T >::size(), CVD::SubImage< T >::totalsize(), and CVD::ImageRef::x.

Referenced by CVD::CastCopy< T, T >::cast_copy(), CVD::combineImages(), CVD::Image< CVD::Rgb< unsigned char > >::copy_from(), CVD::flipVertical(), CVD::GetPixelRowTyped< A, B >::get(), CVD::Internal::haar1D(), and CVD::joinImages().


Generated on Wed Feb 18 10:23:03 2009 for CVD by  doxygen 1.5.3