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 5300 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 5315 of file processor.h.

05316                 {
05317                         return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size.";
05318                 }

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 5305 of file processor.h.

References NAME.

05306                 {
05307                         return NAME;
05308                 }

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 5320 of file processor.h.

References EMAN::TypeDict::put(), and EMAN::EMObject::STRING.

05321                 {
05322                         TypeDict d;
05323                         d.put("filename", EMObject::STRING, "mask image file name");
05324                         return d;
05325                 }

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

Definition at line 5310 of file processor.h.

05311                 {
05312                         return new CoordinateMaskFileProcessor();
05313                 }

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 5994 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().

05995 {
05996         if (!image) {
05997                 LOGWARN("NULL Image");
05998                 return;
05999         }
06000 
06001         const char *filename = params["filename"];
06002         EMData *msk = new EMData();
06003         msk->read_image(filename);
06004 
06005         int nx = image->get_xsize();
06006         int ny = image->get_ysize();
06007         int nz = image->get_zsize();
06008 
06009         int xm = msk->get_xsize();
06010         int ym = msk->get_ysize();
06011         int zm = msk->get_zsize();
06012 
06013         float apix = image->get_attr("apix_x");
06014         float apixm = msk->get_attr("apix_x");
06015 
06016         float xo = image->get_attr("origin_x");
06017         float yo = image->get_attr("origin_y");
06018         float zo = image->get_attr("origin_z");
06019 
06020         float xom = msk->get_attr("origin_x");
06021         float yom = msk->get_attr("origin_y");
06022         float zom = msk->get_attr("origin_z");
06023 
06024         float *dp = image->get_data();
06025         float *dpm = msk->get_data();
06026         int nxy = nx * ny;
06027 
06028         for (int k = 0; k < nz; k++) {
06029                 float zc = zo + k * apix;
06030                 if (zc <= zom || zc >= zom + zm * apixm) {
06031                         memset(&(dp[k * nxy]), 0, sizeof(float) * nxy);
06032                 }
06033                 else {
06034                         int km = (int) ((zc - zom) / apixm);
06035 
06036                         for (int j = 0; j < ny; j++) {
06037                                 float yc = yo + j * apix;
06038                                 if (yc <= yom || yc >= yom + ym * apixm) {
06039                                         memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx);
06040                                 }
06041                                 else {
06042                                         int jm = (int) ((yc - yom) / apixm);
06043                                         size_t idx = 0;
06044                                         float xc;
06045                                         int im;
06046                                         for (int i = 0; i < nx; i++) {
06047                                                 xc = xo + i * apix;
06048                                                 idx = (size_t)k * nxy + j * nx + i;
06049                                                 if (xc <= xom || xc >= xom + xm * apixm) {
06050                                                         dp[idx] = 0;
06051                                                 }
06052                                                 else {
06053                                                         im = (int) ((xc - xom) / apixm);
06054                                                         if (dpm[km * xm * ym + jm * xm + im] <= 0) {
06055                                                                 dp[idx] = 0;
06056                                                         }
06057                                                 }
06058                                         }
06059                                 }
06060                         }
06061                 }
06062         }
06063 
06064         image->update();
06065         msk->update();
06066         if( msk )
06067         {
06068                 delete msk;
06069                 msk = 0;
06070         }
06071 }


Member Data Documentation

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

Definition at line 5327 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon May 2 13:30:53 2011 for EMAN2 by  doxygen 1.4.7