#include <processor.h>


Public Member Functions | |
| string | get_name () const |
| Get the processor's name. | |
| void | process_inplace (EMData *image) |
| To process an image in-place. | |
| void | set_params (const Dict &new_params) |
| Set the processor parameters using a key/value dictionary. | |
| TypeDict | get_param_types () const |
| Get processor parameter information in a dictionary. | |
| string | get_desc () const |
| Get the descrition of this specific processor. | |
Static Public Member Functions | |
| static Processor * | NEW () |
Static Public Attributes | |
| static const string | NAME = "filter.ampweight" |
Protected Attributes | |
| EMData * | sum |
| int | dosqrt |
| sum | Adds the weights to sum for normalization | |
| sqrt | Weights using sqrt of the amplitude if set |
Definition at line 443 of file processor.h.
| string EMAN::AmpweightFourierProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 446 of file processor.h.
References NAME.
00447 { 00448 return NAME; 00449 }
| void AmpweightFourierProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
To process an image in-place.
For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.
| image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 693 of file processor.cpp.
References EMAN::EMData::do_fft(), EMAN::EMData::do_ift(), dosqrt, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::is_complex(), LOGWARN, sum, and EMAN::EMData::update().
00694 { 00695 EMData *fft; 00696 float *fftd; 00697 int i,f=0; 00698 // static float sum1=0,sum1a=0; 00699 // static double sum2=0,sum2a=0; 00700 00701 if (!image) { 00702 LOGWARN("NULL Image"); 00703 return; 00704 } 00705 00706 if (!image->is_complex()) { 00707 fft = image->do_fft(); 00708 fftd = fft->get_data(); 00709 f=1; 00710 } 00711 else { 00712 fft=image; 00713 fftd=image->get_data(); 00714 } 00715 float *sumd = NULL; 00716 if (sum) sumd=sum->get_data(); 00717 //printf("%d %d %d %d\n",fft->get_xsize(),fft->get_ysize(),sum->get_xsize(),sum->get_ysize()); 00718 int n = fft->get_xsize()*fft->get_ysize()*fft->get_zsize(); 00719 for (i=0; i<n; i+=2) { 00720 float c; 00721 if (dosqrt) c=pow(fftd[i]*fftd[i]+fftd[i+1]*fftd[i+1],0.25f); 00722 #ifdef _WIN32 00723 else c = static_cast<float>(_hypot(fftd[i],fftd[i+1])); 00724 #else 00725 else c = static_cast<float>(hypot(fftd[i],fftd[i+1])); 00726 #endif //_WIN32 00727 if (c==0) c=1.0e-30f; // prevents divide by zero in normalization 00728 fftd[i]*=c; 00729 fftd[i+1]*=c; 00730 if (sumd) { sumd[i]+=c; sumd[i+1]+=0; } 00731 00732 // debugging 00733 /* if (i==290*1+12) { 00734 sum1+=fftd[i]; 00735 sum2+=fftd[i]; 00736 printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1,sum2,fftd[i],fftd[i+1],sumd[i],c); 00737 } 00738 if (i==290*50+60) { 00739 sum1a+=fftd[i]; 00740 sum2a+=fftd[i]; 00741 printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1a,sum2a,fftd[i],fftd[i+1],sumd[i],c); 00742 }*/ 00743 } 00744 00745 if (f) { 00746 fft->update(); 00747 EMData *ift=fft->do_ift(); 00748 memcpy(image->get_data(),ift->get_data(),n*sizeof(float)); 00749 delete fft; 00750 delete ift; 00751 } 00752 00753 sum->update(); 00754 image->update(); 00755 00756 }
| void EMAN::AmpweightFourierProcessor::set_params | ( | const Dict & | new_params | ) | [inline, virtual] |
Set the processor parameters using a key/value dictionary.
| new_params | A dictionary containing the new parameters. |
Reimplemented from EMAN::Processor.
Definition at line 453 of file processor.h.
References dosqrt, EMAN::Processor::params, and sum.
00454 { 00455 params = new_params; 00456 sum = params["sum"]; 00457 dosqrt = params["sqrt"]; 00458 // printf("%s %f\n",params.keys()[0].c_str(),lowpass); 00459 }
| TypeDict EMAN::AmpweightFourierProcessor::get_param_types | ( | ) | const [inline, virtual] |
Get processor parameter information in a dictionary.
Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor.
Definition at line 461 of file processor.h.
References EMAN::EMObject::EMDATA, EMAN::EMObject::INT, and EMAN::TypeDict::put().
00462 { 00463 TypeDict d; 00464 d.put("sum", EMObject::EMDATA, "Adds the weights to sum for normalization"); 00465 d.put("sqrt", EMObject::INT, "Weights using sqrt of the amplitude if set"); 00466 return d; 00467 }
| static Processor* EMAN::AmpweightFourierProcessor::NEW | ( | ) | [inline, static] |
Definition at line 469 of file processor.h.
00470 { 00471 return new AmpweightFourierProcessor(); 00472 }
| string EMAN::AmpweightFourierProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 474 of file processor.h.
const string AmpweightFourierProcessor::NAME = "filter.ampweight" [static] |
EMData* EMAN::AmpweightFourierProcessor::sum [protected] |
int EMAN::AmpweightFourierProcessor::dosqrt [protected] |
1.5.6