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

EMAN::SymSearchProcessor Class Reference

Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel. More...

#include <processor.h>

Inheritance diagram for EMAN::SymSearchProcessor:

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

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 string get_desc () const
 Get the descrition of this specific processor.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "misc.symsearch"

Detailed Description

Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel.

Author:
Wen Jiang <wjiang@bcm.tmc.edu>
Date:
2005-1-9
Parameters:
sym[in] the list of symmetries to search
thresh[in] the minimal level of symmetry to be accepted (0-1)
output_symlabel[in] if output the symmetry label map in which the pixel value is the index of symmetry in the symmetry list
symlabel_map[out] the optional return map when output_symlabel=1

Definition at line 5226 of file processor.h.


Member Function Documentation

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

05237                 {
05238                         return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel.";
05239                 }

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

References NAME.

05232                 {
05233                         return NAME;
05234                 }

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

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

05247                 {
05248                         TypeDict d;
05249                         d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search");
05250                         d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)");
05251                         d.put("output_symlabel", EMObject::INT, "if output the symmetry label map in which the pixel value is the index of symmetry in the symmetry list");
05252                         d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1");
05253                         return d;
05254                 }

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

Definition at line 5241 of file processor.h.

05242                 {
05243                         return new SymSearchProcessor();
05244                 }

void SymSearchProcessor::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 5813 of file processor.cpp.

References EMAN::EMData::copy(), EMAN::Util::fast_floor(), EMAN::EMData::get_data(), EMAN::Symmetry3D::get_symmetries(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, EMAN::Dict::put(), EMAN::Dict::size(), t, EMAN::EMData::to_zero(), EMAN::Util::trilinear_interpolate(), v, and x.

05814 {
05815         if (!image) {
05816                 LOGWARN("NULL Image");
05817                 return;
05818         }
05819         float thresh = params["thresh"];
05820         int output_symlabel = params["output_symlabel"];
05821 
05822         // set up all the symmetry transforms for all the searched symmetries
05823         const vector<string> sym_list = params["sym"];
05824         int sym_num = sym_list.size();
05825         vector< vector< Transform > > transforms(sym_num);
05826         vector< float* > symvals(sym_num);
05827         for (int i =0; i < sym_num; i++) {
05828                 vector<Transform> sym_transform =  Symmetry3D::get_symmetries(sym_list[i]);
05829                 transforms[i] = sym_transform;
05830                 symvals[i] = new float[sym_transform.size()]; // new float(nsym);
05831         }
05832 
05833         EMData *orig = image->copy();
05834 
05835         image->to_zero();
05836 
05837         int nx= image->get_xsize();
05838         int ny= image->get_ysize();
05839         int nz= image->get_zsize();
05840         int xy = nx * ny;
05841         float * data = image->get_data();
05842         float * sdata = orig->get_data();
05843 
05844         EMData *symlabel = 0;
05845         float * ldata = symlabel->get_data();
05846         if (output_symlabel) {
05847                 symlabel = image->copy();
05848                 symlabel->to_zero();
05849                 ldata = symlabel->get_data();
05850         }
05851 
05852         for (int k = 0; k < nz; k++) {
05853                 for (int j = 0; j < ny; j++) {
05854                         for(int i = 0; i < nx; i++) {
05855                                 size_t index = k * nx * ny + j * nx + i;
05856                                 float val = sdata[ index ];
05857                                 float bestmean = val, bestsymlevel = FLT_MAX;
05858                                 int bestsym = 0;
05859                                 for( int sym = 0; sym< sym_num; sym++) {
05860                                         int cur_sym_num = transforms[sym].size();
05861                                         float *symval = symvals[sym];
05862                                         // first find out all the symmetry related location values
05863                                         for( int s = 0; s < cur_sym_num; s++){
05864                                                 Transform r = transforms[sym][s];
05865                                                 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2);
05866                                                 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2);
05867                                                 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2);
05868 
05869                                                 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1)
05870                                                         && z2 < (nz - 1)) {
05871                                                         float x = (float)Util::fast_floor(x2);
05872                                                         float y = (float)Util::fast_floor(y2);
05873                                                         float z = (float)Util::fast_floor(z2);
05874 
05875                                                         float t = x2 - x;
05876                                                         float u = y2 - y;
05877                                                         float v = z2 - z;
05878 
05879                                                         int ii = (int) (x + y * nx + z * xy);
05880 
05881                                                         symval[s]=
05882                                                                 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],
05883                                                                                                                         sdata[ii + nx + 1], sdata[ii + nx * ny],
05884                                                                                                                         sdata[ii + xy + 1], sdata[ii + xy + nx],
05885                                                                                                                         sdata[ii + xy + nx + 1], t, u, v);
05886                                                 }
05887                                                 else {
05888                                                         symval[s] = 0.0 ;
05889                                                 }
05890                                         }
05891                                         float tmean=0, tsigma=0;
05892                                         for( int s = 0; s < cur_sym_num; s++) {
05893                                                 tmean += symval[s];
05894                                                 tsigma += symval[s] * symval[s];
05895                                         }
05896                                         tmean /= cur_sym_num;
05897                                         tsigma = tsigma/cur_sym_num - tmean*tmean;
05898                                         if (tsigma < bestsymlevel ) {
05899                                                 bestsymlevel = tsigma;
05900                                                 bestmean = tmean;
05901                                                 bestsym = sym;
05902                                         }
05903                                 }
05904                                 if ( bestsymlevel > thresh) {
05905                                         if (output_symlabel) ldata[index] = (float)bestsym;
05906                                         data[index] = bestmean;
05907                                 }
05908                                 else {
05909                                         if (output_symlabel) ldata[index] = -1;
05910                                         data[index] = val;
05911                                 }
05912                         }
05913                 }
05914         }
05915         if( orig )
05916         {
05917                 delete orig;
05918                 orig = 0;
05919         }
05920         for (int i =0; i < sym_num; i++) {
05921                 if( symvals[i] )
05922                 {
05923                         delete symvals[i];
05924                         symvals[i] = 0;
05925                 }
05926         }
05927         if (symlabel) params.put("symlabel_map", EMObject(symlabel));
05928 }


Member Data Documentation

const string SymSearchProcessor::NAME = "misc.symsearch" [static]
 

Definition at line 5256 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:37:39 2010 for EMAN2 by  doxygen 1.4.4