EMAN2
|
IMAGIC-5 Header File Format. More...
#include <imagicio.h>
Classes | |
struct | ImagicHeader |
Public Member Functions | |
ImagicIO (const string &fname, IOMode rw_mode=READ_ONLY) | |
~ImagicIO () | |
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 | |
Static Public Attributes | |
static const char * | HED_EXT = "hed" |
static const char * | IMG_EXT = "img" |
Private Types | |
enum | DataType { IMAGIC_UCHAR , IMAGIC_USHORT , IMAGIC_FLOAT , IMAGIC_FLOAT_COMPLEX , IMAGIC_FFT_FLOAT_COMPLEX , IMAGIC_UNKNOWN_TYPE } |
enum | { NUM_4BYTES_PRE_IXOLD = 14 , NUM_4BYTES_AFTER_IXOLD = 14 , NUM_4BYTES_AFTER_SPACE = 207 } |
Private Member Functions | |
size_t | get_datatype_size (DataType t) |
int | to_em_datatype (DataType t) |
void | make_header_host_endian (ImagicHeader &hed) |
void | swap_header (ImagicHeader &hed) |
DataType | get_datatype_from_name (const char *name) |
Ctf * | read_ctf (const ImagicHeader &hed) const |
the Ctf object is a EMAN1Ctf object. More... | |
void | write_ctf (const Ctf *const ctf, int image_index=0) |
Private Attributes | |
string | hed_filename |
string | img_filename |
FILE * | hed_file |
FILE * | img_file |
ImagicHeader | imagich |
bool | is_big_endian |
bool | is_new_hed |
bool | is_new_img |
DataType | datatype |
int | nz |
Static Private Attributes | |
static const char * | REAL_TYPE_MAGIC = "REAL" |
static const char * | CTF_MAGIC = "!-" |
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 |
IMAGIC-5 Header File Format.
An IMAGIC-5 file has 2 files: a) a header file with extension ".hed". It contains information for every image. b) an image file with extension ".img". It contains raw data.
The header file contains one (fixed-size) record per image stored. Every header record consists of 256 REAL/float for every image.
The image file contains only the raw data. Depending on the internal IMAGIC-5 format used, which can be REAL, INTG, PACK or COMP, the data is stored as REAL/float, INTEGER/int, INTEGER*1/byte or 2x REAL/float, respectively. The first pixel stored is the upper left one. The data is stored line by line, section by section, volume by volume.
3D imagic uses the same format to 2D. it is a bunch of 2D slices. use the 'hint' IS_3D to treat "2D slices" as 3D volume.
imagic doesn't store multiple 3D images in one file (header/data pair).
Definition at line 65 of file imagicio.h.
|
private |
Enumerator | |
---|---|
NUM_4BYTES_PRE_IXOLD | |
NUM_4BYTES_AFTER_IXOLD | |
NUM_4BYTES_AFTER_SPACE |
Definition at line 99 of file imagicio.h.
|
private |
Enumerator | |
---|---|
IMAGIC_UCHAR | |
IMAGIC_USHORT | |
IMAGIC_FLOAT | |
IMAGIC_FLOAT_COMPLEX | |
IMAGIC_FFT_FLOAT_COMPLEX | |
IMAGIC_UNKNOWN_TYPE |
Definition at line 89 of file imagicio.h.
Definition at line 50 of file imagicio.cpp.
References EMAN::Util::change_filename_ext(), EMAN::ImagicIO::ImagicHeader::count, datatype, EMAN::ImageIO::filename, HED_EXT, hed_filename, IMAGIC_UNKNOWN_TYPE, imagich, IMG_EXT, img_filename, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), is_new_hed, is_new_img, and nz.
ImagicIO::~ImagicIO | ( | ) |
|
private |
Definition at line 628 of file imagicio.cpp.
References IMAGIC_FFT_FLOAT_COMPLEX, IMAGIC_FLOAT, IMAGIC_FLOAT_COMPLEX, IMAGIC_UCHAR, IMAGIC_UNKNOWN_TYPE, IMAGIC_USHORT, and REAL_TYPE_MAGIC.
|
private |
Definition at line 650 of file imagicio.cpp.
References IMAGIC_FFT_FLOAT_COMPLEX, IMAGIC_FLOAT, IMAGIC_FLOAT_COMPLEX, IMAGIC_UCHAR, and IMAGIC_USHORT.
|
virtual |
Return the number of images in this image file.
Reimplemented from EMAN::ImageIO.
Definition at line 622 of file imagicio.cpp.
References EMAN::ImagicIO::ImagicHeader::count, imagich, and EMAN::ImageIO::init().
|
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.
Definition at line 77 of file imagicio.h.
|
static |
Definition at line 121 of file imagicio.cpp.
References ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().
Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().
|
private |
Definition at line 690 of file imagicio.cpp.
References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and swap_header().
|
private |
the Ctf object is a EMAN1Ctf object.
Definition at line 567 of file imagicio.cpp.
References CTF_MAGIC, ENTERFUNC, EXITFUNC, EMAN::Ctf::from_string(), imagich, and EMAN::ImagicIO::ImagicHeader::label.
|
private |
Definition at line 698 of file imagicio.cpp.
References EMAN::ImagicIO::ImagicHeader::ixold, NUM_4BYTES_AFTER_IXOLD, NUM_4BYTES_AFTER_SPACE, NUM_4BYTES_PRE_IXOLD, EMAN::ImagicIO::ImagicHeader::space, and EMAN::ByteOrder::swap_bytes().
Referenced by make_header_host_endian().
|
private |
Definition at line 672 of file imagicio.cpp.
References EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_FLOAT_COMPLEX, EMAN::EMUtil::EM_UCHAR, EMAN::EMUtil::EM_UNKNOWN, EMAN::EMUtil::EM_USHORT, IMAGIC_FLOAT, IMAGIC_FLOAT_COMPLEX, IMAGIC_UCHAR, and IMAGIC_USHORT.
|
private |
Definition at line 589 of file imagicio.cpp.
References CTF_MAGIC, ENTERFUNC, EXITFUNC, hed_file, hed_filename, ImageWriteException, imagich, EMAN::ImageIO::init(), EMAN::ImagicIO::ImagicHeader::label, and EMAN::Ctf::to_string().
|
staticprivate |
Definition at line 86 of file imagicio.h.
Referenced by read_ctf(), and write_ctf().
|
private |
Definition at line 193 of file imagicio.h.
Referenced by ImagicIO().
EMAN::ImagicIO::DEFINE_IMAGEIO_FUNC |
Definition at line 74 of file imagicio.h.
|
static |
Definition at line 68 of file imagicio.h.
Referenced by EMAN::EMUtil::get_image_type(), and ImagicIO().
|
private |
Definition at line 185 of file imagicio.h.
Referenced by write_ctf(), and ~ImagicIO().
|
private |
Definition at line 182 of file imagicio.h.
Referenced by ImagicIO(), and write_ctf().
|
private |
Definition at line 188 of file imagicio.h.
Referenced by get_nimg(), ImagicIO(), read_ctf(), and write_ctf().
|
static |
Definition at line 69 of file imagicio.h.
Referenced by EMAN::EMUtil::get_image_type(), and ImagicIO().
|
private |
Definition at line 186 of file imagicio.h.
Referenced by ~ImagicIO().
|
private |
Definition at line 183 of file imagicio.h.
Referenced by ImagicIO().
|
private |
Definition at line 189 of file imagicio.h.
Referenced by ImagicIO(), and make_header_host_endian().
|
private |
Definition at line 190 of file imagicio.h.
Referenced by ImagicIO().
|
private |
Definition at line 191 of file imagicio.h.
Referenced by ImagicIO().
|
private |
Definition at line 194 of file imagicio.h.
Referenced by ImagicIO().
|
staticprivate |
Definition at line 85 of file imagicio.h.
Referenced by get_datatype_from_name().