#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 5225 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 5235 of file processor.h. 05236 { 05237 return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel."; 05238 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5230 of file processor.h. 05231 {
05232 return NAME;
05233 }
|
|
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 5245 of file processor.h. References EMAN::TypeDict::put(). 05246 { 05247 TypeDict d; 05248 d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search"); 05249 d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)"); 05250 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"); 05251 d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1"); 05252 return d; 05253 }
|
|
Definition at line 5240 of file processor.h. 05241 { 05242 return new SymSearchProcessor(); 05243 }
|
|
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 5782 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. 05783 { 05784 if (!image) { 05785 LOGWARN("NULL Image"); 05786 return; 05787 } 05788 float thresh = params["thresh"]; 05789 int output_symlabel = params["output_symlabel"]; 05790 05791 // set up all the symmetry transforms for all the searched symmetries 05792 const vector<string> sym_list = params["sym"]; 05793 int sym_num = sym_list.size(); 05794 vector< vector< Transform > > transforms(sym_num); 05795 vector< float* > symvals(sym_num); 05796 for (int i =0; i < sym_num; i++) { 05797 vector<Transform> sym_transform = Symmetry3D::get_symmetries(sym_list[i]); 05798 transforms[i] = sym_transform; 05799 symvals[i] = new float[sym_transform.size()]; // new float(nsym); 05800 } 05801 05802 EMData *orig = image->copy(); 05803 05804 image->to_zero(); 05805 05806 int nx= image->get_xsize(); 05807 int ny= image->get_ysize(); 05808 int nz= image->get_zsize(); 05809 int xy = nx * ny; 05810 float * data = image->get_data(); 05811 float * sdata = orig->get_data(); 05812 05813 EMData *symlabel = 0; 05814 float * ldata = symlabel->get_data(); 05815 if (output_symlabel) { 05816 symlabel = image->copy(); 05817 symlabel->to_zero(); 05818 ldata = symlabel->get_data(); 05819 } 05820 05821 for (int k = 0; k < nz; k++) { 05822 for (int j = 0; j < ny; j++) { 05823 for(int i = 0; i < nx; i++) { 05824 size_t index = k * nx * ny + j * nx + i; 05825 float val = sdata[ index ]; 05826 float bestmean = val, bestsymlevel = FLT_MAX; 05827 int bestsym = 0; 05828 for( int sym = 0; sym< sym_num; sym++) { 05829 int cur_sym_num = transforms[sym].size(); 05830 float *symval = symvals[sym]; 05831 // first find out all the symmetry related location values 05832 for( int s = 0; s < cur_sym_num; s++){ 05833 Transform r = transforms[sym][s]; 05834 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2); 05835 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2); 05836 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2); 05837 05838 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1) 05839 && z2 < (nz - 1)) { 05840 float x = (float)Util::fast_floor(x2); 05841 float y = (float)Util::fast_floor(y2); 05842 float z = (float)Util::fast_floor(z2); 05843 05844 float t = x2 - x; 05845 float u = y2 - y; 05846 float v = z2 - z; 05847 05848 int ii = (int) (x + y * nx + z * xy); 05849 05850 symval[s]= 05851 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx], 05852 sdata[ii + nx + 1], sdata[ii + nx * ny], 05853 sdata[ii + xy + 1], sdata[ii + xy + nx], 05854 sdata[ii + xy + nx + 1], t, u, v); 05855 } 05856 else { 05857 symval[s] = 0.0 ; 05858 } 05859 } 05860 float tmean=0, tsigma=0; 05861 for( int s = 0; s < cur_sym_num; s++) { 05862 tmean += symval[s]; 05863 tsigma += symval[s] * symval[s]; 05864 } 05865 tmean /= cur_sym_num; 05866 tsigma = tsigma/cur_sym_num - tmean*tmean; 05867 if (tsigma < bestsymlevel ) { 05868 bestsymlevel = tsigma; 05869 bestmean = tmean; 05870 bestsym = sym; 05871 } 05872 } 05873 if ( bestsymlevel > thresh) { 05874 if (output_symlabel) ldata[index] = (float)bestsym; 05875 data[index] = bestmean; 05876 } 05877 else { 05878 if (output_symlabel) ldata[index] = -1; 05879 data[index] = val; 05880 } 05881 } 05882 } 05883 } 05884 if( orig ) 05885 { 05886 delete orig; 05887 orig = 0; 05888 } 05889 for (int i =0; i < sym_num; i++) { 05890 if( symvals[i] ) 05891 { 05892 delete symvals[i]; 05893 symvals[i] = 0; 05894 } 05895 } 05896 if (symlabel) params.put("symlabel_map", EMObject(symlabel)); 05897 }
|
|
Definition at line 175 of file processor.cpp. |