Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::GrowSkeletonProcessor Class Reference

Grow a skeleton map toward a local direction. More...

#include <processor.h>

Inheritance diagram for EMAN::GrowSkeletonProcessor:
Inheritance graph
Collaboration diagram for EMAN::GrowSkeletonProcessor:
Collaboration graph

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
virtual string get_name () const
 Get the processor's name. More...
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 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::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 = "morph.grow"

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
 Fourier filter Processor type enum. More...
- Protected Attributes inherited from EMAN::Processor
Dict params

Detailed Description

Grow a skeleton map toward a local direction.

Image should be binarized.

: Muyuan Chen
: 06/2015

Definition at line 9657 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::GrowSkeletonProcessor::get_desc ( ) const

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

The description of this processor.

Implements EMAN::Processor.

Definition at line 9671 of file processor.h.

9672 {
9673 return "Grow a skeleton map toward a local direction.";
9674 }

◆ get_name()

virtual string EMAN::GrowSkeletonProcessor::get_name ( ) const

Get the processor's name.

Each processor is identified by a unique name.

The processor's name.

Implements EMAN::Processor.

Definition at line 9663 of file processor.h.

9664 {
9665 return NAME;
9666 }
static const string NAME
Definition: processor.h:9682

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::GrowSkeletonProcessor::get_param_types ( ) const

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 9675 of file processor.h.

9676 {
9677 TypeDict d;
9678 d.put("verbose", EMObject::INT, "Verbose");
9679 d.put("radius", EMObject::INT, "Half of the box size to determine the local direction.");
9680 return d;
9681 }
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::INT, and EMAN::TypeDict::put().

◆ NEW()

static Processor * EMAN::GrowSkeletonProcessor::NEW ( )

Definition at line 9667 of file processor.h.

9668 {
9669 return new GrowSkeletonProcessor();
9670 }
Grow a skeleton map toward a local direction.
Definition: processor.h:9658

◆ process()

EMData * GrowSkeletonProcessor::process ( const EMData *const  image)

To proccess an image out-of-place.

For those processors which can only be processed out-of-place, override this function to give the right behavior.

imageThe image will be copied, actual process happen on copy of image.
the image processing result, may or may not be the same size of the input image

Reimplemented from EMAN::Processor.

Definition at line 15013 of file processor.cpp.

15015 EMData* imageCp= image -> copy();
15016 process_inplace(imageCp);
15017 return imageCp;
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
virtual void process_inplace(EMData *image)
To process an image in-place.
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....

References copy(), and process_inplace().

◆ process_inplace()

void GrowSkeletonProcessor::process_inplace ( EMData image)

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.

imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 15020 of file processor.cpp.

15020 {
15021 // This function is far from optimized, but it works...
15023 int nx = image->get_xsize();
15024 int ny = image->get_ysize();
15025 int nz = image->get_zsize();
15027 int verbose=params.set_default("verbose",0);
15028 int rad=params.set_default("radius",3);
15031 float *data = image->get_data();
15032 // the index of the boundary points of the box
15033 int *xlist=new int[2*rad*4];
15034 int *ylist=new int[2*rad*4];
15035 int count=0;
15036 for (int i=-rad; i<rad; i++){ xlist[count]=-rad; ylist[count]=i; count++;}
15037 for (int i=-rad; i<rad; i++){ xlist[count]=i; ylist[count]=rad; count++;}
15038 for (int i=-rad; i<rad; i++){ xlist[count]=rad; ylist[count]=-i; count++;}
15039 for (int i=-rad; i<rad; i++){ xlist[count]=-i; ylist[count]=-rad; count++;}
15040 size_t nxy = nx * ny;
15041 for (int k=0; k<nz; k++){
15042 if (verbose>0)
15043 printf("Processing layer %d \n",k);
15045 size_t knxy = (size_t)k * nxy;
15046 // only grow on the endpoints
15047 for (int j=rad; j < ny-rad; j++) {
15048 int jnx=j*nx;
15049 for (int i=rad; i<nx-rad; i++) {
15051 if (data[knxy+i+jnx]==0)
15052 continue;
15053 int nb=-1; // number of neighbors
15054 for (int i2=i-1; i2<=i+1; i2++) {
15055 for (int j2=j-1; j2<=j+1; j2++) {
15056 nb+=(data[knxy+i2+j2*nx]>0 ? 1 : 0);
15057 }
15058 }
15059 if (nb==1){ // endpoint found
15060 int nv=0,cp=0;
15061 for (int ic=0; ic<count; ic++){
15062 int ix=i+xlist[ic], jy=j+ylist[ic];
15063 float v=data[knxy+ix+jy*nx];
15064 if (v>0){
15065 nv++;
15066 cp=ic;
15067 }
15068 }
15069 if (nv != 1)
15070 // more than one possible directions
15071 continue;
15073 // grow towards the oppisite direction
15074 for (int ig=1; ig<=rad; ig++){
15075 int ix=i-(float)xlist[cp]/rad*ig;
15076 int jy=j-(float)ylist[cp]/rad*ig;
15077 data[knxy+ix+jy*nx]=-1;
15078 }
15079 }
15080 }
15081 }
15083 for (int j=rad; j < ny-rad; j++) {
15084 int jnx=j*nx;
15085 for (int i=rad; i<nx-rad; i++) {
15086 if (data[knxy+i+jnx]==-1)
15087 data[knxy+i+jnx]=1;
15088 }
15089 }
15090 }
15091 image->update();
15093 delete[] xlist;
15094 delete[] ylist;
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569

References EMAN::Processor::params, and EMAN::Dict::set_default().

Referenced by process().

Member Data Documentation


const string GrowSkeletonProcessor::NAME = "morph.grow"

Definition at line 9682 of file processor.h.

Referenced by get_name().

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