#include <cstring>
#include "emdata.h"
#include "ctf.h"
Include dependency graph for iminfo.cpp:
Go to the source code of this file.
Functions | |
void | usage (const char *progname) |
int | main (int argc, char *argv[]) |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 47 of file iminfo.cpp.
References EMAN::EMData::get_attr(), EMAN::EMData::get_attr_dict(), EMAN::EMData::get_ctf(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::read_image(), usage(), and EMAN::E2Exception::what().
00048 { 00049 if (argc < 2) { 00050 usage(argv[0]); 00051 exit(1); 00052 } 00053 00054 bool show_all_header = false; 00055 bool stat = false; 00056 00057 Util::set_log_level(argc, argv); 00058 for (int i = 1; i < argc - 1; i++) { 00059 if (strcmp(argv[i], "-H") == 0) { 00060 show_all_header = true; 00061 } 00062 else if (strcmp(argv[i], "-stat") == 0) { 00063 stat = true; 00064 } 00065 } 00066 00067 const char* imagefile = argv[argc-1]; 00068 EMData* d = 0; 00069 try { 00070 int nimg = EMUtil::get_image_count(imagefile); 00071 EMUtil::ImageType imgtype = EMUtil::get_image_type(imagefile); 00072 const char* imgtypename = EMUtil::get_imagetype_name(imgtype); 00073 int image_index = 0; 00074 if (imgtype == EMUtil::IMAGE_SPIDER && !stat) { 00075 image_index = -1; 00076 } 00077 printf("\n%20s: %d\n", "Number of Images", nimg); 00078 printf("%20s: %s\n", "Image Format", imgtypename); 00079 00080 d = new EMData(); 00081 00082 if (!stat) { 00083 d->read_image(imagefile, image_index, true); 00084 } 00085 else { 00086 d->read_image(imagefile, image_index, false); 00087 } 00088 00089 printf("%20s: %d x %d x %d\n", "Image Dimensions", 00090 d->get_xsize(), d->get_ysize(), d->get_zsize()); 00091 00092 printf("%20s: %s\n", "Image Data Type", 00093 EMUtil::get_datatype_string((EMUtil::EMDataType)((int)(d->get_attr("datatype"))))); 00094 00095 if (stat) { 00096 printf("mean=%1.3g sigma=%1.3g skewness=%1.3g kurtosis=%1.3g\n", 00097 (float) d->get_attr("mean"), 00098 (float) d->get_attr("sigma"), 00099 (float) d->get_attr("skewness"), 00100 (float) d->get_attr("kurtosis")); 00101 } 00102 00103 Ctf* ctf = d->get_ctf(); 00104 if (ctf) { 00105 printf("CTF: %s\n", ctf->to_string().c_str()); 00106 delete ctf; 00107 ctf = 0; 00108 } 00109 00110 if (show_all_header) { 00111 Dict dict = d->get_attr_dict(); 00112 printf("\nDetailed Header Information:\n"); 00113 EMUtil::dump_dict(dict); 00114 } 00115 printf("\n"); 00116 00117 00118 00119 if( d ) 00120 { 00121 delete d; 00122 d = 0; 00123 } 00124 } 00125 catch(E2Exception & e) { 00126 if (d) { 00127 delete d; 00128 d = 0; 00129 } 00130 printf("%s\n", e.what()); 00131 } 00132 00133 00134 return 0; 00135 }
void usage | ( | const char * | progname | ) |
Definition at line 38 of file iminfo.cpp.
Referenced by main().
00039 { 00040 printf("\n%s [-H] [-vN] [-stat] <image file>\n", progname); 00041 printf(" -H: show all header information.\n"); 00042 printf(" -vN: set verbosity level. N=0,1,2,3. large N means more verbose.\n"); 00043 printf(" -stat: show statistical information about the image(s).\n"); 00044 printf("\n"); 00045 }