CVD 0.8
Classes | Functions
Image loading and saving, and format conversion

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

Classes

struct  CVD::IsConvertible< In, Out >
 Can two types be converted with CVD::convert_image? More...
struct  CVD::PixelByPixelConvertible< In, Out >
 Can individual pixels of two types be converted with ConvertPixels::convert()? E.g. More...

Functions

template<>
void CVD::convert_image (const BasicImage< bayer_bggr > &from, BasicImage< byte > &to)
template<>
void CVD::convert_image (const BasicImage< bayer_bggr > &from, BasicImage< Rgb< byte > > &to)
template<>
void CVD::convert_image (const BasicImage< bayer_bggr16 > &from, BasicImage< unsigned short > &to)
template<>
void CVD::convert_image (const BasicImage< bayer_bggr16 > &from, BasicImage< Rgb< unsigned short > > &to)
template<>
void CVD::convert_image (const BasicImage< bayer_bggr16be > &from, BasicImage< unsigned short > &to)
template<>
void CVD::convert_image (const BasicImage< bayer_bggr16be > &from, BasicImage< Rgb< unsigned short > > &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, const std::map< std::string, Parameter<> > &p=std::map< std::string, Parameter<> >())
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())

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.


Function Documentation

template<>
void CVD::convert_image ( const BasicImage< bayer_bggr > &  from,
BasicImage< byte > &  to 
)

Convert Bayer pattern of various forms to greyscale data.

Parameters:
fromThe input data
toThe output data

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

template<>
void CVD::convert_image ( const BasicImage< bayer_bggr > &  from,
BasicImage< Rgb< byte > > &  to 
)

Convert Bayer pattern of various forms to rgb data.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< bayer_bggr16 > &  from,
BasicImage< unsigned short > &  to 
)

Convert 16bit Bayer pattern of various forms to greyscale data.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< bayer_bggr16 > &  from,
BasicImage< Rgb< unsigned short > > &  to 
)

Convert 16bit Bayer pattern of various forms to rgb data.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< bayer_bggr16be > &  from,
BasicImage< unsigned short > &  to 
)

Convert 16bit big endian Bayer pattern of various forms to greyscale data.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< bayer_bggr16be > &  from,
BasicImage< Rgb< unsigned short > > &  to 
)

Convert 16bit big endian Bayer pattern of various forms to rgb data.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< yuv411 > &  from,
BasicImage< Rgb< byte > > &  to 
)

Convert YUV 411 pixel data to RGB.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< yuv411 > &  from,
BasicImage< byte > &  to 
)

Convert YUV 411 pixel data to Y only.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< yuv422 > &  from,
BasicImage< Rgb< byte > > &  to 
)

Convert YUV 422 pixel data to RGB.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< yuv422 > &  from,
BasicImage< byte > &  to 
)

Convert YUV 422 pixel data to Y only.

Parameters:
fromThe input data
toThe output data
template<>
std::pair<Image<byte>,Image<Rgb<byte> > > CVD::convert_image_pair ( const BasicImage< yuv411 > &  from)

Convert YUV 411 pixel data to both Y and RGB.

Parameters:
fromThe input data
template<>
void CVD::convert_image ( const BasicImage< vuy422 > &  from,
BasicImage< Rgb< byte > > &  to 
)

Convert VUY 422 pixel data to RGB.

Parameters:
fromThe input data
toThe output data
template<>
void CVD::convert_image ( const BasicImage< vuy422 > &  from,
BasicImage< byte > &  to 
)

Convert VUY 422 pixel data to Y only.

Parameters:
fromThe input data
toThe output data
template<class D , class Conv , class C >
Image< D > CVD::convert_image ( const SubImage< C > &  from)

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

Parameters:
DThe destination image pixel type
CThe source image pixel type
ConvThe conversion to use
fromThe 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)

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

Parameters:
DThe destination image pixel type
CThe source image pixel type
fromThe image to convert from

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)

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

Parameters:
D1The first destination image pixel type
D2The second destination image pixel type
CThe source image pixel type
fromThe 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)

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:
iThe istream to load from

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

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

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:
iThe istream to load from
template<class I >
void CVD::img_load ( Image< I > &  im,
std::istream &  i 
)

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:
IThe pixel type of the image
imThe image to receive the loaded image data
iThe stream

Definition at line 219 of file image_io.h.

template<class PixelType >
void CVD::img_save ( const BasicImage< PixelType > &  im,
std::ostream &  o,
ImageType::ImageType  t,
const std::map< std::string, Parameter<> > &  p = std::map<std::string, Parameter<> >() 
)

Save an image to a stream.

This function will convert types if necessary.

Parameters:
PixelTypeThe pixel type of the image
ConversionThe conversion class to use
imThe image to save
oThe stream
tThe image file format to use (see ImageType::ImageType for a list of supported formats)

Definition at line 292 of file image_io.h.

References CVD::ImageType::Automatic, CVD::ImageType::BMP, CVD::ImageType::CVD, CVD::ImageType::EPS, CVD::ImageType::FITS, 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::Internal::esm_opt(), and CVD::pnm_save().

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

Save an image to a stream as a PNM.

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

Parameters:
PixelTypeThe pixel type of the image
imThe image
oThe stream

Definition at line 350 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 
)

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:
PixelTypeThe pixel type of the image
imThe image
iThe stream

Definition at line 371 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:
othe 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:
othe ostream
xsthe width of the image
ysthe 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:
othe ostream
ssize of the image
template<class PixelType >
void CVD::output_eps_header ( std::ostream &  o,
const BasicImage< PixelType > &  im 
)

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:
othe ostream
imthe image

Definition at line 410 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() 
)

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:
ininput image to copy from
outoutput image to copy into
sizesize of the area to copy. By default this is the entirty of the input image
beginupper left corner of the area to copy, by default the upper left corner of the input image
dstupper left corner of the destination in the output image, by default the upper left corner of the output image
Exceptions:
ImageRefNotInImageif either begin is not in the input image or dst not in the output image

Definition at line 30 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::combineImages(), CVD::Image< GRADIENT >::copy_from(), CVD::flipHorizontal(), CVD::flipVertical(), and CVD::joinImages().