Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File 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]
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

ProcessorNEW ()

Static Public Attributes

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

03711                 {
03712                         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).";
03713                 }

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

03702                 {
03703                         return NAME;
03704                 }

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

03716                 {
03717                         TypeDict d;
03718 /*                      d.put("mask", EMObject::EMDATA, "mask object: nonzero pixel positions will be used to fit plane. default = 0");
03719                         d.put("changeZero", EMObject::INT, "if zero pixels are modified when removing gradient. default = 0");
03720                         d.put("planeParam", EMObject::FLOATARRAY, "fitted plane parameters output");*/
03721                         return d;
03722                 }

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

Definition at line 3705 of file processor.h.

03706                 {
03707                         return new NonConvexProcessor();
03708                 }

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 2780 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.

02780                                                        {
02781         if (!image) { LOGWARN("NULL IMAGE"); return; }
02782         //int isinten=image->get_attr_default("is_intensity",0);
02783         
02784         // 1-D
02785         if (image->get_ysize()==1) {
02786                 
02787         }
02788         // 2-D
02789         else if (image->get_zsize()==1) {
02790 //              if (!isinten) throw ImageDimensionException("Only complex intensity images currently supported by NonConvexProcessor");
02791                 int nx2=image->get_xsize()/2;
02792                 int ny2=image->get_ysize()/2;
02793                 vector<float> rdist = image->calc_radial_dist(nx2*1.5,0,1,false);               // radial distribution to make sure nonconvex values decrease radially
02794                 // Make sure rdist is decreasing (or flat)
02795                 for (int i=1; i<nx2; i++) {
02796                         if (rdist[i]>rdist[i-1]) rdist[i]=rdist[i-1];
02797                 }
02798                 
02799                 image->process_inplace("xform.fourierorigin.tocenter");
02800                 EMData* binary=image->copy();
02801                 
02802                 // First we eliminate convex points from the input image (set to zero)
02803                 for (int x=0; x<image->get_xsize(); x+=2) {
02804                         for (int y=1; y<image->get_ysize()-1; y++) {
02805                                 int r=(int)hypot((float)(x/2),(float)(y-ny2));
02806                                 float cen=(*binary)(x,y);
02807                                 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
02808                                         image->set_value_at_fast(x/2+nx2,y,0.0);        // we are turning image into a full real-space intensity image for now
02809                                         image->set_value_at_fast(nx2-x/2,ny2*2-y-1,0.0);
02810                                 }
02811                                 else {
02812                                         image->set_value_at_fast(x/2+nx2,y,cen);        // we are turning image into a full real-space intensity image for now
02813                                         image->set_value_at_fast(nx2-x/2,ny2*2-y-1,cen);        // It will contain non-zero values only for nonconvex points
02814                                 }
02815                         }
02816                 }
02817                 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
02818                 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
02819                 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
02820                 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
02821                 for (int y=0; y<ny2*2; y++) image->set_value_at_fast(0,y,0.0f);
02822                 
02823                 // Now make a binary version of the convex points
02824                 float *idat=image->get_data();
02825                 float *bdat=binary->get_data();
02826                 int nxy=(nx2*ny2*4);
02827                 for (int i=0; i<nxy; i++) {
02828                         bdat[i]=idat[i]==0?0:1.0f;              // binary version of the convex points in image
02829                 }
02830                 binary->update();
02831                 
02832                 // We now use a Gaussian filter on both images, to use Gaussian interpolation to fill in zero values
02833                 image->set_complex(false);              // so we can use a Gaussian filter on it 
02834                 binary->set_complex(false);
02835 
02836 /*              image->write_image("con.hdf",0);*/
02837                 image->set_fftpad(false);
02838                 binary->set_fftpad(false);
02839                 
02840                 // Gaussian blur of both images
02841                 image->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
02842                 binary->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.04f));
02843 
02844 /*              image->write_image("con.hdf",1);
02845                 binary->write_image("con.hdf",2);*/
02846                 
02847                 for (int x=0; x<image->get_xsize(); x+=2) {
02848                         for (int y=0; y<image->get_ysize(); y++) {
02849                                 float bv=binary->get_value_at(x/2+nx2,y);
02850                                 image->set_value_at_fast(x,y,image->get_value_at(x/2+nx2,y)/(bv<=0?1.0f:bv));
02851                                 image->set_value_at_fast(x+1,y,0.0);
02852                         }
02853                 }
02854                 image->set_complex(true);
02855                 image->set_fftpad(true);
02856                 image->process_inplace("xform.fourierorigin.tocorner");
02857                 delete binary;
02858         }
02859         else throw ImageDimensionException("3D maps not yet supported by NonConvexProcessor");
02860         
02861 }


Member Data Documentation

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

Definition at line 118 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:42:29 2013 for EMAN2 by  doxygen 1.3.9.1