#include <processor.h>


Public Member Functions | |||||||
| virtual string | get_name () const | ||||||
| Get the processor's name. | |||||||
| virtual void | process_inplace (EMData *image) | ||||||
| |||||||
| 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 Processor * | NEW () | ||||||
Static Public Attributes | |||||||
| static const string | NAME = "threshold.binary.fourier" | ||||||
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
| value | The Fourier amplitude threshold cutoff |
Definition at line 1805 of file processor.h.
| virtual string EMAN::BinarizeFourierProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 1808 of file processor.h.
References NAME.
01809 { 01810 return NAME; 01811 }
| static Processor* EMAN::BinarizeFourierProcessor::NEW | ( | ) | [inline, static] |
Definition at line 1812 of file processor.h.
01813 { 01814 return new BinarizeFourierProcessor(); 01815 }
| void BinarizeFourierProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
| 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 3708 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.
03708 { 03709 ENTERFUNC; 03710 if (!image->is_complex()) throw ImageFormatException("Fourier binary thresholding processor only works for complex images"); 03711 03712 float threshold = params.set_default("value",-1.0f); 03713 if (threshold < 0) throw InvalidParameterException("For fourier amplitude-based thresholding, the threshold must be greater than or equal to 0."); 03714 03715 image->ri2ap(); // works for cuda 03716 03717 #ifdef EMAN2_USING_CUDA 03718 if (image->gpu_operation_preferred()) { 03719 EMDataForCuda tmp = image->get_data_struct_for_cuda(); 03720 binarize_fourier_amp_processor(&tmp,threshold); 03721 image->set_ri(true); // So it can be used for fourier multiplaction, for example 03722 image->gpu_update(); 03723 EXITFUNC; 03724 return; 03725 } 03726 #endif 03727 03728 float* d = image->get_data(); 03729 for( size_t i = 0; i < image->get_size()/2; ++i, d+=2) { 03730 float v = *d; 03731 if ( v >= threshold ) { 03732 *d = 1; 03733 *(d+1) = 0; 03734 } else { 03735 *d = 0; 03736 *(d+1) = 0; 03737 } 03738 } 03739 03740 // No need to run ap2ri, because 1+0i is the same in either notation 03741 image->set_ri(true); // So it can be used for fourier multiplaction, for example 03742 image->update(); 03743 EXITFUNC; 03744 }
| 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.
Reimplemented from EMAN::Processor.
Definition at line 1825 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
01826 { 01827 TypeDict d; 01828 d.put("value", EMObject::FLOAT, "The Fourier amplitude threshold cutoff" ); 01829 return d; 01830 }
| virtual string EMAN::BinarizeFourierProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 1832 of file processor.h.
01833 { 01834 return "f(k) = 0 + 0i if ||f(k)|| < value; f(k) = 1 + 0i if ||f(k)|| >= value."; 01835 }
const string BinarizeFourierProcessor::NAME = "threshold.binary.fourier" [static] |
1.5.6