40ImageIO::ImageIO(
const string & fname,
IOMode rw)
41 : filename(fname), rw_mode(rw)
59 bool is_new_file,
bool inbounds_only)
68 if (area_ndim > img_ndim) {
70 sprintf(desc,
"Image is %dD. Cannot read %dD region", img_ndim, area_ndim);
79 sprintf(desc,
"Region box %s is outside image area (%d,%d,%d)",
81 (
int)max_size[1], (
int)max_size[2]);
89 bool is_new_file,
bool inbounds_only)
92 is_new_file,inbounds_only);
100 if (image_index < 0 || image_index >= nimg) {
121 if ((image_index < -1) || (max_nimg > 0 && image_index >= max_nimg)) {
127 int max_nimg,
const float *data)
136 bool * is_new,
bool overwrite)
150 FILE *f1 = fopen(
filename.c_str(),
"wb");
Ctf is the base class for all CTF model.
FloatSize is used to describe a 1D, 2D or 3D rectangular size in floating numbers.
int get_ndim() const
Get its dimension, 1D, 2D, or 3D.
void check_region(const Region *area, const FloatSize &max_size, bool is_new_file=false, bool inbounds_only=true)
Validate image I/O region.
virtual int get_nimg()
Return the number of images in this image file.
FILE * sfopen(const string &filename, IOMode mode, bool *is_new=0, bool overwrite=false)
Run fopen safely.
virtual void write_ctf(const Ctf &ctf, int image_index=0)
Write CTF data to this image.
void check_read_access(int image_index)
Validate 'image_index' in file reading.
virtual int read_ctf(Ctf &ctf, int image_index=0)
Read CTF data from this image.
virtual void init()=0
Do some initialization before doing the read/write.
void check_write_access(IOMode rw_mode, int image_index, int max_nimg=0)
Validate rw_mode and image_index in file writing.
IntSize is used to describe a 1D, 2D or 3D rectangular size in integers.
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
int get_ndim() const
Get the region's dimension.
string get_string() const
Get the description of this region in a string.
bool is_region_in_box(const FloatSize &box) const
To check whether 'this' region is inside a given box assuming the box's origins are (0,...
#define ImageReadException(filename, desc)
#define OutofRangeException(low, high, input, objname)
#define FileAccessException(filename)
#define ImageWriteException(imagename, desc)
#define NullPointerException(desc)