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:

[legend]
Collaboration diagram for EMAN::CoordinateMaskFileProcessor:
[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

ProcessorNEW ()

Static Public Attributes

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

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

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

05339                 {
05340                         return NAME;
05341                 }

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

References EMAN::TypeDict::put().

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

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

Definition at line 5343 of file processor.h.

05344                 {
05345                         return new CoordinateMaskFileProcessor();
05346                 }

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 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 }


Member Data Documentation

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

Definition at line 178 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:26 2010 for EMAN2 by  doxygen 1.3.9.1