#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 5957 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 5971 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 5966 of file processor.h.
References NAME.
05967 { 05968 return NAME; 05969 }
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 5981 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
05982 { 05983 TypeDict d; 05984 d.put("int", EMObject::FLOAT, "radius of the lines emanating from the origin"); 05985 d.put("fill", EMObject::FLOAT, "value to make non-zero pixels"); 05986 return d; 05987 }
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 7090 of file processor.cpp.
References min, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update().
07091 { 07092 preprocess(image); 07093 07094 float fill = params.set_default("fill", 1.0f); 07095 // get the central coordinates 07096 int cx = nx/2; 07097 int cy = ny/2; 07098 int cz = nz/2; 07099 07100 // Offsets are used to detect when "the extra pixel" needs to be filled in 07101 // They are implemented on the assumption that for odd dimensions 07102 // the "center pixel" is the center pixel, but for even dimensions the "center 07103 // pixel" is displaced in the positive direction by 1 07104 int xoffset = (nx % 2 == 0? 1:0); 07105 int yoffset = (ny % 2 == 0? 1:0); 07106 int zoffset = (nz % 2 == 0? 1:0); 07107 07108 // This should never occur - but if indeed it did occur, the code in this function 07109 // would break - the function would proceed into the final "else" and seg fault 07110 // It is commented out but left for clarity 07111 // if ( nx < 1 || ny < 1 || nz < 1 ) throw ImageDimensionException("Error: one of the image dimensions was less than zero"); 07112 07113 if ( nx == 1 && ny == 1 && nz == 1 ) 07114 { 07115 (*image)(0) = fill; 07116 } 07117 else if ( ny == 1 && nz == 1 ) 07118 { 07119 int radius = params.set_default("radius", cx ); 07120 if ( radius > cx ) radius = cx; 07121 07122 (*image)(cx) = fill; 07123 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i) = fill; 07124 for ( int i = 1; i <= radius; ++i ) (*image)(cx-i) = fill; 07125 } 07126 else if ( nz == 1 ) 07127 { 07128 int min = ( nx < ny ? nx : ny ); 07129 min /= 2; 07130 07131 int radius = params.set_default("radius", min ); 07132 if ( radius > min ) radius = min; 07133 07134 (*image)(cx,cy) = fill; 07135 07136 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i,cy) = fill; 07137 for ( int i = 1; i <= radius-yoffset; ++i )(*image)(cx,cy+i) = fill; 07138 07139 for ( int i = 1; i <= radius; ++i ) 07140 { 07141 (*image)(cx-i,cy) = fill; 07142 (*image)(cx,cy-i) = fill; 07143 } 07144 07145 } 07146 else 07147 { 07148 // nx > 1 && ny > 1 && nz > 1 07149 int min = ( nx < ny ? nx : ny ); 07150 if (nz < min ) min = nz; 07151 min /= 2; 07152 07153 int radius = params.set_default("radius", min); 07154 if ( radius > min ) radius = min; 07155 07156 07157 (*image)(cx,cy,cz) = fill; 07158 for ( int i = 1; i <=radius-xoffset; ++i ) (*image)(cx+i,cy,cz) = fill; 07159 for ( int i = 1; i <=radius-yoffset; ++i ) (*image)(cx,cy+i,cz) = fill; 07160 for ( int i = 1; i <=radius-zoffset; ++i ) (*image)(cx,cy,cz+i) = fill; 07161 for ( int i = 1; i <= radius; ++i ) 07162 { 07163 (*image)(cx-i,cy,cz) = fill; 07164 (*image)(cx,cy-i,cz) = fill; 07165 (*image)(cx,cy,cz-i) = fill; 07166 } 07167 } 07168 07169 image->update(); 07170 }
const string TestImageAxes::NAME = "testimage.axes" [static] |