#include <processor.h>
Inheritance diagram for EMAN::CoordinateMaskFileProcessor:
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 = "mask.fromfile.sizediff" |
The images can be different size.
filename | mask image file name |
Definition at line 5455 of file processor.h.
virtual string EMAN::CoordinateMaskFileProcessor::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 5470 of file processor.h.
05471 { 05472 return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size."; 05473 }
virtual string EMAN::CoordinateMaskFileProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5460 of file processor.h.
References NAME.
05461 { 05462 return NAME; 05463 }
virtual TypeDict EMAN::CoordinateMaskFileProcessor::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 5475 of file processor.h.
References EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
05476 { 05477 TypeDict d; 05478 d.put("filename", EMObject::STRING, "mask image file name"); 05479 return d; 05480 }
static Processor* EMAN::CoordinateMaskFileProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5465 of file processor.h.
05466 { 05467 return new CoordinateMaskFileProcessor(); 05468 }
void CoordinateMaskFileProcessor::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 6249 of file processor.cpp.
References EMAN::EMData::get_attr(), EMAN::EMData::get_attr_default(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, EMAN::EMData::read_image(), and EMAN::EMData::update().
06250 { 06251 if (!image) { 06252 LOGWARN("NULL Image"); 06253 return; 06254 } 06255 06256 const char *filename = params["filename"]; 06257 EMData *msk = new EMData(); 06258 msk->read_image(filename); 06259 06260 int nx = image->get_xsize(); 06261 int ny = image->get_ysize(); 06262 int nz = image->get_zsize(); 06263 06264 int xm = msk->get_xsize(); 06265 int ym = msk->get_ysize(); 06266 int zm = msk->get_zsize(); 06267 06268 float apix = image->get_attr("apix_x"); 06269 float apixm = msk->get_attr("apix_x"); 06270 06271 float xo = image->get_attr_default("origin_x",0.0); 06272 float yo = image->get_attr_default("origin_y",0.0); 06273 float zo = image->get_attr_default("origin_z",0.0); 06274 06275 float xom = msk->get_attr_default("origin_x",0.0); 06276 float yom = msk->get_attr_default("origin_y",0.0); 06277 float zom = msk->get_attr_default("origin_z",0.0); 06278 06279 float *dp = image->get_data(); 06280 float *dpm = msk->get_data(); 06281 int nxy = nx * ny; 06282 06283 for (int k = 0; k < nz; k++) { 06284 float zc = zo + k * apix; 06285 if (zc <= zom || zc >= zom + zm * apixm) { 06286 memset(&(dp[k * nxy]), 0, sizeof(float) * nxy); 06287 } 06288 else { 06289 int km = (int) ((zc - zom) / apixm); 06290 06291 for (int j = 0; j < ny; j++) { 06292 float yc = yo + j * apix; 06293 if (yc <= yom || yc >= yom + ym * apixm) { 06294 memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx); 06295 } 06296 else { 06297 int jm = (int) ((yc - yom) / apixm); 06298 size_t idx = 0; 06299 float xc; 06300 int im; 06301 for (int i = 0; i < nx; i++) { 06302 xc = xo + i * apix; 06303 idx = (size_t)k * nxy + j * nx + i; 06304 if (xc <= xom || xc >= xom + xm * apixm) { 06305 dp[idx] = 0; 06306 } 06307 else { 06308 im = (int) ((xc - xom) / apixm); 06309 if (dpm[km * xm * ym + jm * xm + im] <= 0) { 06310 dp[idx] = 0; 06311 } 06312 } 06313 } 06314 } 06315 } 06316 } 06317 } 06318 06319 image->update(); 06320 msk->update(); 06321 if( msk ) 06322 { 06323 delete msk; 06324 msk = 0; 06325 } 06326 }
const string CoordinateMaskFileProcessor::NAME = "mask.fromfile.sizediff" [static] |