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

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

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

References NAME.

05420                 {
05421                         return NAME;
05422                 }

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

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

05435                 {
05436                         TypeDict d;
05437                         d.put("filename", EMObject::STRING, "mask image file name");
05438                         return d;
05439                 }

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

Definition at line 5424 of file processor.h.

05425                 {
05426                         return new CoordinateMaskFileProcessor();
05427                 }

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

06181 {
06182         if (!image) {
06183                 LOGWARN("NULL Image");
06184                 return;
06185         }
06186 
06187         const char *filename = params["filename"];
06188         EMData *msk = new EMData();
06189         msk->read_image(filename);
06190 
06191         int nx = image->get_xsize();
06192         int ny = image->get_ysize();
06193         int nz = image->get_zsize();
06194 
06195         int xm = msk->get_xsize();
06196         int ym = msk->get_ysize();
06197         int zm = msk->get_zsize();
06198 
06199         float apix = image->get_attr("apix_x");
06200         float apixm = msk->get_attr("apix_x");
06201 
06202         float xo = image->get_attr("origin_x");
06203         float yo = image->get_attr("origin_y");
06204         float zo = image->get_attr("origin_z");
06205 
06206         float xom = msk->get_attr("origin_x");
06207         float yom = msk->get_attr("origin_y");
06208         float zom = msk->get_attr("origin_z");
06209 
06210         float *dp = image->get_data();
06211         float *dpm = msk->get_data();
06212         int nxy = nx * ny;
06213 
06214         for (int k = 0; k < nz; k++) {
06215                 float zc = zo + k * apix;
06216                 if (zc <= zom || zc >= zom + zm * apixm) {
06217                         memset(&(dp[k * nxy]), 0, sizeof(float) * nxy);
06218                 }
06219                 else {
06220                         int km = (int) ((zc - zom) / apixm);
06221 
06222                         for (int j = 0; j < ny; j++) {
06223                                 float yc = yo + j * apix;
06224                                 if (yc <= yom || yc >= yom + ym * apixm) {
06225                                         memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx);
06226                                 }
06227                                 else {
06228                                         int jm = (int) ((yc - yom) / apixm);
06229                                         size_t idx = 0;
06230                                         float xc;
06231                                         int im;
06232                                         for (int i = 0; i < nx; i++) {
06233                                                 xc = xo + i * apix;
06234                                                 idx = (size_t)k * nxy + j * nx + i;
06235                                                 if (xc <= xom || xc >= xom + xm * apixm) {
06236                                                         dp[idx] = 0;
06237                                                 }
06238                                                 else {
06239                                                         im = (int) ((xc - xom) / apixm);
06240                                                         if (dpm[km * xm * ym + jm * xm + im] <= 0) {
06241                                                                 dp[idx] = 0;
06242                                                         }
06243                                                 }
06244                                         }
06245                                 }
06246                         }
06247                 }
06248         }
06249 
06250         image->update();
06251         msk->update();
06252         if( msk )
06253         {
06254                 delete msk;
06255                 msk = 0;
06256         }
06257 }


Member Data Documentation

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

Definition at line 5441 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:10:41 2012 for EMAN2 by  doxygen 1.4.7