Bsoft  2.1.0
Bernard's software package
rwimg.cpp
Go to the documentation of this file.
1 
9 #include "rwimg.h"
10 #include "file_util.h"
11 #include "UnitCell.h"
12 #include "Complex.h"
13 #include "Vector3.h"
14 #include "utilities.h"
15 
16 #include "rwRAW.h"
17 #include "rwASCII.h"
18 #include "rwBCR.h"
19 #include "rwBIORAD.h"
20 #include "rwBRIX.h"
21 #include "rwBrookhavenSTEM.h"
22 #include "rwCCP4.h"
23 #include "rwDI.h"
24 #include "rwDM.h"
25 #include "rwDSN6.h"
26 #include "rwDX.h"
27 #include "rwEM.h"
28 #include "rwGOODFORD.h"
29 #include "rwGRD.h"
30 #include "rwHKL.h"
31 #include "rwIMAGIC.h"
32 #include "rwIP.h"
33 #include "rwJPEG.h"
34 #include "rwkernel.h"
35 #include "rwMFF.h"
36 #include "rwMIFF.h"
37 #include "rwMRC.h"
38 #include "rwPIC.h"
39 #include "rwPIF.h"
40 #include "rwPNG.h"
41 #include "rwPNM.h"
42 #include "rwPostScript.h"
43 #include "rwSER.h"
44 #include "rwSitus.h"
45 #include "rwSPE.h"
46 #include "rwSPIDER.h"
47 #include "rwSUPRIM.h"
48 #include "rwTGA.h"
49 #include "rwTIFF.h"
50 #include "rwXPLOR.h"
51 
52 // Declaration of global variables
53 extern int verbose; // Level of output to the screen
54 extern string command; // Command line
55 
56 const char* month[] = {"Jan","Feb","Mar","Apr","May","Jun",
57  "Jul","Aug","Sep","Oct","Nov","Dec"} ;
58 
59 // Internal function prototypes
60 
77 Bimage* read_img(char* filename, int readdata, int img_select)
78 {
79  string fn(filename);
80  return read_img(fn, readdata, img_select);
81 }
82 
83 Bimage* read_img(Bstring filename, int readdata, int img_select)
84 {
85  return read_img(filename.str(), readdata, img_select);
86 }
87 
88 Bimage* read_img(string filename, int readdata, int img_select)
89 {
90  if ( verbose & VERB_DEBUG )
91  cout << "DEBUG read_img: Filename=" << filename << " dataflag=" << readdata << endl;
92 
93  if ( !filename.length() ) {
94  cerr << "Error: No input image file given!" << endl;
95  return NULL;
96  }
97 
98  int err = 0;
99 
100 // Bstring path;
101  string path;
102 // Bstring ext = filename.extension();
103  string ext = extension(filename);
104 // Bstring clean_filename(filename.pre('#'));
105 // string clean_filename(filename.pre('#').str());
106  string clean_filename(filename.substr(0, filename.find("#")));
107 
108 // if ( clean_filename.contains("@") ) {
109 // img_select = clean_filename.post('@').integer();
110 // clean_filename = clean_filename.pre('@');
111 // }
112 
113  if ( clean_filename.find("@") != string::npos ) {
114  img_select = stoi(clean_filename.substr(clean_filename.find("@")+1));
115  clean_filename = clean_filename.substr(0, clean_filename.find("@"));
116  }
117 
118 // if ( filename.contains("://") )
119  if ( filename.find("://") != string::npos )
120  clean_filename = find_file(clean_filename, path);
121  else
122 // clean_filename = clean_filename.pre(':');
123  clean_filename = clean_filename.substr(0, clean_filename.find(":"));
124 
125 // if ( access(clean_filename.c_str(), R_OK) && ext.contains("krn") )
126 // clean_filename = parameter_file_path(clean_filename);
127 
128  if ( access(clean_filename.c_str(), R_OK) && ext.find("krn") != string::npos )
129  clean_filename = parameter_file_path(clean_filename);
130 
131  if ( access(clean_filename.c_str(), R_OK) ) {
132  error_show(clean_filename.c_str(), __FILE__, __LINE__);
133  return NULL;
134  }
135 
136  Bimage* p = new Bimage;
137 
138 // if ( filename.contains("#") )
139  if ( filename.find("#") != string::npos )
140  p->file_name(filename);
141  else
142  p->file_name(clean_filename);
143 
144 // cout << (*p)["filename"] << endl;
145 
146 // bexit(-1);
147 
148  if ( verbose & VERB_DEBUG ) {
149  cout << "DEBUG read_img: Transferred filename=" << p->file_name() << endl;
150  cout << "DEBUG read_img: Extension=" << ext << endl;
151  cout << "DEBUG read_img: img_select=" << img_select << endl;
152  }
153 
154  if ( filename.find("#") != string::npos || ext.length() < 1 )
155  err = readRAW(p, img_select);
156  else if ( ext.find("raw") != string::npos )
157  err = readRAW(p, img_select);
158  else if ( ext.find("asc") != string::npos || ext.find( "txt") != string::npos )
159  err = readASCII(p, readdata);
160  else if ( ext.find("bcr") != string::npos )
161  err = readBCR(p, readdata);
162  else if ( ext.find("pic") != string::npos )
163  err = readBIORAD(p, readdata);
164  else if ( ext.find("brx" ) != string::npos || ext.find("brix" ) != string::npos )
165  err = readBRIX(p, readdata);
166  else if ( ext.find("dat" ) != string::npos )
167  err = readBrookhavenSTEM(p, readdata);
168  else if ( ext.find("ccp") != string::npos || ext.find("map") != string::npos )
169  err = readCCP4(p, readdata);
170  else if ( ext.find("di") != string::npos )
171  err = readDI(p, readdata, img_select);
172  else if ( ext.find("dm") != string::npos )
173  err = readDM(p, readdata, img_select);
174  else if ( ext.find("omap" ) != string::npos || ext.find("dsn6") != string::npos || ext.find("dn6") != string::npos )
175  err = readDSN6(p, readdata);
176  else if ( ext.find("dx") != string::npos )
177  err = readDX(p, readdata);
178  else if ( ext.find("em") != string::npos )
179  err = readEM(p, readdata);
180  else if ( ext.find("pot") != string::npos )
181  err = readGOODFORD(p, readdata);
182  else if ( ext.find("grd") != string::npos )
183  err = readGRD(p, readdata, img_select);
184  else if ( ext.find("hkl") != string::npos )
185  err = readHKL(p, readdata);
186  else if ( ext.find("img") != string::npos || ext.find("hed") != string::npos )
187  err = readIMAGIC(p, readdata, img_select);
188  else if ( ext.find("ip") != string::npos )
189  err = readIP(p, readdata);
190  else if ( ext.find("jpg") != string::npos || ext.find("jpeg") != string::npos )
191  err = readJPEG(p, readdata);
192  else if ( ext.find("krn") != string::npos )
193  err = readKernel(p);
194  else if ( ext.find("mif") != string::npos )
195  err = readMIFF(p, readdata, img_select);
196  else if ( ext.find("mff") != string::npos )
197  err = readMFF(p, readdata);
198  else if ( ext.find("mrc") != string::npos || ext == "stk" )
199  err = readMRC(p, readdata, img_select);
200  else if ( ext == "st" || ext.find("ali") != string::npos || ext.find("rec") != string::npos ) // IMOD extensions
201  err = readMRC(p, readdata, img_select);
202  else if ( ext.find("pif") != string::npos || ext.find("sf") != string::npos )
203  err = readPIF(p, readdata, img_select);
204  else if ( ext.find("bp") != string::npos || ext.find("bq") != string::npos )
205  err = readPIC(p, readdata);
206  else if ( ext.find("png") != string::npos )
207  err = readPNG(p, readdata);
208  else if ( ext.find("pbm") != string::npos || ext.find("pgm") != string::npos || ext.find("ppm") != string::npos )
209  err = readPNM(p, readdata, img_select);
210  else if ( ext.find("ser") != string::npos )
211  err = readSER(p, readdata);
212  else if ( ext.find("sit") != string::npos )
213  err = readSitus(p, readdata);
214  else if ( ext.find("spe") != string::npos )
215  err = readSPE(p, readdata, img_select);
216  else if ( ext.find("spi") != string::npos )
217  err = readSPIDER(p, readdata, img_select);
218  else if ( ext.find("spm") != string::npos || ext.find("sup") != string::npos || ext == "f" )
219  err = readSUPRIM(p, readdata);
220  else if ( ext.find("tga") != string::npos )
221  err = readTGA(p, readdata);
222  else if ( ext.find("tif") != string::npos )
223  err = readTIFF(p, readdata, img_select);
224  else if ( ext.find("xpl") != string::npos || ext.find("cns") != string::npos || ext.find("rfl") != string::npos )
225  err = readXPLOR(p, readdata);
226  else {
227  cerr << "Error: File format with extension \"" << ext << "\" not supported!" << endl;
228  err = -1;
229  }
230 
231  // Deallocate strings
232 // ext = 0;
233 // path = 0;
234 // clean_filename = 0;
235 
236  if ( err < 0 ) {
237  error_show(filename, __FILE__, __LINE__);
238  delete p;
239  return NULL;
240  }
241 
242 // write_img("test.pif", p);
243 
245 
246  p->check();
247 
248  p->show_slice((long)p->image->origin()[2]);
249 // if ( p->show_slice() < 0 ) p->show_slice(0);
250  if ( p->show_slice() >= p->size()[2] ) p->show_slice(p->size()[2] - 1);
251 
252  if ( verbose & ( VERB_PROCESS | VERB_LABEL ) ) {
253  if ( img_select < 0 )
254  cout << "Reading file: " << p->file_name() << endl;
255  else
256  cout << "Reading image " << img_select << " from file: " << p->file_name() << endl;
257  }
258 
259  if ( verbose & VERB_PROCESS ) {
260  p->information();
261  if ( !p->data_pointer() ) cout << "Data not read!" << endl << endl;
262  }
263 
264  if ( verbose & VERB_STATS )
266 
267  return p;
268 }
269 
281 int write_img(const char* filename, Bimage* p, int compression)
282 {
283  string thefile(filename);
284 // cout << "char*: length = " << thefile.length() << endl;
285  return write_img(thefile, p, compression);
286 }
287 
288 int write_img(Bstring filename, Bimage* p, int compression)
289 {
290  return write_img(filename.str(), p, compression);
291 }
292 
293 int write_img(string filename, Bimage* p, int compression)
294 {
295  if ( !p ) return -1;
296 
297  if ( !filename.length() ) {
298  cerr << "Error: No output image file name given!" << endl;
299  return -1;
300  }
301 
302  int err(0), flags(compression);
303 
304 // Bstring ext = filename.extension();
305  string ext = extension(filename);
306 // cout << "extension = " << ext << endl;
307 
308  if ( ext.length() < 1 ) {
309  cerr << "Error: No extension found in the file name " << filename << endl << endl;
310  error_show(filename, __FILE__, __LINE__);
311  return -2;
312  }
313 /*
314  if ( p->compound_type() == TRGB || p->compound_type() == TRGBA ) {
315  if ( !ext.contains("tif") && !ext.contains("jp") && !ext.contains("mif")
316  && !ext.contains("png") && !ext.contains("pbm") && !ext.contains("pgm")
317  && !ext.contains("ppm") && !ext.contains("ps") && !ext.contains("tga") ) {
318  cerr << "Warning: Only TIFF, JPEG, PNG, PBM, PGM, PPM, MIFF, TGA or postscript files are acceptable as RGB output formats!" << endl;
319  }
320  }
321 */
322  if ( p->compound_type() == TRGB || p->compound_type() == TRGBA ) {
323  if ( ext.find("tif") == string::npos && ext.find("jp") == string::npos
324  && ext.find("mif") == string::npos && ext.find("png") == string::npos
325  && ext.find("pbm") == string::npos && ext.find("pgm") == string::npos
326  && ext.find("ppm") == string::npos && ext.find("ps") == string::npos
327  && ext.find("tga") == string::npos ) {
328  cerr << "Warning: Only TIFF, JPEG, PNG, PBM, PGM, PPM, MIFF, TGA or postscript files are acceptable as RGB output formats!" << endl;
329  }
330  }
331 
332 // filename = filename.pre(':');
333 
334 // filename = filename.pre('#');
335 
336  string::size_type pos = filename.find(":");
337  if ( pos != string::npos ) filename = filename.substr(pos);
338 
339  pos = filename.find("#");
340  if ( pos != string::npos ) filename = filename.substr(pos);
341 
342  p->file_name(filename);
343 
344  p->statistics();
345 
346  p->set_time(time(NULL));
347 
348  p->check();
349 
350  p->label(command);
351 
352  p->meta_data_update();
353 
354  if ( verbose & VERB_DEBUG ) {
355  cout << "DEBUG write_img: Image setup done for file " << p->file_name() << " (extension " << ext << ")" << endl;
356  cout << p->meta_data() << endl;
357  }
358 
359  if ( ext.find("raw") != string::npos )
360  err = writeRAW(p);
361  else if ( ext.find("asc") != string::npos || ext.find( "txt") != string::npos )
362  err = writeASCII(p);
363  else if ( ext.find("bcr") != string::npos )
364  err = writeBCR(p);
365  else if ( ext.find("pic") != string::npos )
366  err = writeBIORAD(p);
367  else if ( ext.find("brx" ) != string::npos || ext.find("brix" ) != string::npos )
368  err = writeBRIX(p);
369  else if ( ext.find("dat" ) != string::npos )
370  err = writeBrookhavenSTEM(p);
371  else if ( ( ext.find("ccp") != string::npos || ext.find("map") != string::npos ) )
372  err = writeCCP4(p);
373  else if ( ext.find("omap" ) != string::npos || ext.find("dsn6") != string::npos || ext.find("dn6") != string::npos )
374  err = writeDSN6(p);
375  else if ( ext.find("em") != string::npos )
376  err = writeEM(p);
377  else if ( ext.find("dm") != string::npos )
378  err = writeDM(p);
379  else if ( ext.find("dx") != string::npos )
380  err = writeDX(p);
381  else if ( ext.find("pot") != string::npos )
382  err = writeGOODFORD(p);
383  else if ( ext.find("grd") != string::npos )
384  err = writeGRD(p);
385  else if ( ext.find("hkl") != string::npos )
386  err = writeHKL(p);
387  else if ( ext.find("img") != string::npos || ext.find("hed") != string::npos )
388  err = writeIMAGIC(p);
389  else if ( ext.find("ip") != string::npos )
390  err = writeIP(p);
391  else if ( ext.find("jpg") != string::npos || ext.find("jpeg") != string::npos )
392  err = writeJPEG(p);
393  else if ( ext.find("krn") != string::npos )
394  err = writeKernel(p);
395  else if ( ext.find("mff") != string::npos )
396  err = writeMFF(p);
397  else if ( ext.find("mif") != string::npos )
398  err = writeMIFF(p);
399  else if ( ext.find("mrc") != string::npos || ext == "stk" )
400  err = writeMRC(p);
401  else if ( ext == "st" || ext.find("ali") != string::npos || ext.find("rec") != string::npos ) // IMOD extensions
402  err = writeMRC(p);
403  else if ( ext.find("pif") != string::npos || ext.find("sf") != string::npos )
404  err = writePIF(p);
405  else if ( ext.find("bp") != string::npos || ext.find("bq") != string::npos )
406  err = writePIC(p);
407  else if ( ext.find("png") != string::npos )
408  err = writePNG(p);
409  else if ( ext.find("pbm") != string::npos || ext.find("pgm") != string::npos || ext.find("ppm") != string::npos )
410  err = writePNM(p);
411  else if ( ext.find("ps") != string::npos )
412  err = writePostScriptImage(p);
413  else if ( ext.find("ser") != string::npos )
414  err = writeSER(p);
415  else if ( ext.find("sit") != string::npos )
416  err = writeSitus(p);
417  else if ( ext.find("spe") != string::npos )
418  err = writeSPE(p);
419  else if ( ext.find("spi") != string::npos )
420  err = writeSPIDER(p);
421  else if ( ext.find("spm") != string::npos || ext.find("sup") != string::npos || ext == "f" )
422  err = writeSUPRIM(p);
423  else if ( ext.find("tga") != string::npos )
424  err = writeTGA(p);
425  else if ( ext.find("tif") != string::npos ) {
426  if ( p->sizeZ() > 1 ) flags |= 1;
427  err = writeTIFF(p, flags);
428  } else if ( ext.find("xpl") != string::npos || ext.find("cns") != string::npos || ext.find("rfl") != string::npos )
429  err = writeXPLOR(p);
430  else {
431  cout << "File format with extension \"" << ext << "\" not supported!" << endl << endl;
432  err = -1;
433  }
434 
435  // Deallocate string
436 // ext = 0;
437 
438  if ( err < 0 ) {
439  error_show(filename, __FILE__, __LINE__);
440  return err;
441  }
442 
443  if ( verbose & ( VERB_PROCESS | VERB_LABEL ) )
444  cout << "Writing file: " << p->file_name() << endl;
445 
446  if ( verbose & VERB_DEBUG )
447  cout << "DEBUG write_img: p->data_pointer()=" << static_cast<void*>(p->data_pointer()) << endl;
448 
449  if ( verbose & VERB_PROCESS )
450  p->information();
451 
452  if ( verbose & VERB_STATS )
454 
455  return err;
456 }
457 
459  long hermx, long friedel, long oldx, long nux,
460  long xo1, long xo2, long yo1, long yo2,
461  long zo1, long zo2, int z_even, int y_even)
462 {
463  Complex<short>* sdata = (Complex<short> *) p->data_pointer();
464  Complex<int>* idata = (Complex<int> *) p->data_pointer();
465  Complex<float>* fdata = (Complex<float> *) p->data_pointer();
466  Complex<double>* ddata = (Complex<double> *) p->data_pointer();
467 
468  long x, y, z, nz, i, j, izi, izf, iyi, iyf, jz, jy;
469  long xf, yf, zf, xi, yi, zi;
470  int phisgn = 1;
471  Complex<double>* nuddata = (Complex<double> *) nufdata;
472  Complex<int>* nuidata = (Complex<int> *) nufdata;
473  Complex<short>* nusdata = (Complex<short> *) nufdata;
474 
475  nz = n*p->sizeZ();
476  for ( z=0; z<p->sizeZ(); z++ ) {
477  zi = z + zo1 - zo2;
478  if ( zi < 0 ) zi += p->sizeZ();
479  if ( zi >= (int)p->sizeZ() ) zi -= p->sizeZ();
480  if ( z_even )
481  zf = (zi)? p->sizeZ()-zi: zi;
482  else
483  zf = 2*zo1 - zi;
484  if ( zf < 0 ) zf += p->sizeZ();
485  izi = (nz + zi)*p->sizeY();
486  izf = (nz + zf)*p->sizeY();
487  jz = (nz + z)*p->sizeY();
488  for ( y=0; y<p->sizeY(); y++ ) {
489  yi = y + yo1 - yo2;
490  if ( yi < 0 ) yi += p->sizeY();
491  if ( yi >= (int)p->sizeY() ) yi -= p->sizeY();
492  if ( y_even )
493  yf = (yi)? p->sizeY()-yi: yi;
494  else
495  yf = 2*yo1 - yi;
496  if ( yf < 0 ) yf += p->sizeY();
497  iyi = (izi + yi)*oldx;
498  iyf = (izf + yf)*oldx;
499  jy = (jz + y)*nux;
500  for ( x=0; x<nux; x++ ) { //cout << "%d %d %d\n", x, y, z);
501  xi = x + xo1 - xo2;
502  if ( xi < 0 ) xi += p->sizeX();
503  if ( xi >= (int)p->sizeX() ) xi -= p->sizeX();
504  xf = (xi)? p->sizeX()-xi: xi;
505  if ( !friedel || ( xi < (int)hermx ) ) {
506  i = iyi + xi;
507  phisgn = 1;
508  } else {
509  i = iyf + xf;
510  phisgn = -1;
511  }
512  j = jy + x;
513  if ( p->data_type() == Short ) {
514  if ( phisgn > 0 ) nusdata[j] = sdata[i];
515  else nusdata[j] = sdata[i].conj();
516  } else if ( p->data_type() == Integer ) {
517  if ( phisgn > 0 ) nuidata[j] = idata[i];
518  else nuidata[j] = idata[i].conj();
519  } else if ( p->data_type() == Float ) {
520  if ( phisgn > 0 ) nufdata[j] = fdata[i];
521  else nufdata[j] = fdata[i].conj();
522  } else if ( p->data_type() == Double ) {
523  if ( phisgn > 0 ) nuddata[j] = ddata[i];
524  else nuddata[j] = ddata[i].conj();
525  }
526  }
527  }
528  }
529 
530  return 0;
531 }
532 
553 {
554  if ( !p ) return -1;
555 
556  if ( !p->data_pointer() ) return -1;
557 
558  if ( verbose & VERB_DEBUG ) {
559  cout << "DEBUG img_convert_fourier: old transform type = " << p->fourier_type() << endl;
560  cout << "DEBUG img_convert_fourier: new transform type = " << nutransform << endl;
561  cout << "DEBUG img_convert_fourier: input size = " << p->size() << endl;
562  }
563 
564  if ( p->compound_type() != TComplex ) {
566  return 0;
567  }
568 
569  if ( p->fourier_type() == NoTransform ) p->fourier_type(Standard);
570 
571  if ( nutransform == p->fourier_type() ) return 0;
572 
573  if ( verbose & VERB_PROCESS ) {
574  cout << "Converting Fourier transform: ";
575  switch ( p->fourier_type() ) {
576  case Standard: cout << "Standard -> "; break;
577  case Centered: cout << "Centered -> "; break;
578  case Hermitian: cout << "Hermitian -> "; break;
579  case CentHerm: cout << "Centered hermitian -> "; break;
580  default: break;
581  }
582  switch ( nutransform ) {
583  case Standard: cout << "Standard"; break;
584  case Centered: cout << "Centered"; break;
585  case Hermitian: cout << "Hermitian"; break;
586  case CentHerm: cout << "Centered hermitian"; break;
587  default: break;
588  }
589  cout << endl << endl;
590  }
591 
592  long hermx = p->sizeX()/2 + 1;
593  long friedel = 0;
594  long oldx = p->sizeX(), nux = p->sizeX();
595  if ( p->fourier_type() == Hermitian || p->fourier_type() == CentHerm ) {
596  oldx = hermx;
597  if ( nutransform == Standard || nutransform == Centered )
598  friedel = 1; // Flag => fill in friedel pairs
599  }
600  if ( nutransform == Hermitian || nutransform == CentHerm )
601  nux = hermx;
602 
603  long xo1, yo1, zo1, xo2, yo2, zo2; // Origins
604  switch ( p->fourier_type() ) {
605  case Centered:
606  xo1 = p->sizeX()/2;
607  yo1 = p->sizeY()/2;
608  zo1 = p->sizeZ()/2;
609  break;
610  case CentHerm:
611  xo1 = 0;
612  yo1 = p->sizeY()/2;
613  zo1 = p->sizeZ()/2;
614  break;
615  default:
616  xo1 = yo1 = zo1 = 0;
617  break;
618  }
619 
620  switch ( nutransform ) {
621  case Centered:
622  xo2 = p->sizeX()/2;
623  yo2 = p->sizeY()/2;
624  zo2 = p->sizeZ()/2;
625  break;
626  case CentHerm:
627  xo2 = 0;
628  yo2 = p->sizeY()/2;
629  zo2 = p->sizeZ()/2;
630  break;
631  default:
632  xo2 = yo2 = zo2 = 0;
633  break;
634  }
635 
636  if ( verbose & VERB_DEBUG ) {
637  cout << "DEBUG img_convert_fourier: hermx=" << hermx << " oldx=" << oldx << " nux=" << nux << endl;
638  cout << "DEBUG img_convert_fourier: input origin={" << xo1 << "," << yo1 << "," << zo1 << endl;
639  cout << "DEBUG img_convert_fourier: output origin={" << xo2 << "," << yo2 << "," << zo2 << endl;
640  }
641 
642  long datasize = p->alloc_size();
643  Complex<float>* nudata = new Complex<float>[datasize];
644 
645  int z_even = 0, y_even = 0;
646  if ( p->sizeZ()%2 == 0 ) z_even = 1;
647  if ( p->sizeY()%2 == 0 ) y_even = 1;
648 
649 #ifdef HAVE_GCD
650  dispatch_apply(p->images(), dispatch_get_global_queue(0, 0), ^(size_t n){
651  img_convert_fourier_one(p, nudata, n, hermx, friedel, oldx, nux,
652  xo1, xo2, yo1, yo2, zo1, zo2, z_even, y_even);
653  });
654 #else
655 #pragma omp parallel for
656  for ( long n=0; n<p->images(); n++ )
657  img_convert_fourier_one(p, nudata, n, hermx, friedel, oldx, nux,
658  xo1, xo2, yo1, yo2, zo1, zo2, z_even, y_even);
659 #endif
660 
661  p->data_assign((unsigned char *) nudata);
662 
663  p->fourier_type(nutransform);
664 
665  return 0;
666 }
667 
readCCP4
int readCCP4(Bimage *p, int readdata)
Reading a CCP4 map image file format.
Definition: rwCCP4.cpp:81
CentHerm
@ CentHerm
Definition: Bimage.h:45
writeIP
int writeIP(Bimage *p)
Writing an image plate reader file format.
Definition: rwIP.cpp:116
rwBRIX.h
Header file for reading and writing Brix files.
rwMFF.h
Header file for reading and writing the What If MFF files.
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:392
readBrookhavenSTEM
int readBrookhavenSTEM(Bimage *p, int readdata)
Reading a BrookhavenSTEM image file format.
Definition: rwBrookhavenSTEM.cpp:101
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:281
writeKernel
int writeKernel(Bimage *p)
Writes a text kernel file.
Definition: rwkernel.cpp:89
writePIC
int writePIC(Bimage *p)
Writing a PIC image file format(s). A 2D image format used in electron microscopy.
Definition: rwPIC.cpp:131
readTIFF
int readTIFF(Bimage *p, int readdata, int img_select)
Definition: rwTIFF.cpp:626
readDX
int readDX(Bimage *p, int readdata)
Reading an OpenDX image format.
Definition: rwDX.cpp:44
writeSPIDER
int writeSPIDER(Bimage *p)
Writing a SPIDER image file format. A 3D image format used in electron microscopy.
Definition: rwSPIDER.cpp:243
readSitus
int readSitus(Bimage *p, int readdata)
Reading a Situs image format.
Definition: rwSitus.cpp:27
writeGRD
int writeGRD(Bimage *p)
Writing a Basel GRD map image file format.
Definition: rwGRD.cpp:139
FourierType
FourierType
Fourier transform format specifier.
Definition: Bimage.h:40
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:116
command
string command
Definition: utilities.cpp:20
writeBRIX
int writeBRIX(Bimage *p)
Writing a BRIX image file format.
Definition: rwBRIX.cpp:120
Complex
Definition: Complex.h:23
rwBrookhavenSTEM.h
Header file for reading and writing Brookhaven STEM files.
file_util.h
Header file for file checking functions.
Bstring
Definition: Bstring.h:29
Bimage::set_time
void set_time(time_t t)
Definition: Bimage.h:264
rwSPE.h
Header file for reading and writing SPE files.
rwkernel.h
Header file for functions to read and write kernel files.
readJPEG
int readJPEG(Bimage *p, int readdata)
Definition: rwJPEG.cpp:155
rwBIORAD.h
Header file for reading and writing BioRad files.
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:390
rwIMAGIC.h
Header file for reading and writing Image Science's Imagic files.
writeHKL
int writeHKL(Bimage *p)
Writing a HKL structure factor file format. This function writes a HKL structure factor file.
Definition: rwHKL.cpp:210
writeBIORAD
int writeBIORAD(Bimage *p)
Writing a BioRad image file format.
Definition: rwBIORAD.cpp:99
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:719
Complex.h
Class for complex numbers.
Bimage::information
int information()
Prints out header information for an image.
Definition: Bimage.cpp:2508
rwDI.h
Header file for reading (only) Digital Instruments files.
TComplex
@ TComplex
Definition: Bimage.h:60
parameter_file_path
Bstring parameter_file_path(Bstring filename)
Finds the parameter file path.
Definition: Bstring.cpp:795
rwGRD.h
Header file for reading and writing Basel GRD files.
writeGOODFORD
int writeGOODFORD(Bimage *p)
Writing Peter Goodford's GRID map image file format. A 3D image format used for electrostatic potenti...
Definition: rwGOODFORD.cpp:103
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:386
readDM
int readDM(Bimage *p, int readdata, int img_select)
Reading a Digital Micrograph image file format.
Definition: rwDM.cpp:41
UnitCell.h
Header file for unit cell functions.
writeRAW
int writeRAW(Bimage *p)
Writing a raw block of data in a file.
Definition: rwRAW.cpp:192
readGRD
int readGRD(Bimage *p, int readdata, int img_select)
Reading a Basel GRD map image file format.
Definition: rwGRD.cpp:33
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:77
readSER
int readSER(Bimage *p, int readdata)
Definition: rwSER.cpp:32
Bimage::image
Bsub_image * image
Definition: Bimage.h:202
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
Hermitian
@ Hermitian
Definition: Bimage.h:44
rwBCR.h
Header file for reading and writing AFM BCR-STM files.
writeSPE
int writeSPE(Bimage *p)
Writing a SPE image file format.
Definition: rwSPE.cpp:119
writeMFF
int writeMFF(Bimage *p)
Writeing a MFF image format.
Definition: rwMFF.cpp:104
Standard
@ Standard
Definition: Bimage.h:42
rwSitus.h
Header file for reading and writing Situs files.
writeEM
int writeEM(Bimage *p)
Writing a EM map image file format. A 3D image format used in electron microscopy.
Definition: rwEM.cpp:115
writeTIFF
int writeTIFF(Bimage *p, int istiled)
Definition: rwTIFF.cpp:633
Bimage::images
long images()
Definition: Bimage.h:504
rwPostScript.h
Header file for (reading and) writing postscript image files.
rwTGA.h
Header file for reading and writing Truevision TGA files.
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:136
readPNM
int readPNM(Bimage *p, int readdata, int img_select)
Reading a PNM type file. A simple image format. PBM bit image format. PGM grayscale image format....
Definition: rwPNM.cpp:79
Short
@ Short
Definition: utilities.h:156
Bstring::str
string str()
Definition: Bstring.h:42
img_convert_fourier
int img_convert_fourier(Bimage *p, FourierType nutransform)
Converts Fourier transform types.
Definition: rwimg.cpp:552
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:391
Bimage::alloc_size
long alloc_size() const
Definition: Bimage.h:267
rwDX.h
Header file for reading and writing OpenDX files.
rwCCP4.h
Header file for reading and writing CCP4 files.
writeSER
int writeSER(Bimage *p)
Definition: rwSER.cpp:108
readGOODFORD
int readGOODFORD(Bimage *p, int readdata)
Reading Peter Goodford's GRID map image file format. A 3D image format used for electrostatic potenti...
Definition: rwGOODFORD.cpp:29
TRGBA
@ TRGBA
Definition: Bimage.h:64
Bimage::fourier_type
FourierType fourier_type()
Definition: Bimage.h:380
readSUPRIM
int readSUPRIM(Bimage *p, int readdata)
Reading a SUPRIM map image file format. A 3D image format used in electron microscopy....
Definition: rwSUPRIM.cpp:60
rwHKL.h
Header file for reading and writing HKL reflection files as images.
writePostScriptImage
int writePostScriptImage(Bimage *p)
Writing a postscript image format.
Definition: rwPostScript.cpp:27
rwSUPRIM.h
Header file for reading and writing SUPRIM files.
Bimage::meta_data
JSvalue & meta_data()
Definition: Bimage.h:234
TRGB
@ TRGB
Definition: Bimage.h:63
rwIP.h
Header file for reading and writing image plate reader files.
writePNG
int writePNG(Bimage *p)
Definition: rwPNG.cpp:380
Bimage
General image parameter class.
Definition: Bimage.h:177
Bimage::compound_type
CompoundType compound_type()
Definition: Bimage.h:364
rwDM.h
Header file for reading and writing DM files.
Vector3.h
Class for 3-value vectors.
readMIFF
int readMIFF(Bimage *p, int readdata, int img_select)
Reading an Image Magick map image file format. A 2D image format used for X-windows display....
Definition: rwMIFF.cpp:30
readEM
int readEM(Bimage *p, int readdata)
Reading a EM map image file format. A 3D image format used in electron microscopy....
Definition: rwEM.cpp:41
verbose
int verbose
readKernel
int readKernel(Bimage *p)
Reads a text kernel file.
Definition: rwkernel.cpp:21
Centered
@ Centered
Definition: Bimage.h:43
readDSN6
int readDSN6(Bimage *p, int readdata)
Reading a DSN6 map image file format.
Definition: rwDSN6.cpp:27
readHKL
int readHKL(Bimage *p, int readdata)
Reading a HKL structure factor file format. This function reads a HKL file typically produced with MT...
Definition: rwHKL.cpp:36
writeCCP4
int writeCCP4(Bimage *p)
Writing a CCP4 map image file format.
Definition: rwCCP4.cpp:209
readPIC
int readPIC(Bimage *p, int readdata)
Reading a PIC image file format(s). A 2D image format used in electron microscopy....
Definition: rwPIC.cpp:27
writeASCII
int writeASCII(Bimage *p)
Writing an ASCII or text image format.
Definition: rwASCII.cpp:279
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:245
rwASCII.h
Header file for reading and writing ASCII files.
writeIMAGIC
int writeIMAGIC(Bimage *p)
Writing an IMAGIC image format. A file format for the IMAGIC package.
Definition: rwIMAGIC.cpp:246
Bimage::data_type
DataType data_type()
Definition: Bimage.h:362
utilities.h
Header file for general utilities.
rwMIFF.h
Integer
@ Integer
Definition: utilities.h:158
writeDX
int writeDX(Bimage *p)
Writing a DX image format.
Definition: rwDX.cpp:112
readASCII
int readASCII(Bimage *p, int readdata)
Reading an ASCII or text image format.
Definition: rwASCII.cpp:34
rwMRC.h
Header file for reading and writing MRC files.
rwPNG.h
Header file for reading and writing PNG files.
writeBrookhavenSTEM
int writeBrookhavenSTEM(Bimage *p)
Writing a BrookhavenSTEM image file format.
Definition: rwBrookhavenSTEM.cpp:188
rwDSN6.h
Header file for reading and writing DSN6 files.
writeDM
int writeDM(Bimage *p)
Writing a Digital Micrograph map image file format.
Definition: rwDM.cpp:81
img_convert_fourier_one
int img_convert_fourier_one(Bimage *p, Complex< float > *nufdata, int n, long hermx, long friedel, long oldx, long nux, long xo1, long xo2, long yo1, long yo2, long zo1, long zo2, int z_even, int y_even)
Definition: rwimg.cpp:458
readIMAGIC
int readIMAGIC(Bimage *p, int readdata, int img_select)
Reading an IMAGIC image format. A 2D file format for the IMAGIC package. The header is stored in a se...
Definition: rwIMAGIC.cpp:65
writePIF
int writePIF(Bimage *p)
Writing a PIF image file format. A 2D and 3D image format used in electron microscopy.
Definition: rwPIF.cpp:370
rwimg.h
Header file for 2D and 3D image I/O.
Complex::conj
Complex conj()
Definition: Complex.h:106
readTGA
int readTGA(Bimage *p, int readdata)
Reading a Truevision TGA image file format.
Definition: rwTGA.cpp:134
writeXPLOR
int writeXPLOR(Bimage *p)
Writing a XPLOR map or structure factor file format. A text format used in X-ray crystallography.
Definition: rwXPLOR.cpp:221
Bimage::meta_data_update
void meta_data_update()
Update metadata from the sub-image information.
Definition: Bimage.cpp:678
rwSPIDER.h
Header file for reading and writing SPIDER files.
readBIORAD
int readBIORAD(Bimage *p, int readdata)
Reading a BioRad image file format.
Definition: rwBIORAD.cpp:40
Bimage::check
void check()
Checks an image for reasonable properties.
Definition: Bimage.cpp:419
rwTIFF.h
Header file for reading and writing TIFF files.
find_file
Bstring find_file(Bstring filename, Bstring path, int flag=0)
Searches for a file within or without the given path.
Definition: file_util.cpp:54
writeMIFF
int writeMIFF(Bimage *p)
Writing an Image Magick map image file format. A 2D image format used for X-windows display.
Definition: rwMIFF.cpp:150
Bimage::subimage_information
int subimage_information()
Prints out header information for all sub-images.
Definition: Bimage.cpp:2571
readDI
int readDI(Bimage *p, int readdata, int img_select)
Reading a Digital Instruments image file format. A two-image 2D image format used in Digital Instrume...
Definition: rwDI.cpp:42
extension
string extension(string filename)
Definition: string_util.cpp:32
readMFF
int readMFF(Bimage *p, int readdata)
Reading a MFF image format.
Definition: rwMFF.cpp:32
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:284
rwRAW.h
Header file for reading and writing Raw files.
writeJPEG
int writeJPEG(Bimage *p)
Definition: rwJPEG.cpp:162
readMRC
int readMRC(Bimage *p, int readdata, int img_select)
Reading a MRC map image file format.
Definition: rwMRC.cpp:58
VERB_STATS
#define VERB_STATS
Definition: utilities.h:112
Bimage::data_assign
unsigned char * data_assign(unsigned char *nudata)
Assign image data.
Definition: Bimage.cpp:875
rwPIC.h
Header file for reading and writing PIC's BP and BQ files.
readIP
int readIP(Bimage *p, int readdata)
Reading an image plate reader file format.
Definition: rwIP.cpp:50
rwJPEG.h
Header file for reading and writing JPEG files.
writeSUPRIM
int writeSUPRIM(Bimage *p)
Writing a SUPRIM map image file format. A 3D image format used in electron microscopy.
Definition: rwSUPRIM.cpp:203
readBCR
int readBCR(Bimage *p, int readdata)
Reading a BCR-STM image format.
Definition: rwBCR.cpp:48
month
const char * month[]
Definition: rwimg.cpp:56
rwPIF.h
Header file for reading and writing PIF files.
Double
@ Double
Definition: utilities.h:162
rwPNM.h
Header file for reading and writing PNM files.
writeSitus
int writeSitus(Bimage *p)
Writing a Situs image format.
Definition: rwSitus.cpp:82
readPIF
int readPIF(Bimage *p, int readdata, int img_select)
Reading a PIF image and structure factor file format. A 2D and 3D image format used in electron micro...
Definition: rwPIF.cpp:60
writeDSN6
int writeDSN6(Bimage *p)
Writing a DSN6 map image file format.
Definition: rwDSN6.cpp:112
Float
@ Float
Definition: utilities.h:161
rwXPLOR.h
Header file for reading and writing XPLOR reflection files.
VERB_LABEL
#define VERB_LABEL
Definition: utilities.h:110
writeMRC
int writeMRC(Bimage *p)
Writing a MRC map image file format.
Definition: rwMRC.cpp:276
rwGOODFORD.h
Header file for reading and writing Peter Goodford's GRID files.
readPNG
int readPNG(Bimage *p, int readdata)
Definition: rwPNG.cpp:373
readBRIX
int readBRIX(Bimage *p, int readdata)
Reading a BRIX image file format.
Definition: rwBRIX.cpp:37
NoTransform
@ NoTransform
Definition: Bimage.h:41
readSPE
int readSPE(Bimage *p, int readdata, int img_select)
Reading a SPE image file format.
Definition: rwSPE.cpp:33
writeTGA
int writeTGA(Bimage *p)
Writing a Truevision TGA map image file format.
Definition: rwTGA.cpp:266
rwEM.h
Header file for reading and writing EM files.
Bimage::statistics
long statistics()
Calculates the statistics for an image.
Definition: Bimage_stats.cpp:22
rwSER.h
Header file for reading and writing FEI Ser files.
writeBCR
int writeBCR(Bimage *p)
Writing a BCR-STM image format.
Definition: rwBCR.cpp:121
readRAW
int readRAW(Bimage *p, int img_select)
Reading a raw block of data in a file.
Definition: rwRAW.cpp:44
readXPLOR
int readXPLOR(Bimage *p, int readdata)
Reading a XPLOR map or structure factor file format. A minimal implementation.
Definition: rwXPLOR.cpp:32
writePNM
int writePNM(Bimage *p)
Writing a PNM type file. A simple image format.
Definition: rwPNM.cpp:182
Bimage::label
void label(string s)
Definition: Bimage.h:250
readSPIDER
int readSPIDER(Bimage *p, int readdata, int img_select)
Reading a SPIDER image file format.
Definition: rwSPIDER.cpp:82
Bimage::show_slice
long show_slice()
Definition: Bimage.h:561