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