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

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

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

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

Author
Wen Jiang wjian.nosp@m.g@bc.nosp@m.m.tmc.nosp@m..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 7359 of file processor.h.

Member Function Documentation

◆ get_desc()

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

7370 {
7371 return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel.";
7372 }

◆ get_name()

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

7365 {
7366 return NAME;
7367 }
static const string NAME
Definition: processor.h:7389

References NAME.

◆ get_param_types()

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

7380 {
7381 TypeDict d;
7382 d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search");
7383 d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)");
7384 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");
7385 d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1");
7386 return d;
7387 }
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::EMDATA, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRINGARRAY.

◆ NEW()

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

Definition at line 7374 of file processor.h.

7375 {
7376 return new SymSearchProcessor();
7377 }
Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetr...
Definition: processor.h:7360

◆ process_inplace()

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

Implements EMAN::Processor.

Definition at line 8000 of file processor.cpp.

8001{
8002 if (!image) {
8003 LOGWARN("NULL Image");
8004 return;
8005 }
8006 float thresh = params["thresh"];
8007 int output_symlabel = params["output_symlabel"];
8008
8009 // set up all the symmetry transforms for all the searched symmetries
8010 const vector<string> sym_list = params["sym"];
8011 int sym_num = sym_list.size();
8012 vector< vector< Transform > > transforms(sym_num);
8013 vector< float* > symvals(sym_num);
8014 for (int i =0; i < sym_num; i++) {
8015 vector<Transform> sym_transform = Symmetry3D::get_symmetries(sym_list[i]);
8016 transforms[i] = sym_transform;
8017 symvals[i] = new float[sym_transform.size()]; // new float(nsym);
8018 }
8019
8020 EMData *orig = image->copy();
8021
8022 image->to_zero();
8023
8024 int nx= image->get_xsize();
8025 int ny= image->get_ysize();
8026 int nz= image->get_zsize();
8027 int xy = nx * ny;
8028 float * data = image->get_data();
8029 float * sdata = orig->get_data();
8030
8031 EMData *symlabel = 0;
8032 float * ldata = symlabel->get_data();
8033 if (output_symlabel) {
8034 symlabel = image->copy();
8035 symlabel->to_zero();
8036 ldata = symlabel->get_data();
8037 }
8038
8039 for (int k = 0; k < nz; k++) {
8040 for (int j = 0; j < ny; j++) {
8041 for(int i = 0; i < nx; i++) {
8042 size_t index = (size_t)k * nx * ny + j * nx + i;
8043 float val = sdata[ index ];
8044 float bestmean = val, bestsymlevel = FLT_MAX;
8045 int bestsym = 0;
8046 for( int sym = 0; sym< sym_num; sym++) {
8047 int cur_sym_num = transforms[sym].size();
8048 float *symval = symvals[sym];
8049 // first find out all the symmetry related location values
8050 for( int s = 0; s < cur_sym_num; s++){
8051 Transform r = transforms[sym][s];
8052 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2);
8053 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2);
8054 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2);
8055
8056 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1)
8057 && z2 < (nz - 1)) {
8058 float x = (float)Util::fast_floor(x2);
8059 float y = (float)Util::fast_floor(y2);
8060 float z = (float)Util::fast_floor(z2);
8061
8062 float t = x2 - x;
8063 float u = y2 - y;
8064 float v = z2 - z;
8065
8066 size_t ii = x + y * nx + z * (size_t)xy;
8067
8068 symval[s]=
8069 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],
8070 sdata[ii + nx + 1], sdata[ii + nx * ny],
8071 sdata[ii + xy + 1], sdata[ii + xy + nx],
8072 sdata[ii + xy + nx + 1], t, u, v);
8073 }
8074 else {
8075 symval[s] = 0.0 ;
8076 }
8077 }
8078 float tmean=0, tsigma=0;
8079 for( int s = 0; s < cur_sym_num; s++) {
8080 tmean += symval[s];
8081 tsigma += symval[s] * symval[s];
8082 }
8083 tmean /= cur_sym_num;
8084 tsigma = tsigma/cur_sym_num - tmean*tmean;
8085 if (tsigma < bestsymlevel ) {
8086 bestsymlevel = tsigma;
8087 bestmean = tmean;
8088 bestsym = sym;
8089 }
8090 }
8091 if ( bestsymlevel > thresh) {
8092 if (output_symlabel) ldata[index] = (float)bestsym;
8093 data[index] = bestmean;
8094 }
8095 else {
8096 if (output_symlabel) ldata[index] = -1;
8097 data[index] = val;
8098 }
8099 }
8100 }
8101 }
8102 if( orig )
8103 {
8104 delete orig;
8105 orig = 0;
8106 }
8107 for (int i =0; i < sym_num; i++) {
8108 if( symvals[i] )
8109 {
8110 delete symvals[i];
8111 symvals[i] = 0;
8112 }
8113 }
8114 if (symlabel) params.put("symlabel_map", EMObject(symlabel));
8115}
size_t size() const
Ask the Dictionary for its size.
Definition: emobject.h:519
void put(const string &key, EMObject val)
Put the value/key pair into the dictionary probably better to just use operator[].
Definition: emobject.h:545
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
Definition: emobject.h:123
static vector< Transform > get_symmetries(const string &symmetry)
Definition: symmetry.cpp:1240
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
static int fast_floor(float x)
A fast way to calculate a floor, which is largest integral value not greater than argument.
Definition: util.h:874
static float trilinear_interpolate(float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8, float t, float u, float v)
Calculate trilinear interpolation.
Definition: util.h:619
#define LOGWARN
Definition: log.h:53
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::fast_floor(), EMAN::Symmetry3D::get_symmetries(), LOGWARN, EMAN::Processor::params, EMAN::Dict::put(), EMAN::Dict::size(), EMAN::Util::trilinear_interpolate(), x, and y.

Member Data Documentation

◆ NAME

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

Definition at line 7389 of file processor.h.

Referenced by get_name().


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