#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 5310 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 5320 of file processor.h. 05321 { 05322 return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel."; 05323 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5315 of file processor.h. 05316 {
05317 return NAME;
05318 }
|
|
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 5330 of file processor.h. References EMAN::TypeDict::put(). 05331 { 05332 TypeDict d; 05333 d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search"); 05334 d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)"); 05335 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"); 05336 d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1"); 05337 return d; 05338 }
|
|
Definition at line 5325 of file processor.h. 05326 { 05327 return new SymSearchProcessor(); 05328 }
|
|
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 6103 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. 06104 { 06105 if (!image) { 06106 LOGWARN("NULL Image"); 06107 return; 06108 } 06109 float thresh = params["thresh"]; 06110 int output_symlabel = params["output_symlabel"]; 06111 06112 // set up all the symmetry transforms for all the searched symmetries 06113 const vector<string> sym_list = params["sym"]; 06114 int sym_num = sym_list.size(); 06115 vector< vector< Transform > > transforms(sym_num); 06116 vector< float* > symvals(sym_num); 06117 for (int i =0; i < sym_num; i++) { 06118 vector<Transform> sym_transform = Symmetry3D::get_symmetries(sym_list[i]); 06119 transforms[i] = sym_transform; 06120 symvals[i] = new float[sym_transform.size()]; // new float(nsym); 06121 } 06122 06123 EMData *orig = image->copy(); 06124 06125 image->to_zero(); 06126 06127 int nx= image->get_xsize(); 06128 int ny= image->get_ysize(); 06129 int nz= image->get_zsize(); 06130 int xy = nx * ny; 06131 float * data = image->get_data(); 06132 float * sdata = orig->get_data(); 06133 06134 EMData *symlabel = 0; 06135 float * ldata = symlabel->get_data(); 06136 if (output_symlabel) { 06137 symlabel = image->copy(); 06138 symlabel->to_zero(); 06139 ldata = symlabel->get_data(); 06140 } 06141 06142 for (int k = 0; k < nz; k++) { 06143 for (int j = 0; j < ny; j++) { 06144 for(int i = 0; i < nx; i++) { 06145 size_t index = (size_t)k * nx * ny + j * nx + i; 06146 float val = sdata[ index ]; 06147 float bestmean = val, bestsymlevel = FLT_MAX; 06148 int bestsym = 0; 06149 for( int sym = 0; sym< sym_num; sym++) { 06150 int cur_sym_num = transforms[sym].size(); 06151 float *symval = symvals[sym]; 06152 // first find out all the symmetry related location values 06153 for( int s = 0; s < cur_sym_num; s++){ 06154 Transform r = transforms[sym][s]; 06155 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2); 06156 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2); 06157 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2); 06158 06159 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1) 06160 && z2 < (nz - 1)) { 06161 float x = (float)Util::fast_floor(x2); 06162 float y = (float)Util::fast_floor(y2); 06163 float z = (float)Util::fast_floor(z2); 06164 06165 float t = x2 - x; 06166 float u = y2 - y; 06167 float v = z2 - z; 06168 06169 size_t ii = x + y * nx + z * (size_t)xy; 06170 06171 symval[s]= 06172 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], 06173 sdata[ii + nx + 1], sdata[ii + nx * ny], 06174 sdata[ii + xy + 1], sdata[ii + xy + nx], 06175 sdata[ii + xy + nx + 1], t, u, v); 06176 } 06177 else { 06178 symval[s] = 0.0 ; 06179 } 06180 } 06181 float tmean=0, tsigma=0; 06182 for( int s = 0; s < cur_sym_num; s++) { 06183 tmean += symval[s]; 06184 tsigma += symval[s] * symval[s]; 06185 } 06186 tmean /= cur_sym_num; 06187 tsigma = tsigma/cur_sym_num - tmean*tmean; 06188 if (tsigma < bestsymlevel ) { 06189 bestsymlevel = tsigma; 06190 bestmean = tmean; 06191 bestsym = sym; 06192 } 06193 } 06194 if ( bestsymlevel > thresh) { 06195 if (output_symlabel) ldata[index] = (float)bestsym; 06196 data[index] = bestmean; 06197 } 06198 else { 06199 if (output_symlabel) ldata[index] = -1; 06200 data[index] = val; 06201 } 06202 } 06203 } 06204 } 06205 if( orig ) 06206 { 06207 delete orig; 06208 orig = 0; 06209 } 06210 for (int i =0; i < sym_num; i++) { 06211 if( symvals[i] ) 06212 { 06213 delete symvals[i]; 06214 symvals[i] = 0; 06215 } 06216 } 06217 if (symlabel) params.put("symlabel_map", EMObject(symlabel)); 06218 }
|
|
Definition at line 176 of file processor.cpp. |