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_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 NAME;
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 static const string NAME;
00077 };
00078
00079
00080
00081 class NewFourierProcessor:public Processor
00082 {
00083 public:
00084
00085
00086 static string get_group_desc()
00087 {
00088 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. ";
00089 }
00090
00091 TypeDict get_param_types() const
00092 {
00093 TypeDict d;
00094
00095 d.put("sigma", EMObject::FLOAT, "Gaussian sigma (0-.5)");
00096 d.put("cutoff_abs", EMObject::FLOAT, "Processor radius in terms of Nyquist (0-.5)");
00097 d.put("cutoff_pixels", EMObject::FLOAT, "Width in Fourier pixels (0 - size()/2");
00098 d.put("cutoff_freq", EMObject::FLOAT, "Resolution in 1/A (0 - 1 / size*apix)");
00099 d.put("apix", EMObject::FLOAT, " Override A/pix in the image header (changes x,y and z)");
00100 return d;
00101 }
00102
00103 protected:
00104 virtual void preprocess(EMData * image) {
00105 if(params.has_key("apix")) {
00106 image->set_attr("apix_x", (float)params["apix"]);
00107 image->set_attr("apix_y", (float)params["apix"]);
00108 image->set_attr("apix_z", (float)params["apix"]);
00109 }
00110
00111 const Dict dict = image->get_attr_dict();
00112 if( params.has_key("sigma")) {
00113 params["cutoff_abs"] = params["sigma"];
00114 }
00115 else if( params.has_key("cutoff_abs") ) {
00116 params["sigma"] = params["cutoff_abs"];
00117 }
00118 else if( params.has_key("cutoff_freq") ) {
00119 float val = (float)params["cutoff_freq"] * (float)dict["apix_x"];
00120 params["cutoff_abs"] = val;
00121 params["sigma"] = val;
00122 }
00123 else if( params.has_key("cutoff_pixels") ) {
00124 float val = 0.5f*(float)params["cutoff_pixels"] / (float)dict["nx"];
00125 params["cutoff_abs"] = val;
00126 params["sigma"] = val;
00127 }
00128 }
00129 };
00130
00134 class NewLowpassTopHatProcessor:public NewFourierProcessor
00135 {
00136 public:
00137 string get_name() const
00138 { return NAME; }
00139 static Processor *NEW()
00140 { return new NewLowpassTopHatProcessor(); }
00141 string get_desc() const
00142 {
00143 return "Lowpass top-hat filter processor applied in Fourier space.";
00144 }
00145 void process_inplace(EMData* image) {
00146 params["filter_type"] = TOP_HAT_LOW_PASS;
00147 preprocess(image);
00148 EMFourierFilterInPlace(image, params);
00149 }
00150
00151 static const string NAME;
00152 };
00153
00157 class NewHighpassTopHatProcessor:public NewFourierProcessor
00158 {
00159 public:
00160 string get_name() const
00161 { return NAME; }
00162 static Processor *NEW()
00163 { return new NewHighpassTopHatProcessor(); }
00164 string get_desc() const
00165 {
00166 return "Highpass top-hat filter applied in Fourier space.";
00167 }
00168 void process_inplace(EMData* image) {
00169 params["filter_type"] = TOP_HAT_HIGH_PASS;
00170 preprocess(image);
00171 EMFourierFilterInPlace(image, params);
00172 }
00173
00174 static const string NAME;
00175 };
00176
00181 class NewBandpassTopHatProcessor:public NewFourierProcessor
00182 {
00183 public:
00184 string get_name() const
00185 { return NAME; }
00186 static Processor *NEW()
00187 { return new NewBandpassTopHatProcessor(); }
00188 string get_desc() const
00189 {
00190 return "Bandpass top-hat filter processor applied in Fourier space.";
00191 }
00192 void process_inplace(EMData* image) {
00193 params["filter_type"] = TOP_HAT_BAND_PASS;
00194 EMFourierFilterInPlace(image, params);
00195 }
00196 TypeDict get_param_types() const
00197 {
00198 TypeDict d = NewFourierProcessor::get_param_types();
00199 d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00200 d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00201 return d;
00202 }
00203
00204 static const string NAME;
00205 };
00206
00212 class NewHomomorphicTopHatProcessor:public NewFourierProcessor
00213 {
00214 public:
00215 string get_name() const
00216 { return NAME; }
00217 static Processor *NEW()
00218 { return new NewHomomorphicTopHatProcessor(); }
00219 string get_desc() const
00220 {
00221 return "Homomorphic top-hat filter processor applied in Fourier space.";
00222 }
00223 void process_inplace(EMData* image) {
00224 params["filter_type"] = TOP_HOMOMORPHIC;
00225 EMFourierFilterInPlace(image, params);
00226 }
00227 TypeDict get_param_types() const
00228 {
00229 TypeDict d = NewFourierProcessor::get_param_types();
00230 d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00231 d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00232 d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00233 return d;
00234 }
00235
00236 static const string NAME;
00237 };
00238
00242 class NewLowpassGaussProcessor:public NewFourierProcessor
00243 {
00244 public:
00245 string get_name() const
00246 { return NAME; }
00247 static Processor *NEW()
00248 { return new NewLowpassGaussProcessor(); }
00249 string get_desc() const
00250 {
00251 return "Lowpass Gauss filter processor applied in Fourier space.";
00252 }
00253 void process_inplace(EMData* image) {
00254 params["filter_type"] = GAUSS_LOW_PASS;
00255 preprocess(image);
00256 EMFourierFilterInPlace(image, params);
00257 }
00258
00259 static const string NAME;
00260 };
00261
00265 class NewHighpassGaussProcessor:public NewFourierProcessor
00266 {
00267 public:
00268 string get_name() const
00269 { return NAME; }
00270 static Processor *NEW()
00271 { return new NewHighpassGaussProcessor(); }
00272 string get_desc() const
00273 {
00274 return "Highpass Gauss filter processor applied in Fourier space.";
00275 }
00276 void process_inplace(EMData* image) {
00277 params["filter_type"] = GAUSS_HIGH_PASS;
00278 preprocess(image);
00279 EMFourierFilterInPlace(image, params);
00280 }
00281
00282 static const string NAME;
00283 };
00284
00289 class NewBandpassGaussProcessor:public NewFourierProcessor
00290 {
00291 public:
00292 string get_name() const
00293 { return NAME; }
00294 static Processor *NEW()
00295 { return new NewBandpassGaussProcessor(); }
00296 string get_desc() const
00297 {
00298 return "Bandpass Gauss filter processor applied in Fourier space.";
00299 }
00300 void process_inplace(EMData* image) {
00301 params["filter_type"] = GAUSS_BAND_PASS;
00302 preprocess(image);
00303 EMFourierFilterInPlace(image, params);
00304 }
00305 TypeDict get_param_types() const
00306 {
00307 TypeDict d = NewFourierProcessor::get_param_types();
00308 d.put("center", EMObject::FLOAT, "Gaussian center.");
00309 return d;
00310 }
00311
00312 static const string NAME;
00313 };
00314
00319 class NewHomomorphicGaussProcessor:public NewFourierProcessor
00320 {
00321 public:
00322 string get_name() const
00323 { return NAME; }
00324 static Processor *NEW()
00325 { return new NewHomomorphicGaussProcessor(); }
00326 string get_desc() const
00327 {
00328 return "Homomorphic Gauss filter processor applied in Fourier space.";
00329 }
00330 void process_inplace(EMData* image) {
00331 params["filter_type"] = GAUSS_HOMOMORPHIC;
00332 preprocess(image);
00333 EMFourierFilterInPlace(image, params);
00334 }
00335 TypeDict get_param_types() const
00336 {
00337 TypeDict d = NewFourierProcessor::get_param_types();
00338 d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00339 return d;
00340 }
00341
00342 static const string NAME;
00343 };
00344
00348 class NewInverseGaussProcessor:public NewFourierProcessor
00349 {
00350 public:
00351 string get_name() const
00352 { return NAME; }
00353 static Processor *NEW()
00354 { return new NewInverseGaussProcessor(); }
00355 string get_desc() const
00356 {
00357 return "Divide by a Gaussian in Fourier space.";
00358 }
00359 void process_inplace(EMData* image) {
00360 params["filter_type"] = GAUSS_INVERSE;
00361 preprocess(image);
00362 EMFourierFilterInPlace(image, params);
00363 }
00364
00365 static const string NAME;
00366 };
00367
00370 class SHIFTProcessor:public NewFourierProcessor
00371 {
00372 public:
00373 string get_name() const
00374 { return NAME; }
00375 static Processor *NEW()
00376 { return new SHIFTProcessor(); }
00377 string get_desc() const
00378 {
00379 return "Shift by phase multiplication in Fourier space.";
00380 }
00381 void process_inplace(EMData* image) {
00382 params["filter_type"] = SHIFT;
00383 EMFourierFilterInPlace(image, params);
00384 }
00385 TypeDict get_param_types() const
00386 {
00387 TypeDict d = NewFourierProcessor::get_param_types();
00388 d.put("x_shift", EMObject::FLOAT, "Shift x");
00389 d.put("y_shift", EMObject::FLOAT, "Shift y");
00390 d.put("z_shift", EMObject::FLOAT, "Shift z");
00391 return d;
00392 }
00393
00394 static const string NAME;
00395 };
00396
00399 class InverseKaiserI0Processor:public NewFourierProcessor
00400 {
00401 public:
00402 string get_name() const
00403 { return NAME; }
00404 static Processor *NEW()
00405 { return new InverseKaiserI0Processor(); }
00406 string get_desc() const
00407 {
00408 return "Divide by a Kaiser-Bessel I0 func in Fourier space.";
00409 }
00410 void process_inplace(EMData* image) {
00411 params["filter_type"] = KAISER_I0_INVERSE;
00412 EMFourierFilterInPlace(image, params);
00413 }
00414 TypeDict get_param_types() const
00415 {
00416 TypeDict d = NewFourierProcessor::get_param_types();
00417 return d;
00418 }
00419
00420 static const string NAME;
00421 };
00422
00425 class InverseKaiserSinhProcessor:public NewFourierProcessor
00426 {
00427 public:
00428 string get_name() const
00429 { return NAME; }
00430 static Processor *NEW()
00431 { return new InverseKaiserSinhProcessor(); }
00432 string get_desc() const
00433 {
00434 return "Divide by a Kaiser-Bessel Sinh func in Fourier space.";
00435 }
00436 void process_inplace(EMData* image) {
00437 params["filter_type"] = KAISER_SINH_INVERSE;
00438 EMFourierFilterInPlace(image, params);
00439 }
00440 TypeDict get_param_types() const
00441 {
00442 TypeDict d = NewFourierProcessor::get_param_types();
00443 return d;
00444 }
00445
00446 static const string NAME;
00447 };
00448
00452 class NewRadialTableProcessor:public NewFourierProcessor
00453 {
00454 public:
00455 string get_name() const
00456 { return NAME; }
00457
00458 static Processor *NEW()
00459 { return new NewRadialTableProcessor(); }
00460
00461 string get_desc() const
00462 {
00463 return "Filter with tabulated data in Fourier space. 1 value per Fourier pixel, extending to corners. Missing value assumed to be 0.";
00464 }
00465 void process_inplace(EMData* image) {
00466 params["filter_type"] = RADIAL_TABLE;
00467 EMFourierFilterInPlace(image, params);
00468 }
00469 TypeDict get_param_types() const
00470 {
00471
00472 TypeDict d;
00473 d.put("table", EMObject::FLOATARRAY, "Radial data array. 1 value per Fourier image pixel.");
00474 return d;
00475 }
00476
00477 static const string NAME;
00478 };
00479
00484 class NewLowpassButterworthProcessor:public NewFourierProcessor
00485 {
00486 public:
00487 string get_name() const
00488 { return NAME; }
00489 static Processor *NEW()
00490 { return new NewLowpassButterworthProcessor(); }
00491 string get_desc() const
00492 {
00493 return "Lowpass Butterworth filter processor applied in Fourier space.";
00494 }
00495 void process_inplace(EMData* image) {
00496 params["filter_type"] = BUTTERWORTH_LOW_PASS;
00497 EMFourierFilterInPlace(image, params);
00498 }
00499 TypeDict get_param_types() const
00500 {
00501 TypeDict d = NewFourierProcessor::get_param_types();
00502 d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00503 d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00504 return d;
00505 }
00506
00507 static const string NAME;
00508 };
00509
00514 class NewHighpassButterworthProcessor:public NewFourierProcessor
00515 {
00516 public:
00517 string get_name() const
00518 { return NAME; }
00519 static Processor *NEW()
00520 { return new NewHighpassButterworthProcessor(); }
00521 string get_desc() const
00522 {
00523 return "Highpass Butterworth filter processor applied in Fourier space.";
00524 }
00525 void process_inplace(EMData* image) {
00526 params["filter_type"] = BUTTERWORTH_HIGH_PASS;
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 return d;
00535 }
00536
00537 static const string NAME;
00538 };
00539
00545 class NewHomomorphicButterworthProcessor:public NewFourierProcessor
00546 {
00547 public:
00548 string get_name() const
00549 { return NAME; }
00550 static Processor *NEW()
00551 { return new NewHomomorphicButterworthProcessor(); }
00552 string get_desc() const
00553 {
00554 return "Homomorphic Butterworth filter processor applied in Fourier space.";
00555 }
00556 void process_inplace(EMData* image) {
00557 params["filter_type"] = BUTTERWORTH_HOMOMORPHIC;
00558 EMFourierFilterInPlace(image, params);
00559 }
00560 TypeDict get_param_types() const
00561 {
00562 TypeDict d = NewFourierProcessor::get_param_types();
00563 d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00564 d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00565 d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00566 return d;
00567 }
00568
00569 static const string NAME;
00570 };
00571
00576 class NewLowpassTanhProcessor:public NewFourierProcessor
00577 {
00578 public:
00579 string get_name() const
00580 { return NAME; }
00581 static Processor *NEW()
00582 { return new NewLowpassTanhProcessor(); }
00583 string get_desc() const
00584 {
00585 return "Lowpass tanh filter processor applied in Fourier space.";
00586 }
00587 void process_inplace(EMData* image) {
00588 params["filter_type"] = TANH_LOW_PASS;
00589 preprocess(image);
00590 params.set_default("fall_off",.5f);
00591 EMFourierFilterInPlace(image, params);
00592 }
00593 TypeDict get_param_types() const
00594 {
00595 TypeDict d = NewFourierProcessor::get_param_types();
00596 d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00597 return d;
00598 }
00599
00600 static const string NAME;
00601 };
00602
00607 class NewHighpassTanhProcessor:public NewFourierProcessor
00608 {
00609 public:
00610 string get_name() const
00611 { return NAME; }
00612 static Processor *NEW()
00613 { return new NewHighpassTanhProcessor(); }
00614 string get_desc() const
00615 {
00616 return "Highpass tanh filter processor applied in Fourier space.";
00617 }
00618 void process_inplace(EMData* image) {
00619 params["filter_type"] = TANH_HIGH_PASS;
00620 params.set_default("fall_off",.5f);
00621 preprocess(image);
00622 EMFourierFilterInPlace(image, params);
00623 }
00624 TypeDict get_param_types() const
00625 {
00626 TypeDict d = NewFourierProcessor::get_param_types();
00627 d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00628 return d;
00629 }
00630
00631 static const string NAME;
00632 };
00633
00639 class NewHomomorphicTanhProcessor:public NewFourierProcessor
00640 {
00641 public:
00642 string get_name() const
00643 { return NAME; }
00644 static Processor *NEW()
00645 { return new NewHomomorphicTanhProcessor(); }
00646 string get_desc() const
00647 {
00648 return "Homomorphic Tanh processor applied in Fourier space";
00649 }
00650 void process_inplace(EMData* image) {
00651 params["filter_type"] = TANH_HOMOMORPHIC;
00652 params.set_default("fall_off",.5f);
00653 preprocess(image);
00654 EMFourierFilterInPlace(image, params);
00655 }
00656 TypeDict get_param_types() const
00657 {
00658 TypeDict d = NewFourierProcessor::get_param_types();
00659 d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00660 d.put("value_at_zero_frequency", EMObject::FLOAT, "Value at zero frequency.");
00661 return d;
00662 }
00663
00664 static const string NAME;
00665 };
00666
00674 class NewBandpassTanhProcessor:public NewFourierProcessor
00675 {
00676 public:
00677 string get_name() const
00678 { return NAME; }
00679 static Processor *NEW()
00680 { return new NewBandpassTanhProcessor(); }
00681 string get_desc() const
00682 {
00683 return "Bandpass tanh processor applied in Fourier space.";
00684 }
00685 void process_inplace(EMData* image) {
00686 params["filter_type"] = TANH_BAND_PASS;
00687 EMFourierFilterInPlace(image, params);
00688 }
00689 TypeDict get_param_types() const
00690 {
00691 TypeDict d = NewFourierProcessor::get_param_types();
00692 d.put("low_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] low cut-off frequency.");
00693 d.put("Low_fall_off", EMObject::FLOAT, "Tanh low decay rate.");
00694 d.put("high_cutoff_frequency", EMObject::FLOAT, "Absolute [0,0.5] high cut-off frequency.");
00695 d.put("high_fall_off", EMObject::FLOAT, "Tanh high decay rate.");
00696 d.put("fall_off", EMObject::FLOAT, "Tanh decay rate.");
00697 return d;
00698 }
00699
00700 static const string NAME;
00701 };
00702
00703 class CTF_Processor:public NewFourierProcessor
00704 {
00705 public:
00706 string get_name() const
00707 { return NAME; }
00708 static Processor *NEW()
00709 { return new CTF_Processor(); }
00710 string get_desc() const
00711 {
00712 return "CTF_ is applied in Fourier image.";
00713 }
00714 void process_inplace(EMData* image) {
00715 params["filter_type"] = CTF_;
00716 EMFourierFilterInPlace(image, params);
00717 }
00718 TypeDict get_param_types() const
00719 {
00720 TypeDict d = NewFourierProcessor::get_param_types();
00721 d.put("defocus", EMObject::FLOAT, "defocus value in Angstrom.");
00722 d.put("cs", EMObject::FLOAT, "cs in CM.");
00723 d.put("voltage", EMObject::FLOAT, "voltage in Kv.");
00724 d.put("ps", EMObject::FLOAT, "pixel size.");
00725 d.put("b_factor", EMObject::FLOAT, "Gaussian like evelope function (b_factor).");
00726 d.put("wgh", EMObject::FLOAT, "Amplitude contrast ratio.");
00727 d.put("sign", EMObject::FLOAT, "Sign of Contrast transfer function,and use -1 to compensate.");
00728 d.put("npow", EMObject::FLOAT, "power of transfer function.");
00729 return d;
00730 }
00731
00732 static const string NAME;
00733 };
00734 }
00735
00736 #endif //eman_processor_sparx_h__