EMAN::ChaoProjector Class Reference

Fast real space projection using Bi-Linear interpolation. More...

#include <projector.h>

Inheritance diagram for EMAN::ChaoProjector:

Inheritance graph
[legend]
Collaboration diagram for EMAN::ChaoProjector:

Collaboration graph
[legend]
List of all members.

Public Member Functions

EMDataproject3d (EMData *vol) const
 Project an 3D image into a 2D image.
EMDatabackproject3d (EMData *imagestack) const
 Back-project a 2D image into a 3D image.
string get_name () const
 Get the projector's name.
string get_desc () const
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static ProjectorNEW ()

Static Public Attributes

static const string NAME = "chao"

Private Member Functions

int getnnz (Vec3i volsize, int ri, Vec3i origin, int *nray, int *nnz) const
int cb2sph (float *cube, Vec3i volsize, int ri, Vec3i origin, int nnz0, int *ptrs, int *cord, float *sphere) const
int sph2cb (float *sphere, Vec3i volsize, int nray, int ri, int nnz0, int *ptrs, int *cord, float *cube) const
int fwdpj3 (Vec3i volsize, int nray, int nnz, float *dm, Vec3i origin, int ri, int *ptrs, int *cord, float *x, float *y) const
int bckpj3 (Vec3i volsize, int nray, int nnz, float *dm, Vec3i origin, int ri, int *ptrs, int *cord, float *x, float *y) const
int ifix (float a) const
void setdm (vector< float > anglelist, string const angletype, float *dm) const

Detailed Description

Fast real space projection using Bi-Linear interpolation.

(C. Yang)

Definition at line 338 of file projector.h.


Member Function Documentation

EMData * ChaoProjector::backproject3d ( EMData imagestack  )  const [virtual]

Back-project a 2D image into a 3D image.

Returns:
A 3D image from the backprojection.

Implements EMAN::Projector.

Definition at line 1726 of file projector.cpp.

References anglelist, bckpj3(), cb2sph(), cord, cube, dm, EMDeleteArray(), EMAN::EMData::get_data(), EMAN::Util::get_min(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), getnnz(), EMAN::Dict::has_key(), images, LOGERR, nnz, nrays, NullPointerException, EMAN::Projector::params, phi, ptrs, EMAN::EMData::set_complex(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), setdm(), EMAN::Dict::size(), sph2cb(), sphere, status, theta, EMAN::EMData::to_zero(), and EMAN::EMData::update().

01727 {
01728         int nrays, nnz, status, j;
01729         float *dm;
01730         int   *ptrs, *cord;
01731         float *sphere, *images, *cube;
01732 
01733         int nximg   = imagestack->get_xsize();
01734         int nyimg   = imagestack->get_ysize();
01735         int nslices = imagestack->get_zsize();
01736 
01737         int dim = Util::get_min(nximg,nyimg);
01738         Vec3i volsize(nximg,nyimg,dim);
01739 
01740         Vec3i origin(0,0,0);
01741         // If a sensible origin isn't passed in, choose the middle of
01742         // the cube.
01743         if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
01744         else {origin[0] = nximg/2+1;}
01745         if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
01746         else {origin[1] = nyimg/2+1;}
01747         if (params.has_key("origin_z")) {origin[1] = params["origin_z"];}
01748         else {origin[2] = dim/2+1;}
01749 
01750         int ri;
01751         if (params.has_key("radius")) {ri = params["radius"];}
01752         else {ri = dim/2 - 1;}
01753 
01754         // retrieve the voxel values
01755         images = imagestack->get_data();
01756 
01757         // count the number of voxels within a sphere centered at icent,
01758         // with radius ri
01759         status = getnnz(volsize, ri, origin, &nrays, &nnz);
01760         // need to check status...
01761 
01762         // convert from cube to sphere
01763         sphere = new float[nnz];
01764         ptrs   = new int[nrays+1];
01765         cord   = new int[3*nrays];
01766         if (sphere == NULL || ptrs == NULL || cord == NULL) {
01767                 fprintf(stderr,"ChaoProjector::backproject3d, failed to allocate!\n");
01768                 exit(1);
01769         }
01770         for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
01771         for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
01772         for (int i = 0; i<3*nrays; i++) cord[i] = 0;
01773 
01774         int nangles = 0;
01775         vector<float> anglelist;
01776         string angletype = "SPIDER";
01777         // Do we have a list of angles?
01778         if (params.has_key("anglelist")) {
01779                 anglelist = params["anglelist"];
01780                 nangles = anglelist.size() / 3;
01781         } else {
01782                 Transform* t3d = params["transform"];
01783                 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
01784                 // This part was modified by David Woolford -
01785                 // Before this the code worked only for SPIDER and EMAN angles,
01786                 // but the framework of the Transform3D allows for a generic implementation
01787                 // as specified here.
01788                 //  This was broken by david.  we need here a loop over all projections and put all angles on stack  PAP 06/28/09
01789                 Dict p = t3d->get_rotation("spider");
01790                 if(t3d) {delete t3d; t3d=0;}
01791 
01792                 float phi = p["phi"];
01793                 float theta = p["theta"];
01794                 float psi = p["psi"];
01795                 anglelist.push_back(phi);
01796                 anglelist.push_back(theta);
01797                 anglelist.push_back(psi);
01798                 nangles = 1;
01799         }
01800 
01801         // End David Woolford modifications
01802 
01803         if (nslices != nangles) {
01804                 LOGERR("the number of images does not match the number of angles");
01805                 return 0;
01806         }
01807 
01808         dm = new float[nangles*9];
01809         setdm(anglelist, angletype, dm);
01810 
01811         // return volume
01812         EMData *ret = new EMData();
01813         ret->set_size(nximg, nyimg, dim);
01814         ret->set_complex(false);
01815         ret->set_ri(true);
01816         ret->to_zero();
01817 
01818         cube = ret->get_data();
01819         // cb2sph should be replaced by something that touches only ptrs and cord
01820         status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
01821         // check status
01822 
01823         for (j = 1; j <= nangles; j++) {
01824                 status = bckpj3(volsize, nrays, nnz, &dm(1,j), origin, ri,
01825                          ptrs   , cord , &images(1,1,j), sphere);
01826         // check status?
01827         }
01828 
01829         status = sph2cb(sphere, volsize, nrays, ri, nnz, ptrs, cord, cube);
01830         // check status?
01831 
01832         // deallocate all temporary work space
01833         EMDeleteArray(dm);
01834         EMDeleteArray(ptrs);
01835         EMDeleteArray(cord);
01836         EMDeleteArray(sphere);
01837 
01838         ret->update();
01839         return ret;
01840 }

int ChaoProjector::bckpj3 ( Vec3i  volsize,
int  nray,
int  nnz,
float *  dm,
Vec3i  origin,
int  ri,
int *  ptrs,
int *  cord,
float *  x,
float *  y 
) const [private]

Definition at line 1479 of file projector.cpp.

References cord, dm, ifix(), nx, ptrs, status, x, and y.

Referenced by backproject3d().

01482 {
01483     int       i, j, iqx,iqy, xc, yc, zc;
01484     float     xb, yb, dx, dy, dx1m, dy1m, dxdy;
01485     int       status = 0;
01486 
01487     int xcent = origin[0];
01488     int ycent = origin[1];
01489     int zcent = origin[2];
01490 
01491     int nx = volsize[0];
01492 
01493     if ( nx > 2*ri) {
01494         for (i = 1; i <= nrays; i++) {
01495             zc = cord(1,i) - zcent;
01496             yc = cord(2,i) - ycent;
01497             xc = cord(3,i) - xcent;
01498 
01499             xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
01500             yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
01501 
01502             for (j = ptrs(i); j <ptrs(i+1); j++) {
01503                 iqx = ifix((float)(xb));
01504                 iqy = ifix((float)(yb));
01505 
01506                 dx = xb - (float)(iqx);
01507                 dy = yb - (float)(iqy);
01508                 dx1m = 1.0f - dx;
01509                 dy1m = 1.0f - dy;
01510                 dxdy = dx*dy;
01511 /*
01512 c               y(j) = y(j) + dx1m*dy1m*x(iqx  , iqy)
01513 c     &                     + dx1m*dy  *x(iqx  , iqy+1)
01514 c     &                     + dx  *dy1m*x(iqx+1, iqy)
01515 c     &                     + dx  *dy  *x(iqx+1, iqy+1)
01516 c
01517 c              --- faster version of the above commented out
01518 c                  code (derived by summing the following table
01519 c                  of coefficients along  the colunms) ---
01520 c
01521 c                        1         dx        dy      dxdy
01522 c                     ------   --------  --------  -------
01523 c                      x(i,j)   -x(i,j)   -x(i,j)    x(i,j)
01524 c                                        x(i,j+1) -x(i,j+1)
01525 c                              x(i+1,j)           -x(i+1,j)
01526 c                                                x(i+1,j+1)
01527 c
01528 */
01529                y(j) += x(iqx,iqy)
01530                     +  dx*(-x(iqx,iqy)+x(iqx+1,iqy))
01531                     +  dy*(-x(iqx,iqy)+x(iqx,iqy+1))
01532                     +  dxdy*( x(iqx,iqy) - x(iqx,iqy+1)
01533                              -x(iqx+1,iqy) + x(iqx+1,iqy+1) );
01534 
01535                xb += dm(1);
01536                yb += dm(4);
01537             } // end for j
01538         } // end for i
01539      }
01540     else {
01541         fprintf(stderr, "bckpj3: nx must be greater than 2*ri\n");
01542     }
01543 
01544     return status;
01545 }

int ChaoProjector::cb2sph ( float *  cube,
Vec3i  volsize,
int  ri,
Vec3i  origin,
int  nnz0,
int *  ptrs,
int *  cord,
float *  sphere 
) const [private]

Definition at line 1309 of file projector.cpp.

References cord, cube, nnz, nrays, nx, ny, ptrs, sphere, and status.

Referenced by backproject3d(), and project3d().

01311 {
01312     int    xs, ys, zs, xx, yy, zz, rs, r2;
01313     int    ix, iy, iz, jnz, nnz, nrays;
01314     int    ftm = 0, status = 0;
01315 
01316     int xcent = (int)origin[0];
01317     int ycent = (int)origin[1];
01318     int zcent = (int)origin[2];
01319 
01320     int nx = (int)volsize[0];
01321     int ny = (int)volsize[1];
01322     int nz = (int)volsize[2];
01323 
01324     r2      = ri*ri;
01325     nnz     = 0;
01326     nrays    = 0;
01327     ptrs(1) = 1;
01328 
01329     for (ix = 1; ix <= nx; ix++) {
01330        xs  = ix-xcent;
01331        xx  = xs*xs;
01332        for ( iy = 1; iy <= ny; iy++ ) {
01333            ys = iy-ycent;
01334            yy = ys*ys;
01335            jnz = 0;
01336 
01337            ftm = 1;
01338            // not the most efficient implementation
01339            for (iz = 1; iz <= nz; iz++) {
01340                zs = iz-zcent;
01341                zz = zs*zs;
01342                rs = xx + yy + zz;
01343                if (rs <= r2) {
01344                   jnz++;
01345                   nnz++;
01346                   sphere(nnz) = cube(iz, iy, ix);
01347 
01348                   //  record the coordinates of the first nonzero ===
01349                   if (ftm) {
01350                      nrays++;
01351                      cord(1,nrays) = iz;
01352                      cord(2,nrays) = iy;
01353                      cord(3,nrays) = ix;
01354                      ftm = 0;
01355                   }
01356                }
01357             } // end for (iz..)
01358             if (jnz > 0) {
01359                 ptrs(nrays+1) = ptrs(nrays) + jnz;
01360             }  // endif (jnz)
01361        } // end for iy
01362     } // end for ix
01363     if (nnz != nnz0) status = -1;
01364     return status;
01365 }

int ChaoProjector::fwdpj3 ( Vec3i  volsize,
int  nray,
int  nnz,
float *  dm,
Vec3i  origin,
int  ri,
int *  ptrs,
int *  cord,
float *  x,
float *  y 
) const [private]

Definition at line 1403 of file projector.cpp.

References cord, dm, ifix(), nx, ptrs, status, x, and y.

Referenced by project3d().

01406 {
01407     /*
01408         purpose:  y <--- proj(x)
01409         input  :  volsize  the size (nx,ny,nz) of the volume
01410                   nrays    number of rays within the compact spherical
01411                            representation
01412                   nnz      number of voxels within the sphere
01413                   dm       an array of size 9 storing transformation
01414                            associated with the projection direction
01415                   origin   coordinates of the center of the volume
01416                   ri       radius of the sphere
01417                   ptrs     the beginning address of each ray
01418                   cord     the coordinates of the first point in each ray
01419                   x        3d input volume
01420                   y        2d output image
01421     */
01422 
01423     int    iqx, iqy, i, j, xc, yc, zc;
01424     float  ct, dipx, dipy, dipx1m, dipy1m, xb, yb, dm1, dm4;
01425     int    status = 0;
01426 
01427     int xcent = origin[0];
01428     int ycent = origin[1];
01429     int zcent = origin[2];
01430 
01431     int nx = volsize[0];
01432 
01433     dm1 = dm(1);
01434     dm4 = dm(4);
01435 
01436     if ( nx > 2*ri ) {
01437         for (i = 1; i <= nrays; i++) {
01438             zc = cord(1,i)-zcent;
01439             yc = cord(2,i)-ycent;
01440             xc = cord(3,i)-xcent;
01441 
01442             xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
01443             yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
01444 
01445             for (j = ptrs(i); j< ptrs(i+1); j++) {
01446                iqx = ifix(xb);
01447                iqy = ifix(yb);
01448 
01449                ct   = x(j);
01450                dipx =  xb - (float)(iqx);
01451                dipy = (yb - (float)(iqy)) * ct;
01452 
01453                dipy1m = ct - dipy;
01454                dipx1m = 1.0f - dipx;
01455 
01456                y(iqx  ,iqy)   = y(iqx  ,iqy)   + dipx1m*dipy1m;
01457                y(iqx+1,iqy)   = y(iqx+1,iqy)   + dipx*dipy1m;
01458                y(iqx+1,iqy+1) = y(iqx+1,iqy+1) + dipx*dipy;
01459                y(iqx  ,iqy+1) = y(iqx  ,iqy+1) + dipx1m*dipy;
01460 
01461                xb += dm1;
01462                yb += dm4;
01463            }
01464         }
01465     }
01466     else {
01467         fprintf(stderr, " nx must be greater than 2*ri\n");
01468         exit(1);
01469     }
01470     return status;
01471 }

string EMAN::ChaoProjector::get_desc (  )  const [inline, virtual]

Implements EMAN::Projector.

Definition at line 349 of file projector.h.

00350                 {
00351                         return "Fast real space projection generation with Bi-Linear interpolation.";
00352                 }

string EMAN::ChaoProjector::get_name (  )  const [inline, virtual]

Get the projector's name.

Each projector is indentified by unique name.

Returns:
The projector's name.

Implements EMAN::Projector.

Definition at line 344 of file projector.h.

References NAME.

00345                 {
00346                         return NAME;
00347                 }

TypeDict EMAN::ChaoProjector::get_param_types (  )  const [inline, virtual]

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Projector.

Definition at line 359 of file projector.h.

References EMAN::EMObject::FLOAT, EMAN::EMObject::FLOATARRAY, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::TRANSFORM.

00360                 {
00361                         TypeDict d;
00362                         d.put("transform", EMObject::TRANSFORM);
00363                         d.put("origin_x",  EMObject::INT);
00364                         d.put("origin_y",  EMObject::INT);
00365                         d.put("origin_z",  EMObject::INT);
00366                         d.put("anglelist", EMObject::FLOATARRAY);
00367                         d.put("radius",    EMObject::FLOAT);
00368                         return d;
00369                 }

int ChaoProjector::getnnz ( Vec3i  volsize,
int  ri,
Vec3i  origin,
int *  nray,
int *  nnz 
) const [private]

Definition at line 1249 of file projector.cpp.

References nnz, nrays, nx, ny, and status.

Referenced by backproject3d(), and project3d().

01251           : count the number of voxels within a sphere centered
01252             at origin and with a radius ri.
01253 
01254      input:
01255      volsize contains the size information (nx,ny,nz) about the volume
01256      ri      radius of the object embedded in the cube.
01257      origin  coordinates for the center of the volume
01258 
01259      output:
01260      nnz    total number of voxels within the sphere (of radius ri)
01261      nrays  number of rays in z-direction.
01262 */
01263 {
01264         int  ix, iy, iz, rs, r2, xs, ys, zs, xx, yy, zz;
01265         int  ftm=0, status = 0;
01266 
01267         r2    = ri*ri;
01268         *nnz  = 0;
01269         *nrays = 0;
01270         int nx = (int)volsize[0];
01271         int ny = (int)volsize[1];
01272         int nz = (int)volsize[2];
01273 
01274         int xcent = (int)origin[0];
01275         int ycent = (int)origin[1];
01276         int zcent = (int)origin[2];
01277 
01278         // need to add some error checking
01279         for (ix = 1; ix <=nx; ix++) {
01280             xs  = ix-xcent;
01281             xx  = xs*xs;
01282             for (iy = 1; iy <= ny; iy++) {
01283                 ys = iy-ycent;
01284                 yy = ys*ys;
01285                 ftm = 1;
01286                 for (iz = 1; iz <= nz; iz++) {
01287                     zs = iz-zcent;
01288                     zz = zs*zs;
01289                     rs = xx + yy + zz;
01290                     if (rs <= r2) {
01291                         (*nnz)++;
01292                         if (ftm) {
01293                            (*nrays)++;
01294                            ftm = 0;
01295                         }
01296                     }
01297                 }
01298             } // end for iy
01299         } // end for ix
01300         return status;
01301 }

int ChaoProjector::ifix ( float  a  )  const [private]

Definition at line 1552 of file projector.cpp.

Referenced by bckpj3(), and fwdpj3().

01553 {
01554     int ia;
01555 
01556     if (a>=0) {
01557        ia = (int)floor(a);
01558     }
01559     else {
01560        ia = (int)ceil(a);
01561     }
01562     return ia;
01563 }

static Projector* EMAN::ChaoProjector::NEW (  )  [inline, static]

Definition at line 354 of file projector.h.

00355                 {
00356                         return new ChaoProjector();
00357                 }

EMData * ChaoProjector::project3d ( EMData vol  )  const [virtual]

Project an 3D image into a 2D image.

Returns:
A 2D image from the projection.

Implements EMAN::Projector.

Definition at line 1607 of file projector.cpp.

References anglelist, cb2sph(), cord, cube, dm, EMDeleteArray(), fwdpj3(), EMAN::EMData::get_data(), EMAN::Util::get_min(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), getnnz(), EMAN::Dict::has_key(), images, LOGERR, nnz, nrays, NullPointerException, EMAN::Projector::params, phi, ptrs, EMAN::EMData::set_attr(), EMAN::EMData::set_complex(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), setdm(), EMAN::Dict::size(), sphere, status, theta, and EMAN::EMData::update().

01608 {
01609 
01610         int nrays, nnz, status, j;
01611         float *dm;
01612         int   *ptrs, *cord;
01613         float *sphere, *images;
01614 
01615         int nxvol = vol->get_xsize();
01616         int nyvol = vol->get_ysize();
01617         int nzvol = vol->get_zsize();
01618         Vec3i volsize(nxvol,nyvol,nzvol);
01619 
01620         int dim = Util::get_min(nxvol,nyvol,nzvol);
01621         if (nzvol == 1) {
01622                 LOGERR("The ChaoProjector needs a volume!");
01623                 return 0;
01624         }
01625         Vec3i origin(0,0,0);
01626         // If a sensible origin isn't passed in, choose the middle of
01627         // the cube.
01628         if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
01629         else {origin[0] = nxvol/2+1;}
01630         if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
01631         else {origin[1] = nyvol/2+1;}
01632         if (params.has_key("origin_z")) {origin[2] = params["origin_z"];}
01633         else {origin[2] = nzvol/2+1;}
01634 
01635         int ri;
01636         if (params.has_key("radius")) {ri = params["radius"];}
01637         else {ri = dim/2 - 1;}
01638 
01639         // retrieve the voxel values
01640         float *cube = vol->get_data();
01641 
01642         // count the number of voxels within a sphere centered at icent,
01643         // with radius ri
01644         status = getnnz(volsize, ri, origin, &nrays, &nnz);
01645         // need to check status...
01646 
01647         // convert from cube to sphere
01648         sphere = new float[nnz];
01649         ptrs   = new int[nrays+1];
01650         cord   = new int[3*nrays];
01651         if (sphere == NULL || ptrs == NULL || cord == NULL) {
01652                 fprintf(stderr,"ChaoProjector::project3d, failed to allocate!\n");
01653                 exit(1);
01654         }
01655         for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
01656         for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
01657         for (int i = 0; i<3*nrays; i++) cord[i] = 0;
01658 
01659         status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
01660         // check status
01661 
01662         int nangles = 0;
01663         vector<float> anglelist;
01664         string angletype = "SPIDER";
01665         // Do we have a list of angles?
01666         if (params.has_key("anglelist")) {
01667                 anglelist = params["anglelist"];
01668                 nangles = anglelist.size() / 3;
01669         } else {
01670                 Transform* t3d = params["transform"];
01671                 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
01672                 // This part was modified by David Woolford -
01673                 // Before this the code worked only for SPIDER and EMAN angles,
01674                 // but the framework of the Transform3D allows for a generic implementation
01675                 // as specified here.
01676                 Dict p = t3d->get_rotation("spider");
01677                 if(t3d) {delete t3d; t3d=0;}
01678 
01679                 float phi   = p["phi"];
01680                 float theta = p["theta"];
01681                 float psi   = p["psi"];
01682                 anglelist.push_back(phi);
01683                 anglelist.push_back(theta);
01684                 anglelist.push_back(psi);
01685                 nangles = 1;
01686         }
01687         // End David Woolford modifications
01688 
01689         dm = new float[nangles*9];
01690         setdm(anglelist, angletype, dm);
01691 
01692                 // return images
01693         EMData *ret = new EMData();
01694         ret->set_size(nxvol, nyvol, nangles);
01695         ret->set_complex(false);
01696         ret->set_ri(true);
01697 
01698         images = ret->get_data();
01699 
01700         for (j = 1; j <= nangles; j++) {
01701                 status = fwdpj3(volsize, nrays, nnz   , &dm(1,j), origin, ri,
01702                                                 ptrs   ,  cord, sphere, &images(1,1,j));
01703         // check status?
01704         }
01705 
01706         // deallocate all temporary work space
01707         EMDeleteArray(dm);
01708         EMDeleteArray(ptrs);
01709         EMDeleteArray(cord);
01710         EMDeleteArray(sphere);
01711 
01712         if (!params.has_key("anglelist")) {
01713                 Transform* t3d = params["transform"];
01714                 ret->set_attr("xform.projection",t3d);
01715                 if(t3d) {delete t3d; t3d=0;}
01716         }
01717         ret->update();
01718         return ret;
01719 }

void ChaoProjector::setdm ( vector< float >  anglelist,
string const   angletype,
float *  dm 
) const [private]

Definition at line 1569 of file projector.cpp.

References anglelist, dgr_to_rad, dm, phi, and theta.

Referenced by backproject3d(), and project3d().

01570 { // convert Euler angles to transformations, dm is an 9 by nangles array
01571 
01572         float  psi, theta, phi;
01573         double cthe, sthe, cpsi, spsi, cphi, sphi;
01574         int    j;
01575 
01576         int nangles = anglelist.size() / 3;
01577 
01578         // now convert all angles
01579         for (j = 1; j <= nangles; j++) {
01580                 phi   = static_cast<float>(anglelist(1,j)*dgr_to_rad);
01581                 theta = static_cast<float>(anglelist(2,j)*dgr_to_rad);
01582                 psi   = static_cast<float>(anglelist(3,j)*dgr_to_rad);
01583 
01584                 //              cout << phi << " " << theta << " " << psi << endl;
01585                 cthe  = cos(theta);
01586                 sthe  = sin(theta);
01587                 cpsi  = cos(psi);
01588                 spsi  = sin(psi);
01589                 cphi  = cos(phi);
01590                 sphi  = sin(phi);
01591 
01592                 dm(1,j)=static_cast<float>(cphi*cthe*cpsi-sphi*spsi);
01593                 dm(2,j)=static_cast<float>(sphi*cthe*cpsi+cphi*spsi);
01594                 dm(3,j)=static_cast<float>(-sthe*cpsi);
01595                 dm(4,j)=static_cast<float>(-cphi*cthe*spsi-sphi*cpsi);
01596                 dm(5,j)=static_cast<float>(-sphi*cthe*spsi+cphi*cpsi);
01597                 dm(6,j)=static_cast<float>(sthe*spsi);
01598                 dm(7,j)=static_cast<float>(sthe*cphi);
01599                 dm(8,j)=static_cast<float>(sthe*sphi);
01600                 dm(9,j)=static_cast<float>(cthe);
01601         }
01602 }

int ChaoProjector::sph2cb ( float *  sphere,
Vec3i  volsize,
int  nray,
int  ri,
int  nnz0,
int *  ptrs,
int *  cord,
float *  cube 
) const [private]

Definition at line 1368 of file projector.cpp.

References cord, cube, nnz, nx, ny, ptrs, sphere, and status.

Referenced by backproject3d().

01370 {
01371     int       status=0;
01372     int       r2, i, j, ix, iy, iz,  nnz;
01373 
01374     int nx = (int)volsize[0];
01375     int ny = (int)volsize[1];
01376     // int nz = (int)volsize[2];
01377 
01378     r2      = ri*ri;
01379     nnz     = 0;
01380     ptrs(1) = 1;
01381 
01382     // no need to initialize
01383     // for (i = 0; i<nx*ny*nz; i++) cube[i]=0.0;
01384 
01385     nnz = 0;
01386     for (j = 1; j <= nrays; j++) {
01387        iz = cord(1,j);
01388        iy = cord(2,j);
01389        ix = cord(3,j);
01390        for (i = ptrs(j); i<=ptrs(j+1)-1; i++, iz++) {
01391            nnz++;
01392            cube(iz,iy,ix) = sphere(nnz);
01393        }
01394     }
01395     if (nnz != nnz0) status = -1;
01396     return status;
01397 }


Member Data Documentation

const string ChaoProjector::NAME = "chao" [static]

Definition at line 371 of file projector.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:11:08 2012 for EMAN2 by  doxygen 1.4.7