| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
img_util.cpp
Go to the documentation of this file.
1
9 #include "rwimg.h"
10 #include "utilities.h"
11
12 // Declaration of global variables
13 extern int verbose; // Level of output to the screen
14
15
25 Bimage* img_rotate_by_pi(Bimage* p)
26 {
27 if ( !p->data_pointer() ) return NULL;
28
29 if ( p->size().volume() < 1 ) {
30 error_show("img_rotate_by_pi", __FILE__, __LINE__);
31 cerr << "Error: Size of image is less than one!" << endl;
32 return NULL;
33 }
34
35 Bimage* prot = p->copy_header();
36 prot->data_alloc();
37
38 unsigned long i, j, c, x, y, z, n, oldx, oldy, oldz;
39
40 if ( verbose & VERB_LABEL )
41 cout << "Rotating an image by PI" << endl << endl;
42
43 for ( i=n=0; n<p->images(); n++ ) {
44 for ( z=0; z<p->sizeZ(); z++ ) {
45 oldz = p->sizeZ() - z - 1;
46 for ( y=0; y<p->sizeY(); y++ ) {
47 oldy = p->sizeY() - y - 1;
48 for ( x=0; x<p->sizeX(); x++ ) {
49 oldx = p->sizeX() - x - 1;
50 j = (((n*p->sizeZ()+oldz)*p->sizeY() + oldy)*p->sizeX() + oldx)*p->channels();
51 for ( c=0; c<p->channels(); c++, i++, j++ ) prot->set(i, (*p)[j]);
52 }
53 }
54 }
55 }
56
57 return prot;
58 }
59
Bimage::images
unsigned long images()
Definition: Bimage.h:402
Bimage::copy_header
Bimage * copy_header()
Definition: Bimage.h:478
img_rotate_by_pi
Bimage * img_rotate_by_pi(Bimage *p)
Rotates an image by pi.
Definition: img_util.cpp:25
Bimage::sizeX
void sizeX(unsigned long nx)
Definition: Bimage.h:332
verbose
int verbose
utilities.h
Header file for general utilities.
error_show
int error_show(const char *message, const char *file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:616
Bimage::channels
unsigned long channels()
Definition: Bimage.h:327
Bimage::size
Vector3< int > size()
Definition: Bimage.h:329
Bimage
General image parameter class.
Definition: Bimage.h:149
Bimage::data_alloc
unsigned char * data_alloc()
Definition: Bimage.h:220
Bimage::set
void set(unsigned long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:885
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:225
Bimage::sizeZ
void sizeZ(unsigned long nz)
Definition: Bimage.h:334
rwimg.h
Header file for 2D and 3D image I/O.
Bimage::sizeY
void sizeY(unsigned long ny)
Definition: Bimage.h:333
VERB_LABEL
#define VERB_LABEL
Definition: utilities.h:98
Vector3::volume
double volume()
Definition: Vector3.h:207