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

Binarize an image based on the circular average around each pixel in real space. More...

#include <processor.h>

Inheritance diagram for EMAN::CircularAverageBinarizeProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::CircularAverageBinarizeProcessor:
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 = "threshold.binary.circularmean"
 

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

Binarize an image based on the circular average around each pixel in real space.

The pixel is set to 1 when the ring average around the pixel keeps decreasing for n pixels as the radius of the ring increases. Here n is the threshold. This essentially picks out the local maximum pixels with some noise tolerance.

Author
: Muyuan Chen
Date
: 03/2015

Definition at line 9444 of file processor.h.

Member Function Documentation

◆ get_desc()

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

9459 {
9460 return "Binarize an image based on the circular average around each pixel in real space.";
9461 }

◆ get_name()

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

9451 {
9452 return NAME;
9453 }

References NAME.

◆ get_param_types()

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

9463 {
9464 TypeDict d;
9465 d.put("thresh", EMObject::INT, "The radius threshold that the circular average of density keep dropping.");
9466 return d;
9467 }
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::CircularAverageBinarizeProcessor::NEW ( )
inlinestatic

Definition at line 9454 of file processor.h.

9455 {
9457 }
Binarize an image based on the circular average around each pixel in real space.
Definition: processor.h:9445

◆ process()

EMData * CircularAverageBinarizeProcessor::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 14438 of file processor.cpp.

14439{
14440 int thr=params.set_default("thresh",5);
14441
14442 EMData* bwmap= image -> copy();
14443 int x_size = image->get_xsize();
14444 int y_size = image->get_ysize();
14445 int z_size = image->get_zsize();
14446
14447 int ix,iy,iz,it,count,ic;
14448 int *dx=new int[thr*8],*dy=new int[thr*8];
14449 for (it=1; it<=thr; it++){
14450 // calculate the indexes
14451 count=0;
14452 for (ix=-thr-1; ix<=thr+1; ix++){
14453 for (iy=-thr-1; iy<=thr+1; iy++){
14454 int d2=ix*ix+iy*iy;
14455 if (d2>=it*it && d2<(it+1)*(it+1)){
14456 dx[count]=ix;
14457 dy[count]=iy;
14458 count++;
14459 }
14460 }
14461 }
14462 // for each pixel
14463 for (iz=0; iz<z_size; iz++){
14464 for (ix=0; ix<x_size; ix++){
14465 for (iy=0; iy<y_size; iy++){
14466 // circular average on each ring
14467 float mn=0;
14468 if (bwmap->get_value_at(ix,iy,iz)==0)
14469 continue;
14470 for (ic=0; ic<count; ic++){
14471 mn+=image->sget_value_at(ix+dx[ic],iy+dy[ic],iz);
14472 }
14473 mn/=count;
14474 if (mn>bwmap->get_value_at(ix,iy,iz))
14475 mn=0;
14476 bwmap->set_value_at(ix,iy,iz,mn);
14477 }
14478 }
14479 }
14480 }
14481 // binarize image
14482 for (iz=0; iz<z_size; iz++){
14483 for (ix=0; ix<x_size; ix++){
14484 for (iy=0; iy<y_size; iy++){
14485 if (bwmap->get_value_at(ix,iy,iz)>0)
14486 bwmap->set_value_at(ix,iy,iz,1);
14487 else
14488 bwmap->set_value_at(ix,iy,iz,0);
14489 }
14490 }
14491 }
14492 delete[] dx;
14493 delete[] dy;
14494 return bwmap;
14495
14496
14497}
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
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....

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

Referenced by process_inplace().

◆ process_inplace()

void CircularAverageBinarizeProcessor::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 14498 of file processor.cpp.

14499{
14500 EMData *tmp=process(image);
14501 memcpy(image->get_data(),tmp->get_data(),(size_t)image->get_xsize()*image->get_ysize()*image->get_zsize()*sizeof(float));
14502 delete tmp;
14503 image->update();
14504 return;
14505
14506}
virtual EMData * process(const EMData *const image)
To proccess an image out-of-place.

References process().

Member Data Documentation

◆ NAME

const string CircularAverageBinarizeProcessor::NAME = "threshold.binary.circularmean"
static

Definition at line 9468 of file processor.h.

Referenced by get_name().


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