#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 5369 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 5384 of file processor.h. 05385 { 05386 return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size."; 05387 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5374 of file processor.h. 05375 {
05376 return NAME;
05377 }
|
|
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 5389 of file processor.h. References EMAN::TypeDict::put(). 05390 { 05391 TypeDict d; 05392 d.put("filename", EMObject::STRING, "mask image file name"); 05393 return d; 05394 }
|
|
Definition at line 5379 of file processor.h. 05380 { 05381 return new CoordinateMaskFileProcessor(); 05382 }
|
|
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 6108 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(). 06109 { 06110 if (!image) { 06111 LOGWARN("NULL Image"); 06112 return; 06113 } 06114 06115 const char *filename = params["filename"]; 06116 EMData *msk = new EMData(); 06117 msk->read_image(filename); 06118 06119 int nx = image->get_xsize(); 06120 int ny = image->get_ysize(); 06121 int nz = image->get_zsize(); 06122 06123 int xm = msk->get_xsize(); 06124 int ym = msk->get_ysize(); 06125 int zm = msk->get_zsize(); 06126 06127 float apix = image->get_attr("apix_x"); 06128 float apixm = msk->get_attr("apix_x"); 06129 06130 float xo = image->get_attr("origin_x"); 06131 float yo = image->get_attr("origin_y"); 06132 float zo = image->get_attr("origin_z"); 06133 06134 float xom = msk->get_attr("origin_x"); 06135 float yom = msk->get_attr("origin_y"); 06136 float zom = msk->get_attr("origin_z"); 06137 06138 float *dp = image->get_data(); 06139 float *dpm = msk->get_data(); 06140 int nxy = nx * ny; 06141 06142 for (int k = 0; k < nz; k++) { 06143 float zc = zo + k * apix; 06144 if (zc <= zom || zc >= zom + zm * apixm) { 06145 memset(&(dp[k * nxy]), 0, sizeof(float) * nxy); 06146 } 06147 else { 06148 int km = (int) ((zc - zom) / apixm); 06149 06150 for (int j = 0; j < ny; j++) { 06151 float yc = yo + j * apix; 06152 if (yc <= yom || yc >= yom + ym * apixm) { 06153 memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx); 06154 } 06155 else { 06156 int jm = (int) ((yc - yom) / apixm); 06157 size_t idx = 0; 06158 float xc; 06159 int im; 06160 for (int i = 0; i < nx; i++) { 06161 xc = xo + i * apix; 06162 idx = (size_t)k * nxy + j * nx + i; 06163 if (xc <= xom || xc >= xom + xm * apixm) { 06164 dp[idx] = 0; 06165 } 06166 else { 06167 im = (int) ((xc - xom) / apixm); 06168 if (dpm[km * xm * ym + jm * xm + im] <= 0) { 06169 dp[idx] = 0; 06170 } 06171 } 06172 } 06173 } 06174 } 06175 } 06176 } 06177 06178 image->update(); 06179 msk->update(); 06180 if( msk ) 06181 { 06182 delete msk; 06183 msk = 0; 06184 } 06185 }
|
|
Definition at line 179 of file processor.cpp. |