Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

ProjectorNEW ()

Static Public Attributes

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 374 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 1881 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, 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(), EMAN::EMData::update(), and EMAN::Vec3i.

01882 {
01883         int nrays, nnz, status, j;
01884         float *dm;
01885         int   *ptrs, *cord;
01886         float *sphere, *images, *cube;
01887 
01888         int nximg   = imagestack->get_xsize();
01889         int nyimg   = imagestack->get_ysize();
01890         int nslices = imagestack->get_zsize();
01891 
01892         int dim = Util::get_min(nximg,nyimg);
01893         Vec3i volsize(nximg,nyimg,dim);
01894 
01895         Vec3i origin(0,0,0);
01896         // If a sensible origin isn't passed in, choose the middle of
01897         // the cube.
01898         if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
01899         else {origin[0] = nximg/2+1;}
01900         if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
01901         else {origin[1] = nyimg/2+1;}
01902         if (params.has_key("origin_z")) {origin[1] = params["origin_z"];}
01903         else {origin[2] = dim/2+1;}
01904 
01905         int ri;
01906         if (params.has_key("radius")) {ri = params["radius"];}
01907         else {ri = dim/2 - 1;}
01908 
01909         // retrieve the voxel values
01910         images = imagestack->get_data();
01911 
01912         // count the number of voxels within a sphere centered at icent,
01913         // with radius ri
01914         status = getnnz(volsize, ri, origin, &nrays, &nnz);
01915         // need to check status...
01916 
01917         // convert from cube to sphere
01918         sphere = new float[nnz];
01919         ptrs   = new int[nrays+1];
01920         cord   = new int[3*nrays];
01921         if (sphere == NULL || ptrs == NULL || cord == NULL) {
01922                 fprintf(stderr,"ChaoProjector::backproject3d, failed to allocate!\n");
01923                 exit(1);
01924         }
01925         for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
01926         for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
01927         for (int i = 0; i<3*nrays; i++) cord[i] = 0;
01928 
01929         int nangles = 0;
01930         vector<float> anglelist;
01931         string angletype = "SPIDER";
01932         // Do we have a list of angles?
01933         if (params.has_key("anglelist")) {
01934                 anglelist = params["anglelist"];
01935                 nangles = anglelist.size() / 3;
01936         } else {
01937                 Transform* t3d = params["transform"];
01938                 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
01939                 // This part was modified by David Woolford -
01940                 // Before this the code worked only for SPIDER and EMAN angles,
01941                 // but the framework of the Transform3D allows for a generic implementation
01942                 // as specified here.
01943                 //  This was broken by david.  we need here a loop over all projections and put all angles on stack  PAP 06/28/09
01944                 Dict p = t3d->get_rotation("spider");
01945                 if(t3d) {delete t3d; t3d=0;}
01946 
01947                 float phi = p["phi"];
01948                 float theta = p["theta"];
01949                 float psi = p["psi"];
01950                 anglelist.push_back(phi);
01951                 anglelist.push_back(theta);
01952                 anglelist.push_back(psi);
01953                 nangles = 1;
01954         }
01955 
01956         // End David Woolford modifications
01957 
01958         if (nslices != nangles) {
01959                 LOGERR("the number of images does not match the number of angles");
01960                 return 0;
01961         }
01962 
01963         dm = new float[nangles*9];
01964         setdm(anglelist, angletype, dm);
01965 
01966         // return volume
01967         EMData *ret = new EMData();
01968         ret->set_size(nximg, nyimg, dim);
01969         ret->set_complex(false);
01970         ret->set_ri(true);
01971         ret->to_zero();
01972 
01973         cube = ret->get_data();
01974         // cb2sph should be replaced by something that touches only ptrs and cord
01975         status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
01976         // check status
01977 
01978         for (j = 1; j <= nangles; j++) {
01979                 status = bckpj3(volsize, nrays, nnz, &dm(1,j), origin, ri,
01980                          ptrs   , cord , &images(1,1,j), sphere);
01981         // check status?
01982         }
01983 
01984         status = sph2cb(sphere, volsize, nrays, ri, nnz, ptrs, cord, cube);
01985         // check status?
01986 
01987         // deallocate all temporary work space
01988         EMDeleteArray(dm);
01989         EMDeleteArray(ptrs);
01990         EMDeleteArray(cord);
01991         EMDeleteArray(sphere);
01992 
01993         ret->update();
01994         return ret;
01995 }

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 1634 of file projector.cpp.

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

Referenced by backproject3d().

01637 {
01638     int       i, j, iqx,iqy, xc, yc, zc;
01639     float     xb, yb, dx, dy, dx1m, dy1m, dxdy;
01640     int       status = 0;
01641 
01642     int xcent = origin[0];
01643     int ycent = origin[1];
01644     int zcent = origin[2];
01645 
01646     int nx = volsize[0];
01647 
01648     if ( nx > 2*ri) {
01649         for (i = 1; i <= nrays; i++) {
01650             zc = cord(1,i) - zcent;
01651             yc = cord(2,i) - ycent;
01652             xc = cord(3,i) - xcent;
01653 
01654             xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
01655             yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
01656 
01657             for (j = ptrs(i); j <ptrs(i+1); j++) {
01658                 iqx = ifix((float)(xb));
01659                 iqy = ifix((float)(yb));
01660 
01661                 dx = xb - (float)(iqx);
01662                 dy = yb - (float)(iqy);
01663                 dx1m = 1.0f - dx;
01664                 dy1m = 1.0f - dy;
01665                 dxdy = dx*dy;
01666 /*
01667 c               y(j) = y(j) + dx1m*dy1m*x(iqx  , iqy)
01668 c     &                     + dx1m*dy  *x(iqx  , iqy+1)
01669 c     &                     + dx  *dy1m*x(iqx+1, iqy)
01670 c     &                     + dx  *dy  *x(iqx+1, iqy+1)
01671 c
01672 c              --- faster version of the above commented out
01673 c                  code (derived by summing the following table
01674 c                  of coefficients along  the colunms) ---
01675 c
01676 c                        1         dx        dy      dxdy
01677 c                     ------   --------  --------  -------
01678 c                      x(i,j)   -x(i,j)   -x(i,j)    x(i,j)
01679 c                                        x(i,j+1) -x(i,j+1)
01680 c                              x(i+1,j)           -x(i+1,j)
01681 c                                                x(i+1,j+1)
01682 c
01683 */
01684                y(j) += x(iqx,iqy)
01685                     +  dx*(-x(iqx,iqy)+x(iqx+1,iqy))
01686                     +  dy*(-x(iqx,iqy)+x(iqx,iqy+1))
01687                     +  dxdy*( x(iqx,iqy) - x(iqx,iqy+1)
01688                              -x(iqx+1,iqy) + x(iqx+1,iqy+1) );
01689 
01690                xb += dm(1);
01691                yb += dm(4);
01692             } // end for j
01693         } // end for i
01694      }
01695     else {
01696         fprintf(stderr, "bckpj3: nx must be greater than 2*ri\n");
01697     }
01698 
01699     return status;
01700 }

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

Definition at line 1464 of file projector.cpp.

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

Referenced by backproject3d(), and project3d().

01466 {
01467     int    xs, ys, zs, xx, yy, zz, rs, r2;
01468     int    ix, iy, iz, jnz, nnz, nrays;
01469     int    ftm = 0, status = 0;
01470 
01471     int xcent = (int)origin[0];
01472     int ycent = (int)origin[1];
01473     int zcent = (int)origin[2];
01474 
01475     int nx = (int)volsize[0];
01476     int ny = (int)volsize[1];
01477     int nz = (int)volsize[2];
01478 
01479     r2      = ri*ri;
01480     nnz     = 0;
01481     nrays    = 0;
01482     ptrs(1) = 1;
01483 
01484     for (ix = 1; ix <= nx; ix++) {
01485        xs  = ix-xcent;
01486        xx  = xs*xs;
01487        for ( iy = 1; iy <= ny; iy++ ) {
01488            ys = iy-ycent;
01489            yy = ys*ys;
01490            jnz = 0;
01491 
01492            ftm = 1;
01493            // not the most efficient implementation
01494            for (iz = 1; iz <= nz; iz++) {
01495                zs = iz-zcent;
01496                zz = zs*zs;
01497                rs = xx + yy + zz;
01498                if (rs <= r2) {
01499                   jnz++;
01500                   nnz++;
01501                   sphere(nnz) = cube(iz, iy, ix);
01502 
01503                   //  record the coordinates of the first nonzero ===
01504                   if (ftm) {
01505                      nrays++;
01506                      cord(1,nrays) = iz;
01507                      cord(2,nrays) = iy;
01508                      cord(3,nrays) = ix;
01509                      ftm = 0;
01510                   }
01511                }
01512             } // end for (iz..)
01513             if (jnz > 0) {
01514                 ptrs(nrays+1) = ptrs(nrays) + jnz;
01515             }  // endif (jnz)
01516        } // end for iy
01517     } // end for ix
01518     if (nnz != nnz0) status = -1;
01519     return status;
01520 }

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 1558 of file projector.cpp.

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

Referenced by project3d().

01561 {
01562     /*
01563         purpose:  y <--- proj(x)
01564         input  :  volsize  the size (nx,ny,nz) of the volume
01565                   nrays    number of rays within the compact spherical
01566                            representation
01567                   nnz      number of voxels within the sphere
01568                   dm       an array of size 9 storing transformation
01569                            associated with the projection direction
01570                   origin   coordinates of the center of the volume
01571                   ri       radius of the sphere
01572                   ptrs     the beginning address of each ray
01573                   cord     the coordinates of the first point in each ray
01574                   x        3d input volume
01575                   y        2d output image
01576     */
01577 
01578     int    iqx, iqy, i, j, xc, yc, zc;
01579     float  ct, dipx, dipy, dipx1m, dipy1m, xb, yb, dm1, dm4;
01580     int    status = 0;
01581 
01582     int xcent = origin[0];
01583     int ycent = origin[1];
01584     int zcent = origin[2];
01585 
01586     int nx = volsize[0];
01587 
01588     dm1 = dm(1);
01589     dm4 = dm(4);
01590 
01591     if ( nx > 2*ri ) {
01592         for (i = 1; i <= nrays; i++) {
01593             zc = cord(1,i)-zcent;
01594             yc = cord(2,i)-ycent;
01595             xc = cord(3,i)-xcent;
01596 
01597             xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
01598             yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
01599 
01600             for (j = ptrs(i); j< ptrs(i+1); j++) {
01601                iqx = ifix(xb);
01602                iqy = ifix(yb);
01603 
01604                ct   = x(j);
01605                dipx =  xb - (float)(iqx);
01606                dipy = (yb - (float)(iqy)) * ct;
01607 
01608                dipy1m = ct - dipy;
01609                dipx1m = 1.0f - dipx;
01610 
01611                y(iqx  ,iqy)   = y(iqx  ,iqy)   + dipx1m*dipy1m;
01612                y(iqx+1,iqy)   = y(iqx+1,iqy)   + dipx*dipy1m;
01613                y(iqx+1,iqy+1) = y(iqx+1,iqy+1) + dipx*dipy;
01614                y(iqx  ,iqy+1) = y(iqx  ,iqy+1) + dipx1m*dipy;
01615 
01616                xb += dm1;
01617                yb += dm4;
01618            }
01619         }
01620     }
01621     else {
01622         fprintf(stderr, " nx must be greater than 2*ri\n");
01623         exit(1);
01624     }
01625     return status;
01626 }

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

Implements EMAN::Projector.

Definition at line 385 of file projector.h.

00386                 {
00387                         return "Fast real space projection generation with Bi-Linear interpolation.";
00388                 }

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 380 of file projector.h.

00381                 {
00382                         return NAME;
00383                 }

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 395 of file projector.h.

References EMAN::TypeDict::put().

00396                 {
00397                         TypeDict d;
00398                         d.put("transform", EMObject::TRANSFORM);
00399                         d.put("origin_x",  EMObject::INT);
00400                         d.put("origin_y",  EMObject::INT);
00401                         d.put("origin_z",  EMObject::INT);
00402                         d.put("anglelist", EMObject::FLOATARRAY);
00403                         d.put("radius",    EMObject::FLOAT);
00404                         return d;
00405                 }

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

Definition at line 1404 of file projector.cpp.

References nnz, nrays, nx, ny, status, and EMAN::Vec3i.

Referenced by backproject3d(), and project3d().

01406           : count the number of voxels within a sphere centered
01407             at origin and with a radius ri.
01408 
01409      input:
01410      volsize contains the size information (nx,ny,nz) about the volume
01411      ri      radius of the object embedded in the cube.
01412      origin  coordinates for the center of the volume
01413 
01414      output:
01415      nnz    total number of voxels within the sphere (of radius ri)
01416      nrays  number of rays in z-direction.
01417 */
01418 {
01419         int  ix, iy, iz, rs, r2, xs, ys, zs, xx, yy, zz;
01420         int  ftm=0, status = 0;
01421 
01422         r2    = ri*ri;
01423         *nnz  = 0;
01424         *nrays = 0;
01425         int nx = (int)volsize[0];
01426         int ny = (int)volsize[1];
01427         int nz = (int)volsize[2];
01428 
01429         int xcent = (int)origin[0];
01430         int ycent = (int)origin[1];
01431         int zcent = (int)origin[2];
01432 
01433         // need to add some error checking
01434         for (ix = 1; ix <=nx; ix++) {
01435             xs  = ix-xcent;
01436             xx  = xs*xs;
01437             for (iy = 1; iy <= ny; iy++) {
01438                 ys = iy-ycent;
01439                 yy = ys*ys;
01440                 ftm = 1;
01441                 for (iz = 1; iz <= nz; iz++) {
01442                     zs = iz-zcent;
01443                     zz = zs*zs;
01444                     rs = xx + yy + zz;
01445                     if (rs <= r2) {
01446                         (*nnz)++;
01447                         if (ftm) {
01448                            (*nrays)++;
01449                            ftm = 0;
01450                         }
01451                     }
01452                 }
01453             } // end for iy
01454         } // end for ix
01455         return status;
01456 }

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

Definition at line 1707 of file projector.cpp.

Referenced by bckpj3(), and fwdpj3().

01708 {
01709     int ia;
01710 
01711     if (a>=0) {
01712        ia = (int)floor(a);
01713     }
01714     else {
01715        ia = (int)ceil(a);
01716     }
01717     return ia;
01718 }

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

Definition at line 390 of file projector.h.

00391                 {
00392                         return new ChaoProjector();
00393                 }

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 1762 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, 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, EMAN::EMData::update(), and EMAN::Vec3i.

01763 {
01764 
01765         int nrays, nnz, status, j;
01766         float *dm;
01767         int   *ptrs, *cord;
01768         float *sphere, *images;
01769 
01770         int nxvol = vol->get_xsize();
01771         int nyvol = vol->get_ysize();
01772         int nzvol = vol->get_zsize();
01773         Vec3i volsize(nxvol,nyvol,nzvol);
01774 
01775         int dim = Util::get_min(nxvol,nyvol,nzvol);
01776         if (nzvol == 1) {
01777                 LOGERR("The ChaoProjector needs a volume!");
01778                 return 0;
01779         }
01780         Vec3i origin(0,0,0);
01781         // If a sensible origin isn't passed in, choose the middle of
01782         // the cube.
01783         if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
01784         else {origin[0] = nxvol/2+1;}
01785         if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
01786         else {origin[1] = nyvol/2+1;}
01787         if (params.has_key("origin_z")) {origin[2] = params["origin_z"];}
01788         else {origin[2] = nzvol/2+1;}
01789 
01790         int ri;
01791         if (params.has_key("radius")) {ri = params["radius"];}
01792         else {ri = dim/2 - 1;}
01793 
01794         // retrieve the voxel values
01795         float *cube = vol->get_data();
01796 
01797         // count the number of voxels within a sphere centered at icent,
01798         // with radius ri
01799         status = getnnz(volsize, ri, origin, &nrays, &nnz);
01800         // need to check status...
01801 
01802         // convert from cube to sphere
01803         sphere = new float[nnz];
01804         ptrs   = new int[nrays+1];
01805         cord   = new int[3*nrays];
01806         if (sphere == NULL || ptrs == NULL || cord == NULL) {
01807                 fprintf(stderr,"ChaoProjector::project3d, failed to allocate!\n");
01808                 exit(1);
01809         }
01810         for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
01811         for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
01812         for (int i = 0; i<3*nrays; i++) cord[i] = 0;
01813 
01814         status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
01815         // check status
01816 
01817         int nangles = 0;
01818         vector<float> anglelist;
01819         string angletype = "SPIDER";
01820         // Do we have a list of angles?
01821         if (params.has_key("anglelist")) {
01822                 anglelist = params["anglelist"];
01823                 nangles = anglelist.size() / 3;
01824         } else {
01825                 Transform* t3d = params["transform"];
01826                 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
01827                 // This part was modified by David Woolford -
01828                 // Before this the code worked only for SPIDER and EMAN angles,
01829                 // but the framework of the Transform3D allows for a generic implementation
01830                 // as specified here.
01831                 Dict p = t3d->get_rotation("spider");
01832                 if(t3d) {delete t3d; t3d=0;}
01833 
01834                 float phi   = p["phi"];
01835                 float theta = p["theta"];
01836                 float psi   = p["psi"];
01837                 anglelist.push_back(phi);
01838                 anglelist.push_back(theta);
01839                 anglelist.push_back(psi);
01840                 nangles = 1;
01841         }
01842         // End David Woolford modifications
01843 
01844         dm = new float[nangles*9];
01845         setdm(anglelist, angletype, dm);
01846 
01847                 // return images
01848         EMData *ret = new EMData();
01849         ret->set_size(nxvol, nyvol, nangles);
01850         ret->set_complex(false);
01851         ret->set_ri(true);
01852 
01853         images = ret->get_data();
01854 
01855         for (j = 1; j <= nangles; j++) {
01856                 status = fwdpj3(volsize, nrays, nnz   , &dm(1,j), origin, ri,
01857                                                 ptrs   ,  cord, sphere, &images(1,1,j));
01858         // check status?
01859         }
01860 
01861         // deallocate all temporary work space
01862         EMDeleteArray(dm);
01863         EMDeleteArray(ptrs);
01864         EMDeleteArray(cord);
01865         EMDeleteArray(sphere);
01866 
01867         if (!params.has_key("anglelist")) {
01868                 Transform* t3d = params["transform"];
01869                 ret->set_attr("xform.projection",t3d);
01870                 if(t3d) {delete t3d; t3d=0;}
01871         }
01872         ret->update();
01873         return ret;
01874 }

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

Definition at line 1724 of file projector.cpp.

References anglelist, dm, phi, and theta.

Referenced by backproject3d(), and project3d().

01725 { // convert Euler angles to transformations, dm is an 9 by nangles array
01726 
01727         float  psi, theta, phi;
01728         double cthe, sthe, cpsi, spsi, cphi, sphi;
01729         int    j;
01730 
01731         int nangles = anglelist.size() / 3;
01732 
01733         // now convert all angles
01734         for (j = 1; j <= nangles; j++) {
01735                 phi   = static_cast<float>(anglelist(1,j)*dgr_to_rad);
01736                 theta = static_cast<float>(anglelist(2,j)*dgr_to_rad);
01737                 psi   = static_cast<float>(anglelist(3,j)*dgr_to_rad);
01738 
01739                 //              cout << phi << " " << theta << " " << psi << endl;
01740                 cthe  = cos(theta);
01741                 sthe  = sin(theta);
01742                 cpsi  = cos(psi);
01743                 spsi  = sin(psi);
01744                 cphi  = cos(phi);
01745                 sphi  = sin(phi);
01746 
01747                 dm(1,j)=static_cast<float>(cphi*cthe*cpsi-sphi*spsi);
01748                 dm(2,j)=static_cast<float>(sphi*cthe*cpsi+cphi*spsi);
01749                 dm(3,j)=static_cast<float>(-sthe*cpsi);
01750                 dm(4,j)=static_cast<float>(-cphi*cthe*spsi-sphi*cpsi);
01751                 dm(5,j)=static_cast<float>(-sphi*cthe*spsi+cphi*cpsi);
01752                 dm(6,j)=static_cast<float>(sthe*spsi);
01753                 dm(7,j)=static_cast<float>(sthe*cphi);
01754                 dm(8,j)=static_cast<float>(sthe*sphi);
01755                 dm(9,j)=static_cast<float>(cthe);
01756         }
01757 }

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

Definition at line 1523 of file projector.cpp.

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

Referenced by backproject3d().

01525 {
01526     int       status=0;
01527     int       r2, i, j, ix, iy, iz,  nnz;
01528 
01529     int nx = (int)volsize[0];
01530     int ny = (int)volsize[1];
01531     // int nz = (int)volsize[2];
01532 
01533     r2      = ri*ri;
01534     nnz     = 0;
01535     ptrs(1) = 1;
01536 
01537     // no need to initialize
01538     // for (i = 0; i<nx*ny*nz; i++) cube[i]=0.0;
01539 
01540     nnz = 0;
01541     for (j = 1; j <= nrays; j++) {
01542        iz = cord(1,j);
01543        iy = cord(2,j);
01544        ix = cord(3,j);
01545        for (i = ptrs(j); i<=ptrs(j+1)-1; i++, iz++) {
01546            nnz++;
01547            cube(iz,iy,ix) = sphere(nnz);
01548        }
01549     }
01550     if (nnz != nnz0) status = -1;
01551     return status;
01552 }


Member Data Documentation

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

Definition at line 59 of file projector.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:42:53 2013 for EMAN2 by  doxygen 1.3.9.1