EMAN::AmpweightFourierProcessor Class Reference

Multiplies each Fourier pixel by its amplitude. More...

#include <processor.h>

Inheritance diagram for EMAN::AmpweightFourierProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::AmpweightFourierProcessor:

Collaboration graph
[legend]
List of all members.

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 ProcessorNEW ()

Static Public Attributes

static const string NAME = "filter.ampweight"

Protected Attributes

EMDatasum
int dosqrt

Detailed Description

Multiplies each Fourier pixel by its amplitude.

Parameters:
sum Adds the weights to sum for normalization
sqrt Weights using sqrt of the amplitude if set

Definition at line 468 of file processor.h.


Member Function Documentation

string EMAN::AmpweightFourierProcessor::get_desc (  )  const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 499 of file processor.h.

00500                 {
00501                         return "Multiplies each Fourier pixel by its amplitude";
00502                 }

string EMAN::AmpweightFourierProcessor::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 471 of file processor.h.

References NAME.

00472                 {
00473                         return NAME;
00474                 }

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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 486 of file processor.h.

References EMAN::EMObject::EMDATA, EMAN::EMObject::INT, and EMAN::TypeDict::put().

00487                 {
00488                         TypeDict d;
00489                         d.put("sum", EMObject::EMDATA, "Adds the weights to sum for normalization");
00490                         d.put("sqrt", EMObject::INT, "Weights using sqrt of the amplitude if set");
00491                         return d;
00492                 }

static Processor* EMAN::AmpweightFourierProcessor::NEW (  )  [inline, static]

Definition at line 494 of file processor.h.

00495                 {
00496                         return new AmpweightFourierProcessor();
00497                 }

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.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 716 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().

00717 {
00718         EMData *fft;
00719         float *fftd;
00720         int f=0;
00721 //      static float sum1=0,sum1a=0;
00722 //      static double sum2=0,sum2a=0;
00723 
00724         if (!image) {
00725                 LOGWARN("NULL Image");
00726                 return;
00727         }
00728 
00729         if (!image->is_complex()) {
00730                 fft = image->do_fft();
00731                 fftd = fft->get_data();
00732                 f=1;
00733         }
00734         else {
00735                 fft=image;
00736                 fftd=image->get_data();
00737         }
00738         float *sumd = NULL;
00739         if (sum) sumd=sum->get_data();
00740 //printf("%d %d    %d %d\n",fft->get_xsize(),fft->get_ysize(),sum->get_xsize(),sum->get_ysize());
00741         size_t n = (size_t)fft->get_xsize()*fft->get_ysize()*fft->get_zsize();
00742         for (size_t i=0; i<n; i+=2) {
00743                 float c;
00744                 if (dosqrt) c=pow(fftd[i]*fftd[i]+fftd[i+1]*fftd[i+1],0.25f);
00745 #ifdef  _WIN32
00746                 else c = static_cast<float>(_hypot(fftd[i],fftd[i+1]));
00747 #else
00748                 else c = static_cast<float>(hypot(fftd[i],fftd[i+1]));
00749 #endif  //_WIN32
00750                 if (c==0) c=1.0e-30f;   // prevents divide by zero in normalization
00751                 fftd[i]*=c;
00752                 fftd[i+1]*=c;
00753                 if (sumd) { sumd[i]+=c; sumd[i+1]+=0; }
00754 
00755                 // debugging
00756 /*              if (i==290*1+12) {
00757                         sum1+=fftd[i];
00758                         sum2+=fftd[i];
00759                         printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1,sum2,fftd[i],fftd[i+1],sumd[i],c);
00760                 }
00761                 if (i==290*50+60) {
00762                         sum1a+=fftd[i];
00763                         sum2a+=fftd[i];
00764                         printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1a,sum2a,fftd[i],fftd[i+1],sumd[i],c);
00765         }*/
00766         }
00767 
00768         if (f) {
00769                 fft->update();
00770                 EMData *ift=fft->do_ift();
00771                 memcpy(image->get_data(),ift->get_data(),n*sizeof(float));
00772                 delete fft;
00773                 delete ift;
00774         }
00775 
00776         sum->update();
00777         image->update();
00778 
00779 }

void EMAN::AmpweightFourierProcessor::set_params ( const Dict new_params  )  [inline, virtual]

Set the processor parameters using a key/value dictionary.

Parameters:
new_params A dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 478 of file processor.h.

References dosqrt, EMAN::Processor::params, and sum.

00479                 {
00480                         params = new_params;
00481                         sum = params["sum"];
00482                         dosqrt = params["sqrt"];
00483 //                      printf("%s %f\n",params.keys()[0].c_str(),lowpass);
00484                 }


Member Data Documentation

int EMAN::AmpweightFourierProcessor::dosqrt [protected]

Definition at line 508 of file processor.h.

Referenced by process_inplace(), and set_params().

const string AmpweightFourierProcessor::NAME = "filter.ampweight" [static]

Definition at line 504 of file processor.h.

Referenced by get_name().

EMData* EMAN::AmpweightFourierProcessor::sum [protected]

Definition at line 507 of file processor.h.

Referenced by process_inplace(), and set_params().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:09:34 2012 for EMAN2 by  doxygen 1.4.7