#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 5244 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 5259 of file processor.h. 05260 { 05261 return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size."; 05262 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5249 of file processor.h. 05250 {
05251 return NAME;
05252 }
|
|
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 5264 of file processor.h. References EMAN::TypeDict::put(). 05265 { 05266 TypeDict d; 05267 d.put("filename", EMObject::STRING, "mask image file name"); 05268 return d; 05269 }
|
|
Definition at line 5254 of file processor.h. 05255 { 05256 return new CoordinateMaskFileProcessor(); 05257 }
|
|
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 5992 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(). 05993 { 05994 if (!image) { 05995 LOGWARN("NULL Image"); 05996 return; 05997 } 05998 05999 const char *filename = params["filename"]; 06000 EMData *msk = new EMData(); 06001 msk->read_image(filename); 06002 06003 int nx = image->get_xsize(); 06004 int ny = image->get_ysize(); 06005 int nz = image->get_zsize(); 06006 06007 int xm = msk->get_xsize(); 06008 int ym = msk->get_ysize(); 06009 int zm = msk->get_zsize(); 06010 06011 float apix = image->get_attr("apix_x"); 06012 float apixm = msk->get_attr("apix_x"); 06013 06014 float xo = image->get_attr("origin_x"); 06015 float yo = image->get_attr("origin_y"); 06016 float zo = image->get_attr("origin_z"); 06017 06018 float xom = msk->get_attr("origin_x"); 06019 float yom = msk->get_attr("origin_y"); 06020 float zom = msk->get_attr("origin_z"); 06021 06022 float *dp = image->get_data(); 06023 float *dpm = msk->get_data(); 06024 int nxy = nx * ny; 06025 06026 for (int k = 0; k < nz; k++) { 06027 float zc = zo + k * apix; 06028 if (zc <= zom || zc >= zom + zm * apixm) { 06029 memset(&(dp[k * nxy]), 0, sizeof(float) * nxy); 06030 } 06031 else { 06032 int km = (int) ((zc - zom) / apixm); 06033 06034 for (int j = 0; j < ny; j++) { 06035 float yc = yo + j * apix; 06036 if (yc <= yom || yc >= yom + ym * apixm) { 06037 memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx); 06038 } 06039 else { 06040 int jm = (int) ((yc - yom) / apixm); 06041 size_t idx = 0; 06042 float xc; 06043 int im; 06044 for (int i = 0; i < nx; i++) { 06045 xc = xo + i * apix; 06046 idx = (size_t)k * nxy + j * nx + i; 06047 if (xc <= xom || xc >= xom + xm * apixm) { 06048 dp[idx] = 0; 06049 } 06050 else { 06051 im = (int) ((xc - xom) / apixm); 06052 if (dpm[km * xm * ym + jm * xm + im] <= 0) { 06053 dp[idx] = 0; 06054 } 06055 } 06056 } 06057 } 06058 } 06059 } 06060 } 06061 06062 image->update(); 06063 msk->update(); 06064 if( msk ) 06065 { 06066 delete msk; 06067 msk = 0; 06068 } 06069 }
|
|
Definition at line 176 of file processor.cpp. |