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