#include <projector.h>
Inheritance diagram for EMAN::ChaoProjector:
Public Member Functions | |
EMData * | project3d (EMData *vol) const |
Project an 3D image into a 2D image. | |
EMData * | backproject3d (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 Projector * | NEW () |
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 |
(C. Yang)
Definition at line 338 of file projector.h.
Back-project a 2D image into a 3D image.
Implements EMAN::Projector.
Definition at line 1718 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().
01719 { 01720 int nrays, nnz, status, j; 01721 float *dm; 01722 int *ptrs, *cord; 01723 float *sphere, *images, *cube; 01724 01725 int nximg = imagestack->get_xsize(); 01726 int nyimg = imagestack->get_ysize(); 01727 int nslices = imagestack->get_zsize(); 01728 01729 int dim = Util::get_min(nximg,nyimg); 01730 Vec3i volsize(nximg,nyimg,dim); 01731 01732 Vec3i origin(0,0,0); 01733 // If a sensible origin isn't passed in, choose the middle of 01734 // the cube. 01735 if (params.has_key("origin_x")) {origin[0] = params["origin_x"];} 01736 else {origin[0] = nximg/2+1;} 01737 if (params.has_key("origin_y")) {origin[1] = params["origin_y"];} 01738 else {origin[1] = nyimg/2+1;} 01739 if (params.has_key("origin_z")) {origin[1] = params["origin_z"];} 01740 else {origin[2] = dim/2+1;} 01741 01742 int ri; 01743 if (params.has_key("radius")) {ri = params["radius"];} 01744 else {ri = dim/2 - 1;} 01745 01746 // retrieve the voxel values 01747 images = imagestack->get_data(); 01748 01749 // count the number of voxels within a sphere centered at icent, 01750 // with radius ri 01751 status = getnnz(volsize, ri, origin, &nrays, &nnz); 01752 // need to check status... 01753 01754 // convert from cube to sphere 01755 sphere = new float[nnz]; 01756 ptrs = new int[nrays+1]; 01757 cord = new int[3*nrays]; 01758 if (sphere == NULL || ptrs == NULL || cord == NULL) { 01759 fprintf(stderr,"ChaoProjector::backproject3d, failed to allocate!\n"); 01760 exit(1); 01761 } 01762 for (int i = 0; i<nnz; i++) sphere[i] = 0.0; 01763 for (int i = 0; i<nrays+1; i++) ptrs[i] = 0; 01764 for (int i = 0; i<3*nrays; i++) cord[i] = 0; 01765 01766 int nangles = 0; 01767 vector<float> anglelist; 01768 string angletype = "SPIDER"; 01769 // Do we have a list of angles? 01770 if (params.has_key("anglelist")) { 01771 anglelist = params["anglelist"]; 01772 nangles = anglelist.size() / 3; 01773 } else { 01774 Transform* t3d = params["transform"]; 01775 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified"); 01776 // This part was modified by David Woolford - 01777 // Before this the code worked only for SPIDER and EMAN angles, 01778 // but the framework of the Transform3D allows for a generic implementation 01779 // as specified here. 01780 // This was broken by david. we need here a loop over all projections and put all angles on stack PAP 06/28/09 01781 Dict p = t3d->get_rotation("spider"); 01782 if(t3d) {delete t3d; t3d=0;} 01783 01784 float phi = p["phi"]; 01785 float theta = p["theta"]; 01786 float psi = p["psi"]; 01787 anglelist.push_back(phi); 01788 anglelist.push_back(theta); 01789 anglelist.push_back(psi); 01790 nangles = 1; 01791 } 01792 01793 // End David Woolford modifications 01794 01795 if (nslices != nangles) { 01796 LOGERR("the number of images does not match the number of angles"); 01797 return 0; 01798 } 01799 01800 dm = new float[nangles*9]; 01801 setdm(anglelist, angletype, dm); 01802 01803 // return volume 01804 EMData *ret = new EMData(); 01805 ret->set_size(nximg, nyimg, dim); 01806 ret->set_complex(false); 01807 ret->set_ri(true); 01808 ret->to_zero(); 01809 01810 cube = ret->get_data(); 01811 // cb2sph should be replaced by something that touches only ptrs and cord 01812 status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere); 01813 // check status 01814 01815 for (j = 1; j <= nangles; j++) { 01816 status = bckpj3(volsize, nrays, nnz, &dm(1,j), origin, ri, 01817 ptrs , cord , &images(1,1,j), sphere); 01818 // check status? 01819 } 01820 01821 status = sph2cb(sphere, volsize, nrays, ri, nnz, ptrs, cord, cube); 01822 // check status? 01823 01824 // deallocate all temporary work space 01825 EMDeleteArray(dm); 01826 EMDeleteArray(ptrs); 01827 EMDeleteArray(cord); 01828 EMDeleteArray(sphere); 01829 01830 ret->update(); 01831 return ret; 01832 }
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 1471 of file projector.cpp.
References cord, dm, ifix(), nx, ptrs, status, x, and y.
Referenced by backproject3d().
01474 { 01475 int i, j, iqx,iqy, xc, yc, zc; 01476 float xb, yb, dx, dy, dx1m, dy1m, dxdy; 01477 int status = 0; 01478 01479 int xcent = origin[0]; 01480 int ycent = origin[1]; 01481 int zcent = origin[2]; 01482 01483 int nx = volsize[0]; 01484 01485 if ( nx > 2*ri) { 01486 for (i = 1; i <= nrays; i++) { 01487 zc = cord(1,i) - zcent; 01488 yc = cord(2,i) - ycent; 01489 xc = cord(3,i) - xcent; 01490 01491 xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent; 01492 yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent; 01493 01494 for (j = ptrs(i); j <ptrs(i+1); j++) { 01495 iqx = ifix((float)(xb)); 01496 iqy = ifix((float)(yb)); 01497 01498 dx = xb - (float)(iqx); 01499 dy = yb - (float)(iqy); 01500 dx1m = 1.0f - dx; 01501 dy1m = 1.0f - dy; 01502 dxdy = dx*dy; 01503 /* 01504 c y(j) = y(j) + dx1m*dy1m*x(iqx , iqy) 01505 c & + dx1m*dy *x(iqx , iqy+1) 01506 c & + dx *dy1m*x(iqx+1, iqy) 01507 c & + dx *dy *x(iqx+1, iqy+1) 01508 c 01509 c --- faster version of the above commented out 01510 c code (derived by summing the following table 01511 c of coefficients along the colunms) --- 01512 c 01513 c 1 dx dy dxdy 01514 c ------ -------- -------- ------- 01515 c x(i,j) -x(i,j) -x(i,j) x(i,j) 01516 c x(i,j+1) -x(i,j+1) 01517 c x(i+1,j) -x(i+1,j) 01518 c x(i+1,j+1) 01519 c 01520 */ 01521 y(j) += x(iqx,iqy) 01522 + dx*(-x(iqx,iqy)+x(iqx+1,iqy)) 01523 + dy*(-x(iqx,iqy)+x(iqx,iqy+1)) 01524 + dxdy*( x(iqx,iqy) - x(iqx,iqy+1) 01525 -x(iqx+1,iqy) + x(iqx+1,iqy+1) ); 01526 01527 xb += dm(1); 01528 yb += dm(4); 01529 } // end for j 01530 } // end for i 01531 } 01532 else { 01533 fprintf(stderr, "bckpj3: nx must be greater than 2*ri\n"); 01534 } 01535 01536 return status; 01537 }
int ChaoProjector::cb2sph | ( | float * | cube, | |
Vec3i | volsize, | |||
int | ri, | |||
Vec3i | origin, | |||
int | nnz0, | |||
int * | ptrs, | |||
int * | cord, | |||
float * | sphere | |||
) | const [private] |
Definition at line 1301 of file projector.cpp.
References cord, cube, nnz, nrays, nx, ny, ptrs, sphere, and status.
Referenced by backproject3d(), and project3d().
01303 { 01304 int xs, ys, zs, xx, yy, zz, rs, r2; 01305 int ix, iy, iz, jnz, nnz, nrays; 01306 int ftm = 0, status = 0; 01307 01308 int xcent = (int)origin[0]; 01309 int ycent = (int)origin[1]; 01310 int zcent = (int)origin[2]; 01311 01312 int nx = (int)volsize[0]; 01313 int ny = (int)volsize[1]; 01314 int nz = (int)volsize[2]; 01315 01316 r2 = ri*ri; 01317 nnz = 0; 01318 nrays = 0; 01319 ptrs(1) = 1; 01320 01321 for (ix = 1; ix <= nx; ix++) { 01322 xs = ix-xcent; 01323 xx = xs*xs; 01324 for ( iy = 1; iy <= ny; iy++ ) { 01325 ys = iy-ycent; 01326 yy = ys*ys; 01327 jnz = 0; 01328 01329 ftm = 1; 01330 // not the most efficient implementation 01331 for (iz = 1; iz <= nz; iz++) { 01332 zs = iz-zcent; 01333 zz = zs*zs; 01334 rs = xx + yy + zz; 01335 if (rs <= r2) { 01336 jnz++; 01337 nnz++; 01338 sphere(nnz) = cube(iz, iy, ix); 01339 01340 // record the coordinates of the first nonzero === 01341 if (ftm) { 01342 nrays++; 01343 cord(1,nrays) = iz; 01344 cord(2,nrays) = iy; 01345 cord(3,nrays) = ix; 01346 ftm = 0; 01347 } 01348 } 01349 } // end for (iz..) 01350 if (jnz > 0) { 01351 ptrs(nrays+1) = ptrs(nrays) + jnz; 01352 } // endif (jnz) 01353 } // end for iy 01354 } // end for ix 01355 if (nnz != nnz0) status = -1; 01356 return status; 01357 }
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 1395 of file projector.cpp.
References cord, dm, ifix(), nx, ptrs, status, x, and y.
Referenced by project3d().
01398 { 01399 /* 01400 purpose: y <--- proj(x) 01401 input : volsize the size (nx,ny,nz) of the volume 01402 nrays number of rays within the compact spherical 01403 representation 01404 nnz number of voxels within the sphere 01405 dm an array of size 9 storing transformation 01406 associated with the projection direction 01407 origin coordinates of the center of the volume 01408 ri radius of the sphere 01409 ptrs the beginning address of each ray 01410 cord the coordinates of the first point in each ray 01411 x 3d input volume 01412 y 2d output image 01413 */ 01414 01415 int iqx, iqy, i, j, xc, yc, zc; 01416 float ct, dipx, dipy, dipx1m, dipy1m, xb, yb, dm1, dm4; 01417 int status = 0; 01418 01419 int xcent = origin[0]; 01420 int ycent = origin[1]; 01421 int zcent = origin[2]; 01422 01423 int nx = volsize[0]; 01424 01425 dm1 = dm(1); 01426 dm4 = dm(4); 01427 01428 if ( nx > 2*ri ) { 01429 for (i = 1; i <= nrays; i++) { 01430 zc = cord(1,i)-zcent; 01431 yc = cord(2,i)-ycent; 01432 xc = cord(3,i)-xcent; 01433 01434 xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent; 01435 yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent; 01436 01437 for (j = ptrs(i); j< ptrs(i+1); j++) { 01438 iqx = ifix(xb); 01439 iqy = ifix(yb); 01440 01441 ct = x(j); 01442 dipx = xb - (float)(iqx); 01443 dipy = (yb - (float)(iqy)) * ct; 01444 01445 dipy1m = ct - dipy; 01446 dipx1m = 1.0f - dipx; 01447 01448 y(iqx ,iqy) = y(iqx ,iqy) + dipx1m*dipy1m; 01449 y(iqx+1,iqy) = y(iqx+1,iqy) + dipx*dipy1m; 01450 y(iqx+1,iqy+1) = y(iqx+1,iqy+1) + dipx*dipy; 01451 y(iqx ,iqy+1) = y(iqx ,iqy+1) + dipx1m*dipy; 01452 01453 xb += dm1; 01454 yb += dm4; 01455 } 01456 } 01457 } 01458 else { 01459 fprintf(stderr, " nx must be greater than 2*ri\n"); 01460 exit(1); 01461 } 01462 return status; 01463 }
string EMAN::ChaoProjector::get_desc | ( | ) | const [inline, virtual] |
string EMAN::ChaoProjector::get_name | ( | ) | const [inline, virtual] |
Get the projector's name.
Each projector is indentified by unique 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.
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 1241 of file projector.cpp.
References nnz, nrays, nx, ny, and status.
Referenced by backproject3d(), and project3d().
01243 : count the number of voxels within a sphere centered 01244 at origin and with a radius ri. 01245 01246 input: 01247 volsize contains the size information (nx,ny,nz) about the volume 01248 ri radius of the object embedded in the cube. 01249 origin coordinates for the center of the volume 01250 01251 output: 01252 nnz total number of voxels within the sphere (of radius ri) 01253 nrays number of rays in z-direction. 01254 */ 01255 { 01256 int ix, iy, iz, rs, r2, xs, ys, zs, xx, yy, zz; 01257 int ftm=0, status = 0; 01258 01259 r2 = ri*ri; 01260 *nnz = 0; 01261 *nrays = 0; 01262 int nx = (int)volsize[0]; 01263 int ny = (int)volsize[1]; 01264 int nz = (int)volsize[2]; 01265 01266 int xcent = (int)origin[0]; 01267 int ycent = (int)origin[1]; 01268 int zcent = (int)origin[2]; 01269 01270 // need to add some error checking 01271 for (ix = 1; ix <=nx; ix++) { 01272 xs = ix-xcent; 01273 xx = xs*xs; 01274 for (iy = 1; iy <= ny; iy++) { 01275 ys = iy-ycent; 01276 yy = ys*ys; 01277 ftm = 1; 01278 for (iz = 1; iz <= nz; iz++) { 01279 zs = iz-zcent; 01280 zz = zs*zs; 01281 rs = xx + yy + zz; 01282 if (rs <= r2) { 01283 (*nnz)++; 01284 if (ftm) { 01285 (*nrays)++; 01286 ftm = 0; 01287 } 01288 } 01289 } 01290 } // end for iy 01291 } // end for ix 01292 return status; 01293 }
int ChaoProjector::ifix | ( | float | a | ) | const [private] |
Definition at line 1544 of file projector.cpp.
Referenced by bckpj3(), and fwdpj3().
01545 { 01546 int ia; 01547 01548 if (a>=0) { 01549 ia = (int)floor(a); 01550 } 01551 else { 01552 ia = (int)ceil(a); 01553 } 01554 return ia; 01555 }
static Projector* EMAN::ChaoProjector::NEW | ( | ) | [inline, static] |
Project an 3D image into a 2D image.
Implements EMAN::Projector.
Definition at line 1599 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().
01600 { 01601 01602 int nrays, nnz, status, j; 01603 float *dm; 01604 int *ptrs, *cord; 01605 float *sphere, *images; 01606 01607 int nxvol = vol->get_xsize(); 01608 int nyvol = vol->get_ysize(); 01609 int nzvol = vol->get_zsize(); 01610 Vec3i volsize(nxvol,nyvol,nzvol); 01611 01612 int dim = Util::get_min(nxvol,nyvol,nzvol); 01613 if (nzvol == 1) { 01614 LOGERR("The ChaoProjector needs a volume!"); 01615 return 0; 01616 } 01617 Vec3i origin(0,0,0); 01618 // If a sensible origin isn't passed in, choose the middle of 01619 // the cube. 01620 if (params.has_key("origin_x")) {origin[0] = params["origin_x"];} 01621 else {origin[0] = nxvol/2+1;} 01622 if (params.has_key("origin_y")) {origin[1] = params["origin_y"];} 01623 else {origin[1] = nyvol/2+1;} 01624 if (params.has_key("origin_z")) {origin[2] = params["origin_z"];} 01625 else {origin[2] = nzvol/2+1;} 01626 01627 int ri; 01628 if (params.has_key("radius")) {ri = params["radius"];} 01629 else {ri = dim/2 - 1;} 01630 01631 // retrieve the voxel values 01632 float *cube = vol->get_data(); 01633 01634 // count the number of voxels within a sphere centered at icent, 01635 // with radius ri 01636 status = getnnz(volsize, ri, origin, &nrays, &nnz); 01637 // need to check status... 01638 01639 // convert from cube to sphere 01640 sphere = new float[nnz]; 01641 ptrs = new int[nrays+1]; 01642 cord = new int[3*nrays]; 01643 if (sphere == NULL || ptrs == NULL || cord == NULL) { 01644 fprintf(stderr,"ChaoProjector::project3d, failed to allocate!\n"); 01645 exit(1); 01646 } 01647 for (int i = 0; i<nnz; i++) sphere[i] = 0.0; 01648 for (int i = 0; i<nrays+1; i++) ptrs[i] = 0; 01649 for (int i = 0; i<3*nrays; i++) cord[i] = 0; 01650 01651 status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere); 01652 // check status 01653 01654 int nangles = 0; 01655 vector<float> anglelist; 01656 string angletype = "SPIDER"; 01657 // Do we have a list of angles? 01658 if (params.has_key("anglelist")) { 01659 anglelist = params["anglelist"]; 01660 nangles = anglelist.size() / 3; 01661 } else { 01662 Transform* t3d = params["transform"]; 01663 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified"); 01664 // This part was modified by David Woolford - 01665 // Before this the code worked only for SPIDER and EMAN angles, 01666 // but the framework of the Transform3D allows for a generic implementation 01667 // as specified here. 01668 Dict p = t3d->get_rotation("spider"); 01669 if(t3d) {delete t3d; t3d=0;} 01670 01671 float phi = p["phi"]; 01672 float theta = p["theta"]; 01673 float psi = p["psi"]; 01674 anglelist.push_back(phi); 01675 anglelist.push_back(theta); 01676 anglelist.push_back(psi); 01677 nangles = 1; 01678 } 01679 // End David Woolford modifications 01680 01681 dm = new float[nangles*9]; 01682 setdm(anglelist, angletype, dm); 01683 01684 // return images 01685 EMData *ret = new EMData(); 01686 ret->set_size(nxvol, nyvol, nangles); 01687 ret->set_complex(false); 01688 ret->set_ri(true); 01689 01690 images = ret->get_data(); 01691 01692 for (j = 1; j <= nangles; j++) { 01693 status = fwdpj3(volsize, nrays, nnz , &dm(1,j), origin, ri, 01694 ptrs , cord, sphere, &images(1,1,j)); 01695 // check status? 01696 } 01697 01698 // deallocate all temporary work space 01699 EMDeleteArray(dm); 01700 EMDeleteArray(ptrs); 01701 EMDeleteArray(cord); 01702 EMDeleteArray(sphere); 01703 01704 if (!params.has_key("anglelist")) { 01705 Transform* t3d = params["transform"]; 01706 ret->set_attr("xform.projection",t3d); 01707 if(t3d) {delete t3d; t3d=0;} 01708 } 01709 ret->update(); 01710 return ret; 01711 }
void ChaoProjector::setdm | ( | vector< float > | anglelist, | |
string const | angletype, | |||
float * | dm | |||
) | const [private] |
Definition at line 1561 of file projector.cpp.
References anglelist, dgr_to_rad, dm, phi, and theta.
Referenced by backproject3d(), and project3d().
01562 { // convert Euler angles to transformations, dm is an 9 by nangles array 01563 01564 float psi, theta, phi; 01565 double cthe, sthe, cpsi, spsi, cphi, sphi; 01566 int j; 01567 01568 int nangles = anglelist.size() / 3; 01569 01570 // now convert all angles 01571 for (j = 1; j <= nangles; j++) { 01572 phi = static_cast<float>(anglelist(1,j)*dgr_to_rad); 01573 theta = static_cast<float>(anglelist(2,j)*dgr_to_rad); 01574 psi = static_cast<float>(anglelist(3,j)*dgr_to_rad); 01575 01576 // cout << phi << " " << theta << " " << psi << endl; 01577 cthe = cos(theta); 01578 sthe = sin(theta); 01579 cpsi = cos(psi); 01580 spsi = sin(psi); 01581 cphi = cos(phi); 01582 sphi = sin(phi); 01583 01584 dm(1,j)=static_cast<float>(cphi*cthe*cpsi-sphi*spsi); 01585 dm(2,j)=static_cast<float>(sphi*cthe*cpsi+cphi*spsi); 01586 dm(3,j)=static_cast<float>(-sthe*cpsi); 01587 dm(4,j)=static_cast<float>(-cphi*cthe*spsi-sphi*cpsi); 01588 dm(5,j)=static_cast<float>(-sphi*cthe*spsi+cphi*cpsi); 01589 dm(6,j)=static_cast<float>(sthe*spsi); 01590 dm(7,j)=static_cast<float>(sthe*cphi); 01591 dm(8,j)=static_cast<float>(sthe*sphi); 01592 dm(9,j)=static_cast<float>(cthe); 01593 } 01594 }
int ChaoProjector::sph2cb | ( | float * | sphere, | |
Vec3i | volsize, | |||
int | nray, | |||
int | ri, | |||
int | nnz0, | |||
int * | ptrs, | |||
int * | cord, | |||
float * | cube | |||
) | const [private] |
Definition at line 1360 of file projector.cpp.
References cord, cube, nnz, nx, ny, ptrs, sphere, and status.
Referenced by backproject3d().
01362 { 01363 int status=0; 01364 int r2, i, j, ix, iy, iz, nnz; 01365 01366 int nx = (int)volsize[0]; 01367 int ny = (int)volsize[1]; 01368 // int nz = (int)volsize[2]; 01369 01370 r2 = ri*ri; 01371 nnz = 0; 01372 ptrs(1) = 1; 01373 01374 // no need to initialize 01375 // for (i = 0; i<nx*ny*nz; i++) cube[i]=0.0; 01376 01377 nnz = 0; 01378 for (j = 1; j <= nrays; j++) { 01379 iz = cord(1,j); 01380 iy = cord(2,j); 01381 ix = cord(3,j); 01382 for (i = ptrs(j); i<=ptrs(j+1)-1; i++, iz++) { 01383 nnz++; 01384 cube(iz,iy,ix) = sphere(nnz); 01385 } 01386 } 01387 if (nnz != nnz0) status = -1; 01388 return status; 01389 }
const string ChaoProjector::NAME = "chao" [static] |