EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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:
value1val1 is dx/dy
value2val2 is lowpass freq cutoff in pixels

Definition at line 3452 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 3474 of file processor.h.

                {
                        return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor.";
                }
string EMAN::CutoffBlockProcessor::get_name ( ) const [inline, virtual]
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 3466 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("value1", EMObject::FLOAT, "val1 is dx/dy");
                        d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels");
                        return d;
                }
static Processor* EMAN::CutoffBlockProcessor::NEW ( ) [inline, static]

Definition at line 3461 of file processor.h.

                {
                        return new CutoffBlockProcessor();
                }
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:
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 1877 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.

Referenced by EMAN::RotateInFSProcessor::process(), and EMAN::NSigmaClampingProcessor::process_inplace().

{
        if (!image) {
                LOGWARN("NULL Image");
                return;
        }
        int nz = image->get_zsize();

        if (nz > 1) {
                LOGERR("%s Processor doesn't support 3D", get_name().c_str());
                throw ImageDimensionException("3D model not supported");
        }

        int nx = image->get_xsize();
        int ny = image->get_ysize();

        float value1 = params["value1"];
        float value2 = params["value2"];

        int v1 = (int) value1;
        int v2 = (int) value2;
        if (v2 > v1 / 2) {
                LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2);
                return;
        }

        if (v2 <= 0) {
                v2 = v1;
        }

        float *data = image->get_data();
        int y = 0, x = 0;
        for (y = 0; y <= ny - v1; y += v1) {
                for (x = 0; x <= nx - v1; x += v1) {

                        EMData *clip = image->get_clip(Region(x, y, v1, v1));
                        EMData *fft = clip->do_fft();

                        float *fft_data = fft->get_data();
                        float sum = 0;
                        int nitems = 0;

                        for (int i = -v2; i < v2; i++) {
                                for (int j = 0; j < v2; j++) {
                                        if (j == 0 && i == 0) {
                                                continue;
                                        }

#ifdef  _WIN32
                                        if (_hypot(j, i) < value2) {
#else
                                        if (hypot(j, i) < value2) {
#endif
                                                int t = j * 2 + (i + v1 / 2) * (v1 + 2);
                                                sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]);
                                                nitems++;
                                        }
                                }
                        }

                        if( clip )
                        {
                                delete clip;
                                clip = 0;
                        }

                        float mean = sum / nitems;

                        for (int i = y; i < y + v1; i++) {
                                for (int j = x; j < x + v1; j++) {
                                        data[i * nx + j] = mean;
                                }
                        }
                }
        }

        memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float));

        for (int i = 0; i < ny; i++) {
                memset(&data[i * nx + x], 0, (nx - x) * sizeof(float));
        }

        image->update();
}

Member Data Documentation

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

Definition at line 3479 of file processor.h.

Referenced by get_name().


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