#include <processor.h>
Inheritance diagram for EMAN::ConvolutionKernelProcessor:
Public Member Functions | |
virtual EMData * | process (const EMData *const image) |
To proccess an image out-of-place. | |
virtual void | process_inplace (EMData *image) |
To process an image in-place. | |
virtual string | get_name () const |
Get the processor's name. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
virtual TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "filter.convolution.kernel" |
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 7049 of file processor.h. 07050 { 07051 return "Filters an image with a convolution kernel in real space."; 07052 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 7041 of file processor.h. 07042 {
07043 return NAME;
07044 }
|
|
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 7053 of file processor.h. References EMAN::TypeDict::put(). 07054 { 07055 TypeDict d; 07056 d.put("kernel", EMObject::FLOATARRAY, "the convolution kernel"); 07057 return d; 07058 }
|
|
Definition at line 7045 of file processor.h. 07046 { 07047 return new ConvolutionKernelProcessor(); 07048 }
|
|
To proccess an image out-of-place. For those processors which can only be processed out-of-place, override this function to give the right behavior.
Reimplemented from EMAN::Processor. Definition at line 9936 of file processor.cpp. References data, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, InvalidParameterException, nx, ny, and sqrt(). 09937 { 09938 if (image->get_zsize()!=1) throw ImageDimensionException("Only 2-D images supported"); 09939 09940 EMData* conv = new EMData(image->get_xsize(),image->get_ysize(),1); 09941 vector<float>kernel = params["kernel"]; 09942 09943 if (fmod(sqrt((float)kernel.size()), 1.0f) != 0) throw InvalidParameterException("Convolution kernel must be square!!"); 09944 09945 float* data = image->get_data(); 09946 float* cdata = conv->get_data(); // Yes I could use set_value_at_fast, but is still slower than this.... 09947 09948 //I could do the edges by wrapping around, but this is not necessary(such functionality can be iplemented later) 09949 int ks = int(sqrt(float(kernel.size()))); 09950 int n = (ks - 1)/2; 09951 int nx = image->get_xsize(); 09952 int ny = image->get_ysize(); 09953 for (int i = n; i < (nx - n); i++) { 09954 for (int j = n; j < (ny - n); j++) { 09955 //now do the convolution 09956 float cpixel = 0; 09957 int idx = 0; 09958 // Perahps I could use some ofrm of Caching to speed things up? 09959 for (int cx = -n; cx <= n; cx++) { 09960 for (int cy = -n; cy <= n; cy++) { 09961 cpixel += data[(i+cx) + (j+cy) * nx]*kernel[idx]; 09962 idx++; 09963 } 09964 } 09965 cdata[i + j * nx] = cpixel; 09966 } 09967 } 09968 09969 return conv; 09970 }
|
|
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 9972 of file processor.cpp. References UnexpectedBehaviorException. 09973 { 09974 throw UnexpectedBehaviorException("Not implemented yet"); 09975 09976 return; 09977 }
|
|
Definition at line 244 of file processor.cpp. |