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

03664                 {
03665                         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).";
03666                 }

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

References NAME.

03655                 {
03656                         return NAME;
03657                 }

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

03669                 {
03670                         TypeDict d;
03671 /*                      d.put("mask", EMObject::EMDATA, "mask object: nonzero pixel positions will be used to fit plane. default = 0");
03672                         d.put("changeZero", EMObject::INT, "if zero pixels are modified when removing gradient. default = 0");
03673                         d.put("planeParam", EMObject::FLOATARRAY, "fitted plane parameters output");*/
03674                         return d;
03675                 }

static Processor* EMAN::NonConvexProcessor::NEW (  )  [inline, static]

Definition at line 3658 of file processor.h.

03659                 {
03660                         return new NonConvexProcessor();
03661                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 2702 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(), and x.

02702                                                        {
02703         if (!image) { LOGWARN("NULL IMAGE"); return; }
02704         //int isinten=image->get_attr_default("is_intensity",0);
02705         
02706         // 1-D
02707         if (image->get_ysize()==1) {
02708                 
02709         }
02710         // 2-D
02711         else if (image->get_zsize()==1) {
02712 //              if (!isinten) throw ImageDimensionException("Only complex intensity images currently supported by NonConvexProcessor");
02713                 int nx2=image->get_xsize()/2;
02714                 int ny2=image->get_ysize()/2;
02715                 vector<float> rdist = image->calc_radial_dist(nx2*1.5,0,1,false);               // radial distribution to make sure nonconvex values decrease radially
02716                 // Make sure rdist is decreasing (or flat)
02717                 for (int i=1; i<nx2; i++) {
02718                         if (rdist[i]>rdist[i-1]) rdist[i]=rdist[i-1];
02719                 }
02720                 
02721                 image->process_inplace("xform.fourierorigin.tocenter");
02722                 EMData* binary=image->copy();
02723                 
02724                 // First we eliminate convex points from the input image (set to zero)
02725                 for (int x=0; x<image->get_xsize(); x+=2) {
02726                         for (int y=1; y<image->get_ysize()-1; y++) {
02727                                 int r=(int)hypot((float)(x/2),(float)(y-ny2));
02728                                 float cen=(*binary)(x,y);
02729                                 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
02730                                         image->set_value_at_fast(x/2+nx2,y,0.0);        // we are turning image into a full real-space intensity image for now
02731                                         image->set_value_at_fast(nx2-x/2,ny2*2-y-1,0.0);
02732                                 }
02733                                 else {
02734                                         image->set_value_at_fast(x/2+nx2,y,cen);        // we are turning image into a full real-space intensity image for now
02735                                         image->set_value_at_fast(nx2-x/2,ny2*2-y-1,cen);        // It will contain non-zero values only for nonconvex points
02736                                 }
02737                         }
02738                 }
02739                 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
02740                 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
02741                 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
02742                 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
02743                 for (int y=0; y<ny2*2; y++) image->set_value_at_fast(0,y,0.0f);
02744                 
02745                 // Now make a binary version of the convex points
02746                 float *idat=image->get_data();
02747                 float *bdat=binary->get_data();
02748                 int nxy=(nx2*ny2*4);
02749                 for (int i=0; i<nxy; i++) {
02750                         bdat[i]=idat[i]==0?0:1.0;               // binary version of the convex points in image
02751                 }
02752                 binary->update();
02753                 
02754                 // We now use a Gaussian filter on both images, to use Gaussian interpolation to fill in zero values
02755                 image->set_complex(false);              // so we can use a Gaussian filter on it 
02756                 binary->set_complex(false);
02757 
02758 /*              image->write_image("con.hdf",0);*/
02759                 image->set_fftpad(false);
02760                 binary->set_fftpad(false);
02761                 
02762                 // Gaussian blur of both images
02763                 image->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
02764                 binary->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
02765 
02766 /*              image->write_image("con.hdf",1);
02767                 binary->write_image("con.hdf",2);*/
02768                 
02769                 for (int x=0; x<image->get_xsize(); x+=2) {
02770                         for (int y=0; y<image->get_ysize(); y++) {
02771                                 float bv=binary->get_value_at(x/2+nx2,y);
02772                                 image->set_value_at_fast(x,y,image->get_value_at(x/2+nx2,y)/(bv<=0?1.0:bv));
02773                                 image->set_value_at_fast(x+1,y,0.0);
02774                         }
02775                 }
02776                 image->set_complex(true);
02777                 image->set_fftpad(true);
02778                 image->process_inplace("xform.fourierorigin.tocorner");
02779                 delete binary;
02780         }
02781         else throw ImageDimensionException("3D maps not yet supported by NonConvexProcessor");
02782         
02783 }


Member Data Documentation

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

Definition at line 3677 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:46:25 2011 for EMAN2 by  doxygen 1.4.7