#include <projector.h>
Inheritance diagram for EMAN::FourierGriddingProjector:
Public Member Functions | |
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 |
TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
static Projector * | NEW () |
Static Public Attributes | |
static const string | NAME = "fourier_gridding" |
Definition at line 206 of file projector.h.
Back-project a 2D image into a 3D image.
Implements EMAN::Projector.
Definition at line 2095 of file projector.cpp.
string EMAN::FourierGriddingProjector::get_desc | ( | ) | const [inline, virtual] |
string EMAN::FourierGriddingProjector::get_name | ( | ) | const [inline, virtual] |
Get the projector's name.
Each projector is indentified by unique name.
Implements EMAN::Projector.
Definition at line 214 of file projector.h.
References NAME.
00215 { 00216 return NAME; 00217 }
TypeDict EMAN::FourierGriddingProjector::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 228 of file projector.h.
References EMAN::EMObject::FLOAT, EMAN::EMObject::FLOATARRAY, EMAN::EMObject::INT, EMAN::TypeDict::put(), EMAN::EMObject::STRING, and EMAN::EMObject::TRANSFORM.
00229 { 00230 TypeDict d; 00231 d.put("transform", EMObject::TRANSFORM); 00232 d.put("kb_alpha", EMObject::FLOAT); 00233 d.put("kb_K", EMObject::FLOAT); 00234 d.put("angletype", EMObject::STRING); 00235 d.put("anglelist", EMObject::FLOATARRAY); 00236 d.put("theta", EMObject::FLOAT); 00237 d.put("psi", EMObject::FLOAT); 00238 d.put("npad", EMObject::INT); 00239 return d; 00240 }
static Projector* EMAN::FourierGriddingProjector::NEW | ( | ) | [inline, static] |
Project an 3D image into a 2D image.
Implements EMAN::Projector.
Definition at line 1149 of file projector.cpp.
References anglelist, EMAN::EMData::center_origin_fft(), EMAN::EMData::copy(), EMAN::EMData::divkbsinh(), EMAN::EMData::do_fft_inplace(), EMAN::EMData::extract_plane(), EMAN::EMData::fft_shuffle(), EMAN::Util::get_min(), EMAN::EMData::get_ndim(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), ImageDimensionException, ImageFormatException, EMAN::EMData::is_complex(), EMAN::EMData::norm_pad(), NullPointerException, nx, ny, EMAN::Projector::params, phi, proj, EMAN::EMData::set_attr(), EMAN::EMData::set_size(), EMAN::Dict::size(), tf(), theta, EMAN::EMData::to_zero(), and EMAN::EMData::update().
01150 { 01151 if (!image) { 01152 return 0; 01153 } 01154 if (3 != image->get_ndim()) 01155 throw ImageDimensionException( 01156 "FourierGriddingProjector needs a 3-D volume"); 01157 if (image->is_complex()) 01158 throw ImageFormatException( 01159 "FourierGriddingProjector requires a real volume"); 01160 const int npad = params.has_key("npad") ? int(params["npad"]) : 2; 01161 const int nx = image->get_xsize(); 01162 const int ny = image->get_ysize(); 01163 const int nz = image->get_zsize(); 01164 if (nx != ny || nx != nz) 01165 throw ImageDimensionException( 01166 "FourierGriddingProjector requires nx==ny==nz"); 01167 const int m = Util::get_min(nx,ny,nz); 01168 const int n = m*npad; 01169 01170 int K = params["kb_K"]; 01171 if ( K == 0 ) K = 6; 01172 float alpha = params["kb_alpha"]; 01173 if ( alpha == 0 ) alpha = 1.25; 01174 Util::KaiserBessel kb(alpha, K, (float)(m/2), K/(2.0f*n), n); 01175 01176 // divide out gridding weights 01177 EMData* tmpImage = image->copy(); 01178 tmpImage->divkbsinh(kb); 01179 // pad and center volume, then FFT and multiply by (-1)**(i+j+k) 01180 //EMData* imgft = tmpImage->pad_fft(npad); 01181 //imgft->center_padded(); 01182 EMData* imgft = tmpImage->norm_pad(false, npad); 01183 imgft->do_fft_inplace(); 01184 imgft->center_origin_fft(); 01185 imgft->fft_shuffle(); 01186 delete tmpImage; 01187 01188 // Do we have a list of angles? 01189 int nangles = 0; 01190 vector<float> anglelist; 01191 // Do we have a list of angles? 01192 if (params.has_key("anglelist")) { 01193 anglelist = params["anglelist"]; 01194 nangles = anglelist.size() / 3; 01195 } else { 01196 // This part was modified by David Woolford - 01197 // Before this the code worked only for SPIDER and EMAN angles, 01198 // but the framework of the Transform3D allows for a generic implementation 01199 // as specified here. 01200 Transform* t3d = params["transform"]; 01201 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified"); 01202 Dict p = t3d->get_rotation("spider"); 01203 01204 string angletype = "SPIDER"; 01205 float phi = p["phi"]; 01206 float theta = p["theta"]; 01207 float psi = p["psi"]; 01208 anglelist.push_back(phi); 01209 anglelist.push_back(theta); 01210 anglelist.push_back(psi); 01211 nangles = 1; 01212 if(t3d) {delete t3d; t3d=0;} 01213 } 01214 01215 // End David Woolford modifications 01216 01217 // initialize return object 01218 EMData* ret = new EMData(); 01219 ret->set_size(nx, ny, nangles); 01220 ret->to_zero(); 01221 // loop over sets of angles 01222 for (int ia = 0; ia < nangles; ia++) { 01223 int indx = 3*ia; 01224 Dict d("type","spider","phi",anglelist[indx],"theta",anglelist[indx+1],"psi",anglelist[indx+2]); 01225 Transform tf(d); 01226 EMData* proj = imgft->extract_plane(tf, kb); 01227 if (proj->is_shuffled()) proj->fft_shuffle(); 01228 proj->center_origin_fft(); 01229 proj->do_ift_inplace(); 01230 EMData* winproj = proj->window_center(m); 01231 delete proj; 01232 for (int iy=0; iy < ny; iy++) 01233 for (int ix=0; ix < nx; ix++) 01234 (*ret)(ix,iy,ia) = (*winproj)(ix,iy); 01235 delete winproj; 01236 } 01237 delete imgft; 01238 01239 if (!params.has_key("anglelist")) { 01240 Transform* t3d = params["transform"]; 01241 ret->set_attr("xform.projection",t3d); 01242 if(t3d) {delete t3d; t3d=0;} 01243 } 01244 ret->update(); 01245 return ret; 01246 }
const string FourierGriddingProjector::NAME = "fourier_gridding" [static] |