#include <processor.h>
Inheritance diagram for EMAN::TestImageGaussian:
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 | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "testimage.gaussian" |
sigma | sigma value for this Gaussian blob | |
axis | specify a major axis for asymmetric features | |
c | distance between focus and the center of an ellipse |
Definition at line 6085 of file processor.h.
virtual string EMAN::TestImageGaussian::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 6095 of file processor.h.
virtual string EMAN::TestImageGaussian::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6090 of file processor.h.
References NAME.
06091 { 06092 return NAME; 06093 }
virtual TypeDict EMAN::TestImageGaussian::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 6105 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
06106 { 06107 TypeDict d; 06108 d.put("sigma", EMObject::FLOAT, "sigma value for this Gaussian blob"); 06109 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06110 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06111 return d; 06112 }
static Processor* EMAN::TestImageGaussian::NEW | ( | ) | [inline, static] |
void TestImageGaussian::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 6923 of file processor.cpp.
References EMAN::EMData::get_data(), InvalidValueException, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update().
06924 { 06925 preprocess(image); 06926 06927 float sigma = params["sigma"]; 06928 string axis = (const char*)params["axis"]; 06929 float c = params["c"]; 06930 06931 float *dat = image->get_data(); 06932 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2) 06933 float x2, y2, z2; //this is the coordinates of this pixel from image center 06934 for (int k = 0; k < nz; ++k) { 06935 for (int j = 0; j < ny; ++j) { 06936 for (int i = 0; i < nx; ++i, ++dat) { 06937 x2 = (float)( i - nx/2 ); 06938 y2 = (float)( j - ny/2 ); 06939 z2 = (float)( k - nz/2 ); 06940 06941 if(axis==""){ 06942 r = (float)sqrt(x2*x2+y2*y2+z2*z2); 06943 } 06944 else if(axis == "x"){ 06945 float lc = -c; 06946 float rc = c; 06947 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) + 06948 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c; 06949 } 06950 else if(axis == "y"){ 06951 float lc = -c; 06952 float rc = c; 06953 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) + 06954 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c; 06955 } 06956 else if(axis == "z"){ 06957 if( nz == 1 ){ 06958 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 06959 } 06960 float lc = -c; 06961 float rc = c; 06962 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) + 06963 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c; 06964 } 06965 else{ 06966 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 06967 } 06968 //the amplitude of the pixel is proportional to the distance of this pixel from the center 06969 *dat = (float)gsl_ran_gaussian_pdf((double)r,(double)sigma); 06970 } 06971 } 06972 } 06973 06974 image->update(); 06975 }
const string TestImageGaussian::NAME = "testimage.gaussian" [static] |