#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 5192 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 5202 of file processor.h. 05203 { 05204 return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel."; 05205 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5197 of file processor.h. 05198 {
05199 return NAME;
05200 }
|
|
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 5212 of file processor.h. References EMAN::TypeDict::put(). 05213 { 05214 TypeDict d; 05215 d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search"); 05216 d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)"); 05217 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"); 05218 d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1"); 05219 return d; 05220 }
|
|
Definition at line 5207 of file processor.h. 05208 { 05209 return new SymSearchProcessor(); 05210 }
|
|
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 5848 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. 05849 { 05850 if (!image) { 05851 LOGWARN("NULL Image"); 05852 return; 05853 } 05854 float thresh = params["thresh"]; 05855 int output_symlabel = params["output_symlabel"]; 05856 05857 // set up all the symmetry transforms for all the searched symmetries 05858 const vector<string> sym_list = params["sym"]; 05859 int sym_num = sym_list.size(); 05860 vector< vector< Transform > > transforms(sym_num); 05861 vector< float* > symvals(sym_num); 05862 for (int i =0; i < sym_num; i++) { 05863 vector<Transform> sym_transform = Symmetry3D::get_symmetries(sym_list[i]); 05864 transforms[i] = sym_transform; 05865 symvals[i] = new float[sym_transform.size()]; // new float(nsym); 05866 } 05867 05868 EMData *orig = image->copy(); 05869 05870 image->to_zero(); 05871 05872 int nx= image->get_xsize(); 05873 int ny= image->get_ysize(); 05874 int nz= image->get_zsize(); 05875 int xy = nx * ny; 05876 float * data = image->get_data(); 05877 float * sdata = orig->get_data(); 05878 05879 EMData *symlabel = 0; 05880 float * ldata = symlabel->get_data(); 05881 if (output_symlabel) { 05882 symlabel = image->copy(); 05883 symlabel->to_zero(); 05884 ldata = symlabel->get_data(); 05885 } 05886 05887 for (int k = 0; k < nz; k++) { 05888 for (int j = 0; j < ny; j++) { 05889 for(int i = 0; i < nx; i++) { 05890 size_t index = (size_t)k * nx * ny + j * nx + i; 05891 float val = sdata[ index ]; 05892 float bestmean = val, bestsymlevel = FLT_MAX; 05893 int bestsym = 0; 05894 for( int sym = 0; sym< sym_num; sym++) { 05895 int cur_sym_num = transforms[sym].size(); 05896 float *symval = symvals[sym]; 05897 // first find out all the symmetry related location values 05898 for( int s = 0; s < cur_sym_num; s++){ 05899 Transform r = transforms[sym][s]; 05900 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2); 05901 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2); 05902 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2); 05903 05904 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1) 05905 && z2 < (nz - 1)) { 05906 float x = (float)Util::fast_floor(x2); 05907 float y = (float)Util::fast_floor(y2); 05908 float z = (float)Util::fast_floor(z2); 05909 05910 float t = x2 - x; 05911 float u = y2 - y; 05912 float v = z2 - z; 05913 05914 size_t ii = x + y * nx + z * (size_t)xy; 05915 05916 symval[s]= 05917 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], 05918 sdata[ii + nx + 1], sdata[ii + nx * ny], 05919 sdata[ii + xy + 1], sdata[ii + xy + nx], 05920 sdata[ii + xy + nx + 1], t, u, v); 05921 } 05922 else { 05923 symval[s] = 0.0 ; 05924 } 05925 } 05926 float tmean=0, tsigma=0; 05927 for( int s = 0; s < cur_sym_num; s++) { 05928 tmean += symval[s]; 05929 tsigma += symval[s] * symval[s]; 05930 } 05931 tmean /= cur_sym_num; 05932 tsigma = tsigma/cur_sym_num - tmean*tmean; 05933 if (tsigma < bestsymlevel ) { 05934 bestsymlevel = tsigma; 05935 bestmean = tmean; 05936 bestsym = sym; 05937 } 05938 } 05939 if ( bestsymlevel > thresh) { 05940 if (output_symlabel) ldata[index] = (float)bestsym; 05941 data[index] = bestmean; 05942 } 05943 else { 05944 if (output_symlabel) ldata[index] = -1; 05945 data[index] = val; 05946 } 05947 } 05948 } 05949 } 05950 if( orig ) 05951 { 05952 delete orig; 05953 orig = 0; 05954 } 05955 for (int i =0; i < sym_num; i++) { 05956 if( symvals[i] ) 05957 { 05958 delete symvals[i]; 05959 symvals[i] = 0; 05960 } 05961 } 05962 if (symlabel) params.put("symlabel_map", EMObject(symlabel)); 05963 }
|
|
Definition at line 175 of file processor.cpp. |