00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef eman__projector_h__
00037 #define eman__projector_h__ 1
00038
00039 #include "transform.h"
00040
00041 using std::string;
00042
00043 namespace EMAN
00044 {
00045 class EMData;
00046
00081 class Projector
00082 {
00083 public:
00084 virtual ~ Projector()
00085 {
00086 }
00087
00091 virtual EMData *project3d(EMData * image) const = 0;
00092
00096 virtual EMData *backproject3d(EMData * image) const = 0;
00097
00102 virtual string get_name() const = 0;
00103
00104 virtual string get_desc() const = 0;
00105
00110 virtual Dict get_params() const
00111 {
00112 return params;
00113 }
00115 void set_params(const Dict & new_params)
00116 {
00117 params = new_params;
00118 }
00125 virtual TypeDict get_param_types() const
00126 {
00127 TypeDict d;
00128 return d;
00129 }
00130
00131 protected:
00132 Dict params;
00133 };
00134
00150 class GaussFFTProjector:public Projector
00151 {
00152 public:
00153 GaussFFTProjector():alt(0), az(0), phi(0)
00154 {
00155 }
00156
00157 EMData *project3d(EMData * image) const;
00158
00159 EMData *backproject3d(EMData * image) const;
00160
00161
00162 void set_params(const Dict & new_params)
00163 {
00164 Projector::set_params(new_params);
00165 alt = params["alt"];
00166 az = params["az"];
00167 phi = params["phi"];
00168 }
00169
00170 string get_name() const
00171 {
00172 return NAME;
00173 }
00174
00175 string get_desc() const
00176 {
00177 return "Projections using a Gaussian kernel in Fourier space. Produces artifacts, not recommended.";
00178 }
00179
00180 static Projector *NEW()
00181 {
00182 return new GaussFFTProjector();
00183 }
00184
00185 TypeDict get_param_types() const
00186 {
00187 TypeDict d;
00188 d.put("transform", EMObject::TRANSFORM);
00189 d.put("mode", EMObject::INT);
00190 return d;
00191 }
00192
00193 static const string NAME;
00194
00195 private:
00196 float alt, az, phi;
00197 bool interp_ft_3d(int mode, EMData * image, float x, float y,
00198 float z, float *data, float gauss_width) const;
00199 };
00200
00206 class FourierGriddingProjector:public Projector
00207 {
00208 public:
00209 EMData * project3d(EMData * image) const;
00210
00211 EMData * backproject3d(EMData * image) const;
00212
00213
00214 string get_name() const
00215 {
00216 return NAME;
00217 }
00218
00219 string get_desc() const
00220 {
00221 return "Fourier-space projection using gridding.";
00222 }
00223
00224 static Projector *NEW()
00225 {
00226 return new FourierGriddingProjector();
00227 }
00228 TypeDict get_param_types() const
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 }
00241
00242 static const string NAME;
00243 };
00244
00245
00248 class PawelProjector:public Projector
00249 {
00250 public:
00251 EMData * project3d(EMData * image) const;
00252 EMData * backproject3d(EMData * image) const;
00253
00254 string get_name() const
00255 {
00256 return NAME;
00257 }
00258
00259 string get_desc() const
00260 {
00261 return "Pawel Penczek's optimized real-space projection generation. Minor interpolation artifacts.";
00262 }
00263
00264 static Projector *NEW()
00265 {
00266 return new PawelProjector();
00267 }
00268
00269 TypeDict get_param_types() const
00270 {
00271 TypeDict d;
00272 d.put("transform", EMObject::TRANSFORM);
00273 d.put("origin_x", EMObject::INT);
00274 d.put("origin_y", EMObject::INT);
00275 d.put("origin_z", EMObject::INT);
00276 d.put("radius", EMObject::INT);
00277 d.put("anglelist", EMObject::FLOATARRAY);
00278 d.put("angletype", EMObject::STRING);
00279 d.put("theta", EMObject::FLOAT);
00280 d.put("psi", EMObject::FLOAT);
00281 return d;
00282 }
00283
00284 static const string NAME;
00285
00286 private:
00287
00288 struct IPCube
00289 {
00290 int start;
00291 int end;
00292 Vec3i loc;
00293 };
00294
00295
00296 void prepcubes(int nx, int ny, int nz, int ri, Vec3i origin,
00297 int& nn, IPCube* ipcube=NULL) const;
00298 };
00299
00303 class MaxValProjector:public Projector
00304 {
00305 public:
00306 TypeDict get_param_types() const
00307 {
00308 TypeDict d;
00309 d.put("transform", EMObject::TRANSFORM, "Transform object used for projection");
00310 return d;
00311 }
00312
00313 EMData * project3d(EMData * image) const;
00314
00315 EMData * backproject3d(EMData * image) const;
00316
00317 string get_name() const
00318 {
00319 return NAME;
00320 }
00321
00322 string get_desc() const
00323 {
00324 return "Real-space projection which computes the maximum value along each line projection rather than the sum";
00325 }
00326
00327 static Projector *NEW()
00328 {
00329 return new MaxValProjector();
00330 }
00331
00332 static const string NAME;
00333 };
00334
00335
00340 class StandardProjector:public Projector
00341 {
00342 public:
00343 TypeDict get_param_types() const
00344 {
00345 TypeDict d;
00346 d.put("transform", EMObject::TRANSFORM, "Transform object used for projection");
00347 return d;
00348 }
00349
00350 EMData * project3d(EMData * image) const;
00351
00352 EMData * backproject3d(EMData * image) const;
00353
00354 string get_name() const
00355 {
00356 return NAME;
00357 }
00358
00359 string get_desc() const
00360 {
00361 return "Simple real-space projection. Most accurate.";
00362 }
00363
00364 static Projector *NEW()
00365 {
00366 return new StandardProjector();
00367 }
00368
00369 static const string NAME;
00370 };
00371
00374 class ChaoProjector:public Projector
00375 {
00376 public:
00377 EMData * project3d(EMData * vol) const;
00378 EMData * backproject3d(EMData * imagestack) const;
00379
00380 string get_name() const
00381 {
00382 return NAME;
00383 }
00384
00385 string get_desc() const
00386 {
00387 return "Fast real space projection generation with Bi-Linear interpolation.";
00388 }
00389
00390 static Projector *NEW()
00391 {
00392 return new ChaoProjector();
00393 }
00394
00395 TypeDict get_param_types() const
00396 {
00397 TypeDict d;
00398 d.put("transform", EMObject::TRANSFORM);
00399 d.put("origin_x", EMObject::INT);
00400 d.put("origin_y", EMObject::INT);
00401 d.put("origin_z", EMObject::INT);
00402 d.put("anglelist", EMObject::FLOATARRAY);
00403 d.put("radius", EMObject::FLOAT);
00404 return d;
00405 }
00406
00407 static const string NAME;
00408
00409 private:
00410 int getnnz(Vec3i volsize, int ri, Vec3i origin, int *nray, int *nnz) const;
00411 int cb2sph(float *cube, Vec3i volsize, int ri, Vec3i origin, int nnz0, int *ptrs,
00412 int *cord , float *sphere) const;
00413 int sph2cb(float *sphere, Vec3i volsize, int nray, int ri, int nnz0,
00414 int *ptrs , int *cord, float *cube) const;
00415 int fwdpj3(Vec3i volsize, int nray, int nnz , float *dm,
00416 Vec3i origin, int ri , int *ptrs,
00417 int *cord, float *x, float *y) const;
00418 int bckpj3(Vec3i volsize, int nray, int nnz, float *dm,
00419 Vec3i origin, int ri, int *ptrs, int *cord,
00420 float *x, float *y) const;
00421 int ifix(float a) const;
00422 void setdm(vector<float> anglelist, string const angletype, float *dm) const;
00423 };
00424
00425 template <> Factory < Projector >::Factory();
00426
00427 void dump_projectors();
00428 map<string, vector<string> > dump_projectors_list();
00429 }
00430
00431 #endif //eman__projector_h__
00432
00433