#include <processor.h>
Inheritance diagram for EMAN::TestImageGradient:
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.gradient" |
axis | The axis the will be used to determine pixel values. Must be x,y or z. Default is x | |
m | m in the equation m*axis+b. Default is 1.0 | |
b | b in the equation m*axis+b. Default is 0.0 |
Definition at line 6129 of file processor.h.
virtual string EMAN::TestImageGradient::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 6139 of file processor.h.
06140 { 06141 return "Make a gradient image of the form y=mx+b, where x is any of the image axes."; 06142 }
virtual string EMAN::TestImageGradient::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6134 of file processor.h.
References NAME.
06135 { 06136 return NAME; 06137 }
virtual TypeDict EMAN::TestImageGradient::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 6149 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
06150 { 06151 TypeDict d; 06152 d.put("axis", EMObject::STRING, "The axis the will be used to determine pixel values. Must be x,y or z"); 06153 d.put("m", EMObject::FLOAT, "m in the equation m*axis+b. Default is 1.0"); 06154 d.put("b", EMObject::FLOAT, "b in the equation m*axis+b. Default is 0.0"); 06155 return d; 06156 }
static Processor* EMAN::TestImageGradient::NEW | ( | ) | [inline, static] |
void TestImageGradient::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 7314 of file processor.cpp.
References b, InvalidParameterException, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), and EMAN::EMData::update().
07315 { 07316 string axis = params.set_default("axis", "x"); 07317 07318 float m = params.set_default("m", 1.0f); 07319 float b = params.set_default("b", 0.0f); 07320 07321 if ( axis != "z" && axis != "y" && axis != "x") throw InvalidParameterException("Axis must be x,y or z"); 07322 07323 preprocess(image); 07324 07325 if ( axis == "x") 07326 { 07327 for(int k=0; k<nz;++k) { 07328 for(int j=0; j<ny; ++j) { 07329 for(int i=0; i <nx; ++i) { 07330 image->set_value_at(i,j,k,m*i+b); 07331 } 07332 } 07333 } 07334 } 07335 else if ( axis == "y") 07336 { 07337 for(int k=0; k<nz;++k) { 07338 for(int j=0; j<ny; ++j) { 07339 for(int i=0; i <nx; ++i) { 07340 image->set_value_at(i,j,k,m*j+b); 07341 } 07342 } 07343 } 07344 } 07345 else if ( axis == "z") 07346 { 07347 for(int k=0; k<nz;++k) { 07348 for(int j=0; j<ny; ++j) { 07349 for(int i=0; i <nx; ++i) { 07350 image->set_value_at(i,j,k,m*k+b); 07351 } 07352 } 07353 } 07354 } 07355 image->update(); 07356 }
const string TestImageGradient::NAME = "testimage.gradient" [static] |