#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 5159 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 5174 of file processor.h. 05175 { 05176 return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size."; 05177 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5164 of file processor.h. 05165 {
05166 return NAME;
05167 }
|
|
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 5179 of file processor.h. References EMAN::TypeDict::put(). 05180 { 05181 TypeDict d; 05182 d.put("filename", EMObject::STRING, "mask image file name"); 05183 return d; 05184 }
|
|
Definition at line 5169 of file processor.h. 05170 { 05171 return new CoordinateMaskFileProcessor(); 05172 }
|
|
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 5928 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(). 05929 { 05930 if (!image) { 05931 LOGWARN("NULL Image"); 05932 return; 05933 } 05934 05935 const char *filename = params["filename"]; 05936 EMData *msk = new EMData(); 05937 msk->read_image(filename); 05938 05939 int nx = image->get_xsize(); 05940 int ny = image->get_ysize(); 05941 int nz = image->get_zsize(); 05942 05943 int xm = msk->get_xsize(); 05944 int ym = msk->get_ysize(); 05945 int zm = msk->get_zsize(); 05946 05947 float apix = image->get_attr("apix_x"); 05948 float apixm = msk->get_attr("apix_x"); 05949 05950 float xo = image->get_attr("origin_x"); 05951 float yo = image->get_attr("origin_y"); 05952 float zo = image->get_attr("origin_z"); 05953 05954 float xom = msk->get_attr("origin_x"); 05955 float yom = msk->get_attr("origin_y"); 05956 float zom = msk->get_attr("origin_z"); 05957 05958 float *dp = image->get_data(); 05959 float *dpm = msk->get_data(); 05960 int nxy = nx * ny; 05961 05962 for (int k = 0; k < nz; k++) { 05963 float zc = zo + k * apix; 05964 if (zc <= zom || zc >= zom + zm * apixm) { 05965 memset(&(dp[k * nxy]), 0, sizeof(float) * nxy); 05966 } 05967 else { 05968 int km = (int) ((zc - zom) / apixm); 05969 05970 for (int j = 0; j < ny; j++) { 05971 float yc = yo + j * apix; 05972 if (yc <= yom || yc >= yom + ym * apixm) { 05973 memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx); 05974 } 05975 else { 05976 int jm = (int) ((yc - yom) / apixm); 05977 size_t idx = 0; 05978 float xc; 05979 int im; 05980 for (int i = 0; i < nx; i++) { 05981 xc = xo + i * apix; 05982 idx = k * nxy + j * nx + i; 05983 if (xc <= xom || xc >= xom + xm * apixm) { 05984 dp[idx] = 0; 05985 } 05986 else { 05987 im = (int) ((xc - xom) / apixm); 05988 if (dpm[km * xm * ym + jm * xm + im] <= 0) { 05989 dp[idx] = 0; 05990 } 05991 } 05992 } 05993 } 05994 } 05995 } 05996 } 05997 05998 image->update(); 05999 msk->update(); 06000 if( msk ) 06001 { 06002 delete msk; 06003 msk = 0; 06004 } 06005 }
|
|
Definition at line 173 of file processor.cpp. |