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

EMAN::StandardProjector Class Reference

Fast real-space 3D projection. More...

#include <projector.h>

Inheritance diagram for EMAN::StandardProjector:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

Static Public Member Functions

ProjectorNEW ()

Static Public Attributes

const string NAME = "standard"

Detailed Description

Fast real-space 3D projection.

Parameters:
Transform object used for projection

Definition at line 342 of file projector.h.


Member Function Documentation

EMData * StandardProjector::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 2083 of file projector.cpp.

02084 {
02085    // no implementation yet
02086    EMData *ret = new EMData();
02087    return ret;
02088 }

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

Implements EMAN::Projector.

Definition at line 361 of file projector.h.

00362                 {
00363                         return "Simple real-space projection. Most accurate.";
00364                 }

string EMAN::StandardProjector::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 356 of file projector.h.

00357                 {
00358                         return NAME;
00359                 }

TypeDict EMAN::StandardProjector::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 345 of file projector.h.

References EMAN::TypeDict::put().

00346                 {
00347                         TypeDict d;
00348                         d.put("transform", EMObject::TRANSFORM, "Transform object used for projection");
00349                         return d;
00350                 }

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

Definition at line 366 of file projector.h.

00367                 {
00368                         return new StandardProjector();
00369                 }

EMData * StandardProjector::project3d EMData image  )  const [virtual]
 

A "fix" for the segmentation fault when calling initmodel.py with standard projector. We'll look into this and make a real fix. -- Grant Tang

Implements EMAN::Projector.

Definition at line 874 of file projector.cpp.

References EMAN::Util::bilinear_interpolate(), EMAN::Util::fast_floor(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, EMAN::Transform::inverse(), EMAN::Util::linear_interpolate(), NullPointerException, nx, ny, proj, EMAN::EMData::set_attr(), EMAN::EMData::set_size(), t, EMAN::EMData::to_zero(), EMAN::Util::trilinear_interpolate(), EMAN::EMData::update(), v, EMAN::Vec2f, EMAN::Vec3f, EMAN::Vec3i, x, and y.

00875 {
00876         Transform* t3d = params["transform"];
00877         if ( t3d == NULL ) throw NullPointerException("The transform object containing the angles(required for projection), was not specified");
00878 //      Dict p = t3d->get_rotation();
00879         if ( image->get_ndim() == 3 )
00880         {
00881 //              float alt = p["alt"];
00882 //              float az = p["az"];
00883 //              float phi = p["phi"];
00884 
00885                 int nx = image->get_xsize();
00886                 int ny = image->get_ysize();
00887                 int nz = image->get_zsize();
00888 
00889 //              Transform3D r(Transform3D::EMAN, az, alt, phi);
00890                 Transform r = t3d->inverse(); // The inverse is taken here because we are rotating the coordinate system, not the image
00891                 int xy = nx * ny;
00892 
00893                 EMData *proj = new EMData();
00894                 proj->set_size(nx, ny, 1);
00895 
00896                 Vec3i offset(nx/2,ny/2,nz/2);
00897 
00898                 float *sdata = image->get_data();
00899                 float *ddata = proj->get_data();
00900                 for (int k = -nz / 2; k < nz - nz / 2; k++) {
00901                         int l = 0;
00902                         for (int j = -ny / 2; j < ny - ny / 2; j++) {
00903                                 ddata[l]=0;
00904                                 for (int i = -nx / 2; i < nx - nx / 2; i++,l++) {
00905 
00906                                         Vec3f coord(i,j,k);
00907                                         Vec3f soln = r*coord;
00908                                         soln += offset;
00909 
00913 //                                      printf(" ");
00914 
00915                                         float x2 = soln[0];
00916                                         float y2 = soln[1];
00917                                         float z2 = soln[2];
00918 
00919                                         float x = (float)Util::fast_floor(x2);
00920                                         float y = (float)Util::fast_floor(y2);
00921                                         float z = (float)Util::fast_floor(z2);
00922 
00923                                         float t = x2 - x;
00924                                         float u = y2 - y;
00925                                         float v = z2 - z;
00926 
00927                                         size_t ii = (size_t) ((size_t)x + (size_t)y * nx + (size_t)z * xy);
00928 
00929                                         if (x2 < 0 || y2 < 0 || z2 < 0 ) continue;
00930                                         if      (x2 > (nx-1) || y2  > (ny-1) || z2 > (nz-1) ) continue;
00931 
00932                                         if (x2 < (nx - 1) && y2 < (ny - 1) && z2 < (nz - 1)) {
00933                                                 ddata[l] +=
00934                                                                 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],
00935                                                                 sdata[ii + nx + 1], sdata[ii + xy],     sdata[ii + xy + 1], sdata[ii + xy + nx],
00936                                                                 sdata[ii + xy + nx + 1], t, u, v);
00937                                         }
00938                                         else if ( x2 == (nx - 1) && y2 == (ny - 1) && z2 == (nz - 1) ) {
00939                                                 ddata[l] += sdata[ii];
00940                                         }
00941                                         else if ( x2 == (nx - 1) && y2 == (ny - 1) ) {
00942                                                 ddata[l] +=     Util::linear_interpolate(sdata[ii], sdata[ii + xy],v);
00943                                         }
00944                                         else if ( x2 == (nx - 1) && z2 == (nz - 1) ) {
00945                                                 ddata[l] += Util::linear_interpolate(sdata[ii], sdata[ii + nx],u);
00946                                         }
00947                                         else if ( y2 == (ny - 1) && z2 == (nz - 1) ) {
00948                                                 ddata[l] += Util::linear_interpolate(sdata[ii], sdata[ii + 1],t);
00949                                         }
00950                                         else if ( x2 == (nx - 1) ) {
00951                                                 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + nx], sdata[ii + xy], sdata[ii + xy + nx],u,v);
00952                                         }
00953                                         else if ( y2 == (ny - 1) ) {
00954                                                 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + xy], sdata[ii + xy + 1],t,v);
00955                                         }
00956                                         else if ( z2 == (nz - 1) ) {
00957                                                 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], sdata[ii + nx + 1],t,u);
00958                                         }
00959                                 }
00960                         }
00961                 }
00962                 proj->update();
00963                 proj->set_attr("xform.projection",t3d);
00964                 proj->set_attr("apix_x",(float)image->get_attr("apix_x"));
00965                 proj->set_attr("apix_y",(float)image->get_attr("apix_y"));
00966                 proj->set_attr("apix_z",(float)image->get_attr("apix_z"));
00967                 
00968                 if(t3d) {delete t3d; t3d=0;}
00969                 return proj;
00970         }
00971         else if ( image->get_ndim() == 2 ) {
00972 
00973                 Transform r = t3d->inverse(); // The inverse is taken here because we are rotating the coordinate system, not the image
00974 
00975                 int nx = image->get_xsize();
00976                 int ny = image->get_ysize();
00977 
00978                 EMData *proj = new EMData();
00979                 proj->set_size(nx, 1, 1);
00980                 proj->to_zero();
00981 
00982                 float *sdata = image->get_data();
00983                 float *ddata = proj->get_data();
00984 
00985                 Vec2f offset(nx/2,ny/2);
00986                 for (int j = -ny / 2; j < ny - ny / 2; j++) { // j represents a column of pixels in the direction of the angle
00987                         int l = 0;
00988                         for (int i = -nx / 2; i < nx - nx / 2; i++,l++) {
00989 
00990                                 Vec2f coord(i,j);
00991                                 Vec2f soln = r*coord;
00992                                 soln += offset;
00993 
00994                                 float x2 = soln[0];
00995                                 float y2 = soln[1];
00996 
00997                                 float x = (float)Util::fast_floor(x2);
00998                                 float y = (float)Util::fast_floor(y2);
00999 
01000                                 int ii = (int) (x + y * nx);
01001                                 float u = x2 - x;
01002                                 float v = y2 - y;
01003 
01004                                 if (x2 < 0 || y2 < 0 ) continue;
01005                                 if      (x2 > (nx-1) || y2  > (ny-1) ) continue;
01006 
01007                                 if (  x2 < (nx - 1) && y2 < (ny - 1) ) {
01008                                         ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],sdata[ii + nx + 1], u, v);
01009                                 }
01010                                 else if (x2 == (nx-1) && y2 == (ny-1) ) {
01011                                         ddata[l] += sdata[ii];
01012                                 }
01013                                 else if (x2 == (nx-1) ) {
01014                                         ddata[l] += Util::linear_interpolate(sdata[ii],sdata[ii + nx], v);
01015                                 }
01016                                 else if (y2 == (ny-1) ) {
01017                                         ddata[l] += Util::linear_interpolate(sdata[ii],sdata[ii + 1], u);
01018                                 }
01019                         }
01020                 }
01021                 proj->set_attr("xform.projection",t3d);
01022                 proj->update();
01023                 if(t3d) {delete t3d; t3d=0;}
01024                 return proj;
01025         }
01026         else throw ImageDimensionException("Standard projection works only for 2D and 3D images");
01027 }


Member Data Documentation

const string StandardProjector::NAME = "standard" [static]
 

Definition at line 52 of file projector.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:48:30 2010 for EMAN2 by  doxygen 1.3.9.1