#include <processor.h>
Inheritance diagram for EMAN::CutoffBlockProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "eman1.filter.blockcutoff" |
Mystery processor.
value1 | val1 is dx/dy | |
value2 | val2 is lowpass freq cutoff in pixels |
Definition at line 3218 of file processor.h.
string EMAN::CutoffBlockProcessor::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 3240 of file processor.h.
03241 { 03242 return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor."; 03243 }
string EMAN::CutoffBlockProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 3223 of file processor.h.
References NAME.
Referenced by process_inplace().
03224 { 03225 return NAME; 03226 }
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.
Reimplemented from EMAN::Processor.
Definition at line 3232 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
03233 { 03234 TypeDict d; 03235 d.put("value1", EMObject::FLOAT, "val1 is dx/dy"); 03236 d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels"); 03237 return d; 03238 }
static Processor* EMAN::CutoffBlockProcessor::NEW | ( | ) | [inline, static] |
Definition at line 3227 of file processor.h.
03228 { 03229 return new CutoffBlockProcessor(); 03230 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 1785 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.
01786 { 01787 if (!image) { 01788 LOGWARN("NULL Image"); 01789 return; 01790 } 01791 int nz = image->get_zsize(); 01792 01793 if (nz > 1) { 01794 LOGERR("%s Processor doesn't support 3D", get_name().c_str()); 01795 throw ImageDimensionException("3D model not supported"); 01796 } 01797 01798 int nx = image->get_xsize(); 01799 int ny = image->get_ysize(); 01800 01801 float value1 = params["value1"]; 01802 float value2 = params["value2"]; 01803 01804 int v1 = (int) value1; 01805 int v2 = (int) value2; 01806 if (v2 > v1 / 2) { 01807 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2); 01808 return; 01809 } 01810 01811 if (v2 <= 0) { 01812 v2 = v1; 01813 } 01814 01815 float *data = image->get_data(); 01816 int y = 0, x = 0; 01817 for (y = 0; y <= ny - v1; y += v1) { 01818 for (x = 0; x <= nx - v1; x += v1) { 01819 01820 EMData *clip = image->get_clip(Region(x, y, v1, v1)); 01821 EMData *fft = clip->do_fft(); 01822 01823 float *fft_data = fft->get_data(); 01824 float sum = 0; 01825 int nitems = 0; 01826 01827 for (int i = -v2; i < v2; i++) { 01828 for (int j = 0; j < v2; j++) { 01829 if (j == 0 && i == 0) { 01830 continue; 01831 } 01832 01833 #ifdef _WIN32 01834 if (_hypot(j, i) < value2) { 01835 #else 01836 if (hypot(j, i) < value2) { 01837 #endif 01838 int t = j * 2 + (i + v1 / 2) * (v1 + 2); 01839 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]); 01840 nitems++; 01841 } 01842 } 01843 } 01844 01845 if( clip ) 01846 { 01847 delete clip; 01848 clip = 0; 01849 } 01850 01851 float mean = sum / nitems; 01852 01853 for (int i = y; i < y + v1; i++) { 01854 for (int j = x; j < x + v1; j++) { 01855 data[i * nx + j] = mean; 01856 } 01857 } 01858 } 01859 } 01860 01861 memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float)); 01862 01863 for (int i = 0; i < ny; i++) { 01864 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float)); 01865 } 01866 01867 image->update(); 01868 }
const string CutoffBlockProcessor::NAME = "eman1.filter.blockcutoff" [static] |