#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 5374 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 5389 of file processor.h. 05390 { 05391 return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size."; 05392 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5379 of file processor.h. References NAME. 05380 { 05381 return NAME; 05382 }
|
|
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 5394 of file processor.h. References EMAN::TypeDict::put(), and EMAN::EMObject::STRING. 05395 { 05396 TypeDict d; 05397 d.put("filename", EMObject::STRING, "mask image file name"); 05398 return d; 05399 }
|
|
Definition at line 5384 of file processor.h. 05385 { 05386 return new CoordinateMaskFileProcessor(); 05387 }
|
|
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.
Implements EMAN::Processor. Definition at line 6066 of file processor.cpp. References EMAN::EMData::get_attr(), 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(). 06067 { 06068 if (!image) { 06069 LOGWARN("NULL Image"); 06070 return; 06071 } 06072 06073 const char *filename = params["filename"]; 06074 EMData *msk = new EMData(); 06075 msk->read_image(filename); 06076 06077 int nx = image->get_xsize(); 06078 int ny = image->get_ysize(); 06079 int nz = image->get_zsize(); 06080 06081 int xm = msk->get_xsize(); 06082 int ym = msk->get_ysize(); 06083 int zm = msk->get_zsize(); 06084 06085 float apix = image->get_attr("apix_x"); 06086 float apixm = msk->get_attr("apix_x"); 06087 06088 float xo = image->get_attr("origin_x"); 06089 float yo = image->get_attr("origin_y"); 06090 float zo = image->get_attr("origin_z"); 06091 06092 float xom = msk->get_attr("origin_x"); 06093 float yom = msk->get_attr("origin_y"); 06094 float zom = msk->get_attr("origin_z"); 06095 06096 float *dp = image->get_data(); 06097 float *dpm = msk->get_data(); 06098 int nxy = nx * ny; 06099 06100 for (int k = 0; k < nz; k++) { 06101 float zc = zo + k * apix; 06102 if (zc <= zom || zc >= zom + zm * apixm) { 06103 memset(&(dp[k * nxy]), 0, sizeof(float) * nxy); 06104 } 06105 else { 06106 int km = (int) ((zc - zom) / apixm); 06107 06108 for (int j = 0; j < ny; j++) { 06109 float yc = yo + j * apix; 06110 if (yc <= yom || yc >= yom + ym * apixm) { 06111 memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx); 06112 } 06113 else { 06114 int jm = (int) ((yc - yom) / apixm); 06115 size_t idx = 0; 06116 float xc; 06117 int im; 06118 for (int i = 0; i < nx; i++) { 06119 xc = xo + i * apix; 06120 idx = k * nxy + j * nx + i; 06121 if (xc <= xom || xc >= xom + xm * apixm) { 06122 dp[idx] = 0; 06123 } 06124 else { 06125 im = (int) ((xc - xom) / apixm); 06126 if (dpm[km * xm * ym + jm * xm + im] <= 0) { 06127 dp[idx] = 0; 06128 } 06129 } 06130 } 06131 } 06132 } 06133 } 06134 } 06135 06136 image->update(); 06137 msk->update(); 06138 if( msk ) 06139 { 06140 delete msk; 06141 msk = 0; 06142 } 06143 }
|
|
Definition at line 5401 of file processor.h. Referenced by get_name(). |