#include <processor.h>
Inheritance diagram for EMAN::TestImageAxes:
Public Member Functions | |
virtual void | process_inplace (EMData *image) |
Make an image where the axes (where x,y and z=0) are some nono zero value. | |
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.axes" |
radius | the radial length of the lines from the origin | |
fill | the value to assign to pixels made non zero |
Definition at line 6082 of file processor.h.
virtual string EMAN::TestImageAxes::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 6096 of file processor.h.
virtual string EMAN::TestImageAxes::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6091 of file processor.h.
References NAME.
06092 { 06093 return NAME; 06094 }
virtual TypeDict EMAN::TestImageAxes::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 6106 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
06107 { 06108 TypeDict d; 06109 d.put("int", EMObject::FLOAT, "radius of the lines emanating from the origin"); 06110 d.put("fill", EMObject::FLOAT, "value to make non-zero pixels"); 06111 return d; 06112 }
static Processor* EMAN::TestImageAxes::NEW | ( | ) | [inline, static] |
void TestImageAxes::process_inplace | ( | EMData * | image | ) | [virtual] |
Make an image where the axes (where x,y and z=0) are some nono zero value.
image | the image to operate upon |
Implements EMAN::Processor.
Definition at line 7206 of file processor.cpp.
References min, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update().
07207 { 07208 preprocess(image); 07209 07210 float fill = params.set_default("fill", 1.0f); 07211 // get the central coordinates 07212 int cx = nx/2; 07213 int cy = ny/2; 07214 int cz = nz/2; 07215 07216 // Offsets are used to detect when "the extra pixel" needs to be filled in 07217 // They are implemented on the assumption that for odd dimensions 07218 // the "center pixel" is the center pixel, but for even dimensions the "center 07219 // pixel" is displaced in the positive direction by 1 07220 int xoffset = (nx % 2 == 0? 1:0); 07221 int yoffset = (ny % 2 == 0? 1:0); 07222 int zoffset = (nz % 2 == 0? 1:0); 07223 07224 // This should never occur - but if indeed it did occur, the code in this function 07225 // would break - the function would proceed into the final "else" and seg fault 07226 // It is commented out but left for clarity 07227 // if ( nx < 1 || ny < 1 || nz < 1 ) throw ImageDimensionException("Error: one of the image dimensions was less than zero"); 07228 07229 if ( nx == 1 && ny == 1 && nz == 1 ) 07230 { 07231 (*image)(0) = fill; 07232 } 07233 else if ( ny == 1 && nz == 1 ) 07234 { 07235 int radius = params.set_default("radius", cx ); 07236 if ( radius > cx ) radius = cx; 07237 07238 (*image)(cx) = fill; 07239 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i) = fill; 07240 for ( int i = 1; i <= radius; ++i ) (*image)(cx-i) = fill; 07241 } 07242 else if ( nz == 1 ) 07243 { 07244 int min = ( nx < ny ? nx : ny ); 07245 min /= 2; 07246 07247 int radius = params.set_default("radius", min ); 07248 if ( radius > min ) radius = min; 07249 07250 (*image)(cx,cy) = fill; 07251 07252 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i,cy) = fill; 07253 for ( int i = 1; i <= radius-yoffset; ++i )(*image)(cx,cy+i) = fill; 07254 07255 for ( int i = 1; i <= radius; ++i ) 07256 { 07257 (*image)(cx-i,cy) = fill; 07258 (*image)(cx,cy-i) = fill; 07259 } 07260 07261 } 07262 else 07263 { 07264 // nx > 1 && ny > 1 && nz > 1 07265 int min = ( nx < ny ? nx : ny ); 07266 if (nz < min ) min = nz; 07267 min /= 2; 07268 07269 int radius = params.set_default("radius", min); 07270 if ( radius > min ) radius = min; 07271 07272 07273 (*image)(cx,cy,cz) = fill; 07274 for ( int i = 1; i <=radius-xoffset; ++i ) (*image)(cx+i,cy,cz) = fill; 07275 for ( int i = 1; i <=radius-yoffset; ++i ) (*image)(cx,cy+i,cz) = fill; 07276 for ( int i = 1; i <=radius-zoffset; ++i ) (*image)(cx,cy,cz+i) = fill; 07277 for ( int i = 1; i <= radius; ++i ) 07278 { 07279 (*image)(cx-i,cy,cz) = fill; 07280 (*image)(cx,cy-i,cz) = fill; 07281 (*image)(cx,cy,cz-i) = fill; 07282 } 07283 } 07284 07285 image->update(); 07286 }
const string TestImageAxes::NAME = "testimage.axes" [static] |