Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

projector.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  *
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  *
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  *
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  *
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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                 // no implementation yet
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                 // no implementation yet
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                 // Same structure as the IPCUBE structure in Spider
00288                 struct IPCube
00289                 {
00290                         int start;
00291                         int end;
00292                         Vec3i loc;
00293                 };
00294                 // Process the number of valid x-lines (rows)
00295                 // within the radius
00296                 void prepcubes(int nx, int ny, int nz, int ri, Vec3i origin,
00297                                        int& nn, IPCube* ipcube=NULL) const;
00298         };
00299 
00304         class StandardProjector:public Projector
00305         {
00306           public:
00307                 TypeDict get_param_types() const
00308                 {
00309                         TypeDict d;
00310                         d.put("transform", EMObject::TRANSFORM, "Transform object used for projection");
00311                         return d;
00312                 }
00313 
00314                 EMData * project3d(EMData * image) const;
00315                 // no implementation yet
00316                 EMData * backproject3d(EMData * image) const;
00317 
00318                 string get_name() const
00319                 {
00320                         return NAME;
00321                 }
00322 
00323                 string get_desc() const
00324                 {
00325                         return "Simple real-space projection. Most accurate.";
00326                 }
00327 
00328                 static Projector *NEW()
00329                 {
00330                         return new StandardProjector();
00331                 }
00332                 
00333                 static const string NAME;
00334         };
00335 
00338         class ChaoProjector:public Projector
00339         {
00340           public:
00341                 EMData * project3d(EMData * vol) const;
00342                 EMData * backproject3d(EMData * imagestack) const;
00343 
00344                 string get_name() const
00345                 {
00346                         return NAME;
00347                 }
00348 
00349                 string get_desc() const
00350                 {
00351                         return "Fast real space projection generation with Bi-Linear interpolation.";
00352                 }
00353 
00354                 static Projector *NEW()
00355                 {
00356                         return new ChaoProjector();
00357                 }
00358 
00359                 TypeDict get_param_types() const
00360                 {
00361                         TypeDict d;
00362                         d.put("transform", EMObject::TRANSFORM);
00363                         d.put("origin_x",  EMObject::INT);
00364                         d.put("origin_y",  EMObject::INT);
00365                         d.put("origin_z",  EMObject::INT);
00366                         d.put("anglelist", EMObject::FLOATARRAY);
00367                         d.put("radius",    EMObject::FLOAT);
00368                         return d;
00369                 }
00370                 
00371                 static const string NAME;
00372 
00373           private:
00374                 int getnnz(Vec3i volsize, int ri, Vec3i origin, int *nray, int *nnz) const;
00375                 int cb2sph(float *cube, Vec3i volsize, int ri, Vec3i origin, int nnz0, int *ptrs,
00376                                 int *cord  , float *sphere) const;
00377                 int sph2cb(float *sphere, Vec3i volsize, int nray, int ri, int nnz0,
00378                                 int   *ptrs  , int *cord, float *cube) const;
00379                 int fwdpj3(Vec3i volsize, int nray, int nnz  , float *dm,
00380                            Vec3i origin, int ri  , int *ptrs,
00381                            int *cord, float *x, float *y) const;
00382                 int bckpj3(Vec3i volsize, int nray, int nnz, float *dm,
00383                            Vec3i origin, int ri, int *ptrs, int *cord,
00384                            float *x, float *y) const;
00385                 int ifix(float a) const;
00386                 void setdm(vector<float> anglelist, string const angletype, float *dm) const;
00387         };
00388 
00389         template <> Factory < Projector >::Factory();
00390 
00391         void dump_projectors();
00392         map<string, vector<string> > dump_projectors_list();
00393 }
00394 
00395 #endif  //eman__projector_h__
00396 
00397 /* vim: set ts=4 noet nospell: */

Generated on Tue Jul 12 13:49:03 2011 for EMAN2 by  doxygen 1.3.9.1