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 "gauss_fft";
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           private:
00194                 float alt, az, phi;
00195                 bool interp_ft_3d(int mode, EMData * image, float x, float y,
00196                                                   float z, float *data, float gauss_width) const;
00197         };
00198 
00204         class FourierGriddingProjector:public Projector
00205         {
00206           public:
00207                 EMData * project3d(EMData * image) const;
00208                 // no implementation yet
00209                 EMData * backproject3d(EMData * image) const;
00210 
00211 
00212                 string get_name() const
00213                 {
00214                         return "fourier_gridding";
00215                 }
00216 
00217                 string get_desc() const
00218                 {
00219                         return "Fourier-space projection using gridding.";
00220                 }
00221 
00222                 static Projector *NEW()
00223                 {
00224                         return new FourierGriddingProjector();
00225                 }
00226                 TypeDict get_param_types() const
00227                 {
00228                         TypeDict d;
00229                         d.put("transform", EMObject::TRANSFORM);
00230                         d.put("kb_alpha", EMObject::FLOAT);
00231                         d.put("kb_K", EMObject::FLOAT);
00232                         d.put("angletype", EMObject::STRING);
00233                         d.put("anglelist", EMObject::FLOATARRAY);
00234                         d.put("theta", EMObject::FLOAT);
00235                         d.put("psi", EMObject::FLOAT);
00236                         d.put("npad", EMObject::INT);
00237                         return d;
00238                 }
00239         };
00240 
00241 
00244         class PawelProjector:public Projector
00245         {
00246           public:
00247                 EMData * project3d(EMData * image) const;
00248                 EMData * backproject3d(EMData * image) const;
00249 
00250                 string get_name() const
00251                 {
00252                         return "pawel";
00253                 }
00254 
00255                 string get_desc() const
00256                 {
00257                         return "Pawel Penczek's optimized real-space projection generation. Minor interpolation artifacts.";
00258                 }
00259 
00260                 static Projector *NEW()
00261                 {
00262                         return new PawelProjector();
00263                 }
00264 
00265                 TypeDict get_param_types() const
00266                 {
00267                         TypeDict d;
00268                         d.put("transform", EMObject::TRANSFORM);
00269                         d.put("origin_x", EMObject::INT);
00270                         d.put("origin_y", EMObject::INT);
00271                         d.put("origin_z", EMObject::INT);
00272                         d.put("radius", EMObject::INT);
00273                         d.put("anglelist", EMObject::FLOATARRAY);
00274                         d.put("angletype", EMObject::STRING);
00275                         d.put("theta", EMObject::FLOAT);
00276                         d.put("psi", EMObject::FLOAT);
00277                         return d;
00278                 }
00279 
00280           private:
00281                 // Same structure as the IPCUBE structure in Spider
00282                 struct IPCube
00283                 {
00284                         int start;
00285                         int end;
00286                         Vec3i loc;
00287                 };
00288                 // Process the number of valid x-lines (rows)
00289                 // within the radius
00290                 void prepcubes(int nx, int ny, int nz, int ri, Vec3i origin,
00291                                        int& nn, IPCube* ipcube=NULL) const;
00292         };
00293 
00294 #ifdef EMAN2_USING_CUDA
00295 
00297                 class CudaStandardProjector:public Projector
00298                 {
00299                   public:
00300                         TypeDict get_param_types() const
00301                         {
00302                                 TypeDict d;
00303                                 d.put("transform", EMObject::TRANSFORM);
00304                                 return d;
00305                         }
00306 
00307                         EMData * project3d(EMData * image) const;
00308                  // no implementation yet
00309                         EMData * backproject3d(EMData * image) const;
00310 
00311                         string get_name() const
00312                         {
00313                                 return "cuda_standard";
00314                         }
00315 
00316                         string get_desc() const
00317                         {
00318                                 return "Simple real-space projection using the GPU. Most accurate.";
00319                         }
00320 
00321                         static Projector *NEW()
00322                         {
00323                                 return new CudaStandardProjector();
00324                         }
00325                   private:
00326                           float matrix[12];
00327                 };
00328 #endif // EMAN2_USING_CUDA
00329 
00333         class StandardProjector:public Projector
00334         {
00335           public:
00336                 TypeDict get_param_types() const
00337                 {
00338                         TypeDict d;
00339                         d.put("transform", EMObject::TRANSFORM, "Transform object used for projection");
00340                         return d;
00341                 }
00342 
00343                 EMData * project3d(EMData * image) const;
00344                 // no implementation yet
00345                 EMData * backproject3d(EMData * image) const;
00346 
00347                 string get_name() const
00348                 {
00349                         return "standard";
00350                 }
00351 
00352                 string get_desc() const
00353                 {
00354                         return "Simple real-space projection. Most accurate.";
00355                 }
00356 
00357                 static Projector *NEW()
00358                 {
00359                         return new StandardProjector();
00360                 }
00361         };
00362 
00365         class ChaoProjector:public Projector
00366         {
00367           public:
00368                 EMData * project3d(EMData * vol) const;
00369                 EMData * backproject3d(EMData * imagestack) const;
00370 
00371                 string get_name() const
00372                 {
00373                         return "chao";
00374                 }
00375 
00376                 string get_desc() const
00377                 {
00378                         return "Fast real space projection generation with Bi-Linear interpolation.";
00379                 }
00380 
00381                 static Projector *NEW()
00382                 {
00383                         return new ChaoProjector();
00384                 }
00385 
00386                 TypeDict get_param_types() const
00387                 {
00388                         TypeDict d;
00389                         d.put("transform", EMObject::TRANSFORM);
00390                         d.put("origin_x",  EMObject::INT);
00391                         d.put("origin_y",  EMObject::INT);
00392                         d.put("origin_z",  EMObject::INT);
00393                         d.put("anglelist", EMObject::FLOATARRAY);
00394                         d.put("radius",    EMObject::FLOAT);
00395                         return d;
00396                 }
00397 
00398           private:
00399                 int getnnz(Vec3i volsize, int ri, Vec3i origin, int *nray, int *nnz) const;
00400                 int cb2sph(float *cube, Vec3i volsize, int ri, Vec3i origin, int nnz0, int *ptrs,
00401                                 int *cord  , float *sphere) const;
00402                 int sph2cb(float *sphere, Vec3i volsize, int nray, int ri, int nnz0,
00403                                 int   *ptrs  , int *cord, float *cube) const;
00404                 int fwdpj3(Vec3i volsize, int nray, int nnz  , float *dm,
00405                            Vec3i origin, int ri  , int *ptrs,
00406                            int *cord, float *x, float *y) const;
00407                 int bckpj3(Vec3i volsize, int nray, int nnz, float *dm,
00408                            Vec3i origin, int ri, int *ptrs, int *cord,
00409                            float *x, float *y) const;
00410                 int ifix(float a) const;
00411                 void setdm(vector<float> anglelist, string const angletype, float *dm) const;
00412         };
00413 
00414         template <> Factory < Projector >::Factory();
00415 
00416         void dump_projectors();
00417         map<string, vector<string> > dump_projectors_list();
00418 }
00419 
00420 #endif  //eman__projector_h__
00421 
00422 /* vim: set ts=4 noet nospell: */

Generated on Sat Nov 21 02:19:16 2009 for EMAN2 by  doxygen 1.5.6