EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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]

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

static ProcessorNEW ()

Static Public Attributes

static 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"
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 7091 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 7115 of file processor.h.

                {
                        return "Computes the DWT (discrete wavelet transform) of an image in one of 3 possible bases";
                }
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 7096 of file processor.h.

References NAME.

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

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

                {
                        TypeDict d;
                        d.put("type", EMObject::STRING, "'daub', 'harr' or 'bspl'");
                        d.put("dir", EMObject::INT, "1 for forward transform, -1 for inverse transform");
                        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)");
                        return d;
                }
static Processor* EMAN::WaveletProcessor::NEW ( ) [inline, static]

Definition at line 7101 of file processor.h.

                {
                        return new WaveletProcessor();
                }
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 8709 of file processor.cpp.

References EMAN::CutoffBlockProcessor::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, EMAN::Processor::params, and EMAN::EMData::set_value_at_fast().

{
        if (image->get_zsize() != 1) {
                        LOGERR("%s Processor doesn't support 3D", get_name().c_str());
                        throw ImageDimensionException("3D model not supported");
        }

        int i,nx,ny;
        const gsl_wavelet_type * T;
        nx=image->get_xsize();
        ny=image->get_ysize();

        if (nx != ny && ny!=1) throw ImageDimensionException("Wavelet transform only supports square images");
//      float l=log((float)nx)/log(2.0f);
//      if (l!=floor(l)) throw ImageDimensionException("Wavelet transform size must be power of 2");
        if( !Util::IsPower2(nx) )  throw ImageDimensionException("Wavelet transform size must be power of 2");

        // Unfortunately GSL works only on double() arrays
        // eventually we should put our own wavelet code in here
        // but this will work for now
        double *cpy = (double *)malloc(nx*ny*sizeof(double));

        for (i=0; i<nx*ny; i++) cpy[i]=image->get_value_at(i,0,0);

        string tp = (const char*)params["type"];
        if (tp=="daub") T=gsl_wavelet_daubechies;
        else if (tp=="harr") T=gsl_wavelet_haar;
        else if (tp=="bspl") T=gsl_wavelet_bspline;
        else throw InvalidStringException(tp,"Invalid wavelet name, 'daub', 'harr' or 'bspl'");

        int K=(int)params["ord"];
        gsl_wavelet_direction dir;

        if ((int)params["dir"]==1) dir=(gsl_wavelet_direction)1;        // defined as 'forward', but name is broken on mac
        else dir=(gsl_wavelet_direction)-1;     // backward

        gsl_wavelet *w = gsl_wavelet_alloc(T, K);
        gsl_wavelet_workspace *work = gsl_wavelet_workspace_alloc(nx);

        if (ny==1) gsl_wavelet_transform (w,cpy, 1, nx, dir, work);
        else gsl_wavelet2d_transform (w, cpy, nx,nx,ny, dir, work);

        gsl_wavelet_workspace_free (work);
        gsl_wavelet_free (w);

        for (i=0; i<nx*ny; i++) image->set_value_at_fast(i,0,0,static_cast<float>(cpy[i]));

        free(cpy);
}

Member Data Documentation

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

Definition at line 7120 of file processor.h.

Referenced by get_name().


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