#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 6085 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 6099 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 6094 of file processor.h.
References NAME.
06095 { 06096 return NAME; 06097 }
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 6109 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
06110 { 06111 TypeDict d; 06112 d.put("int", EMObject::FLOAT, "radius of the lines emanating from the origin"); 06113 d.put("fill", EMObject::FLOAT, "value to make non-zero pixels"); 06114 return d; 06115 }
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 7128 of file processor.cpp.
References min, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update().
07129 { 07130 preprocess(image); 07131 07132 float fill = params.set_default("fill", 1.0f); 07133 // get the central coordinates 07134 int cx = nx/2; 07135 int cy = ny/2; 07136 int cz = nz/2; 07137 07138 // Offsets are used to detect when "the extra pixel" needs to be filled in 07139 // They are implemented on the assumption that for odd dimensions 07140 // the "center pixel" is the center pixel, but for even dimensions the "center 07141 // pixel" is displaced in the positive direction by 1 07142 int xoffset = (nx % 2 == 0? 1:0); 07143 int yoffset = (ny % 2 == 0? 1:0); 07144 int zoffset = (nz % 2 == 0? 1:0); 07145 07146 // This should never occur - but if indeed it did occur, the code in this function 07147 // would break - the function would proceed into the final "else" and seg fault 07148 // It is commented out but left for clarity 07149 // if ( nx < 1 || ny < 1 || nz < 1 ) throw ImageDimensionException("Error: one of the image dimensions was less than zero"); 07150 07151 if ( nx == 1 && ny == 1 && nz == 1 ) 07152 { 07153 (*image)(0) = fill; 07154 } 07155 else if ( ny == 1 && nz == 1 ) 07156 { 07157 int radius = params.set_default("radius", cx ); 07158 if ( radius > cx ) radius = cx; 07159 07160 (*image)(cx) = fill; 07161 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i) = fill; 07162 for ( int i = 1; i <= radius; ++i ) (*image)(cx-i) = fill; 07163 } 07164 else if ( nz == 1 ) 07165 { 07166 int min = ( nx < ny ? nx : ny ); 07167 min /= 2; 07168 07169 int radius = params.set_default("radius", min ); 07170 if ( radius > min ) radius = min; 07171 07172 (*image)(cx,cy) = fill; 07173 07174 for ( int i = 1; i <= radius-xoffset; ++i ) (*image)(cx+i,cy) = fill; 07175 for ( int i = 1; i <= radius-yoffset; ++i )(*image)(cx,cy+i) = fill; 07176 07177 for ( int i = 1; i <= radius; ++i ) 07178 { 07179 (*image)(cx-i,cy) = fill; 07180 (*image)(cx,cy-i) = fill; 07181 } 07182 07183 } 07184 else 07185 { 07186 // nx > 1 && ny > 1 && nz > 1 07187 int min = ( nx < ny ? nx : ny ); 07188 if (nz < min ) min = nz; 07189 min /= 2; 07190 07191 int radius = params.set_default("radius", min); 07192 if ( radius > min ) radius = min; 07193 07194 07195 (*image)(cx,cy,cz) = fill; 07196 for ( int i = 1; i <=radius-xoffset; ++i ) (*image)(cx+i,cy,cz) = fill; 07197 for ( int i = 1; i <=radius-yoffset; ++i ) (*image)(cx,cy+i,cz) = fill; 07198 for ( int i = 1; i <=radius-zoffset; ++i ) (*image)(cx,cy,cz+i) = fill; 07199 for ( int i = 1; i <= radius; ++i ) 07200 { 07201 (*image)(cx-i,cy,cz) = fill; 07202 (*image)(cx,cy-i,cz) = fill; 07203 (*image)(cx,cy,cz-i) = fill; 07204 } 07205 } 07206 07207 image->update(); 07208 }
const string TestImageAxes::NAME = "testimage.axes" [static] |