42 Matrix3 mat,
int fill_type,
double fill)
47 error_show(
"img_transform", __FILE__, __LINE__);
48 cerr <<
"Error: Interpolation not done on compound data types" << endl;
52 if ( fabs(scale.
x()) < 0.001 || p->
sizeX() < 2 ) scale[0] = 1;
53 if ( fabs(scale.
y()) < 0.001 || p->
sizeY() < 2 ) scale[1] = 1;
54 if ( fabs(scale.
z()) < 0.001 || p->
sizeZ() < 2 ) scale[2] = 1;
56 if ( nusize.
x() < 1 ) nusize[0] = (
int) (fabs(scale.
x())*p->
sizeX());
57 if ( nusize.
y() < 1 ) nusize[1] = (
int) (fabs(scale.
y())*p->
sizeY());
58 if ( nusize.
z() < 1 ) nusize[2] = (
int) (fabs(scale.
z())*p->
sizeZ());
60 unsigned long i, c, n, x, y, z;
61 double oldx, oldy, oldz, newx, newy, newz;
71 nuorigin = origin + translate;
74 cout << endl <<
"Geometric transformation:" << endl;
75 cout <<
"Transformation origin: " << oldorigin << endl;
76 cout <<
"New origin: " << nuorigin << endl;
77 cout <<
"Scales: " << scale << endl;
78 cout <<
"New size: " << nusize <<
" voxels" << endl;
79 cout <<
" " << nurealsize <<
" A" << endl;
80 cout <<
"Matrix:" << endl << mat;
81 cout <<
"Fill value: " << fill << endl << endl;
88 unsigned long nudatasize = p->
images()*nusize.x()*nusize.y()*nusize.z()*p->
channels();
89 float* nudata =
new float[nudatasize];
90 for ( i=0; i<nudatasize; i++ ) nudata[i] = 0;
95 for ( i=n=0; n<p->
images(); n++ ) {
97 for ( z=0; z<nusize.z(); z++ ) {
98 nu[2] = z - nuorigin.
z();
99 for ( y=0; y<nusize.y(); y++ ) {
100 nu[1] = y - nuorigin.
y();
101 for ( x=0; x<nusize.x(); x++ ) {
102 nu[0] = x - nuorigin.
x();
103 old = affmat * nu + oldorigin;
104 for ( c=0; c<p->
channels(); c++, i++ )
113 view =
View(viewmat);
118 cout <<
"DEBUG img_transform: Interpolation done" << endl;
125 uc.
size(nurealsize.x(), nurealsize.y(), nurealsize.z());
133 cout <<
"DEBUG img_transform: all done" << endl;
165 for ( n=0; n<p->
images(); n++ ) {
void change_type(char letter)
Get the data type indicated by a single letter code.
int replace(Bimage *img)
Replaces the data with that from the given image.
Matrix3 transpose() const
void view(double x, double y, double z, double a)
Header file for general utilities.
CompoundType compound_type()
void unit_cell(UnitCell u)
int img_transform(Bimage *p, Vector3< int > nusize, Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type, double fill)
Transforms an image by translation, rotation, scaling and skewing.
int error_show(const char *message, const char *file, int line)
Displays the error with file and line reference.
double average(size_t cc, double xf, double yf, double zf, size_t nn, double iscale)
Averages in the xy plane when scaling is less than 1.
double interpolate(size_t cc, double xx, double yy, double zz, size_t nn, double fill) const
Interpolates using a given location.
size_t statistics()
Calculates the statistics for an image.
General image parameter class.
Library routines for interpolating images.
unsigned char * data_assign(unsigned char *nudata)
Assign image data.
int img_unique_shift_global_rotate(Bimage *p, Vector3< float > *origin, Vector3< float > *shift, float angle)
Shifts and rotates each image as defined in individual shift vectors.
void origin(double x, double y, double z)
unsigned char * data_pointer()
void size(double a, double b, double c)
Vector3< size_t > page_size()
int transform(Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type, double fill)
Transforms an image by translation, rotation, scaling and skewing, in place.
Header file for general utilities.