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