Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::CutoffBlockProcessor Class Reference

Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. More...

#include <processor.h>

Inheritance diagram for EMAN::CutoffBlockProcessor:

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

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.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "eman1.filter.blockcutoff"

Detailed Description

Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels.

Mystery processor.

Parameters:
value1 val1 is dx/dy
value2 val2 is lowpass freq cutoff in pixels

Definition at line 3043 of file processor.h.


Member Function Documentation

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

03066                 {
03067                         return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor.";
03068                 }

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

Referenced by process_inplace().

03049                 {
03050                         return NAME;
03051                 }

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

References EMAN::TypeDict::put().

03058                 {
03059                         TypeDict d;
03060                         d.put("value1", EMObject::FLOAT, "val1 is dx/dy");
03061                         d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels");
03062                         return d;
03063                 }

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

Definition at line 3052 of file processor.h.

03053                 {
03054                         return new CutoffBlockProcessor();
03055                 }

void CutoffBlockProcessor::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 1730 of file processor.cpp.

References data, EMAN::EMData::do_fft(), EMAN::EMData::get_clip(), EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, LOGWARN, nx, ny, t, EMAN::EMData::update(), x, and y.

01731 {
01732         if (!image) {
01733                 LOGWARN("NULL Image");
01734                 return;
01735         }
01736         int nz = image->get_zsize();
01737 
01738         if (nz > 1) {
01739                 LOGERR("%s Processor doesn't support 3D", get_name().c_str());
01740                 throw ImageDimensionException("3D model not supported");
01741         }
01742 
01743         int nx = image->get_xsize();
01744         int ny = image->get_ysize();
01745 
01746         float value1 = params["value1"];
01747         float value2 = params["value2"];
01748 
01749         int v1 = (int) value1;
01750         int v2 = (int) value2;
01751         if (v2 > v1 / 2) {
01752                 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2);
01753                 return;
01754         }
01755 
01756         if (v2 <= 0) {
01757                 v2 = v1;
01758         }
01759 
01760         float *data = image->get_data();
01761         int y = 0, x = 0;
01762         for (y = 0; y <= ny - v1; y += v1) {
01763                 for (x = 0; x <= nx - v1; x += v1) {
01764 
01765                         EMData *clip = image->get_clip(Region(x, y, v1, v1));
01766                         EMData *fft = clip->do_fft();
01767 
01768                         float *fft_data = fft->get_data();
01769                         float sum = 0;
01770                         int nitems = 0;
01771 
01772                         for (int i = -v2; i < v2; i++) {
01773                                 for (int j = 0; j < v2; j++) {
01774                                         if (j == 0 && i == 0) {
01775                                                 continue;
01776                                         }
01777 
01778 #ifdef  _WIN32
01779                                         if (_hypot(j, i) < value2) {
01780 #else
01781                                         if (hypot(j, i) < value2) {
01782 #endif
01783                                                 int t = j * 2 + (i + v1 / 2) * (v1 + 2);
01784                                                 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]);
01785                                                 nitems++;
01786                                         }
01787                                 }
01788                         }
01789 
01790                         if( clip )
01791                         {
01792                                 delete clip;
01793                                 clip = 0;
01794                         }
01795 
01796                         float mean = sum / nitems;
01797 
01798                         for (int i = y; i < y + v1; i++) {
01799                                 for (int j = x; j < x + v1; j++) {
01800                                         data[i * nx + j] = mean;
01801                                 }
01802                         }
01803                 }
01804         }
01805 
01806         memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float));
01807 
01808         for (int i = 0; i < ny; i++) {
01809                 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float));
01810         }
01811 
01812         image->update();
01813 }


Member Data Documentation

const string CutoffBlockProcessor::NAME = "eman1.filter.blockcutoff" [static]
 

Definition at line 117 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:47:57 2010 for EMAN2 by  doxygen 1.3.9.1