Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::CoordinateMaskFileProcessor Class Reference

Multiplies the image by the specified file using pixel coordinates instead of pixel indices. More...

#include <processor.h>

Inheritance diagram for EMAN::CoordinateMaskFileProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::CoordinateMaskFileProcessor:

Collaboration graph
[legend]
List of all members.

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 ProcessorNEW ()

Static Public Attributes

static const string NAME = "mask.fromfile.sizediff"

Detailed Description

Multiplies the image by the specified file using pixel coordinates instead of pixel indices.

The images can be different size.

Parameters:
filename mask image file name

Definition at line 5374 of file processor.h.


Member Function Documentation

virtual string EMAN::CoordinateMaskFileProcessor::get_desc  )  const [inline, virtual]
 

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

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                 }

virtual string EMAN::CoordinateMaskFileProcessor::get_name  )  const [inline, virtual]
 

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 5379 of file processor.h.

References NAME.

05380                 {
05381                         return NAME;
05382                 }

virtual TypeDict EMAN::CoordinateMaskFileProcessor::get_param_types  )  const [inline, virtual]
 

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

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                 }

static Processor* EMAN::CoordinateMaskFileProcessor::NEW  )  [inline, static]
 

Definition at line 5384 of file processor.h.

05385                 {
05386                         return new CoordinateMaskFileProcessor();
05387                 }

void CoordinateMaskFileProcessor::process_inplace EMData image  )  [virtual]
 

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.

Parameters:
image The image to be processed.

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 }


Member Data Documentation

const string CoordinateMaskFileProcessor::NAME = "mask.fromfile.sizediff" [static]
 

Definition at line 5401 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 13:07:15 2010 for EMAN2 by  doxygen 1.4.4