#include <projector.h>
Inheritance diagram for EMAN::MaxValProjector:
Public Member Functions | |
TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
EMData * | project3d (EMData *image) const |
Project an 3D image into a 2D image. | |
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 | |
static Projector * | NEW () |
Static Public Attributes | |
static const string | NAME = "maxval" |
Transform | object used for projection |
Definition at line 303 of file projector.h.
Back-project a 2D image into a 3D image.
Implements EMAN::Projector.
Definition at line 2250 of file projector.cpp.
string EMAN::MaxValProjector::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Projector.
Definition at line 322 of file projector.h.
00323 { 00324 return "Real-space projection which computes the maximum value along each line projection rather than the sum"; 00325 }
string EMAN::MaxValProjector::get_name | ( | ) | const [inline, virtual] |
Get the projector's name.
Each projector is indentified by unique name.
Implements EMAN::Projector.
Definition at line 317 of file projector.h.
References NAME.
00318 { 00319 return NAME; 00320 }
TypeDict EMAN::MaxValProjector::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 306 of file projector.h.
References EMAN::TypeDict::put(), and EMAN::EMObject::TRANSFORM.
00307 { 00308 TypeDict d; 00309 d.put("transform", EMObject::TRANSFORM, "Transform object used for projection"); 00310 return d; 00311 }
static Projector* EMAN::MaxValProjector::NEW | ( | ) | [inline, static] |
Project an 3D image into a 2D image.
Implements EMAN::Projector.
Definition at line 1058 of file projector.cpp.
References EMAN::Util::bilinear_interpolate(), EMAN::Util::fast_floor(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::Util::get_max(), 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, EMAN::Projector::params, proj, t, EMAN::Util::trilinear_interpolate(), v, x, and y.
01059 { 01060 Transform* t3d = params["transform"]; 01061 if ( t3d == NULL ) throw NullPointerException("The transform object containing the angles(required for projection), was not specified"); 01062 // Dict p = t3d->get_rotation(); 01063 if ( image->get_ndim() == 3 ) 01064 { 01065 01066 int nx = image->get_xsize(); 01067 int ny = image->get_ysize(); 01068 int nz = image->get_zsize(); 01069 01070 // Transform3D r(Transform3D::EMAN, az, alt, phi); 01071 Transform r = t3d->inverse(); // The inverse is taken here because we are rotating the coordinate system, not the image 01072 int xy = nx * ny; 01073 01074 EMData *proj = new EMData(); 01075 proj->set_size(nx, ny, 1); 01076 01077 Vec3i offset(nx/2,ny/2,nz/2); 01078 01079 float *sdata = image->get_data(); 01080 float *ddata = proj->get_data(); 01081 for (int k = -nz / 2; k < nz - nz / 2; k++) { 01082 int l = 0; 01083 for (int j = -ny / 2; j < ny - ny / 2; j++) { 01084 ddata[l]=0; 01085 for (int i = -nx / 2; i < nx - nx / 2; i++,l++) { 01086 01087 Vec3f coord(i,j,k); 01088 Vec3f soln = r*coord; 01089 soln += offset; 01090 01094 // printf(" "); 01095 01096 float x2 = soln[0]; 01097 float y2 = soln[1]; 01098 float z2 = soln[2]; 01099 01100 float x = (float)Util::fast_floor(x2); 01101 float y = (float)Util::fast_floor(y2); 01102 float z = (float)Util::fast_floor(z2); 01103 01104 float t = x2 - x; 01105 float u = y2 - y; 01106 float v = z2 - z; 01107 01108 size_t ii = (size_t) ((size_t)x + (size_t)y * nx + (size_t)z * xy); 01109 // 01110 if (x2 < 0 || y2 < 0 || z2 < 0 ) continue; 01111 if (x2 > (nx-1) || y2 > (ny-1) || z2 > (nz-1) ) continue; 01112 01113 if (x2 < (nx - 1) && y2 < (ny - 1) && z2 < (nz - 1)) { 01114 ddata[l] = Util::get_max(ddata[l], 01115 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], 01116 sdata[ii + nx + 1], sdata[ii + xy], sdata[ii + xy + 1], sdata[ii + xy + nx], 01117 sdata[ii + xy + nx + 1], t, u, v)); 01118 } 01119 else if ( x2 == (nx - 1) && y2 == (ny - 1) && z2 == (nz - 1) ) { 01120 ddata[l] = Util::get_max(ddata[l],sdata[ii]); 01121 } 01122 else if ( x2 == (nx - 1) && y2 == (ny - 1) ) { 01123 ddata[l] = Util::get_max(ddata[l],Util::linear_interpolate(sdata[ii], sdata[ii + xy],v)); 01124 } 01125 else if ( x2 == (nx - 1) && z2 == (nz - 1) ) { 01126 ddata[l] = Util::get_max(ddata[l],Util::linear_interpolate(sdata[ii], sdata[ii + nx],u)); 01127 } 01128 else if ( y2 == (ny - 1) && z2 == (nz - 1) ) { 01129 ddata[l] = Util::get_max(ddata[l],Util::linear_interpolate(sdata[ii], sdata[ii + 1],t)); 01130 } 01131 else if ( x2 == (nx - 1) ) { 01132 ddata[l] = Util::get_max(ddata[l],Util::bilinear_interpolate(sdata[ii], sdata[ii + nx], sdata[ii + xy], sdata[ii + xy + nx],u,v)); 01133 } 01134 else if ( y2 == (ny - 1) ) { 01135 ddata[l] = Util::get_max(ddata[l],Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + xy], sdata[ii + xy + 1],t,v)); 01136 } 01137 else if ( z2 == (nz - 1) ) { 01138 ddata[l] = Util::get_max(ddata[l],Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], sdata[ii + nx + 1],t,u)); 01139 } 01140 } 01141 } 01142 } 01143 proj->update(); 01144 proj->set_attr("xform.projection",t3d); 01145 proj->set_attr("apix_x",(float)image->get_attr("apix_x")); 01146 proj->set_attr("apix_y",(float)image->get_attr("apix_y")); 01147 proj->set_attr("apix_z",(float)image->get_attr("apix_z")); 01148 01149 if(t3d) {delete t3d; t3d=0;} 01150 return proj; 01151 } 01152 else if ( image->get_ndim() == 2 ) { 01153 01154 Transform r = t3d->inverse(); // The inverse is taken here because we are rotating the coordinate system, not the image 01155 01156 int nx = image->get_xsize(); 01157 int ny = image->get_ysize(); 01158 01159 EMData *proj = new EMData(); 01160 proj->set_size(nx, 1, 1); 01161 proj->to_zero(); 01162 01163 float *sdata = image->get_data(); 01164 float *ddata = proj->get_data(); 01165 01166 Vec2f offset(nx/2,ny/2); 01167 for (int j = -ny / 2; j < ny - ny / 2; j++) { // j represents a column of pixels in the direction of the angle 01168 int l = 0; 01169 for (int i = -nx / 2; i < nx - nx / 2; i++,l++) { 01170 01171 Vec2f coord(i,j); 01172 Vec2f soln = r*coord; 01173 soln += offset; 01174 01175 float x2 = soln[0]; 01176 float y2 = soln[1]; 01177 01178 float x = (float)Util::fast_floor(x2); 01179 float y = (float)Util::fast_floor(y2); 01180 01181 int ii = (int) (x + y * nx); 01182 float u = x2 - x; 01183 float v = y2 - y; 01184 01185 if (x2 < 0 || y2 < 0 ) continue; 01186 if (x2 > (nx-1) || y2 > (ny-1) ) continue; 01187 01188 if ( x2 < (nx - 1) && y2 < (ny - 1) ) { 01189 ddata[l] = Util::get_max(ddata[l],Util::bilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],sdata[ii + nx + 1], u, v)); 01190 } 01191 else if (x2 == (nx-1) && y2 == (ny-1) ) { 01192 ddata[l] = Util::get_max(ddata[l],sdata[ii]); 01193 } 01194 else if (x2 == (nx-1) ) { 01195 ddata[l] = Util::get_max(ddata[l],Util::linear_interpolate(sdata[ii],sdata[ii + nx], v)); 01196 } 01197 else if (y2 == (ny-1) ) { 01198 ddata[l] = Util::get_max(ddata[l],Util::linear_interpolate(sdata[ii],sdata[ii + 1], u)); 01199 } 01200 } 01201 } 01202 proj->set_attr("xform.projection",t3d); 01203 proj->update(); 01204 if(t3d) {delete t3d; t3d=0;} 01205 return proj; 01206 } 01207 else throw ImageDimensionException("Standard projection works only for 2D and 3D images"); 01208 }
const string MaxValProjector::NAME = "maxval" [static] |