#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 6129 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 6143 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 6138 of file processor.h.
References NAME.
06139 { 06140 return NAME; 06141 }
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 6153 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
06154 { 06155 TypeDict d; 06156 d.put("int", EMObject::FLOAT, "radius of the lines emanating from the origin"); 06157 d.put("fill", EMObject::FLOAT, "value to make non-zero pixels"); 06158 return d; 06159 }
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 7293 of file processor.cpp.
References min, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update().
07294 { 07295 preprocess(image); 07296 07297 float fill = params.set_default("fill", 1.0f); 07298 // get the central coordinates 07299 int cx = nx/2; 07300 int cy = ny/2; 07301 int cz = nz/2; 07302 07303 // Offsets are used to detect when "the extra pixel" needs to be filled in 07304 // They are implemented on the assumption that for odd dimensions 07305 // the "center pixel" is the center pixel, but for even dimensions the "center 07306 // pixel" is displaced in the positive direction by 1 07307 int xoffset = (nx % 2 == 0? 1:0); 07308 int yoffset = (ny % 2 == 0? 1:0); 07309 int zoffset = (nz % 2 == 0? 1:0); 07310 07311 // This should never occur - but if indeed it did occur, the code in this function 07312 // would break - the function would proceed into the final "else" and seg fault 07313 // It is commented out but left for clarity 07314 // if ( nx < 1 || ny < 1 || nz < 1 ) throw ImageDimensionException("Error: one of the image dimensions was less than zero"); 07315 07316 if ( nx == 1 && ny == 1 && nz == 1 ) 07317 { 07318 (*image)(0) = fill; 07319 } 07320 else if ( ny == 1 && nz == 1 ) 07321 { 07322 int radius = params.set_default("radius", cx ); 07323 if ( radius > cx ) radius = cx; 07324 07325 (*image)(cx) = fill; 07326 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i) = fill; 07327 for ( int i = 1; i <= radius; ++i ) (*image)(cx-i) = fill; 07328 } 07329 else if ( nz == 1 ) 07330 { 07331 int min = ( nx < ny ? nx : ny ); 07332 min /= 2; 07333 07334 int radius = params.set_default("radius", min ); 07335 if ( radius > min ) radius = min; 07336 07337 (*image)(cx,cy) = fill; 07338 07339 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i,cy) = fill; 07340 for ( int i = 1; i <= radius-yoffset; ++i )(*image)(cx,cy+i) = fill; 07341 07342 for ( int i = 1; i <= radius; ++i ) 07343 { 07344 (*image)(cx-i,cy) = fill; 07345 (*image)(cx,cy-i) = fill; 07346 } 07347 07348 } 07349 else 07350 { 07351 // nx > 1 && ny > 1 && nz > 1 07352 int min = ( nx < ny ? nx : ny ); 07353 if (nz < min ) min = nz; 07354 min /= 2; 07355 07356 int radius = params.set_default("radius", min); 07357 if ( radius > min ) radius = min; 07358 07359 07360 (*image)(cx,cy,cz) = fill; 07361 for ( int i = 1; i <=radius-xoffset; ++i ) (*image)(cx+i,cy,cz) = fill; 07362 for ( int i = 1; i <=radius-yoffset; ++i ) (*image)(cx,cy+i,cz) = fill; 07363 for ( int i = 1; i <=radius-zoffset; ++i ) (*image)(cx,cy,cz+i) = fill; 07364 for ( int i = 1; i <= radius; ++i ) 07365 { 07366 (*image)(cx-i,cy,cz) = fill; 07367 (*image)(cx,cy-i,cz) = fill; 07368 (*image)(cx,cy,cz-i) = fill; 07369 } 07370 } 07371 07372 image->update(); 07373 }
const string TestImageAxes::NAME = "testimage.axes" [static] |