EMAN2
|
PIF(Portable Image Format for EM Data) is an image format from Purdue University. More...
#include <pifio.h>
Classes | |
struct | PifColorMap |
struct | PifFileHeader |
struct | PifImageHeader |
Public Member Functions | |
PifIO (const string &fname, IOMode rw_mode=READ_ONLY) | |
~PifIO () | |
bool | is_single_image_format () const |
Is this image format only storing 1 image or not. More... | |
int | get_nimg () |
Return the number of images in this image file. More... | |
Public Member Functions inherited from EMAN::ImageIO | |
ImageIO (const string &fname, IOMode rw) | |
virtual | ~ImageIO () |
virtual int | read_header (Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false)=0 |
Read the header from an image. More... | |
virtual int | write_header (const Dict &dict, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0 |
Write a header to an image. More... | |
virtual int | read_data (float *data, int image_index=0, const Region *area=0, bool is_3d=false)=0 |
Read the data from an image. More... | |
virtual int | read_data_8bit (unsigned char *data, int image_index=0, const Region *area=0, bool is_3d=false, float minval=0.0f, float maxval=0.0f) |
Read the data from an image as an 8 bit array, regardless of format. More... | |
virtual int | write_data (float *data, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0 |
Write data to an image. More... | |
virtual int | read_ctf (Ctf &ctf, int image_index=0) |
Read CTF data from this image. More... | |
virtual void | write_ctf (const Ctf &ctf, int image_index=0) |
Write CTF data to this image. More... | |
virtual void | flush ()=0 |
Flush the IO buffer. More... | |
virtual bool | is_complex_mode ()=0 |
Is this an complex image or not. More... | |
virtual bool | is_image_big_endian ()=0 |
Is this image in big endian or not. More... | |
template<class T > | |
void | become_host_endian (T *data, size_t n=1) |
Convert data of this image into host endian format. More... | |
string | get_filename () const |
Static Public Member Functions | |
static bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Types | |
enum | { PIF_MAGIC_NUM = 8 } |
enum | PifDataMode { PIF_CHAR = 0 , PIF_SHORT = 1 , PIF_FLOAT_INT = 2 , PIF_SHORT_COMPLEX = 3 , PIF_FLOAT_INT_COMPLEX = 4 , PIF_BOXED_DATA = 6 , PIF_SHORT_FLOAT = 7 , PIF_SHORT_FLOAT_COMPLEX = 8 , PIF_FLOAT = 9 , PIF_FLOAT_COMPLEX = 10 , PIF_MAP_FLOAT_SHORT = 20 , PIF_MAP_FLOAT_INT = 21 , PIF_MAP_FLOAT_INT_2 = 40 , PIF_BOXED_FLOAT_INT = 46 , PIF_INVALID } |
Private Member Functions | |
int | get_mode_size (PifDataMode mode) |
bool | is_float_int (int mode) |
void | fseek_to (int image_index) |
int | to_em_datatype (int pif_datatype) |
int | to_pif_datatype (int em_datatype) |
Private Attributes | |
string | filename |
PifFileHeader | pfh |
int | mode_size |
bool | is_big_endian |
bool | is_new_file |
float | real_scale_factor |
Additional Inherited Members | |
Public Types inherited from EMAN::ImageIO | |
enum | IOMode { READ_ONLY = 1 , READ_WRITE = 2 , WRITE_ONLY = 3 } |
Protected Member Functions inherited from EMAN::ImageIO | |
virtual void | init ()=0 |
Do some initialization before doing the read/write. More... | |
void | check_read_access (int image_index) |
Validate 'image_index' in file reading. More... | |
void | check_read_access (int image_index, const float *data) |
Validate 'image_index' and 'data' in file reading. More... | |
void | check_write_access (IOMode rw_mode, int image_index, int max_nimg=0) |
Validate rw_mode and image_index in file writing. More... | |
void | check_write_access (IOMode rw_mode, int image_index, int max_nimg, const float *data) |
Validate rw_mode, image_index, and data pointer in file writing. More... | |
void | check_region (const Region *area, const FloatSize &max_size, bool is_new_file=false, bool inbounds_only=true) |
Validate image I/O region. More... | |
void | check_region (const Region *area, const IntSize &max_size, bool is_new_file=false, bool inbounds_only=true) |
Validate image I/O region. More... | |
FILE * | sfopen (const string &filename, IOMode mode, bool *is_new=0, bool overwrite=false) |
Run fopen safely. More... | |
Protected Attributes inherited from EMAN::ImageIO | |
string | filename |
IOMode | rw_mode |
FILE * | file = nullptr |
bool | initialized = false |
PIF(Portable Image Format for EM Data) is an image format from Purdue University.
A PIF file = file header + (image header + image data) + (image header + image data) ...
A PIF file has a overall file header followed by n images. Each image has a header and data block.
EMAN only supports homogeneous PIF file, which means all images n a PIF should have the same dimensions. We also assume the (nx,ny,nz) in PifFileHeader are equal to (nx,ny,nz) in each Image header.
|
private |
Definition at line 44 of file pifio.cpp.
References EMAN::ImageIO::file, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), is_new_file, mode_size, pfh, and real_scale_factor.
PifIO::~PifIO | ( | ) |
|
private |
Definition at line 193 of file pifio.cpp.
References EMAN::ImageIO::file, mode_size, EMAN::PifIO::PifFileHeader::nimg, EMAN::PifIO::PifFileHeader::nx, EMAN::PifIO::PifFileHeader::ny, EMAN::PifIO::PifFileHeader::nz, pfh, and portable_fseek().
|
private |
Definition at line 64 of file pifio.cpp.
References PIF_BOXED_DATA, PIF_BOXED_FLOAT_INT, PIF_CHAR, PIF_FLOAT, PIF_FLOAT_COMPLEX, PIF_FLOAT_INT, PIF_FLOAT_INT_COMPLEX, PIF_MAP_FLOAT_INT, PIF_MAP_FLOAT_INT_2, PIF_MAP_FLOAT_SHORT, PIF_SHORT, PIF_SHORT_COMPLEX, PIF_SHORT_FLOAT, and PIF_SHORT_FLOAT_COMPLEX.
|
virtual |
Return the number of images in this image file.
Reimplemented from EMAN::ImageIO.
Definition at line 540 of file pifio.cpp.
References EMAN::ImageIO::init(), EMAN::PifIO::PifFileHeader::nimg, and pfh.
|
private |
Definition at line 97 of file pifio.cpp.
References PIF_BOXED_FLOAT_INT, PIF_FLOAT_INT, PIF_FLOAT_INT_COMPLEX, PIF_MAP_FLOAT_INT, PIF_MAP_FLOAT_INT_2, PIF_MAP_FLOAT_SHORT, PIF_SHORT_FLOAT, and PIF_SHORT_FLOAT_COMPLEX.
|
inlinevirtual |
Is this image format only storing 1 image or not.
Some image formats like MRC only store 1 image in a file, so this function returns 'true' for them. Other image formats like IMAGIC/HDF5 may store mutliple images, so this function returns 'false' for them.
Reimplemented from EMAN::ImageIO.
|
static |
Definition at line 164 of file pifio.cpp.
References ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_host_big_endian(), PIF_MAGIC_NUM, and EMAN::ByteOrder::swap_bytes().
Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().
|
private |
Definition at line 547 of file pifio.cpp.
References EMAN::EMUtil::EM_CHAR, EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_FLOAT_COMPLEX, EMAN::EMUtil::EM_SHORT, EMAN::EMUtil::EM_SHORT_COMPLEX, EMAN::EMUtil::EM_UNKNOWN, PIF_BOXED_DATA, PIF_BOXED_FLOAT_INT, PIF_CHAR, PIF_FLOAT, PIF_FLOAT_COMPLEX, PIF_FLOAT_INT, PIF_FLOAT_INT_COMPLEX, PIF_INVALID, PIF_MAP_FLOAT_INT, PIF_MAP_FLOAT_INT_2, PIF_MAP_FLOAT_SHORT, PIF_SHORT, PIF_SHORT_COMPLEX, PIF_SHORT_FLOAT, and PIF_SHORT_FLOAT_COMPLEX.
|
private |
Definition at line 587 of file pifio.cpp.
References EMAN::EMUtil::EM_CHAR, EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_FLOAT_COMPLEX, EMAN::EMUtil::EM_SHORT, EMAN::EMUtil::EM_SHORT_COMPLEX, LOGERR, PIF_BOXED_DATA, PIF_FLOAT_COMPLEX, PIF_FLOAT_INT, PIF_INVALID, PIF_SHORT, and PIF_SHORT_COMPLEX.
|
private |
|
private |
|
private |
Definition at line 176 of file pifio.h.
Referenced by fseek_to(), and PifIO().
|
private |
Definition at line 175 of file pifio.h.
Referenced by fseek_to(), get_nimg(), and PifIO().
|
private |