Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::WaveletProcessor Class Reference

Perform a Wavelet transform using GSL. More...

#include <processor.h>

Inheritance diagram for EMAN::WaveletProcessor:

[legend]
Collaboration diagram for EMAN::WaveletProcessor:
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "basis.wavelet"

Detailed Description

Perform a Wavelet transform using GSL.

Author:
Steve Ludtke <sludtke@bcm.edu>
Date:
10/15/2006
Parameters:
type "daub", "harr", or "bspl"
dir 1 for forward transform, -1 for inverse transform
ord for 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 6595 of file processor.h.


Member Function Documentation

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

06620                 {
06621                         return "Computes the DWT (discrete wavelet transform) of an image in one of 3 possible bases";
06622                 }

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

Referenced by process_inplace().

06601                 {
06602                         return NAME;
06603                 }

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

References EMAN::TypeDict::put().

06611                 {
06612                         TypeDict d;
06613                         d.put("type", EMObject::STRING, "'daub', 'harr' or 'bspl'");
06614                         d.put("dir", EMObject::INT, "1 for forward transform, -1 for inverse transform");
06615                         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)");
06616                         return d;
06617                 }

Processor* EMAN::WaveletProcessor::NEW  )  [inline, static]
 

Definition at line 6605 of file processor.h.

06606                 {
06607                         return new WaveletProcessor();
06608                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 7900 of file processor.cpp.

References get_name(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, InvalidStringException, EMAN::Util::IsPower2(), LOGERR, nx, ny, and EMAN::EMData::set_value_at_fast().

07901 {
07902         if (image->get_zsize() != 1) {
07903                         LOGERR("%s Processor doesn't support 3D", get_name().c_str());
07904                         throw ImageDimensionException("3D model not supported");
07905         }
07906 
07907         int i,nx,ny;
07908         const gsl_wavelet_type * T;
07909         nx=image->get_xsize();
07910         ny=image->get_ysize();
07911 
07912         if (nx != ny && ny!=1) throw ImageDimensionException("Wavelet transform only supports square images");
07913 //      float l=log((float)nx)/log(2.0f);
07914 //      if (l!=floor(l)) throw ImageDimensionException("Wavelet transform size must be power of 2");
07915         if( !Util::IsPower2(nx) )  throw ImageDimensionException("Wavelet transform size must be power of 2");
07916 
07917         // Unfortunately GSL works only on double() arrays
07918         // eventually we should put our own wavelet code in here
07919         // but this will work for now
07920         double *cpy = (double *)malloc(nx*ny*sizeof(double));
07921 
07922         for (i=0; i<nx*ny; i++) cpy[i]=image->get_value_at(i,0,0);
07923 
07924         string tp = (const char*)params["type"];
07925         if (tp=="daub") T=gsl_wavelet_daubechies;
07926         else if (tp=="harr") T=gsl_wavelet_haar;
07927         else if (tp=="bspl") T=gsl_wavelet_bspline;
07928         else throw InvalidStringException(tp,"Invalid wavelet name, 'daub', 'harr' or 'bspl'");
07929 
07930         int K=(int)params["ord"];
07931         gsl_wavelet_direction dir;
07932         if ((int)params["dir"]==1) dir=forward;
07933         else dir=backward;
07934 
07935         gsl_wavelet *w = gsl_wavelet_alloc(T, K);
07936         gsl_wavelet_workspace *work = gsl_wavelet_workspace_alloc(nx);
07937 
07938         if (ny==1) gsl_wavelet_transform (w,cpy, 1, nx, dir, work);
07939         else gsl_wavelet2d_transform (w, cpy, nx,nx,ny, dir, work);
07940 
07941         gsl_wavelet_workspace_free (work);
07942         gsl_wavelet_free (w);
07943 
07944         for (i=0; i<nx*ny; i++) image->set_value_at_fast(i,0,0,static_cast<float>(cpy[i]));
07945 
07946         free(cpy);
07947 }


Member Data Documentation

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

Definition at line 211 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:29 2010 for EMAN2 by  doxygen 1.3.9.1