#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 3222 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 3244 of file processor.h. 03245 {
03246 return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor.";
03247 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3227 of file processor.h. Referenced by process_inplace(). 03228 {
03229 return NAME;
03230 }
|
|
|
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 3236 of file processor.h. References EMAN::TypeDict::put(). 03237 {
03238 TypeDict d;
03239 d.put("value1", EMObject::FLOAT, "val1 is dx/dy");
03240 d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels");
03241 return d;
03242 }
|
|
|
Definition at line 3231 of file processor.h. 03232 {
03233 return new CutoffBlockProcessor();
03234 }
|
|
|
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 1850 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. 01851 {
01852 if (!image) {
01853 LOGWARN("NULL Image");
01854 return;
01855 }
01856 int nz = image->get_zsize();
01857
01858 if (nz > 1) {
01859 LOGERR("%s Processor doesn't support 3D", get_name().c_str());
01860 throw ImageDimensionException("3D model not supported");
01861 }
01862
01863 int nx = image->get_xsize();
01864 int ny = image->get_ysize();
01865
01866 float value1 = params["value1"];
01867 float value2 = params["value2"];
01868
01869 int v1 = (int) value1;
01870 int v2 = (int) value2;
01871 if (v2 > v1 / 2) {
01872 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2);
01873 return;
01874 }
01875
01876 if (v2 <= 0) {
01877 v2 = v1;
01878 }
01879
01880 float *data = image->get_data();
01881 int y = 0, x = 0;
01882 for (y = 0; y <= ny - v1; y += v1) {
01883 for (x = 0; x <= nx - v1; x += v1) {
01884
01885 EMData *clip = image->get_clip(Region(x, y, v1, v1));
01886 EMData *fft = clip->do_fft();
01887
01888 float *fft_data = fft->get_data();
01889 float sum = 0;
01890 int nitems = 0;
01891
01892 for (int i = -v2; i < v2; i++) {
01893 for (int j = 0; j < v2; j++) {
01894 if (j == 0 && i == 0) {
01895 continue;
01896 }
01897
01898 #ifdef _WIN32
01899 if (_hypot(j, i) < value2) {
01900 #else
01901 if (hypot(j, i) < value2) {
01902 #endif
01903 int t = j * 2 + (i + v1 / 2) * (v1 + 2);
01904 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]);
01905 nitems++;
01906 }
01907 }
01908 }
01909
01910 if( clip )
01911 {
01912 delete clip;
01913 clip = 0;
01914 }
01915
01916 float mean = sum / nitems;
01917
01918 for (int i = y; i < y + v1; i++) {
01919 for (int j = x; j < x + v1; j++) {
01920 data[i * nx + j] = mean;
01921 }
01922 }
01923 }
01924 }
01925
01926 memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float));
01927
01928 for (int i = 0; i < ny; i++) {
01929 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float));
01930 }
01931
01932 image->update();
01933 }
|
|
|
Definition at line 128 of file processor.cpp. |
1.3.9.1