#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 7088 of file processor.h. 07089 { 07090 return "Filters an image with a convolution kernel in real space."; 07091 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 7080 of file processor.h. 07081 {
07082 return NAME;
07083 }
|
|
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 7092 of file processor.h. References EMAN::TypeDict::put(). 07093 { 07094 TypeDict d; 07095 d.put("kernel", EMObject::FLOATARRAY, "the convolution kernel"); 07096 return d; 07097 }
|
|
Definition at line 7084 of file processor.h. 07085 { 07086 return new ConvolutionKernelProcessor(); 07087 }
|
|
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 9999 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(). 10000 { 10001 if (image->get_zsize()!=1) throw ImageDimensionException("Only 2-D images supported"); 10002 10003 EMData* conv = new EMData(image->get_xsize(),image->get_ysize(),1); 10004 vector<float>kernel = params["kernel"]; 10005 10006 if (fmod(sqrt((float)kernel.size()), 1.0f) != 0) throw InvalidParameterException("Convolution kernel must be square!!"); 10007 10008 float* data = image->get_data(); 10009 float* cdata = conv->get_data(); // Yes I could use set_value_at_fast, but is still slower than this.... 10010 10011 //I could do the edges by wrapping around, but this is not necessary(such functionality can be iplemented later) 10012 int ks = int(sqrt(float(kernel.size()))); 10013 int n = (ks - 1)/2; 10014 int nx = image->get_xsize(); 10015 int ny = image->get_ysize(); 10016 for (int i = n; i < (nx - n); i++) { 10017 for (int j = n; j < (ny - n); j++) { 10018 //now do the convolution 10019 float cpixel = 0; 10020 int idx = 0; 10021 // Perahps I could use some ofrm of Caching to speed things up? 10022 for (int cx = -n; cx <= n; cx++) { 10023 for (int cy = -n; cy <= n; cy++) { 10024 cpixel += data[(i+cx) + (j+cy) * nx]*kernel[idx]; 10025 idx++; 10026 } 10027 } 10028 cdata[i + j * nx] = cpixel; 10029 } 10030 } 10031 10032 return conv; 10033 }
|
|
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 10035 of file processor.cpp. References UnexpectedBehaviorException. 10036 { 10037 throw UnexpectedBehaviorException("Not implemented yet"); 10038 10039 return; 10040 }
|
|
Definition at line 245 of file processor.cpp. |