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

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

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

References NAME.

05340                 {
05341                         return NAME;
05342                 }

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

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

05355                 {
05356                         TypeDict d;
05357                         d.put("filename", EMObject::STRING, "mask image file name");
05358                         return d;
05359                 }

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

Definition at line 5344 of file processor.h.

05345                 {
05346                         return new CoordinateMaskFileProcessor();
05347                 }

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

05960 {
05961         if (!image) {
05962                 LOGWARN("NULL Image");
05963                 return;
05964         }
05965 
05966         const char *filename = params["filename"];
05967         EMData *msk = new EMData();
05968         msk->read_image(filename);
05969 
05970         int nx = image->get_xsize();
05971         int ny = image->get_ysize();
05972         int nz = image->get_zsize();
05973 
05974         int xm = msk->get_xsize();
05975         int ym = msk->get_ysize();
05976         int zm = msk->get_zsize();
05977 
05978         float apix = image->get_attr("apix_x");
05979         float apixm = msk->get_attr("apix_x");
05980 
05981         float xo = image->get_attr("origin_x");
05982         float yo = image->get_attr("origin_y");
05983         float zo = image->get_attr("origin_z");
05984 
05985         float xom = msk->get_attr("origin_x");
05986         float yom = msk->get_attr("origin_y");
05987         float zom = msk->get_attr("origin_z");
05988 
05989         float *dp = image->get_data();
05990         float *dpm = msk->get_data();
05991         int nxy = nx * ny;
05992 
05993         for (int k = 0; k < nz; k++) {
05994                 float zc = zo + k * apix;
05995                 if (zc <= zom || zc >= zom + zm * apixm) {
05996                         memset(&(dp[k * nxy]), 0, sizeof(float) * nxy);
05997                 }
05998                 else {
05999                         int km = (int) ((zc - zom) / apixm);
06000 
06001                         for (int j = 0; j < ny; j++) {
06002                                 float yc = yo + j * apix;
06003                                 if (yc <= yom || yc >= yom + ym * apixm) {
06004                                         memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx);
06005                                 }
06006                                 else {
06007                                         int jm = (int) ((yc - yom) / apixm);
06008                                         size_t idx = 0;
06009                                         float xc;
06010                                         int im;
06011                                         for (int i = 0; i < nx; i++) {
06012                                                 xc = xo + i * apix;
06013                                                 idx = k * nxy + j * nx + i;
06014                                                 if (xc <= xom || xc >= xom + xm * apixm) {
06015                                                         dp[idx] = 0;
06016                                                 }
06017                                                 else {
06018                                                         im = (int) ((xc - xom) / apixm);
06019                                                         if (dpm[km * xm * ym + jm * xm + im] <= 0) {
06020                                                                 dp[idx] = 0;
06021                                                         }
06022                                                 }
06023                                         }
06024                                 }
06025                         }
06026                 }
06027         }
06028 
06029         image->update();
06030         msk->update();
06031         if( msk )
06032         {
06033                 delete msk;
06034                 msk = 0;
06035         }
06036 }


Member Data Documentation

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

Definition at line 5361 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:17:24 2010 for EMAN2 by  doxygen 1.4.7