EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
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:
sumAdds the weights to sum for normalization
sqrtWeights using sqrt of the amplitude if set

Definition at line 511 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 542 of file processor.h.

                {
                        return "Multiplies each Fourier pixel by its amplitude";
                }
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 514 of file processor.h.

References NAME.

                {
                        return NAME;
                }
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 529 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("sum", EMObject::EMDATA, "Adds the weights to sum for normalization");
                        d.put("sqrt", EMObject::INT, "Weights using sqrt of the amplitude if set");
                        return d;
                }
static Processor* EMAN::AmpweightFourierProcessor::NEW ( ) [inline, static]

Definition at line 537 of file processor.h.

                {
                        return new AmpweightFourierProcessor();
                }
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:
imageThe image to be processed.

Implements EMAN::Processor.

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

{
        EMData *fft;
        float *fftd;
        int f=0;
//      static float sum1=0,sum1a=0;
//      static double sum2=0,sum2a=0;

        if (!image) {
                LOGWARN("NULL Image");
                return;
        }

        if (!image->is_complex()) {
                fft = image->do_fft();
                fftd = fft->get_data();
                f=1;
        }
        else {
                fft=image;
                fftd=image->get_data();
        }
        float *sumd = NULL;
        if (sum) sumd=sum->get_data();
//printf("%d %d    %d %d\n",fft->get_xsize(),fft->get_ysize(),sum->get_xsize(),sum->get_ysize());
        size_t n = (size_t)fft->get_xsize()*fft->get_ysize()*fft->get_zsize();
        for (size_t i=0; i<n; i+=2) {
                float c;
                if (dosqrt) c=pow(fftd[i]*fftd[i]+fftd[i+1]*fftd[i+1],0.25f);
#ifdef  _WIN32
                else c = static_cast<float>(_hypot(fftd[i],fftd[i+1]));
#else
                else c = static_cast<float>(hypot(fftd[i],fftd[i+1]));
#endif  //_WIN32
                if (c==0) c=1.0e-30f;   // prevents divide by zero in normalization
                fftd[i]*=c;
                fftd[i+1]*=c;
                if (sumd) { sumd[i]+=c; sumd[i+1]+=0; }

                // debugging
/*              if (i==290*1+12) {
                        sum1+=fftd[i];
                        sum2+=fftd[i];
                        printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1,sum2,fftd[i],fftd[i+1],sumd[i],c);
                }
                if (i==290*50+60) {
                        sum1a+=fftd[i];
                        sum2a+=fftd[i];
                        printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1a,sum2a,fftd[i],fftd[i+1],sumd[i],c);
        }*/
        }

        if (f) {
                fft->update();
                EMData *ift=fft->do_ift();
                memcpy(image->get_data(),ift->get_data(),n*sizeof(float));
                delete fft;
                delete ift;
        }

        sum->update();
        image->update();

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

Set the processor parameters using a key/value dictionary.

Parameters:
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 521 of file processor.h.

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

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

Member Data Documentation

Definition at line 551 of file processor.h.

Referenced by process_inplace(), and set_params().

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

Definition at line 547 of file processor.h.

Referenced by get_name().

Definition at line 550 of file processor.h.

Referenced by process_inplace(), and set_params().


The documentation for this class was generated from the following files: