EMAN2
Functions
emdata_io.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void read_image (const string &filename, int img_index=0, bool header_only=false, const Region *region=0, bool is_3d=false)
 $Id$
void read_binedimage (const string &filename, int img_index=0, int binfactor=0, bool fast=false, bool is_3d=false)
 read in a binned image, bin while reading.
void write_image (const string &filename, int img_index=0, EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false, const Region *region=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)
 write the header and data out to an image.
void append_image (const string &filename, EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false)
 append to an image file; If the file doesn't exist, create one.
void write_lst (const string &filename, const string &reffile="", int refn=-1, const string &comment="")
 Append data to a LST image file.
void print_image (const string str=string(""), ostream &out=std::cout)
 Print the image data to a file stream (standard out by default).
static vector
< boost::shared_ptr< EMData > > 
read_images (const string &filename, vector< int >img_indices=vector< int >(), bool header_only=false)
 Read a set of images from file specified by 'filename'.
static vector
< boost::shared_ptr< EMData > > 
read_images_ext (const string &filename, int img_index_start, int img_index_end, bool header_only=false, const string &ext="")
 Read a set of images from file specified by 'filename'.

Function Documentation

void append_image ( const string &  filename,
EMUtil::ImageType  imgtype = EMUtil::IMAGE_UNKNOWN,
bool  header_only = false 
)

append to an image file; If the file doesn't exist, create one.

Parameters:
filenameThe image file name.
imgtypeWrite to the given image format type. if not specified, use the 'filename' extension to decide.
header_onlyTo write only the header or both header and data.
void print_image ( const string  str = string(""),
ostream &  out = std::cout 
)

Print the image data to a file stream (standard out by default).

Parameters:
outOutput stream; cout by default.
strMessage string to be printed.
void read_binedimage ( const string &  filename,
int  img_index = 0,
int  binfactor = 0,
bool  fast = false,
bool  is_3d = false 
)

read in a binned image, bin while reading.

For use in huge files(tomograms)

Parameters:
filenameThe image file name.
img_indexThe nth image you want to read.
binfactorThe amout you want to bin by. Must be an integer
fastOnly bin xy slice every binfactor intervals, otherwise meanshrink z
is_3dWhether to treat the image as a single 3D or a set of 2Ds. This is a hint for certain image formats which has no difference between 3D image and set of 2Ds.
Exceptions:
ImageFormatException
ImageReadException
void read_image ( const string &  filename,
int  img_index = 0,
bool  header_only = false,
const Region *  region = 0,
bool  is_3d = false 
)

$Id$

This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata.h", NEVER directly include this file. read an image file and stores its information to this EMData object.

If a region is given, then only read a region of the image file. The region will be this EMData object. The given region must be inside the given image file. Otherwise, an error will be created.

Parameters:
filenameThe image file name.
img_indexThe nth image you want to read.
header_onlyTo read only the header or both header and data.
regionTo read only a region of the image.
is_3dWhether to treat the image as a single 3D or a set of 2Ds. This is a hint for certain image formats which has no difference between 3D image and set of 2Ds.
Exceptions:
ImageFormatException
ImageReadException
static vector< boost::shared_ptr<EMData> > read_images ( const string &  filename,
vector< int >  img_indices = vector< int >(),
bool  header_only = false 
) [static]

Read a set of images from file specified by 'filename'.

Which images are read is set by 'img_indices'.

Parameters:
filenameThe image file name.
img_indicesWhich images are read. If it is empty, all images are read. If it is not empty, only those in this array are read.
header_onlyIf true, only read image header. If false, read both data and header.
Returns:
The set of images read from filename.

Referenced by EMAN::EMUtil::get_all_attributes().

static vector< boost::shared_ptr<EMData> > read_images_ext ( const string &  filename,
int  img_index_start,
int  img_index_end,
bool  header_only = false,
const string &  ext = "" 
) [static]

Read a set of images from file specified by 'filename'.

If the given 'ext' is not empty, replace 'filename's extension it. Images with index from img_index_start to img_index_end are read.

Parameters:
filenameThe image file name.
img_index_startStarting image index.
img_index_endEnding image index.
header_onlyIf true, only read image header. If false, read both data and header.
extThe new image filename extension.
Returns:
The set of images read from filename.
void write_image ( const string &  filename,
int  img_index = 0,
EMUtil::ImageType  imgtype = EMUtil::IMAGE_UNKNOWN,
bool  header_only = false,
const Region *  region = 0,
EMUtil::EMDataType  filestoragetype = EMUtil::EM_FLOAT,
bool  use_host_endian = true 
)

write the header and data out to an image.

If the img_index = -1, append the image to the given image file.

If the given image file already exists, this image format only stores 1 image, and no region is given, then truncate the image file to zero length before writing data out. For header writing only, no truncation happens.

If a region is given, then write a region only.

Parameters:
filenameThe image file name.
img_indexThe nth image to write as.
imgtypeWrite to the given image format type. if not specified, use the 'filename' extension to decide.
header_onlyTo write only the header or both header and data.
regionDefine the region to write to.
filestoragetypeThe image data type used in the output file.
use_host_endianTo write in the host computer byte order.
Exceptions:
ImageFormatException
ImageWriteException

Referenced by EMAN::EMData::bispecRotTransInvDirect(), EMAN::EMData::bispecRotTransInvN(), and EMAN::RotateInFSProcessor::process_inplace().

void write_lst ( const string &  filename,
const string &  reffile = "",
int  refn = -1,
const string &  comment = "" 
)

Append data to a LST image file.

Parameters:
filenameThe LST image file name.
reffileReference file name.
refnThe reference file number.
commentThe comment to the added reference file.
See also:
lstio.h