#include <projector.h>
Inheritance diagram for EMAN::StandardProjector:


Public Member Functions | |
| TypeDict | get_param_types () const |
| Get processor parameter information in a dictionary. | |
| EMData * | project3d (EMData *image) const |
| EMData * | backproject3d (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 | |
| Projector * | NEW () |
Static Public Attributes | |
| const string | NAME = "standard" |
| Transform | object used for projection |
Definition at line 304 of file projector.h.
|
|
Back-project a 2D image into a 3D image.
Implements EMAN::Projector. Definition at line 2080 of file projector.cpp.
|
|
|
Implements EMAN::Projector. Definition at line 323 of file projector.h. 00324 {
00325 return "Simple real-space projection. Most accurate.";
00326 }
|
|
|
Get the projector's name. Each projector is indentified by unique name.
Implements EMAN::Projector. Definition at line 318 of file projector.h. 00319 {
00320 return NAME;
00321 }
|
|
|
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 307 of file projector.h. References EMAN::TypeDict::put(). 00308 {
00309 TypeDict d;
00310 d.put("transform", EMObject::TRANSFORM, "Transform object used for projection");
00311 return d;
00312 }
|
|
|
Definition at line 328 of file projector.h. 00329 {
00330 return new StandardProjector();
00331 }
|
|
|
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 872 of file projector.cpp. References EMAN::Util::bilinear_interpolate(), EMAN::Transform::copy_matrix_into_array(), 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(), standard_project(), t, EMAN::EMData::to_zero(), EMAN::Util::trilinear_interpolate(), EMAN::EMData::update(), v, EMAN::Vec2f, EMAN::Vec3f, EMAN::Vec3i, x, and y. 00873 {
00874 Transform* t3d = params["transform"];
00875 if ( t3d == NULL ) throw NullPointerException("The transform object containing the angles(required for projection), was not specified");
00876 // Dict p = t3d->get_rotation();
00877 if ( image->get_ndim() == 3 )
00878 {
00879
00880 #ifdef EMAN2_USING_CUDA
00881 if(EMData::usecuda == 1) {
00882 if(!image->isrodataongpu()) image->copy_to_cudaro();
00883 //cout << "CUDA PROJ" << endl;
00884 Transform* t3d = params["transform"];
00885 if ( t3d == NULL ) throw NullPointerException("The transform object containing the angles(required for projection), was not specified");
00886 float * m = new float[12];
00887 t3d->copy_matrix_into_array(m);
00888 image->bindcudaarrayA(true);
00889 EMData* e = new EMData(0,0,image->get_xsize(),image->get_ysize(),1);
00890 //EMData *e = new EMData();
00891 //e->set_size(image->get_xsize(), image->get_ysize(), 1);
00892 e->rw_alloc();
00893 standard_project(m,e->getcudarwdata(), e->get_xsize(), e->get_ysize());
00894 image->unbindcudaarryA();
00895 delete [] m;
00896
00897 e->update();
00898 e->set_attr("xform.projection",t3d);
00899 //e_>copy_from_device();
00900 if(t3d) {delete t3d; t3d=0;}
00901 return e;
00902 }
00903 #endif
00904 int nx = image->get_xsize();
00905 int ny = image->get_ysize();
00906 int nz = image->get_zsize();
00907
00908 // Transform3D r(Transform3D::EMAN, az, alt, phi);
00909 Transform r = t3d->inverse(); // The inverse is taken here because we are rotating the coordinate system, not the image
00910 int xy = nx * ny;
00911
00912 EMData *proj = new EMData();
00913 proj->set_size(nx, ny, 1);
00914
00915 Vec3i offset(nx/2,ny/2,nz/2);
00916
00917 float *sdata = image->get_data();
00918 float *ddata = proj->get_data();
00919 for (int k = -nz / 2; k < nz - nz / 2; k++) {
00920 int l = 0;
00921 for (int j = -ny / 2; j < ny - ny / 2; j++) {
00922 ddata[l]=0;
00923 for (int i = -nx / 2; i < nx - nx / 2; i++,l++) {
00924
00925 Vec3f coord(i,j,k);
00926 Vec3f soln = r*coord;
00927 soln += offset;
00928
00932 // printf(" ");
00933
00934 float x2 = soln[0];
00935 float y2 = soln[1];
00936 float z2 = soln[2];
00937
00938 float x = (float)Util::fast_floor(x2);
00939 float y = (float)Util::fast_floor(y2);
00940 float z = (float)Util::fast_floor(z2);
00941
00942 float t = x2 - x;
00943 float u = y2 - y;
00944 float v = z2 - z;
00945
00946 size_t ii = (size_t) ((size_t)x + (size_t)y * nx + (size_t)z * xy);
00947 //
00948 if (x2 < 0 || y2 < 0 || z2 < 0 ) continue;
00949 if (x2 > (nx-1) || y2 > (ny-1) || z2 > (nz-1) ) continue;
00950
00951 if (x2 < (nx - 1) && y2 < (ny - 1) && z2 < (nz - 1)) {
00952 ddata[l] +=
00953 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],
00954 sdata[ii + nx + 1], sdata[ii + xy], sdata[ii + xy + 1], sdata[ii + xy + nx],
00955 sdata[ii + xy + nx + 1], t, u, v);
00956 }
00957 else if ( x2 == (nx - 1) && y2 == (ny - 1) && z2 == (nz - 1) ) {
00958 ddata[l] += sdata[ii];
00959 }
00960 else if ( x2 == (nx - 1) && y2 == (ny - 1) ) {
00961 ddata[l] += Util::linear_interpolate(sdata[ii], sdata[ii + xy],v);
00962 }
00963 else if ( x2 == (nx - 1) && z2 == (nz - 1) ) {
00964 ddata[l] += Util::linear_interpolate(sdata[ii], sdata[ii + nx],u);
00965 }
00966 else if ( y2 == (ny - 1) && z2 == (nz - 1) ) {
00967 ddata[l] += Util::linear_interpolate(sdata[ii], sdata[ii + 1],t);
00968 }
00969 else if ( x2 == (nx - 1) ) {
00970 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + nx], sdata[ii + xy], sdata[ii + xy + nx],u,v);
00971 }
00972 else if ( y2 == (ny - 1) ) {
00973 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + xy], sdata[ii + xy + 1],t,v);
00974 }
00975 else if ( z2 == (nz - 1) ) {
00976 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], sdata[ii + nx + 1],t,u);
00977 }
00978 }
00979 }
00980 }
00981 proj->update();
00982 proj->set_attr("xform.projection",t3d);
00983 proj->set_attr("apix_x",(float)image->get_attr("apix_x"));
00984 proj->set_attr("apix_y",(float)image->get_attr("apix_y"));
00985 proj->set_attr("apix_z",(float)image->get_attr("apix_z"));
00986
00987 if(t3d) {delete t3d; t3d=0;}
00988 return proj;
00989 }
00990 else if ( image->get_ndim() == 2 ) {
00991
00992 Transform r = t3d->inverse(); // The inverse is taken here because we are rotating the coordinate system, not the image
00993
00994 int nx = image->get_xsize();
00995 int ny = image->get_ysize();
00996
00997 EMData *proj = new EMData();
00998 proj->set_size(nx, 1, 1);
00999 proj->to_zero();
01000
01001 float *sdata = image->get_data();
01002 float *ddata = proj->get_data();
01003
01004 Vec2f offset(nx/2,ny/2);
01005 for (int j = -ny / 2; j < ny - ny / 2; j++) { // j represents a column of pixels in the direction of the angle
01006 int l = 0;
01007 for (int i = -nx / 2; i < nx - nx / 2; i++,l++) {
01008
01009 Vec2f coord(i,j);
01010 Vec2f soln = r*coord;
01011 soln += offset;
01012
01013 float x2 = soln[0];
01014 float y2 = soln[1];
01015
01016 float x = (float)Util::fast_floor(x2);
01017 float y = (float)Util::fast_floor(y2);
01018
01019 int ii = (int) (x + y * nx);
01020 float u = x2 - x;
01021 float v = y2 - y;
01022
01023 if (x2 < 0 || y2 < 0 ) continue;
01024 if (x2 > (nx-1) || y2 > (ny-1) ) continue;
01025
01026 if ( x2 < (nx - 1) && y2 < (ny - 1) ) {
01027 ddata[l] += Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],sdata[ii + nx + 1], u, v);
01028 }
01029 else if (x2 == (nx-1) && y2 == (ny-1) ) {
01030 ddata[l] += sdata[ii];
01031 }
01032 else if (x2 == (nx-1) ) {
01033 ddata[l] += Util::linear_interpolate(sdata[ii],sdata[ii + nx], v);
01034 }
01035 else if (y2 == (ny-1) ) {
01036 ddata[l] += Util::linear_interpolate(sdata[ii],sdata[ii + 1], u);
01037 }
01038 }
01039 }
01040 proj->set_attr("xform.projection",t3d);
01041 proj->update();
01042 if(t3d) {delete t3d; t3d=0;}
01043 return proj;
01044 }
01045 else throw ImageDimensionException("Standard projection works only for 2D and 3D images");
01046 }
|
|
|
Definition at line 57 of file projector.cpp. |
1.3.9.1