EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all 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]

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::TestImageProcessor
static string get_group_desc ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "testimage.squarecube"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Member Functions inherited from EMAN::TestImageProcessor
void preprocess (EMData *image)
 
- Protected Attributes inherited from EMAN::TestImageProcessor
int nx
 
int ny
 
int nz
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

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

Parameters
edge_lengthedge length of the square or cube
axisspecify a major axis for asymmetric features
odd_edgeedge length for the asymmetric axis
fillanswer 'yes' or 'no' to specify if it's filled or hollow, default filled

Definition at line 8604 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::TestImageSquarecube::get_desc ( ) const
inlinevirtual

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

8615 {
8616 return "Replace a source image as a square or cube depends on 2D or 3D of the source image";
8617 }

◆ get_name()

virtual string EMAN::TestImageSquarecube::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 8609 of file processor.h.

8610 {
8611 return NAME;
8612 }
static const string NAME
Definition: processor.h:8634

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::TestImageSquarecube::get_param_types ( ) const
inlinevirtual

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

8625 {
8626 TypeDict d;
8627 d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel");
8628 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
8629 d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis");
8630 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank");
8631 return d;
8632 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

static Processor * EMAN::TestImageSquarecube::NEW ( )
inlinestatic

Definition at line 8619 of file processor.h.

8620 {
8621 return new TestImageSquarecube();
8622 }
Replace a source image as a square or cube depends on 2D or 3D of the source image.
Definition: processor.h:8605

◆ process_inplace()

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
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 9741 of file processor.cpp.

9742{
9743 preprocess(image);
9744
9745 float edge_length = params["edge_length"];
9746 string axis = (const char*)params["axis"];
9747 float odd_edge = params["odd_edge"];
9748 int fill = 1;
9749 if(params.has_key("fill")) {
9750 fill = (int)params["fill"];
9751 }
9752
9753 float *dat = image->get_data();
9754 float x2, y2, z2; //this coordinates of this pixel from center
9755 float xEdge, yEdge, zEdge; //half of edge length for this cube
9756 if(axis == ""){
9757 xEdge = edge_length/2.0f;
9758 yEdge = edge_length/2.0f;
9759 zEdge = edge_length/2.0f;
9760 }
9761 else if(axis == "x"){
9762 xEdge = odd_edge/2.0f;
9763 yEdge = edge_length/2.0f;
9764 zEdge = edge_length/2.0f;
9765 }
9766 else if(axis == "y"){
9767 xEdge = edge_length/2.0f;
9768 yEdge = odd_edge/2.0f;
9769 zEdge = edge_length/2.0f;
9770 }
9771 else if(axis == "z"){
9772 if( nz == 1 ){
9773 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
9774 }
9775 xEdge = edge_length/2.0f;
9776 yEdge = edge_length/2.0f;
9777 zEdge = odd_edge/2.0f;
9778 }
9779 else{
9780 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
9781 }
9782 for (int k = 0; k < nz; ++k) {
9783 for (int j = 0; j < ny; ++j) {
9784 for (int i = 0; i < nx; ++i, ++dat) {
9785 x2 = (float)fabs((float)i - nx/2);
9786 y2 = (float)fabs((float)j - ny/2);
9787 z2 = (float)fabs((float)k - nz/2);
9788 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) {
9789 if( !fill) {
9790 *dat = 0;
9791 }
9792 else {
9793 *dat = 1;
9794 }
9795 }
9796 else {
9797 if( !fill ) {
9798 *dat = 1;
9799 }
9800 else {
9801 *dat = 0;
9802 }
9803 }
9804 }
9805 }
9806 }
9807
9808 image->update();
9809}
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
void preprocess(EMData *image)
Definition: processor.cpp:8923
#define InvalidValueException(val, desc)
Definition: exception.h:285

References EMAN::Dict::has_key(), InvalidValueException, EMAN::TestImageProcessor::nx, EMAN::TestImageProcessor::ny, EMAN::TestImageProcessor::nz, EMAN::Processor::params, and EMAN::TestImageProcessor::preprocess().

Member Data Documentation

◆ NAME

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

Definition at line 8634 of file processor.h.

Referenced by get_name().


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