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