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

static ProcessorNEW ()

Static Public Attributes

static 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 6361 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 6371 of file processor.h.

06372                 {
06373                         return "Replace a source image as a square or cube depends on 2D or 3D of the source image";
06374                 }

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

References NAME.

06367                 {
06368                         return NAME;
06369                 }

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

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

06382                 {
06383                         TypeDict d;
06384                         d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel");
06385                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06386                         d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis");
06387                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank");
06388                         return d;
06389                 }

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

Definition at line 6376 of file processor.h.

06377                 {
06378                         return new TestImageSquarecube();
06379                 }

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 7626 of file processor.cpp.

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

07627 {
07628         preprocess(image);
07629 
07630         float edge_length = params["edge_length"];
07631         string axis = (const char*)params["axis"];
07632         float odd_edge = params["odd_edge"];
07633         int fill = 1;
07634         if(params.has_key("fill")) {
07635                 fill = (int)params["fill"];
07636         }
07637 
07638         float *dat = image->get_data();
07639         float x2, y2, z2; //this coordinates of this pixel from center
07640         float xEdge, yEdge, zEdge; //half of edge length for this cube
07641         if(axis == ""){
07642                 xEdge = edge_length/2.0f;
07643                 yEdge = edge_length/2.0f;
07644                 zEdge = edge_length/2.0f;
07645         }
07646         else if(axis == "x"){
07647                 xEdge = odd_edge/2.0f;
07648                 yEdge = edge_length/2.0f;
07649                 zEdge = edge_length/2.0f;
07650         }
07651         else if(axis == "y"){
07652                 xEdge = edge_length/2.0f;
07653                 yEdge = odd_edge/2.0f;
07654                 zEdge = edge_length/2.0f;
07655         }
07656         else if(axis == "z"){
07657                 if( nz == 1 ){
07658                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07659                 }
07660                 xEdge = edge_length/2.0f;
07661                 yEdge = edge_length/2.0f;
07662                 zEdge = odd_edge/2.0f;
07663         }
07664         else{
07665                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07666         }
07667         for (int k = 0; k < nz; ++k) {
07668                 for (int j = 0; j < ny; ++j) {
07669                         for (int i = 0; i < nx; ++i, ++dat) {
07670                                 x2 = (float)fabs((float)i - nx/2);
07671                                 y2 = (float)fabs((float)j - ny/2);
07672                                 z2 = (float)fabs((float)k - nz/2);
07673                                 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) {
07674                                         if( !fill) {
07675                                                 *dat = 0;
07676                                         }
07677                                         else {
07678                                                 *dat = 1;
07679                                         }
07680                                 }
07681                                 else {
07682                                         if( !fill ) {
07683                                                 *dat = 1;
07684                                         }
07685                                         else {
07686                                                 *dat = 0;
07687                                         }
07688                                 }
07689                         }
07690                 }
07691         }
07692 
07693         image->update();
07694 }


Member Data Documentation

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

Definition at line 6391 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:54 2012 for EMAN2 by  doxygen 1.4.7