processor_sparx.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Pawel A.Penczek, 09/09/2006 (Pawel.A.Penczek@uth.tmc.edu)
00007  * Copyright (c) 2000-2006 The University of Texas - Houston Medical School
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_processor_sparx_h__
00037 #define eman_processor_sparx_h__ 1
00038 
00039 #include "emdata.h"
00040 
00041 namespace EMAN
00042 {
00043 
00044 
00048         class MirrorProcessor:public Processor
00049         {
00050 
00051           public:
00052                 void process_inplace(EMData * image);
00053 
00054                 string get_name() const
00055                 {
00056                         return "mirror";
00057                 }
00058 
00059                 static Processor *NEW()
00060                 {
00061                         return new MirrorProcessor();
00062                 }
00063 
00064                 TypeDict get_param_types() const
00065                 {
00066                         TypeDict d;
00067                         d.put("axis", EMObject::STRING, "'x', 'y', or 'z' axis, means mirror by changing the sign of the respective axis;");
00068                         return d;
00069                 }
00070 
00071                 string get_desc() const
00072                 {
00073                         return "mirror an image.";
00074                 }
00075 
00076         };
00077 
00078 
00079 
00080         class NewFourierProcessor:public Processor
00081         {
00082           public:
00083                 //virtual void process_inplace(EMData * image);
00084 
00085                 static string get_group_desc()
00086                 {
00087                         return "Fourier Filter Processors are frequency domain processors. The input image can be either real or Fourier, and the output processed image format corresponds to that of the input file. FourierFilter class is the base class of fourier space processors. The processors can be either low-pass, high-pass, band-pass, or homomorphic. The processor parameters are in absolute frequency units, valid range is ]0,0.5], where 0.5 is Nyquist freqeuncy. ";
00088                 }
00089 
00090                 TypeDict get_param_types() const
00091                 {
00092                         TypeDict d;
00093 //                      d.put("cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] cut-off frequency.");      //use cutoff_abs
00094                         d.put("sigma", EMObject::FLOAT, "Gaussian sigma (0-.5)");                                                       //use cutoff_abs
00095                         d.put("cutoff_abs", EMObject::FLOAT, "Processor radius in terms of Nyquist (0-.5)");
00096                         d.put("cutoff_pixels", EMObject::FLOAT, "Width in Fourier pixels (0 - size()/2");
00097                         d.put("cutoff_freq", EMObject::FLOAT, "Resolution in 1/A (0 - 1 / size*apix)");
00098                         d.put("apix", EMObject::FLOAT, " Override A/pix in the image header (changes x,y and z)");
00099                         return d;
00100                 }
00101 
00102           protected:
00103                 virtual void preprocess(EMData * image) {
00104                         if(params.has_key("apix")) {
00105                                 image->set_attr("apix_x", (float)params["apix"]);
00106                                 image->set_attr("apix_y", (float)params["apix"]);
00107                                 image->set_attr("apix_z", (float)params["apix"]);
00108                         }
00109 
00110                         const Dict dict = image->get_attr_dict();
00111                         if( params.has_key("sigma")) {
00112                                 params["cutoff_abs"] = params["sigma"];
00113                         }
00114                         else if( params.has_key("cutoff_abs") ) {
00115                                 params["sigma"] = params["cutoff_abs"];
00116                         }
00117                         else if( params.has_key("cutoff_freq") ) {
00118                                 float val =  (float)params["cutoff_freq"] * (float)dict["apix_x"];
00119                                 params["cutoff_abs"] = val;
00120                                 params["sigma"] = val;
00121                         }
00122                         else if( params.has_key("cutoff_pixels") ) {
00123                                 float val = 0.5f*(float)params["cutoff_pixels"] / (float)dict["nx"];
00124                                 params["cutoff_abs"] = val;
00125                                 params["sigma"] = val;
00126                         }
00127                 }
00128         };
00129 
00133         class NewLowpassTopHatProcessor:public NewFourierProcessor
00134         {
00135           public:
00136                 string get_name() const
00137                 { return "filter.lowpass.tophat"; }
00138                 static Processor *NEW()
00139                 { return new NewLowpassTopHatProcessor(); }
00140                 string get_desc() const
00141                 {
00142                         return "Lowpass top-hat filter processor applied in Fourier space.";
00143                 }
00144                 void process_inplace(EMData* image) {
00145                         params["filter_type"] = TOP_HAT_LOW_PASS;
00146                         preprocess(image);
00147                         EMFourierFilterInPlace(image, params);
00148                 }
00149         };
00150 
00154         class NewHighpassTopHatProcessor:public NewFourierProcessor
00155         {
00156           public:
00157                 string get_name() const
00158                 { return "filter.highpass.tophat"; }
00159                 static Processor *NEW()
00160                 { return new NewHighpassTopHatProcessor(); }
00161                 string get_desc() const
00162                 {
00163                         return "Highpass top-hat filter applied in Fourier space.";
00164                 }
00165                 void process_inplace(EMData* image) {
00166                         params["filter_type"] = TOP_HAT_HIGH_PASS;
00167                         preprocess(image);
00168                         EMFourierFilterInPlace(image, params);
00169                 }
00170         };
00171 
00176         class NewBandpassTopHatProcessor:public NewFourierProcessor
00177         {
00178           public:
00179                 string get_name() const
00180                 { return "filter.bandpass.tophat"; }
00181                 static Processor *NEW()
00182                 { return new NewBandpassTopHatProcessor(); }
00183                 string get_desc() const
00184                 {
00185                         return "Bandpass top-hat filter processor applied in Fourier space.";
00186                 }
00187                 void process_inplace(EMData* image) {
00188                         params["filter_type"] = TOP_HAT_BAND_PASS;
00189                         EMFourierFilterInPlace(image, params);
00190                 }
00191                 TypeDict get_param_types() const
00192                 {
00193                         TypeDict d = NewFourierProcessor::get_param_types();
00194                         d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00195                         d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00196                         return d;
00197                 }
00198         };
00199 
00205         class NewHomomorphicTopHatProcessor:public NewFourierProcessor
00206         {
00207           public:
00208                 string get_name() const
00209                 { return "filter.homomorphic.tophat"; }
00210                 static Processor *NEW()
00211                 { return new NewHomomorphicTopHatProcessor(); }
00212                 string get_desc() const
00213                 {
00214                         return "Homomorphic top-hat filter processor applied in Fourier space.";
00215                 }
00216                 void process_inplace(EMData* image) {
00217                         params["filter_type"] = TOP_HOMOMORPHIC;
00218                         EMFourierFilterInPlace(image, params);
00219                 }
00220                 TypeDict get_param_types() const
00221                 {
00222                         TypeDict d = NewFourierProcessor::get_param_types();
00223                         d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00224                         d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00225                         d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00226                         return d;
00227                 }
00228         };
00229 
00233         class NewLowpassGaussProcessor:public NewFourierProcessor
00234         {
00235           public:
00236                 string get_name() const
00237                 { return "filter.lowpass.gauss"; }
00238                 static Processor *NEW()
00239                 { return new NewLowpassGaussProcessor(); }
00240                 string get_desc() const
00241                 {
00242                         return "Lowpass Gauss filter processor applied in Fourier space.";
00243                 }
00244                 void process_inplace(EMData* image) {
00245                         params["filter_type"] = GAUSS_LOW_PASS;
00246                         preprocess(image);
00247                         EMFourierFilterInPlace(image, params);
00248                 }
00249         };
00250 
00254         class NewHighpassGaussProcessor:public NewFourierProcessor
00255         {
00256           public:
00257                 string get_name() const
00258                 { return "filter.highpass.gauss"; }
00259                 static Processor *NEW()
00260                 { return new NewHighpassGaussProcessor(); }
00261                 string get_desc() const
00262                 {
00263                         return "Highpass Gauss filter processor applied in Fourier space.";
00264                 }
00265                 void process_inplace(EMData* image) {
00266                         params["filter_type"] = GAUSS_HIGH_PASS;
00267                         preprocess(image);
00268                         EMFourierFilterInPlace(image, params);
00269                 }
00270         };
00271 
00276         class NewBandpassGaussProcessor:public NewFourierProcessor
00277         {
00278           public:
00279                 string get_name() const
00280                 { return "filter.bandpass.gauss"; }
00281                 static Processor *NEW()
00282                 { return new NewBandpassGaussProcessor(); }
00283                 string get_desc() const
00284                 {
00285                         return "Bandpass Gauss filter processor applied in Fourier space.";
00286                 }
00287                 void process_inplace(EMData* image) {
00288                         params["filter_type"] = GAUSS_BAND_PASS;
00289                         preprocess(image);
00290                         EMFourierFilterInPlace(image, params);
00291                 }
00292                 TypeDict get_param_types() const
00293                 {
00294                         TypeDict d = NewFourierProcessor::get_param_types();
00295                         d.put("center", EMObject::FLOAT, "Gaussian center.");
00296                         return d;
00297                 }
00298         };
00299 
00304         class NewHomomorphicGaussProcessor:public NewFourierProcessor
00305         {
00306           public:
00307                 string get_name() const
00308                 { return "filter.homomorphic.gauss"; }
00309                 static Processor *NEW()
00310                 { return new NewHomomorphicGaussProcessor(); }
00311                 string get_desc() const
00312                 {
00313                         return "Homomorphic Gauss filter processor applied in Fourier space.";
00314                 }
00315                 void process_inplace(EMData* image) {
00316                         params["filter_type"] = GAUSS_HOMOMORPHIC;
00317                         preprocess(image);
00318                         EMFourierFilterInPlace(image, params);
00319                 }
00320                 TypeDict get_param_types() const
00321                 {
00322                         TypeDict d = NewFourierProcessor::get_param_types();
00323                         d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00324                         return d;
00325                 }
00326         };
00327 
00331         class NewInverseGaussProcessor:public NewFourierProcessor
00332         {
00333           public:
00334                 string get_name() const
00335                 { return "filter.gaussinverse"; }
00336                 static Processor *NEW()
00337                 { return new NewInverseGaussProcessor(); }
00338                 string get_desc() const
00339                 {
00340                         return "Divide by a Gaussian in Fourier space.";
00341                 }
00342                 void process_inplace(EMData* image) {
00343                         params["filter_type"] = GAUSS_INVERSE;
00344                         preprocess(image);
00345                         EMFourierFilterInPlace(image, params);
00346                 }
00347         };
00348 
00351         class SHIFTProcessor:public NewFourierProcessor
00352         {
00353           public:
00354                 string get_name() const
00355                 { return "filter.shift"; }
00356                 static Processor *NEW()
00357                 { return new SHIFTProcessor(); }
00358                 string get_desc() const
00359                 {
00360                         return "Shift by phase multiplication in Fourier space.";
00361                 }
00362                 void process_inplace(EMData* image) {
00363                         params["filter_type"] = SHIFT;
00364                         EMFourierFilterInPlace(image, params);
00365                 }
00366                 TypeDict get_param_types() const
00367                 {
00368                         TypeDict d = NewFourierProcessor::get_param_types();
00369                         d.put("x_shift", EMObject::FLOAT, "Shift x");
00370                         d.put("y_shift", EMObject::FLOAT, "Shift y");
00371                         d.put("z_shift", EMObject::FLOAT, "Shift z");
00372                         return d;
00373                 }
00374         };
00375 
00378         class InverseKaiserI0Processor:public NewFourierProcessor
00379         {
00380           public:
00381                 string get_name() const
00382                 { return "filter.kaiser_io_inverse"; }
00383                 static Processor *NEW()
00384                 { return new InverseKaiserI0Processor(); }
00385                 string get_desc() const
00386                 {
00387                         return "Divide by a Kaiser-Bessel I0 func in Fourier space.";
00388                 }
00389                 void process_inplace(EMData* image) {
00390                         params["filter_type"] = KAISER_I0_INVERSE;
00391                         EMFourierFilterInPlace(image, params);
00392                 }
00393                 TypeDict get_param_types() const
00394                 {
00395                         TypeDict d = NewFourierProcessor::get_param_types();
00396                         return d;
00397                 }
00398         };
00399 
00402         class InverseKaiserSinhProcessor:public NewFourierProcessor
00403         {
00404           public:
00405                 string get_name() const
00406                 { return "filter.kaisersinhinverse"; }
00407                 static Processor *NEW()
00408                 { return new InverseKaiserSinhProcessor(); }
00409                 string get_desc() const
00410                 {
00411                         return "Divide by a Kaiser-Bessel Sinh func in Fourier space.";
00412                 }
00413                 void process_inplace(EMData* image) {
00414                         params["filter_type"] = KAISER_SINH_INVERSE;
00415                         EMFourierFilterInPlace(image, params);
00416                 }
00417                 TypeDict get_param_types() const
00418                 {
00419                         TypeDict d = NewFourierProcessor::get_param_types();
00420                         return d;
00421                 }
00422         };
00423 
00427         class NewRadialTableProcessor:public NewFourierProcessor
00428         {
00429           public:
00430                 string get_name() const
00431                 { return "filter.radialtable"; }
00432                 
00433                 static Processor *NEW()
00434                 { return new NewRadialTableProcessor(); }
00435                 
00436                 string get_desc() const
00437                 {
00438                         return "Filter with tabulated data in Fourier space. 1 value per Fourier pixel, extending to corners. Missing value assumed to be 0.";
00439                 }
00440                 void process_inplace(EMData* image) {
00441                         params["filter_type"] = RADIAL_TABLE;
00442                         EMFourierFilterInPlace(image, params);
00443                 }
00444                 TypeDict get_param_types() const
00445                 {
00446 //                      TypeDict d = NewFourierProcessor::get_param_types();
00447                         TypeDict d;
00448                         d.put("table", EMObject::FLOATARRAY, "Radial data array. 1 value per Fourier image pixel.");
00449                         return d;
00450                 }
00451         };
00452 
00457         class NewLowpassButterworthProcessor:public NewFourierProcessor
00458         {
00459           public:
00460                 string get_name() const
00461                 { return "filter.lowpass.butterworth"; }
00462                 static Processor *NEW()
00463                 { return new NewLowpassButterworthProcessor(); }
00464                 string get_desc() const
00465                 {
00466                         return "Lowpass Butterworth filter processor applied in Fourier space.";
00467                 }
00468                 void process_inplace(EMData* image) {
00469                         params["filter_type"] = BUTTERWORTH_LOW_PASS;
00470                         EMFourierFilterInPlace(image, params);
00471                 }
00472                 TypeDict get_param_types() const
00473                 {
00474                         TypeDict d = NewFourierProcessor::get_param_types();
00475                         d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00476                         d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00477                         return d;
00478                 }
00479         };
00480 
00485         class NewHighpassButterworthProcessor:public NewFourierProcessor
00486         {
00487           public:
00488                 string get_name() const
00489                 { return "filter.highpass.butterworth"; }
00490                 static Processor *NEW()
00491                 { return new NewHighpassButterworthProcessor(); }
00492                 string get_desc() const
00493                 {
00494                         return "Highpass Butterworth filter processor applied in Fourier space.";
00495                 }
00496                 void process_inplace(EMData* image) {
00497                         params["filter_type"] = BUTTERWORTH_HIGH_PASS;
00498                         EMFourierFilterInPlace(image, params);
00499                 }
00500                 TypeDict get_param_types() const
00501                 {
00502                         TypeDict d = NewFourierProcessor::get_param_types();
00503                         d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00504                         d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00505                         return d;
00506                 }
00507         };
00508 
00514         class NewHomomorphicButterworthProcessor:public NewFourierProcessor
00515         {
00516           public:
00517                 string get_name() const
00518                 { return "filter.homomorphic.butterworth"; }
00519                 static Processor *NEW()
00520                 { return new NewHomomorphicButterworthProcessor(); }
00521                 string get_desc() const
00522                 {
00523                         return "Homomorphic Butterworth filter processor applied in Fourier space.";
00524                 }
00525                 void process_inplace(EMData* image) {
00526                         params["filter_type"] = BUTTERWORTH_HOMOMORPHIC;
00527                         EMFourierFilterInPlace(image, params);
00528                 }
00529                 TypeDict get_param_types() const
00530                 {
00531                         TypeDict d = NewFourierProcessor::get_param_types();
00532                         d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00533                         d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00534                         d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00535                         return d;
00536                 }
00537         };
00538 
00543         class NewLowpassTanhProcessor:public NewFourierProcessor
00544         {
00545           public:
00546                 string get_name() const
00547                 { return "filter.lowpass.tanh"; }
00548                 static Processor *NEW()
00549                 { return new NewLowpassTanhProcessor(); }
00550                 string get_desc() const
00551                 {
00552                         return "Lowpass tanh filter processor applied in Fourier space.";
00553                 }
00554                 void process_inplace(EMData* image) {
00555                         params["filter_type"] = TANH_LOW_PASS;
00556                         preprocess(image);
00557                         params.set_default("fall_off",.5f); // Only sets it if is not already set
00558                         EMFourierFilterInPlace(image, params);
00559                 }
00560                 TypeDict get_param_types() const
00561                 {
00562                         TypeDict d = NewFourierProcessor::get_param_types();
00563                         d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00564                         return d;
00565                 }
00566         };
00567 
00572         class NewHighpassTanhProcessor:public NewFourierProcessor
00573         {
00574           public:
00575                 string get_name() const
00576                 { return "filter.highpass.tanh"; }
00577                 static Processor *NEW()
00578                 { return new NewHighpassTanhProcessor(); }
00579                 string get_desc() const
00580                 {
00581                         return "Highpass tanh filter processor applied in Fourier space.";
00582                 }
00583                 void process_inplace(EMData* image) {
00584                         params["filter_type"] = TANH_HIGH_PASS;
00585                         params.set_default("fall_off",.5f); // Only sets it if is not already set
00586                         preprocess(image);
00587                         EMFourierFilterInPlace(image, params);
00588                 }
00589                 TypeDict get_param_types() const
00590                 {
00591                         TypeDict d = NewFourierProcessor::get_param_types();
00592                         d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00593                         return d;
00594                 }
00595         };
00596 
00602         class NewHomomorphicTanhProcessor:public NewFourierProcessor
00603         {
00604           public:
00605                 string get_name() const
00606                 { return "filter.homomorphic.tanh"; }
00607                 static Processor *NEW()
00608                 { return new NewHomomorphicTanhProcessor(); }
00609                 string get_desc() const
00610                 {
00611                         return "Homomorphic Tanh processor applied in Fourier space";
00612                 }
00613                 void process_inplace(EMData* image) {
00614                         params["filter_type"] = TANH_HOMOMORPHIC;
00615                         params.set_default("fall_off",.5f); // Only sets it if is not already set
00616                         preprocess(image);
00617                         EMFourierFilterInPlace(image, params);
00618                 }
00619                 TypeDict get_param_types() const
00620                 {
00621                         TypeDict d = NewFourierProcessor::get_param_types();
00622                         d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00623                         d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00624                         return d;
00625                 }
00626         };
00627 
00635         class NewBandpassTanhProcessor:public NewFourierProcessor
00636         {
00637           public:
00638                 string get_name() const
00639                 { return "filter.bandpass.tanh"; }
00640                 static Processor *NEW()
00641                 { return new NewBandpassTanhProcessor(); }
00642                 string get_desc() const
00643                 {
00644                         return "Bandpass tanh processor applied in Fourier space.";
00645                 }
00646                 void process_inplace(EMData* image) {
00647                         params["filter_type"] = TANH_BAND_PASS;
00648                         EMFourierFilterInPlace(image, params);
00649                 }
00650                 TypeDict get_param_types() const
00651                 {
00652                         TypeDict d = NewFourierProcessor::get_param_types();
00653                         d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00654                         d.put("Low_fall_off", EMObject::FLOAT, "Tanh low decay rate.");
00655                         d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00656                         d.put("high_fall_off", EMObject::FLOAT, "Tanh high decay rate.");
00657                         d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00658                         return d;
00659                 }
00660         };
00661 
00662         class CTF_Processor:public NewFourierProcessor
00663         {
00664           public:
00665                 string get_name() const
00666                 { return "filter.CTF_"; }
00667                 static Processor *NEW()
00668                 { return new CTF_Processor(); }
00669                 string get_desc() const
00670                 {
00671                         return "CTF_ is applied in Fourier image.";
00672                 }
00673                 void process_inplace(EMData* image) {
00674                         params["filter_type"] = CTF_;
00675                         EMFourierFilterInPlace(image, params);
00676                 }
00677                 TypeDict get_param_types() const
00678                 {
00679                         TypeDict d = NewFourierProcessor::get_param_types();
00680                         d.put("defocus", EMObject::FLOAT, "defocus value in Angstrom.");
00681                         d.put("cs", EMObject::FLOAT, "cs in CM.");
00682                         d.put("voltage", EMObject::FLOAT, "voltage in Kv.");
00683                         d.put("ps", EMObject::FLOAT, "pixel size.");
00684                         d.put("b_factor", EMObject::FLOAT, "Gaussian like evelope function (b_factor).");
00685                         d.put("wgh", EMObject::FLOAT, "Amplitude contrast ratio.");
00686                         d.put("sign", EMObject::FLOAT, "Sign of Contrast transfer function,and use -1 to compensate.");
00687                         d.put("npow", EMObject::FLOAT, "power of transfer function.");
00688                         return d;
00689                 }
00690         };
00691 }
00692 
00693 #endif  //eman_processor_sparx_h__

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