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:

[legend]
Collaboration diagram for EMAN::TestImageSquarecube:
[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 6278 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 6288 of file processor.h.

06289                 {
06290                         return "Replace a source image as a square or cube depends on 2D or 3D of the source image";
06291                 }

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

06284                 {
06285                         return NAME;
06286                 }

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

References EMAN::TypeDict::put().

06299                 {
06300                         TypeDict d;
06301                         d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel");
06302                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06303                         d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis");
06304                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank");
06305                         return d;
06306                 }

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

Definition at line 6293 of file processor.h.

06294                 {
06295                         return new TestImageSquarecube();
06296                 }

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

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

07339 {
07340         preprocess(image);
07341 
07342         float edge_length = params["edge_length"];
07343         string axis = (const char*)params["axis"];
07344         float odd_edge = params["odd_edge"];
07345         int fill = (int)params["fill"];
07346 
07347         float *dat = image->get_data();
07348         float x2, y2, z2; //this coordinates of this pixel from center
07349         float xEdge, yEdge, zEdge; //half of edge length for this cube
07350         if(axis == ""){
07351                 xEdge = edge_length/2.0f;
07352                 yEdge = edge_length/2.0f;
07353                 zEdge = edge_length/2.0f;
07354         }
07355         else if(axis == "x"){
07356                 xEdge = odd_edge/2.0f;
07357                 yEdge = edge_length/2.0f;
07358                 zEdge = edge_length/2.0f;
07359         }
07360         else if(axis == "y"){
07361                 xEdge = edge_length/2.0f;
07362                 yEdge = odd_edge/2.0f;
07363                 zEdge = edge_length/2.0f;
07364         }
07365         else if(axis == "z"){
07366                 if( nz == 1 ){
07367                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07368                 }
07369                 xEdge = edge_length/2.0f;
07370                 yEdge = edge_length/2.0f;
07371                 zEdge = odd_edge/2.0f;
07372         }
07373         else{
07374                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07375         }
07376         for (int k = 0; k < nz; ++k) {
07377                 for (int j = 0; j < ny; ++j) {
07378                         for (int i = 0; i < nx; ++i, ++dat) {
07379                                 x2 = (float)fabs((float)i - nx/2);
07380                                 y2 = (float)fabs((float)j - ny/2);
07381                                 z2 = (float)fabs((float)k - nz/2);
07382                                 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) {
07383                                         if( !fill) {
07384                                                 *dat = 0;
07385                                         }
07386                                         else {
07387                                                 *dat = 1;
07388                                         }
07389                                 }
07390                                 else {
07391                                         if( !fill ) {
07392                                                 *dat = 1;
07393                                         }
07394                                         else {
07395                                                 *dat = 0;
07396                                         }
07397                                 }
07398                         }
07399                 }
07400         }
07401 
07402         image->update();
07403 }


Member Data Documentation

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

Definition at line 203 of file processor.cpp.


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