7 #ifndef IMPEM_IMAGE_HEADER_H
8 #define IMPEM_IMAGE_HEADER_H
10 #include "IMP/em/em_config.h"
32 typedef enum { IMG_BYTE = 0, IMG_IMPEM = 1,
34 VOL_BYTE = 2, VOL_IMPEM = 3,
36 IMG_FOURIER = -1, VOL_FOURIER = -3
41 set_image_type((
float)IMG_IMPEM );
44 ImageHeader(img_type im) {
46 set_image_type((
float)im );
49 ImageHeader(
float im) {
54 float get_image_type()
const {
55 return spider_header_.fIform;
66 set_image_type((
float)im);
69 void set_image_type(
float im) {
70 spider_header_.fIform=im;
73 void do_show(std::ostream& out)
const {
74 out <<
"Image type : ";
75 switch ((
int) spider_header_.fIform) {
77 out <<
"2D Byte image";
80 out <<
"2D IMP EM image";
83 out <<
"2D INT image";
86 out <<
"3D Byte volume";
89 out <<
"3D IMP EM volume";
92 out <<
"3D INT volume";
95 out <<
"2D Fourier image";
98 out <<
"3D Fourier volume";
102 out <<
"Reversed : ";
104 out <<
"TRUE" << std::endl;
106 out <<
"FALSE" << std::endl;
108 out <<
"dimensions (slices x rows x columns) : "
109 << get_number_of_slices() <<
" "
110 << get_number_of_rows() <<
" "
111 << get_number_of_columns() << std::endl;
112 out <<
"Origin (shift) : " << get_origin() << std::endl;
113 out <<
"Euler angles (Phi, Theta, Psi) (ZYZ convention): "
114 << get_euler_angles() << std::endl;
115 if ( spider_header_.fFlag == 1.0f || spider_header_.fFlag == 2.0f) {
116 out <<
"Euler angles (Phi1, Theta1, Psi1) (ZYZ convention): "
117 << get_euler_angles1() << std::endl;
119 if (spider_header_.fFlag == 2.0f) {
120 out <<
"Euler angles (Phi2, Theta2, Psi2) (ZYZ convention): "
121 << get_euler_angles1() << std::endl;
124 out <<
"Date : " << get_date() << std::endl;
125 out <<
"Time : " << get_time() << std::endl;
126 out <<
"Title : " << get_title() << std::endl;
127 out <<
"Header size : " << get_spider_header_size() << std::endl;
128 out <<
"Weight : " << get_Weight() << std::endl;
133 void print_hard(std::ostream& out)
const;
137 out <<
"(Phi,Theta,Psi) = ( " << spider_header_.fPhi <<
" , "
138 << spider_header_.fTheta <<
" , "
139 << spider_header_.fPsi <<
" ) "
140 <<
" (x,y) = ( " << spider_header_.fXoff <<
" , "
141 << spider_header_.fYoff <<
" ) " << std::endl;
146 int read(
const String filename,
bool skip_type_check =
false,
147 bool force_reversed =
false,
bool skip_extra_checkings =
false);
150 bool read(std::ifstream& f,
bool skip_type_check =
false,
151 bool force_reversed =
false,
bool skip_extra_checkings =
false);
154 void write(
const String &filename,
bool force_reversed =
false);
157 void write(std::ofstream& f,
bool force_reversed =
false);
167 void set_reversed(
bool value) { reversed_=value; }
169 unsigned int get_number_of_slices()
const {
170 return (
unsigned int)spider_header_.fNslice;
172 void set_number_of_slices(
unsigned int n) {
173 spider_header_.fNslice = (float)n;
176 unsigned int get_number_of_rows()
const {
177 return (
unsigned int )spider_header_.fNrow;
179 void set_number_of_rows(
unsigned int n) {
180 spider_header_.fNrow = (float)n;
183 unsigned int get_number_of_columns()
const {
184 return (
unsigned int )spider_header_.fNcol;
186 void set_number_of_columns(
unsigned int n) {
187 spider_header_.fNcol = (float)n;
192 return spider_header_.fAngle1;
197 spider_header_.fAngle1= value;
202 return spider_header_.fAngle1;
207 spider_header_.fAngle1= value;
210 float get_Scale()
const {
211 return spider_header_.fScale;
214 void set_Scale(
float value) {
215 spider_header_.fScale=value;
221 float get_Flip()
const {
return spider_header_.Flip; }
226 void set_Flip(
float value) { spider_header_.Flip=value; }
228 float get_Weight()
const {
return spider_header_.Weight; }
229 void set_Weight(
float value) { spider_header_.Weight=value; }
231 float get_fNrec()
const {
return spider_header_.fNrec; }
232 void set_fNrec(
float value) { spider_header_.fNrec = value; }
234 float get_fNlabel()
const {
return spider_header_.fNlabel; }
235 void set_fNlabel(
float value) { spider_header_.fNlabel=value; }
237 float get_fIform()
const {
return spider_header_.fIform; }
238 void set_fIform(
float value) { spider_header_.fIform = value; }
240 float get_fImami()
const {
return spider_header_.fImami; }
241 void set_fImami(
float value) { spider_header_.fImami=value; }
243 float get_fFmax()
const {
return spider_header_.fFmax; }
244 void set_fFmax(
float value) { spider_header_.fFmax= value; }
246 float get_fFmin()
const {
return spider_header_.fFmin; }
247 void set_fFmin(
float value) { spider_header_.fFmin=value; }
249 float get_fAv()
const {
return spider_header_.fAv; }
250 void set_fAv(
float value) { spider_header_.fAv=value; }
252 float get_fSig()
const {
return spider_header_.fSig; }
253 void set_fSig(
float value) { spider_header_.fSig=value; }
255 float get_fIhist()
const {
return spider_header_.fIhist; }
256 void set_fIhist(
float value) { spider_header_.fIhist=value; }
258 float get_fLabrec()
const {
return spider_header_.fLabrec; }
259 void set_fLabrec(
float value) { spider_header_.fLabrec=value; }
261 float get_fIangle()
const {
return spider_header_.fIangle; }
262 void set_fIangle(
float value) { spider_header_.fIangle=value; }
266 spider_header_.fYoff,
267 spider_header_.fZoff);
271 spider_header_.fXoff=v[0];
272 spider_header_.fYoff=v[1];
273 spider_header_.fZoff=v[2];
277 spider_header_.fXoff=(float)v[0];
278 spider_header_.fYoff=(float)v[1];
279 spider_header_.fZoff=(float)0.0;
282 float get_object_pixel_size()
const {
return spider_header_.fScale; }
283 void set_object_pixel_size(
float value) { spider_header_.fScale = value; }
285 float get_fLabbyt()
const {
return spider_header_.fLabbyt; }
286 void set_fLabbyt(
float value) { spider_header_.fLabbyt=value; }
288 float get_fLenbyt()
const {
return spider_header_.fLenbyt; }
289 void set_fLenbyt(
float value) { spider_header_.fLenbyt=value; }
291 double get_fGeo_matrix(
unsigned int i,
unsigned int j)
const;
299 float get_fFlag()
const {
return spider_header_.fFlag; }
300 void set_fFlag(
float value) { spider_header_.fFlag = value; }
304 spider_header_.fTheta,
305 spider_header_.fPsi);
310 spider_header_.fTheta1,
311 spider_header_.fPsi1);
316 spider_header_.fTheta2,
317 spider_header_.fPsi2);
321 spider_header_.fIangle = 1;
322 spider_header_.fPhi = euler[0];
323 spider_header_.fTheta = euler[1];
324 spider_header_.fPsi = euler[2];
328 if (spider_header_.fFlag != 2.f){
329 spider_header_.fFlag = 1.f;
331 spider_header_.fPhi1 = euler[0];
332 spider_header_.fTheta1 = euler[1];
333 spider_header_.fPsi1 = euler[2];
337 spider_header_.fFlag = 2;
338 spider_header_.fPhi2 = euler[0];
339 spider_header_.fTheta2 = euler[1];
340 spider_header_.fPsi2 = euler[2];
345 bool is_normalized()
const {
346 if(std::abs(get_fAv()) <1e-6 &&
347 std::abs(get_fSig()-1.0) < 1e-6) {
353 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
355 char* get_date()
const;
356 char* get_time()
const;
361 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
363 char* get_title()
const;
367 void set_title(
String newName);
372 int get_spider_header_size()
const {
373 return (
int) spider_header_.fNcol *
374 (int) spider_header_.fLabrec *
379 em::SpiderHeader spider_header_;
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
functions to deal with endian of EM images
Functions to deal with very common math operations.
Various general useful macros for IMP.
std::string String
Basic string value.