#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 6084 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 6094 of file processor.h. 06095 { 06096 return "Replace a source image as a Gaussian Blob"; 06097 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6089 of file processor.h. 06090 {
06091 return NAME;
06092 }
|
|
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 6104 of file processor.h. References EMAN::TypeDict::put(). 06105 { 06106 TypeDict d; 06107 d.put("sigma", EMObject::FLOAT, "sigma value for this Gaussian blob"); 06108 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06109 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06110 return d; 06111 }
|
|
Definition at line 6099 of file processor.h. 06100 { 06101 return new TestImageGaussian(); 06102 }
|
|
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 6892 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update(). 06893 { 06894 preprocess(image); 06895 06896 float sigma = params["sigma"]; 06897 string axis = (const char*)params["axis"]; 06898 float c = params["c"]; 06899 06900 float *dat = image->get_data(); 06901 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2) 06902 float x2, y2, z2; //this is the coordinates of this pixel from image center 06903 for (int k = 0; k < nz; ++k) { 06904 for (int j = 0; j < ny; ++j) { 06905 for (int i = 0; i < nx; ++i, ++dat) { 06906 x2 = (float)( i - nx/2 ); 06907 y2 = (float)( j - ny/2 ); 06908 z2 = (float)( k - nz/2 ); 06909 06910 if(axis==""){ 06911 r = (float)sqrt(x2*x2+y2*y2+z2*z2); 06912 } 06913 else if(axis == "x"){ 06914 float lc = -c; 06915 float rc = c; 06916 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) + 06917 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c; 06918 } 06919 else if(axis == "y"){ 06920 float lc = -c; 06921 float rc = c; 06922 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) + 06923 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c; 06924 } 06925 else if(axis == "z"){ 06926 if( nz == 1 ){ 06927 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 06928 } 06929 float lc = -c; 06930 float rc = c; 06931 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) + 06932 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c; 06933 } 06934 else{ 06935 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 06936 } 06937 //the amplitude of the pixel is proportional to the distance of this pixel from the center 06938 *dat = (float)gsl_ran_gaussian_pdf((double)r,(double)sigma); 06939 } 06940 } 06941 } 06942 06943 image->update(); 06944 }
|
|
Definition at line 198 of file processor.cpp. |