#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "eman1.filter.blockcutoff" |
Mystery processor.
value1 | val1 is dx/dy | |
value2 | val2 is lowpass freq cutoff in pixels |
Definition at line 3128 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 3150 of file processor.h. 03151 { 03152 return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor."; 03153 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3133 of file processor.h. Referenced by process_inplace(). 03134 {
03135 return NAME;
03136 }
|
|
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 3142 of file processor.h. References EMAN::TypeDict::put(). 03143 { 03144 TypeDict d; 03145 d.put("value1", EMObject::FLOAT, "val1 is dx/dy"); 03146 d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels"); 03147 return d; 03148 }
|
|
Definition at line 3137 of file processor.h. 03138 { 03139 return new CutoffBlockProcessor(); 03140 }
|
|
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.
Implements EMAN::Processor. Definition at line 1791 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, nx, ny, t, EMAN::EMData::update(), x, and y. 01792 { 01793 if (!image) { 01794 LOGWARN("NULL Image"); 01795 return; 01796 } 01797 int nz = image->get_zsize(); 01798 01799 if (nz > 1) { 01800 LOGERR("%s Processor doesn't support 3D", get_name().c_str()); 01801 throw ImageDimensionException("3D model not supported"); 01802 } 01803 01804 int nx = image->get_xsize(); 01805 int ny = image->get_ysize(); 01806 01807 float value1 = params["value1"]; 01808 float value2 = params["value2"]; 01809 01810 int v1 = (int) value1; 01811 int v2 = (int) value2; 01812 if (v2 > v1 / 2) { 01813 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2); 01814 return; 01815 } 01816 01817 if (v2 <= 0) { 01818 v2 = v1; 01819 } 01820 01821 float *data = image->get_data(); 01822 int y = 0, x = 0; 01823 for (y = 0; y <= ny - v1; y += v1) { 01824 for (x = 0; x <= nx - v1; x += v1) { 01825 01826 EMData *clip = image->get_clip(Region(x, y, v1, v1)); 01827 EMData *fft = clip->do_fft(); 01828 01829 float *fft_data = fft->get_data(); 01830 float sum = 0; 01831 int nitems = 0; 01832 01833 for (int i = -v2; i < v2; i++) { 01834 for (int j = 0; j < v2; j++) { 01835 if (j == 0 && i == 0) { 01836 continue; 01837 } 01838 01839 #ifdef _WIN32 01840 if (_hypot(j, i) < value2) { 01841 #else 01842 if (hypot(j, i) < value2) { 01843 #endif 01844 int t = j * 2 + (i + v1 / 2) * (v1 + 2); 01845 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]); 01846 nitems++; 01847 } 01848 } 01849 } 01850 01851 if( clip ) 01852 { 01853 delete clip; 01854 clip = 0; 01855 } 01856 01857 float mean = sum / nitems; 01858 01859 for (int i = y; i < y + v1; i++) { 01860 for (int j = x; j < x + v1; j++) { 01861 data[i * nx + j] = mean; 01862 } 01863 } 01864 } 01865 } 01866 01867 memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float)); 01868 01869 for (int i = 0; i < ny; i++) { 01870 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float)); 01871 } 01872 01873 image->update(); 01874 }
|
|
Definition at line 120 of file processor.cpp. |