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

static ProcessorNEW ()

Static Public Attributes

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


Member Function Documentation

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 7659 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, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update().

07660 {
07661         preprocess(image);
07662 
07663         int nx = image->get_xsize();
07664         int ny = image->get_ysize();
07665         int nz = image->get_zsize();
07666 
07667         if(nz == 1) {
07668                 throw ImageDimensionException("This processor only apply to 3D image");
07669         }
07670 
07671         float radius = params["radius"];
07672 #ifdef _WIN32
07673         if(radius > _cpp_min(nx, ny)/2.0) {
07674 #else
07675         if(radius > std::min(nx, ny)/2.0) {
07676 #endif
07677                 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2");
07678         }
07679 
07680         float height;
07681         if(params.has_key("height")) {
07682                 height = params["height"];
07683                 if(height > nz) {
07684                         throw InvalidValueException(radius, "height must be <= nz");
07685                 }
07686         }
07687         else {
07688                 height = static_cast<float>(nz);
07689         }
07690 
07691         float *dat = image->get_data();
07692         float x2, y2; //this is coordinates of this pixel from center axle
07693         float r = 0.0f;
07694         for (int k = 0; k < nz; ++k) {
07695                 for (int j = 0; j < ny; ++j) {
07696                         for (int i = 0; i < nx; ++i, ++dat) {
07697                                 x2 = fabs((float)i - nx/2);
07698                                 y2 = fabs((float)j - ny/2);
07699                                 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius);
07700 
07701                                 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) {
07702                                         *dat = 1;
07703                                 }
07704                                 else {
07705                                         *dat = 0;
07706                                 }
07707                         }
07708                 }
07709         }
07710 
07711         image->update();
07712 }

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

References EMAN::NormalizeUnitSumProcessor::NAME.

06457                 {
06458                         return NAME;
06459                 }

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

06462                 {
06463                         return "Replace a source image as a cylinder";
06464                 }

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

Definition at line 6466 of file processor.h.

06467                 {
06468                         return new TestImageCylinder();
06469                 }

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

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

06472                 {
06473                         TypeDict d;
06474                         d.put("radius", EMObject::FLOAT, "radius for the cylinder");
06475                         d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz");
06476 
06477                         return d;
06478                 }


Member Data Documentation

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

Definition at line 6480 of file processor.h.


The documentation for this class was generated from the following files:

Generated on Sun Mar 14 03:08:41 2010 for EMAN2 by  doxygen 1.5.6