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

static ProcessorNEW ()

Static Public Attributes

static 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 3263 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 3285 of file processor.h.

03286                 {
03287                         return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor.";
03288                 }

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

References NAME.

Referenced by process_inplace().

03269                 {
03270                         return NAME;
03271                 }

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

References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

03278                 {
03279                         TypeDict d;
03280                         d.put("value1", EMObject::FLOAT, "val1 is dx/dy");
03281                         d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels");
03282                         return d;
03283                 }

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

Definition at line 3272 of file processor.h.

03273                 {
03274                         return new CutoffBlockProcessor();
03275                 }

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 1861 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, mean(), nx, ny, EMAN::Processor::params, t, EMAN::EMData::update(), x, and y.

01862 {
01863         if (!image) {
01864                 LOGWARN("NULL Image");
01865                 return;
01866         }
01867         int nz = image->get_zsize();
01868 
01869         if (nz > 1) {
01870                 LOGERR("%s Processor doesn't support 3D", get_name().c_str());
01871                 throw ImageDimensionException("3D model not supported");
01872         }
01873 
01874         int nx = image->get_xsize();
01875         int ny = image->get_ysize();
01876 
01877         float value1 = params["value1"];
01878         float value2 = params["value2"];
01879 
01880         int v1 = (int) value1;
01881         int v2 = (int) value2;
01882         if (v2 > v1 / 2) {
01883                 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2);
01884                 return;
01885         }
01886 
01887         if (v2 <= 0) {
01888                 v2 = v1;
01889         }
01890 
01891         float *data = image->get_data();
01892         int y = 0, x = 0;
01893         for (y = 0; y <= ny - v1; y += v1) {
01894                 for (x = 0; x <= nx - v1; x += v1) {
01895 
01896                         EMData *clip = image->get_clip(Region(x, y, v1, v1));
01897                         EMData *fft = clip->do_fft();
01898 
01899                         float *fft_data = fft->get_data();
01900                         float sum = 0;
01901                         int nitems = 0;
01902 
01903                         for (int i = -v2; i < v2; i++) {
01904                                 for (int j = 0; j < v2; j++) {
01905                                         if (j == 0 && i == 0) {
01906                                                 continue;
01907                                         }
01908 
01909 #ifdef  _WIN32
01910                                         if (_hypot(j, i) < value2) {
01911 #else
01912                                         if (hypot(j, i) < value2) {
01913 #endif
01914                                                 int t = j * 2 + (i + v1 / 2) * (v1 + 2);
01915                                                 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]);
01916                                                 nitems++;
01917                                         }
01918                                 }
01919                         }
01920 
01921                         if( clip )
01922                         {
01923                                 delete clip;
01924                                 clip = 0;
01925                         }
01926 
01927                         float mean = sum / nitems;
01928 
01929                         for (int i = y; i < y + v1; i++) {
01930                                 for (int j = x; j < x + v1; j++) {
01931                                         data[i * nx + j] = mean;
01932                                 }
01933                         }
01934                 }
01935         }
01936 
01937         memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float));
01938 
01939         for (int i = 0; i < ny; i++) {
01940                 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float));
01941         }
01942 
01943         image->update();
01944 }


Member Data Documentation

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

Definition at line 3290 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:36:06 2012 for EMAN2 by  doxygen 1.4.7