EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::WaveletProcessor Class Reference

Perform a Wavelet transform using GSL. More...

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
virtual 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...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using 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 = "basis.wavelet"
 

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...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Perform a Wavelet transform using GSL.

Author
Steve Ludtke sludt.nosp@m.ke@b.nosp@m.cm.ed.nosp@m.u
Date
10/15/2006
Parameters
type"daub", "harr", or "bspl"
dir1 for forward transform, -1 for inverse transform
ordfor Daubechies (4,6,8,...,20), for Harr (2), for B-Splines (103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309)

Definition at line 8958 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::WaveletProcessor::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 8982 of file processor.h.

8983 {
8984 return "Computes the DWT (discrete wavelet transform) of an image in one of 3 possible bases";
8985 }

◆ get_name()

virtual string EMAN::WaveletProcessor::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 8963 of file processor.h.

8964 {
8965 return NAME;
8966 }
static const string NAME
Definition: processor.h:8987

References NAME.

Referenced by process_inplace().

◆ get_param_types()

virtual TypeDict EMAN::WaveletProcessor::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 8973 of file processor.h.

8974 {
8975 TypeDict d;
8976 d.put("type", EMObject::STRING, "'daub', 'harr' or 'bspl'");
8977 d.put("dir", EMObject::INT, "1 for forward transform, -1 for inverse transform");
8978 d.put("ord", EMObject::INT, "Daubechies (4,6,8,...,20), for Harr (2), for B-Splines (103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309)");
8979 return d;
8980 }
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::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.

◆ NEW()

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

Definition at line 8968 of file processor.h.

8969 {
8970 return new WaveletProcessor();
8971 }
Perform a Wavelet transform using GSL.
Definition: processor.h:8959

◆ process_inplace()

void WaveletProcessor::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 10387 of file processor.cpp.

10388{
10389 if (image->get_zsize() != 1) {
10390 LOGERR("%s Processor doesn't support 3D", get_name().c_str());
10391 throw ImageDimensionException("3D model not supported");
10392 }
10393
10394 int i,nx,ny;
10395 const gsl_wavelet_type * T;
10396 nx=image->get_xsize();
10397 ny=image->get_ysize();
10398
10399 if (nx != ny && ny!=1) throw ImageDimensionException("Wavelet transform only supports square images");
10400// float l=log((float)nx)/log(2.0f);
10401// if (l!=floor(l)) throw ImageDimensionException("Wavelet transform size must be power of 2");
10402 if( !Util::IsPower2(nx) ) throw ImageDimensionException("Wavelet transform size must be power of 2");
10403
10404 // Unfortunately GSL works only on double() arrays
10405 // eventually we should put our own wavelet code in here
10406 // but this will work for now
10407 double *cpy = (double *)malloc(nx*ny*sizeof(double));
10408
10409 for (i=0; i<nx*ny; i++) cpy[i]=image->get_value_at(i,0,0);
10410
10411 string tp = (const char*)params["type"];
10412 if (tp=="daub") T=gsl_wavelet_daubechies;
10413 else if (tp=="harr") T=gsl_wavelet_haar;
10414 else if (tp=="bspl") T=gsl_wavelet_bspline;
10415 else throw InvalidStringException(tp,"Invalid wavelet name, 'daub', 'harr' or 'bspl'");
10416
10417 int K=(int)params["ord"];
10418 gsl_wavelet_direction dir;
10419
10420 if ((int)params["dir"]==1) dir=(gsl_wavelet_direction)1; // defined as 'forward', but name is broken on mac
10421 else dir=(gsl_wavelet_direction)-1; // backward
10422
10423 gsl_wavelet *w = gsl_wavelet_alloc(T, K);
10424 gsl_wavelet_workspace *work = gsl_wavelet_workspace_alloc(nx);
10425
10426 if (ny==1) gsl_wavelet_transform (w,cpy, 1, nx, dir, work);
10427 else gsl_wavelet2d_transform (w, cpy, nx,nx,ny, dir, work);
10428
10429 gsl_wavelet_workspace_free (work);
10430 gsl_wavelet_free (w);
10431
10432 for (i=0; i<nx*ny; i++) image->set_value_at_fast(i,0,0,static_cast<float>(cpy[i]));
10433
10434 free(cpy);
10435}
static bool IsPower2(int x)
Return true if an integer is positive and is power of 2.
Definition: util.h:1304
virtual string get_name() const
Get the processor's name.
Definition: processor.h:8963
#define InvalidStringException(str, desc)
Definition: exception.h:306
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGERR
Definition: log.h:51

References get_name(), ImageDimensionException, InvalidStringException, EMAN::Util::IsPower2(), LOGERR, and EMAN::Processor::params.

Member Data Documentation

◆ NAME

const string WaveletProcessor::NAME = "basis.wavelet"
static

Definition at line 8987 of file processor.h.

Referenced by get_name().


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