#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 | |
Processor * | NEW () |
Static Public Attributes | |
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 5997 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 6007 of file processor.h. 06008 { 06009 return "Replace a source image as a Gaussian Blob"; 06010 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6002 of file processor.h. 06003 {
06004 return NAME;
06005 }
|
|
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 6017 of file processor.h. References EMAN::TypeDict::put(). 06018 { 06019 TypeDict d; 06020 d.put("sigma", EMObject::FLOAT, "sigma value for this Gaussian blob"); 06021 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06022 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06023 return d; 06024 }
|
|
Definition at line 6012 of file processor.h. 06013 { 06014 return new TestImageGaussian(); 06015 }
|
|
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 6992 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update(). 06993 { 06994 preprocess(image); 06995 06996 float sigma = params["sigma"]; 06997 string axis = (const char*)params["axis"]; 06998 float c = params["c"]; 06999 07000 float *dat = image->get_data(); 07001 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2) 07002 float x2, y2, z2; //this is the coordinates of this pixel from image center 07003 for (int k = 0; k < nz; ++k) { 07004 for (int j = 0; j < ny; ++j) { 07005 for (int i = 0; i < nx; ++i, ++dat) { 07006 x2 = (float)( i - nx/2 ); 07007 y2 = (float)( j - ny/2 ); 07008 z2 = (float)( k - nz/2 ); 07009 07010 if(axis==""){ 07011 r = (float)sqrt(x2*x2+y2*y2+z2*z2); 07012 } 07013 else if(axis == "x"){ 07014 float lc = -c; 07015 float rc = c; 07016 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) + 07017 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c; 07018 } 07019 else if(axis == "y"){ 07020 float lc = -c; 07021 float rc = c; 07022 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) + 07023 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c; 07024 } 07025 else if(axis == "z"){ 07026 if( nz == 1 ){ 07027 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07028 } 07029 float lc = -c; 07030 float rc = c; 07031 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) + 07032 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c; 07033 } 07034 else{ 07035 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07036 } 07037 //the amplitude of the pixel is proportional to the distance of this pixel from the center 07038 *dat = (float)gsl_ran_gaussian_pdf((double)r,(double)sigma); 07039 } 07040 } 07041 } 07042 07043 image->update(); 07044 }
|
|
Definition at line 196 of file processor.cpp. |