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

Make a curve or surface non-convex (planar or concave), iteratively. More...

#include <processor.h>

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

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
 
string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
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::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 = "math.nonconvex"
 

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

Make a curve or surface non-convex (planar or concave), iteratively.

Author
Steve Ludtke
Date
2011/08/11

Definition at line 5239 of file processor.h.

Member Function Documentation

◆ get_desc()

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

5254 {
5255 return "Makes a curve or plane monotonically decreasing and non-convex. Useful in generating background curves from power spectra. Anchored at edges and (in 2d) at the center. If local value > mean(surrounding values) => mean(surrounding values).";
5256 }

◆ get_name()

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

5245 {
5246 return NAME;
5247 }
static const string NAME
Definition: processor.h:5267

References NAME.

◆ get_param_types()

TypeDict EMAN::NonConvexProcessor::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 5258 of file processor.h.

5259 {
5260 TypeDict d;
5261/* d.put("mask", EMObject::EMDATA, "mask object: nonzero pixel positions will be used to fit plane. default = 0");
5262 d.put("changeZero", EMObject::INT, "if zero pixels are modified when removing gradient. default = 0");
5263 d.put("planeParam", EMObject::FLOATARRAY, "fitted plane parameters output");*/
5264 return d;
5265 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305

◆ NEW()

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

Definition at line 5248 of file processor.h.

5249 {
5250 return new NonConvexProcessor();
5251 }
Make a curve or surface non-convex (planar or concave), iteratively.
Definition: processor.h:5240

◆ process_inplace()

void NonConvexProcessor::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 3724 of file processor.cpp.

3724 {
3725 if (!image) { LOGWARN("NULL IMAGE"); return; }
3726 //int isinten=image->get_attr_default("is_intensity",0);
3727
3728 // 1-D
3729 if (image->get_ysize()==1) {
3730
3731 }
3732 // 2-D
3733 else if (image->get_zsize()==1) {
3734// if (!isinten) throw ImageDimensionException("Only complex intensity images currently supported by NonConvexProcessor");
3735 int nx2=image->get_xsize()/2;
3736 int ny2=image->get_ysize()/2;
3737 vector<float> rdist = image->calc_radial_dist(nx2*1.5,0,1,false); // radial distribution to make sure nonconvex values decrease radially
3738 // Make sure rdist is decreasing (or flat)
3739 for (int i=1; i<nx2; i++) {
3740 if (rdist[i]>rdist[i-1]) rdist[i]=rdist[i-1];
3741 }
3742
3743 image->process_inplace("xform.fourierorigin.tocenter");
3744 EMData* binary=image->copy();
3745
3746 // First we eliminate convex points from the input image (set to zero)
3747 for (int x=0; x<image->get_xsize(); x+=2) {
3748 for (int y=1; y<image->get_ysize()-1; y++) {
3749 int r=(int)hypot((float)(x/2),(float)(y-ny2));
3750 float cen=(*binary)(x,y);
3751 if (x==0 || x==nx2*2-2 || (cen>(*binary)(x+2,y) || cen>(*binary)(x-2,y) || cen>(*binary)(x,y+1) || cen >(*binary)(x,y-1) || (*binary)(x,y)>rdist[r])) { // point is considered nonconvex if lower than surrounding values and lower than mean
3752 image->set_value_at_fast(x/2+nx2,y,0.0); // we are turning image into a full real-space intensity image for now
3753 image->set_value_at_fast(nx2-x/2,ny2*2-y-1,0.0);
3754 }
3755 else {
3756 image->set_value_at_fast(x/2+nx2,y,cen); // we are turning image into a full real-space intensity image for now
3757 image->set_value_at_fast(nx2-x/2,ny2*2-y-1,cen); // It will contain non-zero values only for nonconvex points
3758 }
3759 }
3760 }
3761 image->set_value_at_fast(nx2+1,ny2,(*binary)(2,ny2)); // We keep the points near the Fourier origin as a central anchor even though it's convex
3762 image->set_value_at_fast(nx2-1,ny2,(*binary)(2,ny2)); // We keep the points near the Fourier origin as a central anchor even though it's convex
3763 image->set_value_at_fast(nx2,ny2+1,(*binary)(0,ny2+1)); // We keep the points near the Fourier origin as a central anchor even though it's convex
3764 image->set_value_at_fast(nx2,ny2-1,(*binary)(0,ny2-1)); // We keep the points near the Fourier origin as a central anchor even though it's convex
3765 for (int y=0; y<ny2*2; y++) image->set_value_at_fast(0,y,0.0f);
3766
3767 // Now make a binary version of the convex points
3768 float *idat=image->get_data();
3769 float *bdat=binary->get_data();
3770 int nxy=(nx2*ny2*4);
3771 for (int i=0; i<nxy; i++) {
3772 bdat[i]=idat[i]==0?0:1.0f; // binary version of the convex points in image
3773 }
3774 binary->update();
3775
3776 // We now use a Gaussian filter on both images, to use Gaussian interpolation to fill in zero values
3777 image->set_complex(false); // so we can use a Gaussian filter on it
3778 binary->set_complex(false);
3779
3780/* image->write_image("con.hdf",0);*/
3781 image->set_fftpad(false);
3782 binary->set_fftpad(false);
3783
3784 // Gaussian blur of both images
3785 image->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
3786 binary->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
3787
3788/* image->write_image("con.hdf",1);
3789 binary->write_image("con.hdf",2);*/
3790
3791 for (int x=0; x<image->get_xsize(); x+=2) {
3792 for (int y=0; y<image->get_ysize(); y++) {
3793 float bv=binary->get_value_at(x/2+nx2,y);
3794 image->set_value_at_fast(x,y,image->get_value_at(x/2+nx2,y)/(bv<=0?1.0f:bv));
3795 image->set_value_at_fast(x+1,y,0.0);
3796 }
3797 }
3798 image->set_complex(true);
3799 image->set_fftpad(true);
3800 image->process_inplace("xform.fourierorigin.tocorner");
3801 delete binary;
3802 }
3803 else throw ImageDimensionException("3D maps not yet supported by NonConvexProcessor");
3804
3805}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
vector< float > calc_radial_dist(int n, float x0, float dx, int inten)
calculates radial distribution.
Definition: emdata.cpp:2781
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGWARN
Definition: log.h:53
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::EMData::calc_radial_dist(), ImageDimensionException, LOGWARN, x, and y.

Member Data Documentation

◆ NAME

const string NonConvexProcessor::NAME = "math.nonconvex"
static

Definition at line 5267 of file processor.h.

Referenced by get_name().


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