32#ifndef eman__emutil__h__
33#define eman__emutil__h__ 1
82 const int EMDataTypeBits[] = { 0,8,8,16,16,32,32,32,64,32,32,64,0 };
210 int *area_y,
int nz = 1,
int *area_z = 0);
221 int *p_z0 = 0,
int nz = 1,
int image_index = 0);
249 int image_index,
size_t mode_size,
int nx,
250 int ny,
int nz = 1,
const Region * area = 0,
252 int pre_row = 0,
int post_row = 0);
261 int image_index,
size_t mode_size,
262 int nx,
int ny,
int nz,
263 const Region * area,
bool has_index_line,
264 int nitems_per_line,
const char *outformat);
289 static void jump_lines(FILE * file,
int nlines);
300 static vector<EMObject>
get_all_attributes(
const string & file_name,
const string & attr_name);
310 static void getRenderLimits(
const Dict & dict,
float & rendermin,
float & rendermax,
int & renderbits);
326 static void getRenderMinMax(
float * data,
const int nx,
const int ny,
float & rendermin,
float & rendermax,
int &renderbits,
const int nz = 1);
336 static EMObject read_hdf_attribute(
const string & filename,
const string & key,
int image_index=0);
346 static int write_hdf_attribute(
const string & filename,
const string & key,
EMObject value,
int image_index=0);
355 static int delete_hdf_attribute(
const string & filename,
const string & key,
int image_index=0);
370 inline static void*
em_calloc(
const size_t nmemb,
const size_t size) {
371 return calloc(nmemb,size);
374 inline static void*
em_realloc(
void* data,
const size_t new_size) {
375 return realloc(data, new_size);
377 inline static void em_memset(
void* data,
const int value,
const size_t size) {
378 memset(data, value, size);
384 inline static void em_memcpy(
void* dst,
const void*
const src,
const size_t size) {
385 memcpy(dst,src,size);
389 const void *first_block,
398 size_t mode_size,
int start,
int end,
399 float *data,
int *p_i,
400 const char *outformat);
404 size_t mode_size,
int start,
int end,
405 float * data,
int *p_i,
406 const char *outformat);
409 int nitems_per_line,
size_t mode_size,
410 int nitems,
float *data,
int *p_i,
411 const char *outformat);
429 void set(
int i,
float score);
Dict is a dictionary to store <string, EMObject> pair.
EMData stores an image's data and defines core image processing routines.
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
static void process_region_io(void *cdata, FILE *file, int rw_mode, int image_index, size_t mode_size, int nx, int ny, int nz=1, const Region *area=0, bool need_flip=false, ImageType imgtype=IMAGE_UNKNOWN, int pre_row=0, int post_row=0)
Process image region IO.
static void em_memset(void *data, const int value, const size_t size)
static void em_memcpy(void *dst, const void *const src, const size_t size)
static void dump_dict(const Dict &dict)
Dump a Dict object.
static void close_imageio(const string &filename, const ImageIO *io)
Ian: Close ImageIO object.
static void jump_lines_by_items(FILE *file, int nitems, int nitems_per_line)
static int get_image_count(const string &filename)
Get the number of images in an image file.
static vector< EMObject > get_all_attributes(const string &file_name, const string &attr_name)
Get an attribute from a stack of image, returned as a vector.
EMDataType
Image pixel data type used in EMAN.
static bool is_same_size(const EMData *image1, const EMData *image2)
Check whether two EMData images are of the same size.
static ImageIO * get_imageio(const string &filename, int rw_mode, ImageType image_type=IMAGE_UNKNOWN)
Get an ImageIO object.
static void process_numbers_io(FILE *file, int rw_mode, int nitems_per_line, size_t mode_size, int start, int end, float *data, int *p_i, const char *outformat)
static bool is_complex_type(EMDataType datatype)
static EMData * vertical_acf(const EMData *image, int maxdy)
static void getRenderMinMax(float *data, const int nx, const int ny, float &rendermin, float &rendermax, int &renderbits, const int nz=1)
Calculate the min and max pixel value accepted for image nomalization, if we did not get them from im...
static void * em_calloc(const size_t nmemb, const size_t size)
ImageType
Image format types.
static ImageType get_image_ext_type(const string &file_ext)
Get an image's format type from its filename extension.
static void getRenderLimits(const Dict &dict, float &rendermin, float &rendermax, int &renderbits)
Get the min and max pixel value accepted for image nomalization from image attribute dictionary,...
static bool is_valid_filename(const string &filename)
Ask whether or not the given filename is a valid EM image filename This is the same thing as checking...
static ImageType fast_get_image_type(const string &filename, const void *first_block, off_t file_size)
static void get_region_origins(const Region *area, int *p_x0, int *p_y0, int *p_z0=0, int nz=1, int image_index=0)
Get a region's original locations.
static void exclude_numbers_io(FILE *file, int rw_mode, int nitems_per_line, size_t mode_size, int start, int end, float *data, int *p_i, const char *outformat)
static void process_ascii_region_io(float *data, FILE *file, int rw_mode, int image_index, size_t mode_size, int nx, int ny, int nz, const Region *area, bool has_index_line, int nitems_per_line, const char *outformat)
Works for regions that are outside the image data dimension area.
static void em_free(void *data)
static vector< string > get_euler_names(const string &euler_type)
static bool is_same_ctf(const EMData *image1, const EMData *image2)
Check whether two EMData images have the same CTF parameters.
static void * em_realloc(void *data, const size_t new_size)
static const char * get_imagetype_name(EMUtil::ImageType type)
Give each image type a meaningful name.
static ImageType get_image_type(const string &filename)
Get an image's format type by processing the first 1K of the image.
static void get_region_dims(const Region *area, int nx, int *area_x, int ny, int *area_y, int nz=1, int *area_z=0)
Get a region's dimensions.
static void jump_lines(FILE *file, int nlines)
static double mode_size_product(size_t factor, size_t mode_size)
Return a factor times the mode size, which may be a special value (11111111) meaning one half,...
static void process_lines_io(FILE *file, int rw_mode, int nitems_per_line, size_t mode_size, int nitems, float *data, int *p_i, const char *outformat)
static const char * get_datatype_string(EMDataType type)
Give each data type a meaningful name.
static bool cuda_available()
static void * em_malloc(const size_t size)
ImageIO classes are designed for reading/writing various electron micrography image formats,...
ImageScore * image_scores
float get_score(int i) const
int get_index(int i) const
void set(int i, float score)
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
#define Assert(s)
Define Assert() function that is effective only when -DDEBUG is used.
const int EMDataTypeBits[]
ImageScore(int i=0, float s=0)