23 #include <fvfilters/laplace.h>
25 #include <core/exception.h>
32 #elif defined(HAVE_OPENCV)
35 # error "Neither IPP nor OpenCV available"
50 FilterLaplace::FilterLaplace()
67 kernel = (
int *)malloc( size * size *
sizeof(
int) );
70 kernel_float = (
float *)malloc(size * size *
sizeof(
float));
71 for (
unsigned int i = 0; i < size * size; ++i) {
72 kernel_float[i] = kernel[i];
81 if ( kernel != NULL ) {
84 if ( kernel_float != NULL ) {
100 if ( kernel == NULL ) {
104 size, ippMskSize5x5 );
106 IppiSize ksize = { kernel_size, kernel_size };
107 IppiPoint kanchor = { (kernel_size + 1) / 2, (kernel_size + 1) / 2 };
117 size, kernel, ksize, kanchor, 1 );
121 if ( status != ippStsNoErr ) {
148 #elif defined(HAVE_OPENCV)
157 src_roi[0]->line_step);
165 if ( kernel_float == NULL ) {
166 cv::Laplacian(srcm, dstm, CV_8UC1, 5);
168 cv::Mat kernel(kernel_size, kernel_size, CV_32F, kernel_float);
169 cv::Point kanchor((kernel_size + 1) / 2, (kernel_size + 1) / 2);
170 cv::filter2D(srcm, dstm, -1, kernel, kanchor);
202 for (
int h = (-(
int)(size / 2)); h <= (int)((size - 1) / 2); ++h) {
203 for (
int w = (-(
int)(size / 2)); w <= (int)((size - 1) / 2); ++w) {
206 int v = (int)roundf( - 1/( M_PI * sigma * sigma * sigma * sigma ) *
207 ( 1 - ( (w*w + h*h) / (2 * sigma * sigma) ) )
208 * exp( -( (w*w + h*h) / (2 * sigma * sigma) )) * scale );
210 kernel[ (h + (size / 2)) * size + (w + (size / 2)) ] = v;
fawkes::point_t start
ROI start.
unsigned int x
x coordinate
FilterLaplace()
Constructor.
unsigned int width
ROI width.
~FilterLaplace()
Destructor.
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Base class for exceptions in Fawkes.
virtual void apply()
Apply the filter.
unsigned int y
y coordinate
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
static void calculate_kernel(int *kernel_buffer, float sigma, unsigned int size, float scale)
Calculate a Laplacian of Gaussian kernel.
unsigned int height
ROI height.
unsigned int line_step
line step
unsigned char * dst
Destination buffer.
unsigned int pixel_step
pixel step
ROI * dst_roi
Destination ROI.