#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 3184 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 3206 of file processor.h. 03207 {
03208 return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor.";
03209 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3189 of file processor.h. Referenced by process_inplace(). 03190 {
03191 return NAME;
03192 }
|
|
|
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 3198 of file processor.h. References EMAN::TypeDict::put(). 03199 {
03200 TypeDict d;
03201 d.put("value1", EMObject::FLOAT, "val1 is dx/dy");
03202 d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels");
03203 return d;
03204 }
|
|
|
Definition at line 3193 of file processor.h. 03194 {
03195 return new CutoffBlockProcessor();
03196 }
|
|
|
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 1822 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. 01823 {
01824 if (!image) {
01825 LOGWARN("NULL Image");
01826 return;
01827 }
01828 int nz = image->get_zsize();
01829
01830 if (nz > 1) {
01831 LOGERR("%s Processor doesn't support 3D", get_name().c_str());
01832 throw ImageDimensionException("3D model not supported");
01833 }
01834
01835 int nx = image->get_xsize();
01836 int ny = image->get_ysize();
01837
01838 float value1 = params["value1"];
01839 float value2 = params["value2"];
01840
01841 int v1 = (int) value1;
01842 int v2 = (int) value2;
01843 if (v2 > v1 / 2) {
01844 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2);
01845 return;
01846 }
01847
01848 if (v2 <= 0) {
01849 v2 = v1;
01850 }
01851
01852 float *data = image->get_data();
01853 int y = 0, x = 0;
01854 for (y = 0; y <= ny - v1; y += v1) {
01855 for (x = 0; x <= nx - v1; x += v1) {
01856
01857 EMData *clip = image->get_clip(Region(x, y, v1, v1));
01858 EMData *fft = clip->do_fft();
01859
01860 float *fft_data = fft->get_data();
01861 float sum = 0;
01862 int nitems = 0;
01863
01864 for (int i = -v2; i < v2; i++) {
01865 for (int j = 0; j < v2; j++) {
01866 if (j == 0 && i == 0) {
01867 continue;
01868 }
01869
01870 #ifdef _WIN32
01871 if (_hypot(j, i) < value2) {
01872 #else
01873 if (hypot(j, i) < value2) {
01874 #endif
01875 int t = j * 2 + (i + v1 / 2) * (v1 + 2);
01876 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]);
01877 nitems++;
01878 }
01879 }
01880 }
01881
01882 if( clip )
01883 {
01884 delete clip;
01885 clip = 0;
01886 }
01887
01888 float mean = sum / nitems;
01889
01890 for (int i = y; i < y + v1; i++) {
01891 for (int j = x; j < x + v1; j++) {
01892 data[i * nx + j] = mean;
01893 }
01894 }
01895 }
01896 }
01897
01898 memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float));
01899
01900 for (int i = 0; i < ny; i++) {
01901 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float));
01902 }
01903
01904 image->update();
01905 }
|
|
|
Definition at line 122 of file processor.cpp. |
1.3.9.1