#include <processor.h>
Inheritance diagram for EMAN::RadialProcessor:
Public Member Functions | |
void | process_inplace (EMData *image) |
To process an image in-place. | |
string | get_name () const |
Get the processor's name. | |
TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "mask.radialprofile" |
table | a radial table for multiplication |
ImageFormatException | this filter only apply to real image |
Definition at line 6817 of file processor.h.
string EMAN::RadialProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 6839 of file processor.h.
06840 { 06841 return "Multiply a real-space image by a radial function. 1 value / pixel, extending to corner. Missing values -> 0."; 06842 }
string EMAN::RadialProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6822 of file processor.h.
References NAME.
Referenced by process_inplace().
06823 { 06824 return NAME; 06825 }
TypeDict EMAN::RadialProcessor::get_param_types | ( | ) | const [inline, virtual] |
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 6832 of file processor.h.
References EMAN::EMObject::FLOATARRAY, and EMAN::TypeDict::put().
06833 { 06834 TypeDict d; 06835 d.put("table", EMObject::FLOATARRAY, "Radial array of floats, 1 float/pixel"); 06836 return d; 06837 }
static Processor* EMAN::RadialProcessor::NEW | ( | ) | [inline, static] |
void RadialProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 8099 of file processor.cpp.
References get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageFormatException, EMAN::EMData::is_complex(), LOGERR, LOGWARN, EMAN::Processor::params, EMAN::Dict::size(), sqrt(), and EMAN::EMData::update().
08100 { 08101 if (!image) { 08102 LOGWARN("NULL Image"); 08103 return; 08104 } 08105 08106 //Note : real image only! 08107 if(image->is_complex()) { 08108 LOGERR("%s Processor only operates on real images", get_name().c_str()); 08109 throw ImageFormatException("apply to real image only"); 08110 } 08111 08112 vector<float> table = params["table"]; 08113 vector<float>::size_type tsize = table.size(); 08114 08115 int nx = image->get_xsize(); 08116 int ny = image->get_ysize(); 08117 int nz = image->get_zsize(); 08118 08119 int nx2 = nx / 2; 08120 int ny2 = ny / 2; 08121 int nz2 = nz / 2; 08122 float sz[3]; 08123 sz[0] = static_cast<float>(nx2); 08124 sz[1] = static_cast<float>(ny2); 08125 sz[2] = static_cast<float>(nz2); 08126 float szmax = *std::max_element(&sz[0], &sz[3]); 08127 float maxsize; 08128 if(nz>1) { 08129 maxsize = (float)(1.8f * szmax); 08130 } 08131 else{ 08132 maxsize = (float)(1.5f * szmax); 08133 } 08134 for(int i=tsize+1; i<maxsize; i++) { 08135 table.push_back(0.0f); 08136 } 08137 08138 float dx = 1.0f / (float)nx; 08139 float dy = 1.0f / (float)ny; 08140 float dz = 1.0f / (float)nz; 08141 float dx2 = dx * dx; 08142 float dy2 = dy * dy; 08143 float dz2 = dz * dz; 08144 int iz, iy, ix, jz, jy, jx; 08145 float argx, argy, argz; 08146 float rf, df, f; 08147 int ir; 08148 for(iz=1; iz<=nz; iz++) { 08149 jz = iz - 1; 08150 if(jz > nz2) { 08151 jz -= nz; 08152 } 08153 argz = float(jz*jz) * dz2; 08154 08155 for(iy=1; iy<=ny; iy++) { 08156 jy = iy - 1; 08157 if(jy > ny2) { 08158 jy -= ny; 08159 } 08160 argy = argz + float(jy*jy) * dy2; 08161 08162 for(ix=1; ix<=nx; ix++) { 08163 jx = ix -1; 08164 argx = argy + float(jx*jx)*dx2; 08165 08166 rf = sqrt(argx)*2.0f*nx2; 08167 ir = int(rf); 08168 df = rf - float(ir); 08169 f = table[ir] + df*(table[ir+1]-table[ir]); 08170 08171 (*image)(ix-1,iy-1,iz-1) *= f; 08172 } 08173 } 08174 } 08175 08176 image->update(); 08177 }
const string RadialProcessor::NAME = "mask.radialprofile" [static] |