#include <processor.h>
Inheritance diagram for EMAN::WaveletProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "basis.wavelet" |
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 6596 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6620 of file processor.h. 06621 { 06622 return "Computes the DWT (discrete wavelet transform) of an image in one of 3 possible bases"; 06623 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6601 of file processor.h. References NAME. Referenced by process_inplace(). 06602 { 06603 return NAME; 06604 }
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 6611 of file processor.h. References EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING. 06612 { 06613 TypeDict d; 06614 d.put("type", EMObject::STRING, "'daub', 'harr' or 'bspl'"); 06615 d.put("dir", EMObject::INT, "1 for forward transform, -1 for inverse transform"); 06616 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)"); 06617 return d; 06618 }
|
|
Definition at line 6606 of file processor.h. 06607 { 06608 return new WaveletProcessor(); 06609 }
|
|
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.
Implements EMAN::Processor. Definition at line 7931 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, EMAN::Processor::params, and EMAN::EMData::set_value_at_fast(). 07932 { 07933 if (image->get_zsize() != 1) { 07934 LOGERR("%s Processor doesn't support 3D", get_name().c_str()); 07935 throw ImageDimensionException("3D model not supported"); 07936 } 07937 07938 int i,nx,ny; 07939 const gsl_wavelet_type * T; 07940 nx=image->get_xsize(); 07941 ny=image->get_ysize(); 07942 07943 if (nx != ny && ny!=1) throw ImageDimensionException("Wavelet transform only supports square images"); 07944 // float l=log((float)nx)/log(2.0f); 07945 // if (l!=floor(l)) throw ImageDimensionException("Wavelet transform size must be power of 2"); 07946 if( !Util::IsPower2(nx) ) throw ImageDimensionException("Wavelet transform size must be power of 2"); 07947 07948 // Unfortunately GSL works only on double() arrays 07949 // eventually we should put our own wavelet code in here 07950 // but this will work for now 07951 double *cpy = (double *)malloc(nx*ny*sizeof(double)); 07952 07953 for (i=0; i<nx*ny; i++) cpy[i]=image->get_value_at(i,0,0); 07954 07955 string tp = (const char*)params["type"]; 07956 if (tp=="daub") T=gsl_wavelet_daubechies; 07957 else if (tp=="harr") T=gsl_wavelet_haar; 07958 else if (tp=="bspl") T=gsl_wavelet_bspline; 07959 else throw InvalidStringException(tp,"Invalid wavelet name, 'daub', 'harr' or 'bspl'"); 07960 07961 int K=(int)params["ord"]; 07962 gsl_wavelet_direction dir; 07963 if ((int)params["dir"]==1) dir=forward; 07964 else dir=backward; 07965 07966 gsl_wavelet *w = gsl_wavelet_alloc(T, K); 07967 gsl_wavelet_workspace *work = gsl_wavelet_workspace_alloc(nx); 07968 07969 if (ny==1) gsl_wavelet_transform (w,cpy, 1, nx, dir, work); 07970 else gsl_wavelet2d_transform (w, cpy, nx,nx,ny, dir, work); 07971 07972 gsl_wavelet_workspace_free (work); 07973 gsl_wavelet_free (w); 07974 07975 for (i=0; i<nx*ny; i++) image->set_value_at_fast(i,0,0,static_cast<float>(cpy[i])); 07976 07977 free(cpy); 07978 }
|
|
Definition at line 6625 of file processor.h. Referenced by get_name(). |