EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all 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]

Public Member Functions

EMDataproject3d (EMData *vol) const
 Project an 3D image into a 2D image. More...
 
EMDatabackproject3d (EMData *imagestack) const
 Back-project a 2D image into a 3D image. More...
 
string get_name () const
 Get the projector's name. More...
 
string get_desc () const
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Projector
virtual ~Projector ()
 
virtual Dict get_params () const
 Get the projector parameters in a key/value dictionary. More...
 
void set_params (const Dict &new_params)
 Set the projector parameters using a key/value dictionary. More...
 

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
 

Additional Inherited Members

- Protected Attributes inherited from EMAN::Projector
Dict params
 

Detailed Description

Fast real space projection using Bi-Linear interpolation.

(C. Yang)

Definition at line 371 of file projector.h.

Member Function Documentation

◆ backproject3d()

EMData * ChaoProjector::backproject3d ( EMData image) const
virtual

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

Returns
A 3D image from the backprojection.

Implements EMAN::Projector.

Definition at line 1767 of file projector.cpp.

1768{
1769 int nrays, nnz, status, j;
1770 float *dm;
1771 int *ptrs, *cord;
1772 float *sphere, *images, *cube;
1773
1774 int nximg = imagestack->get_xsize();
1775 int nyimg = imagestack->get_ysize();
1776 int nslices = imagestack->get_zsize();
1777
1778 int dim = Util::get_min(nximg,nyimg);
1779 Vec3i volsize(nximg,nyimg,dim);
1780
1781 Vec3i origin(0,0,0);
1782 // If a sensible origin isn't passed in, choose the middle of
1783 // the cube.
1784 if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
1785 else {origin[0] = nximg/2+1;}
1786 if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
1787 else {origin[1] = nyimg/2+1;}
1788 if (params.has_key("origin_z")) {origin[1] = params["origin_z"];}
1789 else {origin[2] = dim/2+1;}
1790
1791 int ri;
1792 if (params.has_key("radius")) {ri = params["radius"];}
1793 else {ri = dim/2 - 1;}
1794
1795 // retrieve the voxel values
1796 images = imagestack->get_data();
1797
1798 // count the number of voxels within a sphere centered at icent,
1799 // with radius ri
1800 status = getnnz(volsize, ri, origin, &nrays, &nnz);
1801 // need to check status...
1802
1803 // convert from cube to sphere
1804 sphere = new float[nnz];
1805 ptrs = new int[nrays+1];
1806 cord = new int[3*nrays];
1807 if (sphere == NULL || ptrs == NULL || cord == NULL) {
1808 fprintf(stderr,"ChaoProjector::backproject3d, failed to allocate!\n");
1809 exit(1);
1810 }
1811 for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
1812 for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
1813 for (int i = 0; i<3*nrays; i++) cord[i] = 0;
1814
1815 int nangles = 0;
1816 vector<float> anglelist;
1817 string angletype = "SPIDER";
1818 // Do we have a list of angles?
1819 if (params.has_key("anglelist")) {
1820 anglelist = params["anglelist"];
1821 nangles = anglelist.size() / 3;
1822 } else {
1823 Transform* t3d = params["transform"];
1824 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
1825 // This part was modified by David Woolford -
1826 // Before this the code worked only for SPIDER and EMAN angles,
1827 // but the framework of the Transform3D allows for a generic implementation
1828 // as specified here.
1829 // This was broken by david. we need here a loop over all projections and put all angles on stack PAP 06/28/09
1830 Dict p = t3d->get_rotation("spider");
1831 if(t3d) {delete t3d; t3d=0;}
1832
1833 float phi = p["phi"];
1834 float theta = p["theta"];
1835 float psi = p["psi"];
1836 anglelist.push_back(phi);
1837 anglelist.push_back(theta);
1838 anglelist.push_back(psi);
1839 nangles = 1;
1840 }
1841
1842 // End David Woolford modifications
1843
1844 if (nslices != nangles) {
1845 LOGERR("the number of images does not match the number of angles");
1846 return 0;
1847 }
1848
1849 dm = new float[nangles*9];
1850 setdm(anglelist, angletype, dm);
1851
1852 // return volume
1853 EMData *ret = new EMData();
1854 ret->set_size(nximg, nyimg, dim);
1855 ret->set_complex(false);
1856 ret->set_ri(true);
1857 ret->to_zero();
1858
1859 cube = ret->get_data();
1860 // cb2sph should be replaced by something that touches only ptrs and cord
1861 status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
1862 // check status
1863
1864 for (j = 1; j <= nangles; j++) {
1865 status = bckpj3(volsize, nrays, nnz, &dm(1,j), origin, ri,
1866 ptrs , cord , &images(1,1,j), sphere);
1867 // check status?
1868 }
1869
1870 status = sph2cb(sphere, volsize, nrays, ri, nnz, ptrs, cord, cube);
1871 // check status?
1872
1873 // deallocate all temporary work space
1878
1879 ret->update();
1880 return ret;
1881}
int cb2sph(float *cube, Vec3i volsize, int ri, Vec3i origin, int nnz0, int *ptrs, int *cord, float *sphere) const
Definition: projector.cpp:1350
void setdm(vector< float > anglelist, string const angletype, float *dm) const
Definition: projector.cpp:1610
int sph2cb(float *sphere, Vec3i volsize, int nray, int ri, int nnz0, int *ptrs, int *cord, float *cube) const
Definition: projector.cpp:1409
int bckpj3(Vec3i volsize, int nray, int nnz, float *dm, Vec3i origin, int ri, int *ptrs, int *cord, float *x, float *y) const
Definition: projector.cpp:1520
int getnnz(Vec3i volsize, int ri, Vec3i origin, int *nray, int *nnz) const
Definition: projector.cpp:1290
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
Dict get_rotation(const string &euler_type="eman") const
Get a rotation in any Euler format.
Definition: transform.cpp:829
static int get_min(int f1, int f2)
Get the minimum of 2 numbers.
Definition: util.h:922
void EMDeleteArray(T &x)
Definition: emutil.h:62
#define NullPointerException(desc)
Definition: exception.h:241
#define LOGERR
Definition: log.h:51
#define cube(i, j, k)
Definition: projector.cpp:1344
#define ptrs(i)
Definition: projector.cpp:1347
#define sphere(i)
Definition: projector.cpp:1345
#define cord(i, j)
Definition: projector.cpp:1346
#define anglelist(i, j)
Definition: projector.cpp:1607
#define images(i, j, k)
Definition: projector.cpp:1897
#define dm(i)
Definition: projector.cpp:1606

References anglelist, bckpj3(), cb2sph(), cord, cube, dm, EMDeleteArray(), EMAN::Util::get_min(), EMAN::Transform::get_rotation(), getnnz(), EMAN::Dict::has_key(), images, LOGERR, NullPointerException, EMAN::Projector::params, ptrs, setdm(), sph2cb(), and sphere.

◆ bckpj3()

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

1523{
1524 int i, j, iqx,iqy, xc, yc, zc;
1525 float xb, yb, dx, dy, dx1m, dy1m, dxdy;
1526 int status = 0;
1527
1528 int xcent = origin[0];
1529 int ycent = origin[1];
1530 int zcent = origin[2];
1531
1532 int nx = volsize[0];
1533
1534 if ( nx > 2*ri) {
1535 for (i = 1; i <= nrays; i++) {
1536 zc = cord(1,i) - zcent;
1537 yc = cord(2,i) - ycent;
1538 xc = cord(3,i) - xcent;
1539
1540 xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
1541 yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
1542
1543 for (j = ptrs(i); j <ptrs(i+1); j++) {
1544 iqx = ifix((float)(xb));
1545 iqy = ifix((float)(yb));
1546
1547 dx = xb - (float)(iqx);
1548 dy = yb - (float)(iqy);
1549 dx1m = 1.0f - dx;
1550 dy1m = 1.0f - dy;
1551 dxdy = dx*dy;
1552/*
1553c y(j) = y(j) + dx1m*dy1m*x(iqx , iqy)
1554c & + dx1m*dy *x(iqx , iqy+1)
1555c & + dx *dy1m*x(iqx+1, iqy)
1556c & + dx *dy *x(iqx+1, iqy+1)
1557c
1558c --- faster version of the above commented out
1559c code (derived by summing the following table
1560c of coefficients along the colunms) ---
1561c
1562c 1 dx dy dxdy
1563c ------ -------- -------- -------
1564c x(i,j) -x(i,j) -x(i,j) x(i,j)
1565c x(i,j+1) -x(i,j+1)
1566c x(i+1,j) -x(i+1,j)
1567c x(i+1,j+1)
1568c
1569*/
1570 y(j) += x(iqx,iqy)
1571 + dx*(-x(iqx,iqy)+x(iqx+1,iqy))
1572 + dy*(-x(iqx,iqy)+x(iqx,iqy+1))
1573 + dxdy*( x(iqx,iqy) - x(iqx,iqy+1)
1574 -x(iqx+1,iqy) + x(iqx+1,iqy+1) );
1575
1576 xb += dm(1);
1577 yb += dm(4);
1578 } // end for j
1579 } // end for i
1580 }
1581 else {
1582 fprintf(stderr, "bckpj3: nx must be greater than 2*ri\n");
1583 }
1584
1585 return status;
1586}
int ifix(float a) const
Definition: projector.cpp:1593
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

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

Referenced by backproject3d().

◆ cb2sph()

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

Definition at line 1350 of file projector.cpp.

1352{
1353 int xs, ys, zs, xx, yy, zz, rs, r2;
1354 int ix, iy, iz, jnz, nnz, nrays;
1355 int ftm = 0, status = 0;
1356
1357 int xcent = (int)origin[0];
1358 int ycent = (int)origin[1];
1359 int zcent = (int)origin[2];
1360
1361 int nx = (int)volsize[0];
1362 int ny = (int)volsize[1];
1363 int nz = (int)volsize[2];
1364
1365 r2 = ri*ri;
1366 nnz = 0;
1367 nrays = 0;
1368 ptrs(1) = 1;
1369
1370 for (ix = 1; ix <= nx; ix++) {
1371 xs = ix-xcent;
1372 xx = xs*xs;
1373 for ( iy = 1; iy <= ny; iy++ ) {
1374 ys = iy-ycent;
1375 yy = ys*ys;
1376 jnz = 0;
1377
1378 ftm = 1;
1379 // not the most efficient implementation
1380 for (iz = 1; iz <= nz; iz++) {
1381 zs = iz-zcent;
1382 zz = zs*zs;
1383 rs = xx + yy + zz;
1384 if (rs <= r2) {
1385 jnz++;
1386 nnz++;
1387 sphere(nnz) = cube(iz, iy, ix);
1388
1389 // record the coordinates of the first nonzero ===
1390 if (ftm) {
1391 nrays++;
1392 cord(1,nrays) = iz;
1393 cord(2,nrays) = iy;
1394 cord(3,nrays) = ix;
1395 ftm = 0;
1396 }
1397 }
1398 } // end for (iz..)
1399 if (jnz > 0) {
1400 ptrs(nrays+1) = ptrs(nrays) + jnz;
1401 } // endif (jnz)
1402 } // end for iy
1403 } // end for ix
1404 if (nnz != nnz0) status = -1;
1405 return status;
1406}

References cord, cube, ptrs, and sphere.

Referenced by backproject3d(), and project3d().

◆ fwdpj3()

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

1447{
1448 /*
1449 purpose: y <--- proj(x)
1450 input : volsize the size (nx,ny,nz) of the volume
1451 nrays number of rays within the compact spherical
1452 representation
1453 nnz number of voxels within the sphere
1454 dm an array of size 9 storing transformation
1455 associated with the projection direction
1456 origin coordinates of the center of the volume
1457 ri radius of the sphere
1458 ptrs the beginning address of each ray
1459 cord the coordinates of the first point in each ray
1460 x 3d input volume
1461 y 2d output image
1462 */
1463
1464 int iqx, iqy, i, j, xc, yc, zc;
1465 float ct, dipx, dipy, dipx1m, dipy1m, xb, yb, dm1, dm4;
1466 int status = 0;
1467
1468 int xcent = origin[0];
1469 int ycent = origin[1];
1470 int zcent = origin[2];
1471
1472 int nx = volsize[0];
1473
1474 dm1 = dm(1);
1475 dm4 = dm(4);
1476
1477 if ( nx > 2*ri ) {
1478 for (i = 1; i <= nrays; i++) {
1479 zc = cord(1,i)-zcent;
1480 yc = cord(2,i)-ycent;
1481 xc = cord(3,i)-xcent;
1482
1483 xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
1484 yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
1485
1486 for (j = ptrs(i); j< ptrs(i+1); j++) {
1487 iqx = ifix(xb);
1488 iqy = ifix(yb);
1489
1490 ct = x(j);
1491 dipx = xb - (float)(iqx);
1492 dipy = (yb - (float)(iqy)) * ct;
1493
1494 dipy1m = ct - dipy;
1495 dipx1m = 1.0f - dipx;
1496
1497 y(iqx ,iqy) = y(iqx ,iqy) + dipx1m*dipy1m;
1498 y(iqx+1,iqy) = y(iqx+1,iqy) + dipx*dipy1m;
1499 y(iqx+1,iqy+1) = y(iqx+1,iqy+1) + dipx*dipy;
1500 y(iqx ,iqy+1) = y(iqx ,iqy+1) + dipx1m*dipy;
1501
1502 xb += dm1;
1503 yb += dm4;
1504 }
1505 }
1506 }
1507 else {
1508 fprintf(stderr, " nx must be greater than 2*ri\n");
1509 exit(1);
1510 }
1511 return status;
1512}

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

Referenced by project3d().

◆ get_desc()

string EMAN::ChaoProjector::get_desc ( ) const
inlinevirtual

Implements EMAN::Projector.

Definition at line 382 of file projector.h.

383 {
384 return "Fast real space projection generation with Bi-Linear interpolation.";
385 }

◆ get_name()

string EMAN::ChaoProjector::get_name ( ) const
inlinevirtual

Get the projector's name.

Each projector is indentified by unique name.

Returns
The projector's name.

Implements EMAN::Projector.

Definition at line 377 of file projector.h.

378 {
379 return NAME;
380 }
static const string NAME
Definition: projector.h:404

References NAME.

◆ get_param_types()

TypeDict EMAN::ChaoProjector::get_param_types ( ) const
inlinevirtual

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

393 {
394 TypeDict d;
395 d.put("transform", EMObject::TRANSFORM);
396 d.put("origin_x", EMObject::INT);
397 d.put("origin_y", EMObject::INT);
398 d.put("origin_z", EMObject::INT);
399 d.put("anglelist", EMObject::FLOATARRAY);
400 d.put("radius", EMObject::FLOAT);
401 return d;
402 }

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

◆ getnnz()

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

Definition at line 1290 of file projector.cpp.

1304{
1305 int ix, iy, iz, rs, r2, xs, ys, zs, xx, yy, zz;
1306 int ftm=0, status = 0;
1307
1308 r2 = ri*ri;
1309 *nnz = 0;
1310 *nrays = 0;
1311 int nx = (int)volsize[0];
1312 int ny = (int)volsize[1];
1313 int nz = (int)volsize[2];
1314
1315 int xcent = (int)origin[0];
1316 int ycent = (int)origin[1];
1317 int zcent = (int)origin[2];
1318
1319 // need to add some error checking
1320 for (ix = 1; ix <=nx; ix++) {
1321 xs = ix-xcent;
1322 xx = xs*xs;
1323 for (iy = 1; iy <= ny; iy++) {
1324 ys = iy-ycent;
1325 yy = ys*ys;
1326 ftm = 1;
1327 for (iz = 1; iz <= nz; iz++) {
1328 zs = iz-zcent;
1329 zz = zs*zs;
1330 rs = xx + yy + zz;
1331 if (rs <= r2) {
1332 (*nnz)++;
1333 if (ftm) {
1334 (*nrays)++;
1335 ftm = 0;
1336 }
1337 }
1338 }
1339 } // end for iy
1340 } // end for ix
1341 return status;
1342}

Referenced by backproject3d(), and project3d().

◆ ifix()

int ChaoProjector::ifix ( float  a) const
private

Definition at line 1593 of file projector.cpp.

1594{
1595 int ia;
1596
1597 if (a>=0) {
1598 ia = (int)floor(a);
1599 }
1600 else {
1601 ia = (int)ceil(a);
1602 }
1603 return ia;
1604}

Referenced by bckpj3(), and fwdpj3().

◆ NEW()

static Projector * EMAN::ChaoProjector::NEW ( )
inlinestatic

Definition at line 387 of file projector.h.

388 {
389 return new ChaoProjector();
390 }

◆ project3d()

EMData * ChaoProjector::project3d ( EMData image) const
virtual

Project an 3D image into a 2D image.

Returns
A 2D image from the projection.

Implements EMAN::Projector.

Definition at line 1648 of file projector.cpp.

1649{
1650
1651 int nrays, nnz, status, j;
1652 float *dm;
1653 int *ptrs, *cord;
1654 float *sphere, *images;
1655
1656 int nxvol = vol->get_xsize();
1657 int nyvol = vol->get_ysize();
1658 int nzvol = vol->get_zsize();
1659 Vec3i volsize(nxvol,nyvol,nzvol);
1660
1661 int dim = Util::get_min(nxvol,nyvol,nzvol);
1662 if (nzvol == 1) {
1663 LOGERR("The ChaoProjector needs a volume!");
1664 return 0;
1665 }
1666 Vec3i origin(0,0,0);
1667 // If a sensible origin isn't passed in, choose the middle of
1668 // the cube.
1669 if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
1670 else {origin[0] = nxvol/2+1;}
1671 if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
1672 else {origin[1] = nyvol/2+1;}
1673 if (params.has_key("origin_z")) {origin[2] = params["origin_z"];}
1674 else {origin[2] = nzvol/2+1;}
1675
1676 int ri;
1677 if (params.has_key("radius")) {ri = params["radius"];}
1678 else {ri = dim/2 - 1;}
1679
1680 // retrieve the voxel values
1681 float *cube = vol->get_data();
1682
1683 // count the number of voxels within a sphere centered at icent,
1684 // with radius ri
1685 status = getnnz(volsize, ri, origin, &nrays, &nnz);
1686 // need to check status...
1687
1688 // convert from cube to sphere
1689 sphere = new float[nnz];
1690 ptrs = new int[nrays+1];
1691 cord = new int[3*nrays];
1692 if (sphere == NULL || ptrs == NULL || cord == NULL) {
1693 fprintf(stderr,"ChaoProjector::project3d, failed to allocate!\n");
1694 exit(1);
1695 }
1696 for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
1697 for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
1698 for (int i = 0; i<3*nrays; i++) cord[i] = 0;
1699
1700 status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
1701 // check status
1702
1703 int nangles = 0;
1704 vector<float> anglelist;
1705 string angletype = "SPIDER";
1706 // Do we have a list of angles?
1707 if (params.has_key("anglelist")) {
1708 anglelist = params["anglelist"];
1709 nangles = anglelist.size() / 3;
1710 } else {
1711 Transform* t3d = params["transform"];
1712 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
1713 // This part was modified by David Woolford -
1714 // Before this the code worked only for SPIDER and EMAN angles,
1715 // but the framework of the Transform3D allows for a generic implementation
1716 // as specified here.
1717 Dict p = t3d->get_rotation("spider");
1718 if(t3d) {delete t3d; t3d=0;}
1719
1720 float phi = p["phi"];
1721 float theta = p["theta"];
1722 float psi = p["psi"];
1723 anglelist.push_back(phi);
1724 anglelist.push_back(theta);
1725 anglelist.push_back(psi);
1726 nangles = 1;
1727 }
1728 // End David Woolford modifications
1729
1730 dm = new float[nangles*9];
1731 setdm(anglelist, angletype, dm);
1732
1733 // return images
1734 EMData *ret = new EMData();
1735 ret->set_size(nxvol, nyvol, nangles);
1736 ret->set_complex(false);
1737 ret->set_ri(true);
1738
1739 images = ret->get_data();
1740
1741 for (j = 1; j <= nangles; j++) {
1742 status = fwdpj3(volsize, nrays, nnz , &dm(1,j), origin, ri,
1743 ptrs , cord, sphere, &images(1,1,j));
1744 // check status?
1745 }
1746
1747 // deallocate all temporary work space
1752
1753 if (!params.has_key("anglelist")) {
1754 Transform* t3d = params["transform"];
1755 ret->set_attr("xform.projection",t3d);
1756 if(t3d) {delete t3d; t3d=0;}
1757 }
1758 ret->update();
1759 return ret;
1760}
int fwdpj3(Vec3i volsize, int nray, int nnz, float *dm, Vec3i origin, int ri, int *ptrs, int *cord, float *x, float *y) const
Definition: projector.cpp:1444

References anglelist, cb2sph(), cord, cube, dm, EMDeleteArray(), fwdpj3(), EMAN::Util::get_min(), EMAN::Transform::get_rotation(), getnnz(), EMAN::Dict::has_key(), images, LOGERR, NullPointerException, EMAN::Projector::params, ptrs, setdm(), and sphere.

◆ setdm()

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

Definition at line 1610 of file projector.cpp.

1611{ // convert Euler angles to transformations, dm is an 9 by nangles array
1612
1613 float psi, theta, phi;
1614 double cthe, sthe, cpsi, spsi, cphi, sphi;
1615 int j;
1616
1617 int nangles = anglelist.size() / 3;
1618
1619 // now convert all angles
1620 for (j = 1; j <= nangles; j++) {
1621 phi = static_cast<float>(anglelist(1,j)*dgr_to_rad);
1622 theta = static_cast<float>(anglelist(2,j)*dgr_to_rad);
1623 psi = static_cast<float>(anglelist(3,j)*dgr_to_rad);
1624
1625 // cout << phi << " " << theta << " " << psi << endl;
1626 cthe = cos(theta);
1627 sthe = sin(theta);
1628 cpsi = cos(psi);
1629 spsi = sin(psi);
1630 cphi = cos(phi);
1631 sphi = sin(phi);
1632
1633 dm(1,j)=static_cast<float>(cphi*cthe*cpsi-sphi*spsi);
1634 dm(2,j)=static_cast<float>(sphi*cthe*cpsi+cphi*spsi);
1635 dm(3,j)=static_cast<float>(-sthe*cpsi);
1636 dm(4,j)=static_cast<float>(-cphi*cthe*spsi-sphi*cpsi);
1637 dm(5,j)=static_cast<float>(-sphi*cthe*spsi+cphi*cpsi);
1638 dm(6,j)=static_cast<float>(sthe*spsi);
1639 dm(7,j)=static_cast<float>(sthe*cphi);
1640 dm(8,j)=static_cast<float>(sthe*sphi);
1641 dm(9,j)=static_cast<float>(cthe);
1642 }
1643}

References anglelist, and dm.

Referenced by backproject3d(), and project3d().

◆ sph2cb()

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

Definition at line 1409 of file projector.cpp.

1411{
1412 int status=0;
1413 int r2, i, j, ix, iy, iz, nnz;
1414
1415 int nx = (int)volsize[0];
1416 int ny = (int)volsize[1];
1417 // int nz = (int)volsize[2];
1418
1419 r2 = ri*ri;
1420 nnz = 0;
1421 ptrs(1) = 1;
1422
1423 // no need to initialize
1424 // for (i = 0; i<nx*ny*nz; i++) cube[i]=0.0;
1425
1426 nnz = 0;
1427 for (j = 1; j <= nrays; j++) {
1428 iz = cord(1,j);
1429 iy = cord(2,j);
1430 ix = cord(3,j);
1431 for (i = ptrs(j); i<=ptrs(j+1)-1; i++, iz++) {
1432 nnz++;
1433 cube(iz,iy,ix) = sphere(nnz);
1434 }
1435 }
1436 if (nnz != nnz0) status = -1;
1437 return status;
1438}

References cord, cube, ptrs, and sphere.

Referenced by backproject3d().

Member Data Documentation

◆ NAME

const string ChaoProjector::NAME = "chao"
static

Definition at line 404 of file projector.h.

Referenced by get_name().


The documentation for this class was generated from the following files: