34 #define MAXPATHLEN (MAX_PATH*4)
62 static bool initialized =
false;
63 static map < string, ImageType > imagetypes;
213 if (imagetypes.find(file_ext) != imagetypes.end()) {
214 result = imagetypes[file_ext];
230 const void *first_block,
240 if (filename.compare(0,5,
"/dev/")==0)
return IMAGE_V4L;
251 switch (image_type) {
278 if (HdfIO2::is_valid(first_block)) {
295 if (TiffIO::is_valid(first_block)) {
317 if (PngIO::is_valid(first_block)) {
400 Assert(in_filename !=
"");
403 if (in_filename.compare(0,5,
"/dev/")==0)
return IMAGE_V4L;
406 string filename = in_filename;
413 else if (old_ext ==
"hdf") {
417 FILE *in = fopen(filename.c_str(),
"rb");
423 char first_block[1024];
424 size_t n = fread(first_block, 1, 1024, in);
459 else if (HdfIO2::is_valid(first_block)) {
470 else if (TiffIO::is_valid(first_block)) {
478 else if (PngIO::is_valid(first_block)) {
574 imageio = GlobalCache::instance()->get_imageio(filename, rw);
592 switch (image_type) {
595 imageio =
new V4L2IO(filename, rw_mode);
599 imageio =
new MrcIO(filename, rw_mode);
611 imageio =
new ImagicIO2(filename, rw_mode);
614 imageio =
new ImagicIO(filename, rw_mode);
618 imageio =
new DM3IO(filename, rw_mode);
621 imageio =
new DM4IO(filename, rw_mode);
625 imageio =
new TiffIO(filename, rw_mode);
634 imageio =
new HdfIO2(filename, rw_mode);
635 if (((HdfIO2 *)imageio)->init_test()==-1) {
637 imageio =
new HdfIO(filename, rw_mode);
642 imageio =
new LstIO(filename, rw_mode);
645 imageio =
new LstFastIO(filename, rw_mode);
648 imageio =
new PifIO(filename, rw_mode);
651 imageio =
new VtkIO(filename, rw_mode);
654 imageio =
new SpiderIO(filename, rw_mode);
660 imageio =
new PgmIO(filename, rw_mode);
664 imageio =
new JpegIO(filename,rw_mode);
668 imageio =
new IcosIO(filename, rw_mode);
672 imageio =
new PngIO(filename, rw_mode);
676 imageio =
new SalIO(filename, rw_mode);
679 imageio =
new AmiraIO(filename, rw_mode);
682 imageio =
new Gatan2IO(filename, rw_mode);
685 imageio =
new EmIO(filename, rw_mode);
688 imageio =
new XplorIO(filename, rw_mode);
691 imageio =
new FitsIO(filename, rw_mode);
694 imageio =
new Df3IO(filename, rw_mode);
697 imageio =
new OmapIO(filename, rw_mode);
700 imageio =
new SitusIO(filename, rw_mode);
703 imageio =
new SerIO(filename, rw_mode);
711 GlobalCache::instance()->add_imageio(filename, rw, persist, imageio);
724 if (GlobalCache::instance()->contains(filename)) {
725 GlobalCache::instance()->close_imageio(filename);
747 return "Single-SPIDER";
834 return "UNSIGNED CHAR";
838 return "UNSIGNED SHORT";
842 return "UNSIGNED INT";
848 return "SHORT_COMPLEX";
850 return "USHORT_COMPLEX";
852 return "FLOAT_COMPLEX";
861 int ny,
int *area_y,
int nz,
int *area_z)
880 if (area->
get_ndim() > 2 && nz > 1) {
892 int nz,
int image_index)
898 *p_x0 =
static_cast < int >(area->
origin[0]);
899 *p_y0 =
static_cast < int >(area->
origin[1]);
901 if (p_z0 && nz > 1 && area->
get_ndim() > 2) {
902 *p_z0 =
static_cast < int >(area->
origin[2]);
910 *p_z0 = nz > 1 ? 0 : image_index;
917 const size_t mode_size_half = 11111111;
921 if (mode_size == mode_size_half) {
922 product = factor * 0.5;
925 product = factor * mode_size;
932 int rw_mode,
int image_index,
933 size_t mode_size,
int nx,
int ny,
int nz,
934 const Region * area,
bool need_flip,
935 ImageType imgtype,
int pre_row,
int post_row)
945 const size_t mode_size_half = 11111111;
947 unsigned char * cdata = (
unsigned char *)vdata;
955 int fz0 = nz > 1 ? 0 : image_index;
963 bool debug = (getenv(
"DEBUG_IO") != NULL);
966 printf (
"-------------- process_region_io --------------\n");
967 printf (
"rw, indx, modsiz, nx, ny, nz = %d %d %ld %d %d %d\n",
968 rw_mode, image_index, mode_size, nx, ny, nz);
969 printf (
"flip, imtyp, prerow, postrow = %d %d %d %d\n",
970 (
int) need_flip, (
int) imgtype, pre_row, post_row);
971 printf (
"xlen, ylen, zlen = %d %d %d\n", xlen, ylen, zlen);
974 printf (
"x0, y0, z0, mx, my, mz, ndim = %g %g %g %g %g %g %d\n",
988 fx0 = origin[0]; dx0 = origin[0];
989 fy0 = origin[1]; dy0 = origin[1];
991 if (nz > 1 && area->
get_ndim() > 2) {
992 fz0 = origin[2]; dz0 = origin[2];
997 fy0 = ny-(origin[1]+size[1]);
1030 if ((fx0 + xlen)> nx) xlen = nx-fx0;
1031 if ((fy0 + ylen)> ny) ylen = ny-fy0;
1032 if ((fz0 + zlen)> nz && nz > 1) zlen = nz-fz0;
1035 if ( xlen <= 0 || ylen <= 0 || zlen <= 0 )
return;
1037 if (mode_size == mode_size_half) {
1045 if (fx0 % 2 != 0 &&
false) {
1046 cout <<
"First region x-pixel location "
1047 "must be even for packed 8 bit MRC." << endl;
1051 if ((nx - fx0 - xlen) % 2 != 0 &&
false) {
1052 cout <<
"No. of x-pixel locations after region "
1053 "must be even for packed 8 bit MRC." << endl;
1057 if (xlen % 2 != 0) {
1058 cout <<
"No. of region x-pixels "
1059 "must be even for packed 8 bit MRC." << endl;
1070 cout <<
"Xlen was too small " << xlen << endl;
1077 if (area != 0) size = area->
get_size();
1078 else size =
Vec3d(nx,ny,nz);
1087 if ( area_row_size <= 0 ) {
1088 cout <<
"Xlen was too small " << xlen <<
" mode_size " << mode_size << endl;
1096 size_t y_pre_gap = fy0 * img_row_size;
1097 size_t y_post_gap = (ny - fy0 - ylen) * img_row_size;
1099 if (x_pre_gap < 0) x_pre_gap = 0;
1100 if (x_post_gap < 0) x_post_gap = 0;
1102 size_t extra = img_row_size - (x_pre_gap + area_row_size + x_post_gap);
1104 if (extra > 0) x_post_gap += extra;
1109 int floatsize = (int)
sizeof(
float);
1110 nxlendata[0] = (float)(nx * floatsize);
1113 printf (
"fz0, dz0, xlen, ylen, zlen = %d %d %d %d %d\n",
1114 fz0, dz0, xlen, ylen, zlen);
1115 printf (
"x_pre_gap, x_post_gap, y_pre_gap, y_post_gap = %d %d %d %d\n",
1116 x_pre_gap, x_post_gap, y_pre_gap, y_post_gap);
1117 printf (
"mem_sec_siz, img_row_siz, are_row_siz, mem_row_siz = %ld %ld %ld %ld\n",
1118 memory_sec_size, img_row_size, area_row_size, memory_row_size);
1119 printf (
"-----------------------------------------------\n");
1122 for (
int k = dz0; k < (dz0+zlen); k++) {
1124 if (y_pre_gap > 0) {
1129 long k2 = k*memory_sec_size;
1131 for (
int j = dy0; j < (dy0+ylen); j++) {
1134 fwrite(nxlendata, floatsize, 1, file);
1141 if (x_pre_gap > 0) {
1148 jj = (dy0+ylen) - 1 - j;
1158 if (fread(&cdata[k2 + jj * memory_row_size +
1160 area_row_size, 1, file) != 1) {
1167 cout <<
"Reached premature end-of-file reading "
1168 <<
"region from image/slice number " << k
1169 <<
" of file with " << ftell(file)
1170 <<
" bytes." << endl;
1173 "incomplete data read");
1177 if (fwrite(&cdata[k2 + jj * memory_row_size +
1179 area_row_size, 1, file) != 1) {
1184 if (x_post_gap > 0) {
1190 fwrite(nxlendata, floatsize, 1, file);
1198 if (y_post_gap > 0) {
1206 vector < string > keys = dict.
keys();
1207 vector < EMObject > values = dict.
values();
1209 for (
unsigned int i = 0; i < keys.size(); i++) {
1213 string val = obj.
to_str();
1215 if (keys[i] ==
"datatype") {
1219 fprintf(stdout,
"%25s\t%s\n", keys[i].c_str(), val.c_str());
1226 return em1->get_xsize() == em2->get_xsize() &&
1227 em1->get_ysize() == em2->get_ysize() &&
1228 em1->get_zsize() == em2->get_zsize();
1246 int nx = image->get_xsize();
1247 int ny = image->get_ysize();
1253 ret->set_size(nx, maxdy, 1);
1255 float *data = image->get_data();
1256 float *ret_data = ret->get_data();
1258 for (
int x = 0;
x < nx;
x++) {
1259 for (
int y = 0;
y < maxdy;
y++) {
1262 for (
int yy = maxdy; yy < ny - maxdy; yy++) {
1263 dot += data[
x + (yy +
y) * nx] * data[
x + (yy -
y) * nx];
1266 ret_data[
x +
y * nx] =
dot;
1285 Ctf *ctf1 = image1->get_ctf();
1286 Ctf *ctf2 = image2->get_ctf();
1288 if ((!ctf1 && !ctf2) && (image1->has_ctff() ==
false && image2->has_ctff() ==
false)) {
1293 bool result = ctf1->
equal(ctf2);
1366 int ,
size_t mode_size,
int nx,
int ny,
int nz,
1367 const Region * area,
bool has_index_line,
1368 int nitems_per_line,
const char *outformat)
1376 int xlen = 0, ylen = 0, zlen = 0;
1384 x0 = (int)area->
origin[0];
1385 y0 = (
int)area->
origin[1];
1386 z0 = (int)area->
origin[2];
1389 int nlines_per_sec = (nx *ny) / nitems_per_line;
1390 int nitems_last_line = (nx * ny) % nitems_per_line;
1392 if (nitems_last_line != 0) {
1396 if (has_index_line) {
1404 int nlines_pre_sec = (y0 * nx + x0) / nitems_per_line;
1405 int gap_nitems = nx - xlen;
1409 for (
int k = 0; k < zlen; k++) {
1412 int head_nitems = (y0 * nx + x0) % nitems_per_line;
1413 int tail_nitems = 0;
1414 bool is_head_read =
false;
1416 for (
int j = 0; j < ylen; j++) {
1417 if (head_nitems > 0 && !is_head_read) {
1419 nitems_per_line-head_nitems,
1420 nitems_per_line-1, data, &ti, outformat);
1425 mode_size, (xlen - head_nitems),
1426 data, &ti, outformat);
1428 rlines += ((xlen - head_nitems) / nitems_per_line);
1430 tail_nitems = (xlen - head_nitems) % nitems_per_line;
1432 if ((gap_nitems + tail_nitems) > 0) {
1433 head_nitems = nitems_per_line -
1434 (gap_nitems + tail_nitems) % nitems_per_line;
1440 is_head_read =
false;
1442 if (tail_nitems > 0) {
1443 if ((gap_nitems < (nitems_per_line-tail_nitems)) &&
1446 mode_size, tail_nitems,
1447 tail_nitems+gap_nitems-1, data, &ti, outformat);
1448 is_head_read =
true;
1453 0, tail_nitems-1, data, &ti, outformat);
1458 if (gap_nitems > (nitems_per_line-tail_nitems)) {
1459 int gap_nlines = (gap_nitems - (nitems_per_line-tail_nitems)) /
1462 if (gap_nlines > 0 && j != (ylen-1)) {
1468 int ytail_nitems = (ny-ylen-y0) * nx + (nx-xlen-x0) - (nitems_per_line-tail_nitems);
1476 Assert(nitems_per_line > 0);
1482 int nlines = nitems / nitems_per_line;
1484 if ((nitems % nitems_per_line) != 0) {
1498 char line[MAXPATHLEN];
1500 for (
int l = 0; l < nlines; l++) {
1501 if (!fgets(line,
sizeof(line), file)) {
1502 Assert(
"read xplor file failed");
1509 int nitems_per_line,
size_t mode_size,
int start,
1510 int end,
float *data,
int *p_i,
const char * outformat)
1515 Assert(end <= nitems_per_line);
1520 char line[MAXPATHLEN];
1523 if (!fgets(line,
sizeof(line), file)) {
1524 Assert(
"read xplor file failed");
1527 int nitems_in_line = (int) (strlen(line) / mode_size);
1528 Assert(end <= nitems_in_line);
1529 vector<float> d(nitems_in_line);
1530 char * pline = line;
1532 for (
int i = 0; i < nitems_in_line; i++) {
1533 sscanf(pline,
"%f", &d[i]);
1534 pline += (int)mode_size;
1537 for (
int i = start; i <= end; i++) {
1545 for (
int i = start; i <= end; i++) {
1546 fprintf(file, outformat, data[*p_i]);
1550 portable_fseek(file, mode_size * (nitems_per_line - end-1)+1, SEEK_CUR);
1555 int nitems_per_line,
size_t mode_size,
int start,
1556 int end,
float * data,
int *p_i,
const char * outformat)
1561 Assert(end <= nitems_per_line);
1566 char line[MAXPATHLEN];
1570 if (!fgets(line,
sizeof(line), file)) {
1571 Assert(
"read xplor file failed");
1574 int nitems_in_line = (int) (strlen(line) / mode_size);
1575 Assert(end <= nitems_in_line);
1577 vector<float> d(nitems_in_line);
1580 for (
int i = 0; i < nitems_in_line; i++) {
1581 sscanf(pline,
"%f", &d[i]);
1582 pline = pline + (int)mode_size;
1586 for (
int i = 0; i < start; i++) {
1591 for (
int i = end+1; i < nitems_in_line; i++) {
1597 for (
int i = 0; i < start; i++) {
1598 fprintf(file, outformat, data[*p_i]);
1604 for (
int i = end+1; i < nitems_per_line; i++) {
1605 fprintf(file, outformat, data[*p_i]);
1613 int nitems_per_line,
size_t mode_size,
1614 int nitems,
float *data,
int *p_i,
1615 const char * outformat)
1622 int nlines = nitems / nitems_per_line;
1624 for (
int i = 0; i < nlines; i++) {
1626 nitems_per_line-1, data, p_i, outformat);
1634 string b =
"euler_";
1636 if (euler_type ==
"EMAN") {
1637 v.push_back(b +
"alt");
1638 v.push_back(b +
"az");
1639 v.push_back(b +
"phi");
1641 else if (euler_type ==
"MRC") {
1642 v.push_back(b +
"theta");
1643 v.push_back(b +
"phi");
1644 v.push_back(b +
"omega");
1646 else if (euler_type ==
"IMAGIC") {
1647 v.push_back(b +
"alpha");
1648 v.push_back(b +
"beta");
1649 v.push_back(b +
"gamma");
1651 else if (euler_type ==
"SPIDER") {
1652 v.push_back(b +
"phi");
1653 v.push_back(b +
"theta");
1654 v.push_back(b +
"gamma");
1656 else if (euler_type ==
"SPIN" ||
1657 euler_type ==
"SGIROT") {
1658 v.push_back(b +
"q");
1659 v.push_back(b +
"n1");
1660 v.push_back(b +
"n2");
1661 v.push_back(b +
"n3");
1664 else if (euler_type ==
"QUATERNION") {
1665 v.push_back(b +
"e0");
1666 v.push_back(b +
"e1");
1667 v.push_back(b +
"e2");
1668 v.push_back(b +
"e3");
1683 for (
auto iter = vpImg.begin(); iter!=vpImg.end(); ++iter)
1684 v.push_back((*iter)->get_attr_default(attr_name));
1699 if (dict.
has_key(
"render_bits")) renderbits = (int)dict[
"render_bits"];
1702 if (dict.
has_key(
"render_min")) rendermin = (
float) dict[
"render_min"];
1703 if (dict.
has_key(
"render_max")) rendermax = (
float) dict[
"render_max"];
1707 float & rendermin,
float & rendermax,
int &renderbits,
const int nz)
1709 const float flag_base = 1.0e30;
1710 const float use_data_min_or_max = -flag_base;
1711 const float use_num_std_devs = flag_base / 100.0;
1717 if (debug) printf (
"into RenderMinMax, rmin = %g, rmax = %g, rbits = %d\n", rendermin, rendermax, renderbits);
1719 if (renderbits<=0)
return;
1720 if (renderbits>16) renderbits=16;
1722 if (rendermax <= rendermin ||
1724 fabs(rendermin) > use_num_std_devs ||
1725 fabs(rendermax) > use_num_std_devs) {
1727 double m = 0.0f, s = 0.0f;
1728 size_t nint=0,n0=0,n1=0;
1729 size_t size = (size_t)nx*ny*nz;
1730 float min = data[0], max = data[0];
1731 int bitval = 1<<renderbits;
1735 for (
size_t i = 0; i < size; ++i) {
1737 s += data[i] * data[i];
1738 if (data[i]==0.0f) n0++;
1739 else if (data[i]==1.0f) n1++;
1740 if (data[i]==floor(data[i])) nint++;
1742 min = data[i] < min ? data[i] : min;
1743 max = data[i] > max ? data[i] : max;
1748 float mnz = m/(size-n0);
1749 float snz =
sqrt(s/(size-n0)-mnz*mnz);
1751 s =
sqrt(s/(
float)(size)-m*m);
1782 if (debug) printf (
"min, mean, max, s.d., nint, nzer, none = %g %g %g %g %d %d %d\n", min, m, max, s, nint, n0, n1);
1792 else if (nint==size) {
1794 if (max-min<bitval) {
1796 rendermax=min+bitval-1;
1800 int neededbits=ceil(
log(max-min+1)/
log(2.0f));
1801 int step = 1<<(neededbits-renderbits);
1803 rendermin = round( min / step ) * step;
1808 rendermax=rendermin+step*(bitval-1);
1814 else if (min<0<max) {
1828 float step = (max-min)/(bitval-1);
1829 if (min == floor( min/step ) * step) {
1843 step=(max-min)/(bitval-2);
1844 rendermin=(floor(min/step)*step);
1845 rendermax=rendermin+step*(bitval-1);
1861 if (debug) printf (
"out of RenderMinMax, rmin = %g, rmax = %g, rbits = %d\n", rendermin, rendermax, renderbits);
1865EMObject EMUtil::read_hdf_attribute(
const string & filename,
const string & key,
int image_index)
1877 hid_t file = imageio->get_fileid();
1880 sprintf(ipath,
"/MDF/images/%d", image_index);
1882 hid_t igrp = H5Gopen(file, ipath);
1890 hid_t attr = H5Aopen_name(igrp, s.c_str());
1891 EMObject emobj = imageio->read_attr(attr);
1900int EMUtil::write_hdf_attribute(
const string & filename,
const string & key,
EMObject value,
int image_index)
1913 hid_t file = imageio->get_fileid();
1916 sprintf(ipath,
"/MDF/images/%d", image_index);
1918 hid_t igrp = H5Gopen(file, ipath);
1926 int ret = imageio->write_attr(igrp, s.c_str(), value);
1934int EMUtil::delete_hdf_attribute(
const string & filename,
const string & key,
int image_index)
1947 hid_t file = imageio->get_fileid();
1950 sprintf(ipath,
"/MDF/images/%d", image_index);
1952 hid_t igrp = H5Gopen(file,ipath);
1960 herr_t ret = H5Adelete(igrp, s.c_str());
1965 if (ret >= 0)
return 0;
Amira file = ASCII header + binary data.
static bool is_valid(const void *first_block)
Ctf is the base class for all CTF model.
virtual bool equal(const Ctf *ctf1) const =0
Gatan DM3 file is a hierarchical binary image format.
static bool is_valid(const void *first_block)
Gatan DM$ was introduced with the GMS 2.0 release.
static bool is_valid(const void *first_block)
static bool is_valid(const void *first_block, off_t file_size=0)
Dict is a dictionary to store <string, EMObject> pair.
vector< EMObject > values() const
Get a vector containing copies of each of the EMObjects in this dictionary.
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
vector< string > keys() const
Get a vector containing all of the (string) keys in this dictionary.
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.
string to_str() const
Calls to_str( this->type)
bool is_null() const
Checks to see if the EMObject is interpretable This basically equates to checking to see if the type ...
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 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...
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 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 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.
EmIO defines I/O operations on EM image format.
static bool is_valid(const void *first_block, off_t file_size=0)
MRC file = header + data (nx x ny x nz).
static bool is_valid(const void *first_block, off_t file_size=0)
Gatan2 Image file = header + data.
static bool is_valid(const void *first_block)
ICOS file = header + data.
static bool is_valid(const void *first_block)
ImageIO classes are designed for reading/writing various electron micrography image formats,...
virtual int get_nimg()
Return the number of images in this image file.
ImageScore * image_scores
float get_score(int i) const
int get_index(int i) const
void set(int i, float score)
IMAGIC-5 Header File Format.
IMAGIC-5 Header File Format.
static bool is_valid(const void *first_block)
static const char * HED_EXT
static const char * IMG_EXT
A LSX file is a high performance ASCII file that contains a list of image numbers and file names.
static bool is_valid(const void *first_block)
A LST file is an ASCII file that contains a list of image file names.
static bool is_valid(const void *first_block)
MRC file = header + data (nx x ny x nz).
static bool is_valid(const void *first_block, off_t file_size=0)
DSN6 MAP is composed of a series of records which are all 512 bytes long.
static bool is_valid(const void *first_block, off_t file_size=0)
A PGM file = header + data.
static bool is_valid(const void *first_block)
PIF(Portable Image Format for EM Data) is an image format from Purdue University.
static bool is_valid(const void *first_block)
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
float get_width() const
get the width
vector< float > get_size() const
get the size of each dimension as a vector
float y_origin() const
get the y element of the origin
float x_origin() const
get the x element of the origin
int get_ndim() const
Get the region's dimension.
vector< float > get_origin() const
get the origin as a vector
float get_depth() const
get the depth
float z_origin() const
get the z element of the origin
float get_height() const
get the height
A SAL image is an image from Perkin Elmer PDS Microdensitometer.
static bool is_valid(const void *first_block)
SER (Series File Format) is a file format created by Dr.
static bool is_valid(const void *first_block)
Single Spider Image I/O class.
static bool is_valid(const void *first_block)
situs is a a Situs-specific format on a cubic lattice.
static bool is_valid(const void *first_block)
SPIDER: (System for Processing Image Data from Electron microscopy and Related fields) is an image pr...
static bool is_valid(const void *first_block)
static bool is_nan(const float number)
tell whether a float value is a NaN
static string get_filename_ext(const string &filename)
Get a filename's extension.
static string change_filename_ext(const string &old_filename, const string &new_ext)
Change a file's extension and return the new filename.
VtkIO reads/writes VTK image file.
static bool is_valid(const void *first_block)
XPLOR image format is in ASCII:
static bool is_valid(const void *first_block)
Used when an object type, like an EMObject type, doesn't exist.
#define Assert(s)
Define Assert() function that is effective only when -DDEBUG is used.
EMData * log() const
return natural logarithm image for a image
EMData * sqrt() const
return square root of current image
static vector< std::shared_ptr< EMData > > read_images(const string &filename, vector< int > img_indices=vector< int >(), EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false)
Read a set of images from file specified by 'filename'.
static const int ATTR_NAME_LEN
static int imgscore_cmp(const void *imgscore1, const void *imgscore2)
#define ImageReadException(filename, desc)
#define ImageFormatException(desc)
#define UnexpectedBehaviorException(desc)
#define FileAccessException(filename)
#define ImageWriteException(imagename, desc)
#define NullPointerException(desc)
static DecoderIx< 2 > decoder2x
static DecoderIx< 1 > decoder1x
double dot(const Vector3 &w, const Vector3 &v)
static DecoderIx< 0 > decoder0x
off_t portable_ftell(FILE *fp)
int portable_fseek(FILE *fp, off_t offset, int whence)