#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "mask.fromfile.sizediff" |
The images can be different size.
filename | mask image file name |
Definition at line 5338 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 5353 of file processor.h. 05354 { 05355 return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size."; 05356 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5343 of file processor.h. 05344 {
05345 return NAME;
05346 }
|
|
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 5358 of file processor.h. References EMAN::TypeDict::put(). 05359 { 05360 TypeDict d; 05361 d.put("filename", EMObject::STRING, "mask image file name"); 05362 return d; 05363 }
|
|
Definition at line 5348 of file processor.h. 05349 { 05350 return new CoordinateMaskFileProcessor(); 05351 }
|
|
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 6022 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, nx, ny, EMAN::EMData::read_image(), and EMAN::EMData::update(). 06023 { 06024 if (!image) { 06025 LOGWARN("NULL Image"); 06026 return; 06027 } 06028 06029 const char *filename = params["filename"]; 06030 EMData *msk = new EMData(); 06031 msk->read_image(filename); 06032 06033 int nx = image->get_xsize(); 06034 int ny = image->get_ysize(); 06035 int nz = image->get_zsize(); 06036 06037 int xm = msk->get_xsize(); 06038 int ym = msk->get_ysize(); 06039 int zm = msk->get_zsize(); 06040 06041 float apix = image->get_attr("apix_x"); 06042 float apixm = msk->get_attr("apix_x"); 06043 06044 float xo = image->get_attr("origin_x"); 06045 float yo = image->get_attr("origin_y"); 06046 float zo = image->get_attr("origin_z"); 06047 06048 float xom = msk->get_attr("origin_x"); 06049 float yom = msk->get_attr("origin_y"); 06050 float zom = msk->get_attr("origin_z"); 06051 06052 float *dp = image->get_data(); 06053 float *dpm = msk->get_data(); 06054 int nxy = nx * ny; 06055 06056 for (int k = 0; k < nz; k++) { 06057 float zc = zo + k * apix; 06058 if (zc <= zom || zc >= zom + zm * apixm) { 06059 memset(&(dp[k * nxy]), 0, sizeof(float) * nxy); 06060 } 06061 else { 06062 int km = (int) ((zc - zom) / apixm); 06063 06064 for (int j = 0; j < ny; j++) { 06065 float yc = yo + j * apix; 06066 if (yc <= yom || yc >= yom + ym * apixm) { 06067 memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx); 06068 } 06069 else { 06070 int jm = (int) ((yc - yom) / apixm); 06071 size_t idx = 0; 06072 float xc; 06073 int im; 06074 for (int i = 0; i < nx; i++) { 06075 xc = xo + i * apix; 06076 idx = (size_t)k * nxy + j * nx + i; 06077 if (xc <= xom || xc >= xom + xm * apixm) { 06078 dp[idx] = 0; 06079 } 06080 else { 06081 im = (int) ((xc - xom) / apixm); 06082 if (dpm[km * xm * ym + jm * xm + im] <= 0) { 06083 dp[idx] = 0; 06084 } 06085 } 06086 } 06087 } 06088 } 06089 } 06090 } 06091 06092 image->update(); 06093 msk->update(); 06094 if( msk ) 06095 { 06096 delete msk; 06097 msk = 0; 06098 } 06099 }
|
|
Definition at line 184 of file processor.cpp. |