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

EMAN::BinarizeFourierProcessor Class Reference
[a function or class that is CUDA enabled]

A thresholding processor for Fourier images based on the amplitude component. More...

#include <processor.h>

Inheritance diagram for EMAN::BinarizeFourierProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual string get_name () const
 Get the processor's name.
virtual void process_inplace (EMData *image)
 
Exceptions:
ImageFormatException if the input image is not complex
InvalidParameterException if the threshold is less than 0 Note result is always in real-imaginary format Note input can be real-imaginary or amplitude-phase

virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "threshold.binary.fourier"

Detailed Description

A thresholding processor for Fourier images based on the amplitude component.

Useful in tomography when you want to count large complex pixels. Not the fastest approach, if you were going for efficiency it would probably be better just to iterate through the pixels and count. But if you do it this way you can just get the mean of the resulting image (and multiplying by 2). So it's basically easier, but lazy. Originally added for use by e2tomohunter.py

Author:
David Woolford
Date:
April 29th 2009
Parameters:
value The Fourier amplitude threshold cutoff

Definition at line 1865 of file processor.h.


Member Function Documentation

virtual string EMAN::BinarizeFourierProcessor::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 1892 of file processor.h.

01893                         {
01894                                 return "f(k) = 0 + 0i if ||f(k)|| < value; f(k) = 1 + 0i if ||f(k)|| >= value.";
01895                         }

virtual string EMAN::BinarizeFourierProcessor::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 1868 of file processor.h.

References NAME.

01869                         {
01870                                 return NAME;
01871                         }

virtual TypeDict EMAN::BinarizeFourierProcessor::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 1885 of file processor.h.

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

01886                         {
01887                                 TypeDict d;
01888                                 d.put("value", EMObject::FLOAT, "The Fourier amplitude threshold cutoff" );
01889                                 return d;
01890                         }

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

Definition at line 1872 of file processor.h.

01873                         {
01874                                 return new BinarizeFourierProcessor();
01875                         }

void BinarizeFourierProcessor::process_inplace EMData image  )  [virtual]
 

Exceptions:
ImageFormatException if the input image is not complex
InvalidParameterException if the threshold is less than 0 Note result is always in real-imaginary format Note input can be real-imaginary or amplitude-phase

Implements EMAN::Processor.

Definition at line 3802 of file processor.cpp.

References binarize_fourier_amp_processor(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::get_size(), ImageFormatException, InvalidParameterException, EMAN::EMData::is_complex(), EMAN::Processor::params, EMAN::EMData::ri2ap(), EMAN::Dict::set_default(), EMAN::EMData::set_ri(), EMAN::EMData::update(), and v.

03802                                                             {
03803         ENTERFUNC;
03804         if (!image->is_complex()) throw ImageFormatException("Fourier binary thresholding processor only works for complex images");
03805 
03806         float threshold = params.set_default("value",-1.0f);
03807         if (threshold < 0) throw InvalidParameterException("For fourier amplitude-based thresholding, the threshold must be greater than or equal to 0.");
03808 
03809         image->ri2ap(); //  works for cuda
03810 
03811 #ifdef EMAN2_USING_CUDA
03812         if (image->gpu_operation_preferred()) {
03813                 EMDataForCuda tmp = image->get_data_struct_for_cuda();
03814                 binarize_fourier_amp_processor(&tmp,threshold);
03815                 image->set_ri(true); // So it can be used for fourier multiplaction, for example
03816                 image->gpu_update();
03817                 EXITFUNC;
03818                 return;
03819         }
03820 #endif
03821 
03822         float* d = image->get_data();
03823         for( size_t i = 0; i < image->get_size()/2; ++i, d+=2) {
03824                 float v = *d;
03825                 if ( v >= threshold ) {
03826                         *d = 1;
03827                         *(d+1) = 0;
03828                 } else {
03829                         *d = 0;
03830                         *(d+1) = 0;
03831                 }
03832         }
03833 
03834         // No need to run ap2ri, because 1+0i is the same in either notation
03835         image->set_ri(true); // So it can be used for fourier multiplaction, for example
03836         image->update();
03837         EXITFUNC;
03838 }


Member Data Documentation

const string BinarizeFourierProcessor::NAME = "threshold.binary.fourier" [static]
 

Definition at line 1897 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:37:03 2010 for EMAN2 by  doxygen 1.4.4