EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
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]

Public Member Functions

string get_name () const
 Get the processor's name. More...
 
void process_inplace (EMData *image)
 To process an image in-place. More...
 
void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "filter.ampweight"
 

Protected Attributes

EMDatasum
 
int dosqrt
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 

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 591 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::AmpweightFourierProcessor::get_desc ( ) const
inlinevirtual

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 622 of file processor.h.

623 {
624 return "Multiplies each Fourier pixel by its amplitude";
625 }

◆ get_name()

string EMAN::AmpweightFourierProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 594 of file processor.h.

595 {
596 return NAME;
597 }
static const string NAME
Definition: processor.h:627

References NAME.

◆ get_param_types()

TypeDict EMAN::AmpweightFourierProcessor::get_param_types ( ) const
inlinevirtual

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 609 of file processor.h.

610 {
611 TypeDict d;
612 d.put("sum", EMObject::EMDATA, "Adds the weights to sum for normalization");
613 d.put("sqrt", EMObject::INT, "Weights using sqrt of the amplitude if set");
614 return d;
615 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

static Processor * EMAN::AmpweightFourierProcessor::NEW ( )
inlinestatic

Definition at line 617 of file processor.h.

618 {
619 return new AmpweightFourierProcessor();
620 }
Multiplies each Fourier pixel by its amplitude.
Definition: processor.h:592

◆ process_inplace()

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 1380 of file processor.cpp.

1381{
1382 EMData *fft;
1383 float *fftd;
1384 int f=0;
1385// static float sum1=0,sum1a=0;
1386// static double sum2=0,sum2a=0;
1387
1388 if (!image) {
1389 LOGWARN("NULL Image");
1390 return;
1391 }
1392
1393 if (!image->is_complex()) {
1394 fft = image->do_fft();
1395 fftd = fft->get_data();
1396 f=1;
1397 }
1398 else {
1399 fft=image;
1400 fftd=image->get_data();
1401 }
1402 float *sumd = NULL;
1403 if (sum) sumd=sum->get_data();
1404//printf("%d %d %d %d\n",fft->get_xsize(),fft->get_ysize(),sum->get_xsize(),sum->get_ysize());
1405 size_t n = (size_t)fft->get_xsize()*fft->get_ysize()*fft->get_zsize();
1406 for (size_t i=0; i<n; i+=2) {
1407 float c;
1408 if (dosqrt) c=pow(fftd[i]*fftd[i]+fftd[i+1]*fftd[i+1],0.25f);
1409 else c = static_cast<float>(hypot(fftd[i],fftd[i+1]));
1410 if (c==0) c=1.0e-30f; // prevents divide by zero in normalization
1411 fftd[i]*=c;
1412 fftd[i+1]*=c;
1413 if (sumd) { sumd[i]+=c; sumd[i+1]+=0; }
1414
1415 // debugging
1416/* if (i==290*1+12) {
1417 sum1+=fftd[i];
1418 sum2+=fftd[i];
1419 printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1,sum2,fftd[i],fftd[i+1],sumd[i],c);
1420 }
1421 if (i==290*50+60) {
1422 sum1a+=fftd[i];
1423 sum2a+=fftd[i];
1424 printf("%f\t%f\t%f\t%f\t%f\t%f\n",sum1a,sum2a,fftd[i],fftd[i+1],sumd[i],c);
1425 }*/
1426 }
1427
1428 if (f) {
1429 fft->update();
1430 EMData *ift=fft->do_ift();
1431 memcpy(image->get_data(),ift->get_data(),n*sizeof(float));
1432 delete fft;
1433 delete ift;
1434 }
1435
1436 sum->update();
1437 image->update();
1438
1439}
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
#define LOGWARN
Definition: log.h:53

References dosqrt, LOGWARN, and sum.

◆ set_params()

void EMAN::AmpweightFourierProcessor::set_params ( const Dict new_params)
inlinevirtual

Set the processor parameters using a key/value dictionary.

Parameters
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 601 of file processor.h.

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

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

Member Data Documentation

◆ dosqrt

int EMAN::AmpweightFourierProcessor::dosqrt
protected

Definition at line 631 of file processor.h.

Referenced by process_inplace(), and set_params().

◆ NAME

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

Definition at line 627 of file processor.h.

Referenced by get_name().

◆ sum

EMData* EMAN::AmpweightFourierProcessor::sum
protected

Definition at line 630 of file processor.h.

Referenced by process_inplace(), and set_params().


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