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

Replace the value of each pixel with the sum of density of the object it belongs to. More...

#include <processor.h>

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

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.object.density"
 

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 Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Replace the value of each pixel with the sum of density of the object it belongs to.

Objects are defined by continius density above the given threshold.

Author
: Muyuan Chen
Date
: 03/2015

Definition at line 9476 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::ObjDensityProcessor::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 9490 of file processor.h.

9491 {
9492 return "Sum of density of each object above threshold. Treats a 3D volume as 2D slices.";
9493 }

◆ get_name()

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

9483 {
9484 return NAME;
9485 }
static const string NAME
Definition: processor.h:9500

References NAME.

◆ get_param_types()

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

9495 {
9496 TypeDict d;
9497 d.put("thresh", EMObject::FLOAT, "The threshold to seperate objects.");
9498 return d;
9499 }
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, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 9486 of file processor.h.

9487 {
9488 return new ObjDensityProcessor();
9489 }
Replace the value of each pixel with the sum of density of the object it belongs to.
Definition: processor.h:9477

◆ process()

EMData * ObjDensityProcessor::process ( const EMData *const  image)
virtual

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.

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

Reimplemented from EMAN::Processor.

Definition at line 14508 of file processor.cpp.

14509{
14510
14511 EMData* imageCp= image -> copy();
14512 process_inplace(imageCp);
14513
14514 return imageCp;
14515}
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 ObjDensityProcessor::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 14517 of file processor.cpp.

14518{
14519 int nx = image->get_xsize();
14520 int ny = image->get_ysize();
14521 int nz = image->get_zsize();
14522
14523 float threshold=params.set_default("thresh",0);
14524
14525 // label each object first
14526 EMData *label=image->process("threshold.belowtozero",Dict("minval",threshold));
14527 label->process_inplace("threshold.notzero");
14528 label->process_inplace("morph.object.label");
14529 int nobj=int(label->get_attr("maximum"))+1;
14530 vector<float> sden(nobj); // sum density of each object
14531 for (int i=0; i<nobj; i++) sden[i]=0;
14532
14533 for (int x=0; x<nx; x++){
14534 for (int y=0; y<ny; y++){
14535 for (int z=0; z<nz; z++){
14536 float v=image->get_value_at(x,y,z);
14537 if (v<threshold)
14538 continue;
14539
14540 int li=label->get_value_at(x,y,z);
14541 sden[li]+=v;
14542 }
14543 }
14544 }
14545 for (int x=0; x<nx; x++){
14546 for (int y=0; y<ny; y++){
14547 for (int z=0; z<nz; z++){
14548 int li=label->get_value_at(x,y,z);
14549 if (li==0)
14550 continue;
14551 image->set_value_at_fast(x,y,z,sden[li]);
14552 }
14553 }
14554 }
14555 delete label;
14556}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
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
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

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

Referenced by process().

Member Data Documentation

◆ NAME

const string ObjDensityProcessor::NAME = "morph.object.density"
static

Definition at line 9500 of file processor.h.

Referenced by get_name().


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