7 #ifndef IMPEM_IMAGE_HEADER_H
8 #define IMPEM_IMAGE_HEADER_H
10 #include "IMP/em/em_config.h"
44 set_image_type((
float)IMG_IMPEM);
47 ImageHeader(img_type im) {
49 set_image_type((
float)im);
52 ImageHeader(
float im) {
57 float get_image_type()
const {
return spider_header_.fIform; }
68 void set_image_type(
float im) { spider_header_.fIform = im; }
70 void do_show(std::ostream& out)
const {
71 out <<
"Image type : ";
72 switch ((
int)spider_header_.fIform) {
74 out <<
"2D Byte image";
77 out <<
"2D IMP EM image";
80 out <<
"2D INT image";
83 out <<
"3D Byte volume";
86 out <<
"3D IMP EM volume";
89 out <<
"3D INT volume";
92 out <<
"2D Fourier image";
95 out <<
"3D Fourier volume";
101 out <<
"TRUE" << std::endl;
103 out <<
"FALSE" << std::endl;
105 out <<
"dimensions (slices x rows x columns) : " << get_number_of_slices()
106 <<
" " << get_number_of_rows() <<
" " << get_number_of_columns()
108 out <<
"Origin (shift) : " << get_origin() << std::endl;
109 out <<
"Euler angles (Phi, Theta, Psi) (ZYZ convention): "
110 << get_euler_angles() << std::endl;
111 if (spider_header_.fFlag == 1.0f || spider_header_.fFlag == 2.0f) {
112 out <<
"Euler angles (Phi1, Theta1, Psi1) (ZYZ convention): "
113 << get_euler_angles1() << std::endl;
115 if (spider_header_.fFlag == 2.0f) {
116 out <<
"Euler angles (Phi2, Theta2, Psi2) (ZYZ convention): "
117 << get_euler_angles1() << std::endl;
120 out <<
"Date : " << get_date() << std::endl;
121 out <<
"Time : " << get_time() << std::endl;
122 out <<
"Title : " << get_title() << std::endl;
123 out <<
"Header size : " << get_spider_header_size() << std::endl;
124 out <<
"Weight : " << get_Weight() << std::endl;
129 void print_hard(std::ostream& out)
const;
133 out <<
"(Phi,Theta,Psi) = ( " << spider_header_.fPhi <<
" , "
134 << spider_header_.fTheta <<
" , " << spider_header_.fPsi <<
" ) "
135 <<
" (x,y) = ( " << spider_header_.fXoff <<
" , "
136 << spider_header_.fYoff <<
" ) " << std::endl;
141 int read(
const String filename,
bool skip_type_check =
false,
142 bool force_reversed =
false,
bool skip_extra_checkings =
false);
145 bool read(std::ifstream& f,
bool skip_type_check =
false,
146 bool force_reversed =
false,
bool skip_extra_checkings =
false);
149 void write(
const String& filename,
bool force_reversed =
false);
152 void write(std::ofstream& f,
bool force_reversed =
false);
162 void set_reversed(
bool value) { reversed_ = value; }
164 unsigned int get_number_of_slices()
const {
165 return (
unsigned int)spider_header_.fNslice;
167 void set_number_of_slices(
unsigned int n) {
168 spider_header_.fNslice = (float)n;
171 unsigned int get_number_of_rows()
const {
172 return (
unsigned int)spider_header_.fNrow;
174 void set_number_of_rows(
unsigned int n) { spider_header_.fNrow = (float)n; }
176 unsigned int get_number_of_columns()
const {
177 return (
unsigned int)spider_header_.fNcol;
179 void set_number_of_columns(
unsigned int n) {
180 spider_header_.fNcol = (float)n;
195 float get_Scale()
const {
return spider_header_.fScale; }
197 void set_Scale(
float value) { spider_header_.fScale = value; }
202 float get_Flip()
const {
return spider_header_.Flip; }
207 void set_Flip(
float value) { spider_header_.Flip = value; }
209 float get_Weight()
const {
return spider_header_.Weight; }
210 void set_Weight(
float value) { spider_header_.Weight = value; }
212 float get_fNrec()
const {
return spider_header_.fNrec; }
213 void set_fNrec(
float value) { spider_header_.fNrec = value; }
215 float get_fNlabel()
const {
return spider_header_.fNlabel; }
216 void set_fNlabel(
float value) { spider_header_.fNlabel = value; }
218 float get_fIform()
const {
return spider_header_.fIform; }
219 void set_fIform(
float value) { spider_header_.fIform = value; }
221 float get_fImami()
const {
return spider_header_.fImami; }
222 void set_fImami(
float value) { spider_header_.fImami = value; }
224 float get_fFmax()
const {
return spider_header_.fFmax; }
225 void set_fFmax(
float value) { spider_header_.fFmax = value; }
227 float get_fFmin()
const {
return spider_header_.fFmin; }
228 void set_fFmin(
float value) { spider_header_.fFmin = value; }
230 float get_fAv()
const {
return spider_header_.fAv; }
231 void set_fAv(
float value) { spider_header_.fAv = value; }
233 float get_fSig()
const {
return spider_header_.fSig; }
234 void set_fSig(
float value) { spider_header_.fSig = value; }
236 float get_fIhist()
const {
return spider_header_.fIhist; }
237 void set_fIhist(
float value) { spider_header_.fIhist = value; }
239 float get_fLabrec()
const {
return spider_header_.fLabrec; }
240 void set_fLabrec(
float value) { spider_header_.fLabrec = value; }
242 float get_fIangle()
const {
return spider_header_.fIangle; }
243 void set_fIangle(
float value) { spider_header_.fIangle = value; }
247 spider_header_.fZoff);
251 spider_header_.fXoff = v[0];
252 spider_header_.fYoff = v[1];
253 spider_header_.fZoff = v[2];
257 spider_header_.fXoff = (float)v[0];
258 spider_header_.fYoff = (float)v[1];
259 spider_header_.fZoff = (float)0.0;
262 float get_object_pixel_size()
const {
return spider_header_.fScale; }
263 void set_object_pixel_size(
float value) { spider_header_.fScale = value; }
265 float get_fLabbyt()
const {
return spider_header_.fLabbyt; }
266 void set_fLabbyt(
float value) { spider_header_.fLabbyt = value; }
268 float get_fLenbyt()
const {
return spider_header_.fLenbyt; }
269 void set_fLenbyt(
float value) { spider_header_.fLenbyt = value; }
271 double get_fGeo_matrix(
unsigned int i,
unsigned int j)
const;
279 float get_fFlag()
const {
return spider_header_.fFlag; }
280 void set_fFlag(
float value) { spider_header_.fFlag = value; }
284 spider_header_.fPsi);
289 spider_header_.fPsi1);
294 spider_header_.fPsi2);
298 spider_header_.fIangle = 1;
299 spider_header_.fPhi = euler[0];
300 spider_header_.fTheta = euler[1];
301 spider_header_.fPsi = euler[2];
305 if (spider_header_.fFlag != 2.f) {
306 spider_header_.fFlag = 1.f;
308 spider_header_.fPhi1 = euler[0];
309 spider_header_.fTheta1 = euler[1];
310 spider_header_.fPsi1 = euler[2];
314 spider_header_.fFlag = 2;
315 spider_header_.fPhi2 = euler[0];
316 spider_header_.fTheta2 = euler[1];
317 spider_header_.fPsi2 = euler[2];
320 bool is_normalized()
const {
321 if (std::abs(get_fAv()) < 1e-6 && std::abs(get_fSig() - 1.0) < 1e-6) {
327 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
329 char* get_date()
const;
330 char* get_time()
const;
335 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
337 char* get_title()
const;
341 void set_title(
String newName);
345 int get_spider_header_size()
const {
346 return (
int)spider_header_.fNcol * (int)spider_header_.fLabrec *
351 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.
std::string String
Basic string value.
Various general useful macros for IMP.