EMAN2
|
#include <emutil.h>
Public Types | |
enum | EMDataType { EM_UNKNOWN , EM_CHAR , EM_UCHAR , EM_SHORT , EM_USHORT , EM_INT , EM_UINT , EM_FLOAT , EM_DOUBLE , EM_SHORT_COMPLEX , EM_USHORT_COMPLEX , EM_FLOAT_COMPLEX , EM_COMPRESSED } |
Image pixel data type used in EMAN. More... | |
enum | ImageType { IMAGE_UNKNOWN , IMAGE_MRC , IMAGE_EER , IMAGE_EER2X , IMAGE_EER4X , IMAGE_SPIDER , IMAGE_SINGLE_SPIDER , IMAGE_IMAGIC , IMAGE_HDF , IMAGE_DM3 , IMAGE_DM4 , IMAGE_TIFF , IMAGE_PGM , IMAGE_LST , IMAGE_PIF , IMAGE_VTK , IMAGE_PNG , IMAGE_SAL , IMAGE_ICOS , IMAGE_EMIM , IMAGE_GATAN2 , IMAGE_AMIRA , IMAGE_XPLOR , IMAGE_EM , IMAGE_V4L , IMAGE_JPEG , IMAGE_FITS , IMAGE_LSTFAST , IMAGE_DF3 , IMAGE_OMAP , IMAGE_SITUS , IMAGE_SER } |
Image format types. More... | |
Static Public Member Functions | |
static EMData * | vertical_acf (const EMData *image, int maxdy) |
static ImageType | get_image_ext_type (const string &file_ext) |
Get an image's format type from its filename extension. More... | |
static ImageType | get_image_type (const string &filename) |
Get an image's format type by processing the first 1K of the image. More... | |
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 whether or not the return value of EMUtil.get_image_ext_type is IMAGE_UNKNOWN. More... | |
static int | get_image_count (const string &filename) |
Get the number of images in an image file. More... | |
static ImageIO * | get_imageio (const string &filename, int rw_mode, ImageType image_type=IMAGE_UNKNOWN) |
Get an ImageIO object. More... | |
static void | close_imageio (const string &filename, const ImageIO *io) |
Ian: Close ImageIO object. More... | |
static const char * | get_imagetype_name (EMUtil::ImageType type) |
Give each image type a meaningful name. More... | |
static const char * | get_datatype_string (EMDataType type) |
Give each data type a meaningful name. More... | |
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. More... | |
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. More... | |
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, needed for MRC packed 8 bit format. More... | |
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. More... | |
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. More... | |
static void | dump_dict (const Dict &dict) |
Dump a Dict object. More... | |
static bool | is_same_size (const EMData *image1, const EMData *image2) |
Check whether two EMData images are of the same size. More... | |
static bool | is_same_ctf (const EMData *image1, const EMData *image2) |
Check whether two EMData images have the same CTF parameters. More... | |
static bool | is_complex_type (EMDataType datatype) |
static void | jump_lines (FILE *file, int nlines) |
static vector< string > | get_euler_names (const string &euler_type) |
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. More... | |
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, or return zeroes if not present. More... | |
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 image attribute dictionary, or they are not valid values rendermin = mean - 3*sigma rendermax = mean + 3*sigma. More... | |
static bool | cuda_available () |
static void * | em_malloc (const size_t size) |
static void * | em_calloc (const size_t nmemb, const size_t size) |
static void * | em_realloc (void *data, const size_t new_size) |
static void | em_memset (void *data, const int value, const size_t size) |
static void | em_free (void *data) |
static void | em_memcpy (void *dst, const void *const src, const size_t size) |
Static Private Member Functions | |
static ImageType | fast_get_image_type (const string &filename, const void *first_block, off_t file_size) |
static void | jump_lines_by_items (FILE *file, int nitems, int nitems_per_line) |
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 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_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) |
Image pixel data type used in EMAN.
EM_U means "EM unsigned". for example, EM_USHORT means EM unsigned short.
Enumerator | |
---|---|
EM_UNKNOWN | |
EM_CHAR | |
EM_UCHAR | |
EM_SHORT | |
EM_USHORT | |
EM_INT | |
EM_UINT | |
EM_FLOAT | |
EM_DOUBLE | |
EM_SHORT_COMPLEX | |
EM_USHORT_COMPLEX | |
EM_FLOAT_COMPLEX | |
EM_COMPRESSED |
Definition at line 91 of file emutil.h.
Image format types.
Definition at line 111 of file emutil.h.
|
static |
Ian: Close ImageIO object.
Definition at line 720 of file emutil.cpp.
Referenced by get_image_count(), and read_binedimage().
|
inlinestatic |
|
static |
Dump a Dict object.
dict | A Dict object. |
Definition at line 1204 of file emutil.cpp.
References get_datatype_string(), EMAN::EMObject::is_null(), EMAN::Dict::keys(), EMAN::EMObject::to_str(), and EMAN::Dict::values().
|
inlinestatic |
Definition at line 370 of file emutil.h.
Referenced by EMAN::EMData::setup4slice(), and EMAN::TransformProcessor::transform().
|
inlinestatic |
Definition at line 380 of file emutil.h.
Referenced by free_rdata(), and EMAN::EMData::setup4slice().
|
inlinestatic |
Definition at line 366 of file emutil.h.
Referenced by EMAN::EMData::EMData(), and EMAN::EMData::rotate_x().
|
inlinestatic |
Definition at line 384 of file emutil.h.
Referenced by EMAN::EMData::clip_inplace(), EMAN::EMData::EMData(), EMAN::EMData::get_top_half(), EMAN::EMData::operator=(), read_binedimage(), EMAN::EMData::rotate_x(), and set_data_pickle().
|
inlinestatic |
Definition at line 377 of file emutil.h.
Referenced by EMAN::EMData::clip_inplace().
|
inlinestatic |
|
staticprivate |
Definition at line 1554 of file emutil.cpp.
References Assert, portable_fseek(), and EMAN::ImageIO::READ_ONLY.
Referenced by process_ascii_region_io().
|
staticprivate |
Definition at line 229 of file emutil.cpp.
References Assert, ENTERFUNC, EXITFUNC, EMAN::Util::get_filename_ext(), get_image_ext_type(), IMAGE_AMIRA, IMAGE_DF3, IMAGE_DM3, IMAGE_DM4, IMAGE_EER, IMAGE_EER2X, IMAGE_EER4X, IMAGE_EM, IMAGE_GATAN2, IMAGE_HDF, IMAGE_ICOS, IMAGE_IMAGIC, IMAGE_LST, IMAGE_LSTFAST, IMAGE_MRC, IMAGE_OMAP, IMAGE_PGM, IMAGE_PIF, IMAGE_PNG, IMAGE_SAL, IMAGE_SER, IMAGE_SINGLE_SPIDER, IMAGE_SITUS, IMAGE_SPIDER, IMAGE_TIFF, IMAGE_UNKNOWN, IMAGE_V4L, IMAGE_VTK, IMAGE_XPLOR, EMAN::AmiraIO::is_valid(), EMAN::DM3IO::is_valid(), EMAN::DM4IO::is_valid(), EMAN::Gatan2IO::is_valid(), EMAN::IcosIO::is_valid(), EMAN::ImagicIO::is_valid(), EMAN::LstFastIO::is_valid(), EMAN::LstIO::is_valid(), EMAN::PgmIO::is_valid(), EMAN::PifIO::is_valid(), EMAN::SalIO::is_valid(), EMAN::SerIO::is_valid(), EMAN::SitusIO::is_valid(), EMAN::SpiderIO::is_valid(), EMAN::SingleSpiderIO::is_valid(), EMAN::VtkIO::is_valid(), EMAN::XplorIO::is_valid(), EMAN::EmIO::is_valid(), EMAN::MrcIO::is_valid(), and EMAN::OmapIO::is_valid().
Referenced by get_image_type().
|
static |
Get an attribute from a stack of image, returned as a vector.
file_name | the image file name |
attr_name | The header attribute name. |
NotExistingObjectException | when access an non-existing attribute |
InvalidCallException | when call this function for a non-stack image |
Definition at line 1674 of file emutil.cpp.
References Assert, IMAGE_UNKNOWN, and read_images().
|
static |
Give each data type a meaningful name.
type | the EMDataType |
Definition at line 828 of file emutil.cpp.
References EM_CHAR, EM_DOUBLE, EM_FLOAT, EM_FLOAT_COMPLEX, EM_INT, EM_SHORT, EM_SHORT_COMPLEX, EM_UCHAR, EM_UINT, EM_UNKNOWN, EM_USHORT, and EM_USHORT_COMPLEX.
Referenced by dump_dict().
|
static |
Definition at line 1631 of file emutil.cpp.
|
static |
Get the number of images in an image file.
filename | Image file name. |
Definition at line 534 of file emutil.cpp.
References Assert, close_imageio(), ENTERFUNC, EXITFUNC, get_imageio(), EMAN::ImageIO::get_nimg(), and EMAN::ImageIO::READ_ONLY.
|
static |
Get an image's format type from its filename extension.
file_ext | File extension. |
Definition at line 58 of file emutil.cpp.
References ENTERFUNC, EXITFUNC, IMAGE_AMIRA, IMAGE_DF3, IMAGE_DM3, IMAGE_DM4, IMAGE_EER, IMAGE_EM, IMAGE_EMIM, IMAGE_FITS, IMAGE_GATAN2, IMAGE_HDF, IMAGE_ICOS, IMAGE_IMAGIC, IMAGE_JPEG, IMAGE_LST, IMAGE_LSTFAST, IMAGE_MRC, IMAGE_OMAP, IMAGE_PGM, IMAGE_PIF, IMAGE_PNG, IMAGE_SAL, IMAGE_SER, IMAGE_SINGLE_SPIDER, IMAGE_SITUS, IMAGE_SPIDER, IMAGE_TIFF, IMAGE_UNKNOWN, IMAGE_V4L, IMAGE_VTK, and IMAGE_XPLOR.
Referenced by fast_get_image_type(), and is_valid_filename().
|
static |
Get an image's format type by processing the first 1K of the image.
filename | Image file name. |
Definition at line 396 of file emutil.cpp.
References Assert, EMAN::Util::change_filename_ext(), ENTERFUNC, EXITFUNC, fast_get_image_type(), FileAccessException, EMAN::Util::get_filename_ext(), EMAN::ImagicIO::HED_EXT, IMAGE_AMIRA, IMAGE_DF3, IMAGE_DM3, IMAGE_DM4, IMAGE_EM, IMAGE_FITS, IMAGE_GATAN2, IMAGE_HDF, IMAGE_ICOS, IMAGE_IMAGIC, IMAGE_LST, IMAGE_LSTFAST, IMAGE_MRC, IMAGE_OMAP, IMAGE_PGM, IMAGE_PIF, IMAGE_PNG, IMAGE_SAL, IMAGE_SER, IMAGE_SINGLE_SPIDER, IMAGE_SITUS, IMAGE_SPIDER, IMAGE_TIFF, IMAGE_UNKNOWN, IMAGE_V4L, IMAGE_VTK, IMAGE_XPLOR, ImageFormatException, EMAN::ImagicIO::IMG_EXT, EMAN::AmiraIO::is_valid(), EMAN::DM3IO::is_valid(), EMAN::DM4IO::is_valid(), EMAN::Gatan2IO::is_valid(), EMAN::IcosIO::is_valid(), EMAN::ImagicIO::is_valid(), EMAN::LstFastIO::is_valid(), EMAN::LstIO::is_valid(), EMAN::PgmIO::is_valid(), EMAN::PifIO::is_valid(), EMAN::SalIO::is_valid(), EMAN::SerIO::is_valid(), EMAN::SitusIO::is_valid(), EMAN::SpiderIO::is_valid(), EMAN::SingleSpiderIO::is_valid(), EMAN::VtkIO::is_valid(), EMAN::XplorIO::is_valid(), EMAN::Df3IO::is_valid(), EMAN::EmIO::is_valid(), EMAN::FitsIO::is_valid(), EMAN::MrcIO::is_valid(), EMAN::OmapIO::is_valid(), portable_fseek(), and portable_ftell().
Referenced by get_imageio().
|
static |
Get an ImageIO object.
It may be a newly created object. Or an object stored in the cache.
filename | Image file name. |
rw_mode | ImageIO read/write mode. |
image_type | Image format type. |
Definition at line 558 of file emutil.cpp.
References Assert, EMAN::decoder0x, EMAN::decoder1x, EMAN::decoder2x, ENTERFUNC, EXITFUNC, get_image_type(), IMAGE_AMIRA, IMAGE_DF3, IMAGE_DM3, IMAGE_DM4, IMAGE_EER, IMAGE_EER2X, IMAGE_EER4X, IMAGE_EM, IMAGE_FITS, IMAGE_GATAN2, IMAGE_HDF, IMAGE_ICOS, IMAGE_IMAGIC, IMAGE_JPEG, IMAGE_LST, IMAGE_LSTFAST, IMAGE_MRC, IMAGE_OMAP, IMAGE_PGM, IMAGE_PIF, IMAGE_PNG, IMAGE_SAL, IMAGE_SER, IMAGE_SINGLE_SPIDER, IMAGE_SITUS, IMAGE_SPIDER, IMAGE_TIFF, IMAGE_UNKNOWN, IMAGE_V4L, IMAGE_VTK, IMAGE_XPLOR, ImageFormatException, EMAN::ImageIO::READ_ONLY, EMAN::ImageIO::READ_WRITE, and EMAN::ImageIO::WRITE_ONLY.
Referenced by EMAN::LstFastIO::calc_ref_image_index(), EMAN::LstIO::calc_ref_image_index(), get_image_count(), and read_binedimage().
|
static |
Give each image type a meaningful name.
type | Image format type. |
Definition at line 734 of file emutil.cpp.
References IMAGE_AMIRA, IMAGE_DF3, IMAGE_DM3, IMAGE_DM4, IMAGE_EM, IMAGE_EMIM, IMAGE_FITS, IMAGE_GATAN2, IMAGE_HDF, IMAGE_ICOS, IMAGE_IMAGIC, IMAGE_JPEG, IMAGE_LST, IMAGE_LSTFAST, IMAGE_MRC, IMAGE_OMAP, IMAGE_PGM, IMAGE_PIF, IMAGE_PNG, IMAGE_SAL, IMAGE_SER, IMAGE_SINGLE_SPIDER, IMAGE_SITUS, IMAGE_SPIDER, IMAGE_TIFF, IMAGE_UNKNOWN, IMAGE_V4L, IMAGE_VTK, and IMAGE_XPLOR.
|
static |
Get a region's dimensions.
area | The region area. |
nx | Image x size. |
area_x | The pointer used to return the region x size. |
ny | Image y size. |
area_y | The pointer used to return the region y size. |
nz | Image z size. |
area_z | The pointer used to return the region z size. |
Definition at line 860 of file emutil.cpp.
References Assert, EMAN::Region::get_ndim(), and EMAN::Region::get_size().
Referenced by process_ascii_region_io(), process_region_io(), EMAN::MrcIO::read_fei_header(), and EMAN::MrcIO::read_mrc_header().
|
static |
Get a region's original locations.
area | The region area. |
p_x0 | The pointer used to return the region x origin. |
p_y0 | The pointer used to return the region y origin. |
p_z0 | The pointer used to return the region z origin. |
nz | Image z size. |
image_index | Image index. |
Definition at line 891 of file emutil.cpp.
References Assert, EMAN::Region::get_ndim(), and EMAN::Region::origin.
|
static |
Get the min and max pixel value accepted for image nomalization from image attribute dictionary, or return zeroes if not present.
[in] | dict | image attribute dictionary |
[out] | rendermin | the minimum value for normalization |
[out] | rendermax | the maximum value for normalization |
[out] | renderbits | the number of significant bits to retain when performing int conversion (helps with compression) |
Definition at line 1689 of file emutil.cpp.
References EMAN::Dict::has_key().
|
static |
Calculate the min and max pixel value accepted for image nomalization, if we did not get them from image attribute dictionary, or they are not valid values rendermin = mean - 3*sigma rendermax = mean + 3*sigma.
[in] | data | 2D image's data array |
[in] | nx | x dimension size |
[in] | ny | y dimension size |
[out] | rendermin | the minimum value for normalization |
[out] | rendermax | the maximum value for normalization |
[out] | renderbits | the number of significant bits to retain when performing int conversion (helps with compression) |
[in] | nz | z dimension size |
Definition at line 1706 of file emutil.cpp.
References EMAN::Util::is_nan(), log(), and sqrt().
|
static |
Definition at line 1231 of file emutil.cpp.
References EM_FLOAT_COMPLEX, EM_SHORT_COMPLEX, and EM_USHORT_COMPLEX.
Referenced by EMAN::TestUtil::make_image_file_by_mode(), and EMAN::TestUtil::verify_image_file_by_mode().
Check whether two EMData images have the same CTF parameters.
Definition at line 1275 of file emutil.cpp.
References EMAN::Ctf::equal(), and NullPointerException.
Check whether two EMData images are of the same size.
Definition at line 1224 of file emutil.cpp.
Referenced by EMAN::ImageAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::MinMaxAverager::add_image(), EMAN::MedianAverager::add_image(), EMAN::CtfWtAverager::add_image(), EMAN::CtfWtFiltAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::SigmaAverager::add_image(), EMAN::EMData::add_incoherent(), EMAN::EMData::calc_ccfx(), EMAN::NormalizeCircleMeanProcessor::calc_mean(), EMAN::EMData::calc_mutual_correlation(), EMAN::EMData::common_lines(), EMAN::EMData::common_lines_real(), EMAN::EMData::convolute(), EMAN::EMData::dot_rotate_translate(), get_circle_mean(), EMAN::IndexMaskFileProcessor::process_inplace(), and EMAN::Cmp::validate_input_args().
|
static |
Ask whether or not the given filename is a valid EM image filename This is the same thing as checking whether or not the return value of EMUtil.get_image_ext_type is IMAGE_UNKNOWN.
filename | Image file name. |
Definition at line 222 of file emutil.cpp.
References EMAN::Util::get_filename_ext(), get_image_ext_type(), and IMAGE_UNKNOWN.
|
static |
Definition at line 1493 of file emutil.cpp.
References Assert.
Referenced by jump_lines_by_items(), and process_ascii_region_io().
|
staticprivate |
Definition at line 1473 of file emutil.cpp.
References Assert, and jump_lines().
Referenced by process_ascii_region_io().
|
static |
Return a factor times the mode size, which may be a special value (11111111) meaning one half, needed for MRC packed 8 bit format.
Definition at line 915 of file emutil.cpp.
Referenced by process_region_io().
|
static |
Works for regions that are outside the image data dimension area.
The only function that calls this is in xplorio.cpp - that function throws if the region is invalid.
Definition at line 1365 of file emutil.cpp.
References Assert, exclude_numbers_io(), get_region_dims(), jump_lines(), jump_lines_by_items(), EMAN::Region::origin, process_lines_io(), process_numbers_io(), EMAN::ImageIO::READ_ONLY, EMAN::ImageIO::READ_WRITE, and EMAN::ImageIO::WRITE_ONLY.
|
staticprivate |
Definition at line 1612 of file emutil.cpp.
References Assert, and process_numbers_io().
Referenced by process_ascii_region_io().
|
staticprivate |
Definition at line 1508 of file emutil.cpp.
References Assert, portable_fseek(), and EMAN::ImageIO::READ_ONLY.
Referenced by process_ascii_region_io(), and process_lines_io().
|
static |
Process image region IO.
It eithers read a region from an image file. Or write a region to an image file. Works for regions that are outside the image data dimension area.(David Woolford, April 23 2009)
cdata | Data array. |
file | The image file pointer. |
rw_mode | Read/write mode. It is either READ_ONLY or WRITE_ONLY. |
image_index | Image index. |
mode_size | Pixel size. |
nx | Image x size. |
ny | Image y size. |
nz | Image z size. |
area | The region to read/write. |
need_flip | Do we need flip the image? |
imgtype | The Image type of the processed file. |
pre_row | File size needed to be skipped before each row. |
post_row | File size needed to be skipped after each row. |
ImageReadException | If the read has some error. |
ImageWriteException | If the write has some error. |
Definition at line 931 of file emutil.cpp.
References Assert, EMAN::Region::get_depth(), EMAN::Region::get_height(), EMAN::Region::get_ndim(), EMAN::Region::get_origin(), get_region_dims(), EMAN::Region::get_size(), EMAN::Region::get_width(), IMAGE_ICOS, ImageReadException, ImageWriteException, mode_size_product(), portable_fseek(), EMAN::ImageIO::READ_ONLY, EMAN::ImageIO::READ_WRITE, UnexpectedBehaviorException, EMAN::ImageIO::WRITE_ONLY, EMAN::Region::x_origin(), EMAN::Region::y_origin(), and EMAN::Region::z_origin().
Referenced by EMAN::SpiderIO::write_single_data().
Definition at line 1238 of file emutil.cpp.
References EMAN::dot(), NullPointerException, x, and y.