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

EMAN::TestImageSquarecube Class Reference

Replace a source image as a square or cube depends on 2D or 3D of the source image. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageSquarecube:

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

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

ProcessorNEW ()

Static Public Attributes

const string NAME = "testimage.squarecube"

Detailed Description

Replace a source image as a square or cube depends on 2D or 3D of the source image.

Parameters:
edge_length edge length of the square or cube
axis specify a major axis for asymmetric features
odd_edge edge length for the asymmetric axis
fill answer 'yes' or 'no' to specify if it's filled or hollow, default filled

Definition at line 6402 of file processor.h.


Member Function Documentation

virtual string EMAN::TestImageSquarecube::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 6412 of file processor.h.

06413                 {
06414                         return "Replace a source image as a square or cube depends on 2D or 3D of the source image";
06415                 }

virtual string EMAN::TestImageSquarecube::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 6407 of file processor.h.

06408                 {
06409                         return NAME;
06410                 }

virtual TypeDict EMAN::TestImageSquarecube::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 6422 of file processor.h.

References EMAN::TypeDict::put().

06423                 {
06424                         TypeDict d;
06425                         d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel");
06426                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06427                         d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis");
06428                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank");
06429                         return d;
06430                 }

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

Definition at line 6417 of file processor.h.

06418                 {
06419                         return new TestImageSquarecube();
06420                 }

void TestImageSquarecube::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 7706 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::Dict::has_key(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update().

07707 {
07708         preprocess(image);
07709 
07710         float edge_length = params["edge_length"];
07711         string axis = (const char*)params["axis"];
07712         float odd_edge = params["odd_edge"];
07713         int fill = 1;
07714         if(params.has_key("fill")) {
07715                 fill = (int)params["fill"];
07716         }
07717 
07718         float *dat = image->get_data();
07719         float x2, y2, z2; //this coordinates of this pixel from center
07720         float xEdge, yEdge, zEdge; //half of edge length for this cube
07721         if(axis == ""){
07722                 xEdge = edge_length/2.0f;
07723                 yEdge = edge_length/2.0f;
07724                 zEdge = edge_length/2.0f;
07725         }
07726         else if(axis == "x"){
07727                 xEdge = odd_edge/2.0f;
07728                 yEdge = edge_length/2.0f;
07729                 zEdge = edge_length/2.0f;
07730         }
07731         else if(axis == "y"){
07732                 xEdge = edge_length/2.0f;
07733                 yEdge = odd_edge/2.0f;
07734                 zEdge = edge_length/2.0f;
07735         }
07736         else if(axis == "z"){
07737                 if( nz == 1 ){
07738                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07739                 }
07740                 xEdge = edge_length/2.0f;
07741                 yEdge = edge_length/2.0f;
07742                 zEdge = odd_edge/2.0f;
07743         }
07744         else{
07745                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07746         }
07747         for (int k = 0; k < nz; ++k) {
07748                 for (int j = 0; j < ny; ++j) {
07749                         for (int i = 0; i < nx; ++i, ++dat) {
07750                                 x2 = (float)fabs((float)i - nx/2);
07751                                 y2 = (float)fabs((float)j - ny/2);
07752                                 z2 = (float)fabs((float)k - nz/2);
07753                                 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) {
07754                                         if( !fill) {
07755                                                 *dat = 0;
07756                                         }
07757                                         else {
07758                                                 *dat = 1;
07759                                         }
07760                                 }
07761                                 else {
07762                                         if( !fill ) {
07763                                                 *dat = 1;
07764                                         }
07765                                         else {
07766                                                 *dat = 0;
07767                                         }
07768                                 }
07769                         }
07770                 }
07771         }
07772 
07773         image->update();
07774 }


Member Data Documentation

const string TestImageSquarecube::NAME = "testimage.squarecube" [static]
 

Definition at line 204 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:42:47 2013 for EMAN2 by  doxygen 1.3.9.1