#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 7002 of file processor.h. 07003 { 07004 return "Filters an image with a convolution kernel in real space."; 07005 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6994 of file processor.h. 06995 {
06996 return NAME;
06997 }
|
|
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 7006 of file processor.h. References EMAN::TypeDict::put(). 07007 { 07008 TypeDict d; 07009 d.put("kernel", EMObject::FLOATARRAY, "the convolution kernel"); 07010 return d; 07011 }
|
|
Definition at line 6998 of file processor.h. 06999 { 07000 return new ConvolutionKernelProcessor(); 07001 }
|
|
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 9849 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(). 09850 { 09851 if (image->get_zsize()!=1) throw ImageDimensionException("Only 2-D images supported"); 09852 09853 EMData* conv = new EMData(image->get_xsize(),image->get_ysize(),1); 09854 vector<float>kernel = params["kernel"]; 09855 09856 if (fmod(sqrt((float)kernel.size()), 1.0f) != 0) throw InvalidParameterException("Convolution kernel must be square!!"); 09857 09858 float* data = image->get_data(); 09859 float* cdata = conv->get_data(); // Yes I could use set_value_at_fast, but is still slower than this.... 09860 09861 //I could do the edges by wrapping around, but this is not necessary(such functionality can be iplemented later) 09862 int ks = int(sqrt(float(kernel.size()))); 09863 int n = (ks - 1)/2; 09864 int nx = image->get_xsize(); 09865 int ny = image->get_ysize(); 09866 for (int i = n; i < (nx - n); i++) { 09867 for (int j = n; j < (ny - n); j++) { 09868 //now do the convolution 09869 float cpixel = 0; 09870 int idx = 0; 09871 // Perahps I could use some ofrm of Caching to speed things up? 09872 for (int cx = -n; cx <= n; cx++) { 09873 for (int cy = -n; cy <= n; cy++) { 09874 cpixel += data[(i+cx) + (j+cy) * nx]*kernel[idx]; 09875 idx++; 09876 } 09877 } 09878 cdata[i + j * nx] = cpixel; 09879 } 09880 } 09881 09882 return conv; 09883 }
|
|
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 9885 of file processor.cpp. References UnexpectedBehaviorException. 09886 { 09887 throw UnexpectedBehaviorException("Not implemented yet"); 09888 09889 return; 09890 }
|
|
Definition at line 243 of file processor.cpp. |