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

EMAN::TestImageCylinder Class Reference

Replace a source image with a cylinder. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageCylinder:

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

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.cylinder"

Detailed Description

Replace a source image with a cylinder.

Parameters:
radius radius for the cylinder
height height for the cylinder, by default it's the nz

Definition at line 6645 of file processor.h.


Member Function Documentation

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

06656                 {
06657                         return "Replace a source image as a cylinder";
06658                 }

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

06651                 {
06652                         return NAME;
06653                 }

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

References EMAN::TypeDict::put().

06666                 {
06667                         TypeDict d;
06668                         d.put("radius", EMObject::FLOAT, "radius for the cylinder");
06669                         d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz");
06670 
06671                         return d;
06672                 }

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

Definition at line 6660 of file processor.h.

06661                 {
06662                         return new TestImageCylinder();
06663                 }

void TestImageCylinder::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 8041 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), ImageDimensionException, InvalidValueException, min, nx, ny, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update().

08042 {
08043         preprocess(image);
08044 
08045         int nx = image->get_xsize();
08046         int ny = image->get_ysize();
08047         int nz = image->get_zsize();
08048 
08049         if(nz == 1) {
08050                 throw ImageDimensionException("This processor only apply to 3D image");
08051         }
08052 
08053         float radius = params["radius"];
08054 #ifdef _WIN32
08055         if(radius > _cpp_min(nx, ny)/2.0) {
08056 #else
08057         if(radius > std::min(nx, ny)/2.0) {
08058 #endif
08059                 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2");
08060         }
08061 
08062         float height;
08063         if(params.has_key("height")) {
08064                 height = params["height"];
08065                 if(height > nz) {
08066                         throw InvalidValueException(radius, "height must be <= nz");
08067                 }
08068         }
08069         else {
08070                 height = static_cast<float>(nz);
08071         }
08072 
08073         float *dat = image->get_data();
08074         float x2, y2; //this is coordinates of this pixel from center axle
08075         float r = 0.0f;
08076         for (int k = 0; k < nz; ++k) {
08077                 for (int j = 0; j < ny; ++j) {
08078                         for (int i = 0; i < nx; ++i, ++dat) {
08079                                 x2 = fabs((float)i - nx/2);
08080                                 y2 = fabs((float)j - ny/2);
08081                                 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius);
08082 
08083                                 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) {
08084                                         *dat = 1;
08085                                 }
08086                                 else {
08087                                         *dat = 0;
08088                                 }
08089                         }
08090                 }
08091         }
08092 
08093         image->update();
08094 }


Member Data Documentation

const string TestImageCylinder::NAME = "testimage.cylinder" [static]
 

Definition at line 210 of file processor.cpp.


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