#include <processor.h>
Inheritance diagram for EMAN::SymSearchProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "misc.symsearch" |
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 5306 of file processor.h.
virtual string EMAN::SymSearchProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 5316 of file processor.h.
05317 { 05318 return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel."; 05319 }
virtual string EMAN::SymSearchProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5311 of file processor.h.
References NAME.
05312 { 05313 return NAME; 05314 }
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.
Reimplemented from EMAN::Processor.
Definition at line 5326 of file processor.h.
References EMAN::EMObject::EMDATA, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRINGARRAY.
05327 { 05328 TypeDict d; 05329 d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search"); 05330 d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)"); 05331 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"); 05332 d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1"); 05333 return d; 05334 }
static Processor* EMAN::SymSearchProcessor::NEW | ( | ) | [inline, static] |
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 6034 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.
06035 { 06036 if (!image) { 06037 LOGWARN("NULL Image"); 06038 return; 06039 } 06040 float thresh = params["thresh"]; 06041 int output_symlabel = params["output_symlabel"]; 06042 06043 // set up all the symmetry transforms for all the searched symmetries 06044 const vector<string> sym_list = params["sym"]; 06045 int sym_num = sym_list.size(); 06046 vector< vector< Transform > > transforms(sym_num); 06047 vector< float* > symvals(sym_num); 06048 for (int i =0; i < sym_num; i++) { 06049 vector<Transform> sym_transform = Symmetry3D::get_symmetries(sym_list[i]); 06050 transforms[i] = sym_transform; 06051 symvals[i] = new float[sym_transform.size()]; // new float(nsym); 06052 } 06053 06054 EMData *orig = image->copy(); 06055 06056 image->to_zero(); 06057 06058 int nx= image->get_xsize(); 06059 int ny= image->get_ysize(); 06060 int nz= image->get_zsize(); 06061 int xy = nx * ny; 06062 float * data = image->get_data(); 06063 float * sdata = orig->get_data(); 06064 06065 EMData *symlabel = 0; 06066 float * ldata = symlabel->get_data(); 06067 if (output_symlabel) { 06068 symlabel = image->copy(); 06069 symlabel->to_zero(); 06070 ldata = symlabel->get_data(); 06071 } 06072 06073 for (int k = 0; k < nz; k++) { 06074 for (int j = 0; j < ny; j++) { 06075 for(int i = 0; i < nx; i++) { 06076 size_t index = (size_t)k * nx * ny + j * nx + i; 06077 float val = sdata[ index ]; 06078 float bestmean = val, bestsymlevel = FLT_MAX; 06079 int bestsym = 0; 06080 for( int sym = 0; sym< sym_num; sym++) { 06081 int cur_sym_num = transforms[sym].size(); 06082 float *symval = symvals[sym]; 06083 // first find out all the symmetry related location values 06084 for( int s = 0; s < cur_sym_num; s++){ 06085 Transform r = transforms[sym][s]; 06086 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2); 06087 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2); 06088 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2); 06089 06090 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1) 06091 && z2 < (nz - 1)) { 06092 float x = (float)Util::fast_floor(x2); 06093 float y = (float)Util::fast_floor(y2); 06094 float z = (float)Util::fast_floor(z2); 06095 06096 float t = x2 - x; 06097 float u = y2 - y; 06098 float v = z2 - z; 06099 06100 size_t ii = x + y * nx + z * (size_t)xy; 06101 06102 symval[s]= 06103 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], 06104 sdata[ii + nx + 1], sdata[ii + nx * ny], 06105 sdata[ii + xy + 1], sdata[ii + xy + nx], 06106 sdata[ii + xy + nx + 1], t, u, v); 06107 } 06108 else { 06109 symval[s] = 0.0 ; 06110 } 06111 } 06112 float tmean=0, tsigma=0; 06113 for( int s = 0; s < cur_sym_num; s++) { 06114 tmean += symval[s]; 06115 tsigma += symval[s] * symval[s]; 06116 } 06117 tmean /= cur_sym_num; 06118 tsigma = tsigma/cur_sym_num - tmean*tmean; 06119 if (tsigma < bestsymlevel ) { 06120 bestsymlevel = tsigma; 06121 bestmean = tmean; 06122 bestsym = sym; 06123 } 06124 } 06125 if ( bestsymlevel > thresh) { 06126 if (output_symlabel) ldata[index] = (float)bestsym; 06127 data[index] = bestmean; 06128 } 06129 else { 06130 if (output_symlabel) ldata[index] = -1; 06131 data[index] = val; 06132 } 06133 } 06134 } 06135 } 06136 if( orig ) 06137 { 06138 delete orig; 06139 orig = 0; 06140 } 06141 for (int i =0; i < sym_num; i++) { 06142 if( symvals[i] ) 06143 { 06144 delete symvals[i]; 06145 symvals[i] = 0; 06146 } 06147 } 06148 if (symlabel) params.put("symlabel_map", EMObject(symlabel)); 06149 }
const string SymSearchProcessor::NAME = "misc.symsearch" [static] |