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

List of all members.

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place.
string get_name () const
 Get the processor's name.
string get_desc () const
 Get the descrition of this specific processor.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "math.nonconvex"

Detailed Description

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

Author:
Steve Ludtke
Date:
2011/08/11

Definition at line 3883 of file processor.h.


Member Function Documentation

string EMAN::NonConvexProcessor::get_desc ( ) const [inline, virtual]

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

                {
                        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).";
                }
string EMAN::NonConvexProcessor::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 3888 of file processor.h.

References NAME.

                {
                        return NAME;
                }
TypeDict EMAN::NonConvexProcessor::get_param_types ( ) const [inline, virtual]

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

                {
                        TypeDict d;
/*                      d.put("mask", EMObject::EMDATA, "mask object: nonzero pixel positions will be used to fit plane. default = 0");
                        d.put("changeZero", EMObject::INT, "if zero pixels are modified when removing gradient. default = 0");
                        d.put("planeParam", EMObject::FLOATARRAY, "fitted plane parameters output");*/
                        return d;
                }
static Processor* EMAN::NonConvexProcessor::NEW ( ) [inline, static]

Definition at line 3892 of file processor.h.

                {
                        return new NonConvexProcessor();
                }
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 2794 of file processor.cpp.

References EMAN::EMData::calc_radial_dist(), EMAN::EMData::copy(), EMAN::EMData::get_data(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGWARN, EMAN::EMData::process_inplace(), EMAN::EMData::set_complex(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_value_at_fast(), EMAN::EMData::update(), x, and y.

                                                       {
        if (!image) { LOGWARN("NULL IMAGE"); return; }
        //int isinten=image->get_attr_default("is_intensity",0);

        // 1-D
        if (image->get_ysize()==1) {

        }
        // 2-D
        else if (image->get_zsize()==1) {
//              if (!isinten) throw ImageDimensionException("Only complex intensity images currently supported by NonConvexProcessor");
                int nx2=image->get_xsize()/2;
                int ny2=image->get_ysize()/2;
                vector<float> rdist = image->calc_radial_dist(nx2*1.5,0,1,false);               // radial distribution to make sure nonconvex values decrease radially
                // Make sure rdist is decreasing (or flat)
                for (int i=1; i<nx2; i++) {
                        if (rdist[i]>rdist[i-1]) rdist[i]=rdist[i-1];
                }

                image->process_inplace("xform.fourierorigin.tocenter");
                EMData* binary=image->copy();

                // First we eliminate convex points from the input image (set to zero)
                for (int x=0; x<image->get_xsize(); x+=2) {
                        for (int y=1; y<image->get_ysize()-1; y++) {
                                int r=(int)hypot((float)(x/2),(float)(y-ny2));
                                float cen=(*binary)(x,y);
                                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
                                        image->set_value_at_fast(x/2+nx2,y,0.0);        // we are turning image into a full real-space intensity image for now
                                        image->set_value_at_fast(nx2-x/2,ny2*2-y-1,0.0);
                                }
                                else {
                                        image->set_value_at_fast(x/2+nx2,y,cen);        // we are turning image into a full real-space intensity image for now
                                        image->set_value_at_fast(nx2-x/2,ny2*2-y-1,cen);        // It will contain non-zero values only for nonconvex points
                                }
                        }
                }
                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
                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
                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
                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
                for (int y=0; y<ny2*2; y++) image->set_value_at_fast(0,y,0.0f);

                // Now make a binary version of the convex points
                float *idat=image->get_data();
                float *bdat=binary->get_data();
                int nxy=(nx2*ny2*4);
                for (int i=0; i<nxy; i++) {
                        bdat[i]=idat[i]==0?0:1.0f;              // binary version of the convex points in image
                }
                binary->update();

                // We now use a Gaussian filter on both images, to use Gaussian interpolation to fill in zero values
                image->set_complex(false);              // so we can use a Gaussian filter on it
                binary->set_complex(false);

/*              image->write_image("con.hdf",0);*/
                image->set_fftpad(false);
                binary->set_fftpad(false);

                // Gaussian blur of both images
                image->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
                binary->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));

/*              image->write_image("con.hdf",1);
                binary->write_image("con.hdf",2);*/

                for (int x=0; x<image->get_xsize(); x+=2) {
                        for (int y=0; y<image->get_ysize(); y++) {
                                float bv=binary->get_value_at(x/2+nx2,y);
                                image->set_value_at_fast(x,y,image->get_value_at(x/2+nx2,y)/(bv<=0?1.0f:bv));
                                image->set_value_at_fast(x+1,y,0.0);
                        }
                }
                image->set_complex(true);
                image->set_fftpad(true);
                image->process_inplace("xform.fourierorigin.tocorner");
                delete binary;
        }
        else throw ImageDimensionException("3D maps not yet supported by NonConvexProcessor");

}

Member Data Documentation

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

Definition at line 3911 of file processor.h.

Referenced by get_name().


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