23 #include <fvfilters/laplace.h> 25 #include <core/exception.h> 32 #elif defined(HAVE_OPENCV) 33 # if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) 34 # include <opencv/cv.h> 36 # include <opencv/cv.hpp> 38 # error "Neither IPP nor OpenCV available" 70 kernel = (
int *)malloc( size * size *
sizeof(
int) );
73 kernel_float = (
float *)malloc(size * size *
sizeof(
float));
74 for (
unsigned int i = 0; i < size * size; ++i) {
75 kernel_float[i] = kernel[i];
84 if ( kernel != NULL ) {
87 if ( kernel_float != NULL ) {
103 if ( kernel == NULL ) {
107 size, ippMskSize5x5 );
109 IppiSize ksize = { kernel_size, kernel_size };
110 IppiPoint kanchor = { (kernel_size + 1) / 2, (kernel_size + 1) / 2 };
120 size, kernel, ksize, kanchor, 1 );
124 if ( status != ippStsNoErr ) {
151 #elif defined(HAVE_OPENCV) 160 src_roi[0]->line_step);
168 if ( kernel_float == NULL ) {
169 cv::Laplacian(srcm, dstm, CV_8UC1, 5);
171 cv::Mat kernel(kernel_size, kernel_size, CV_32F, kernel_float);
172 cv::Point kanchor((kernel_size + 1) / 2, (kernel_size + 1) / 2);
173 cv::filter2D(srcm, dstm, -1, kernel, kanchor);
205 for (
int h = (-(
int)(size / 2)); h <= (int)((size - 1) / 2); ++h) {
206 for (
int w = (-(
int)(size / 2)); w <= (int)((size - 1) / 2); ++w) {
209 int v = (int)roundf( - 1/( M_PI * sigma * sigma * sigma * sigma ) *
210 ( 1 - ( (w*w + h*h) / (2 * sigma * sigma) ) )
211 * exp( -( (w*w + h*h) / (2 * sigma * sigma) )) * scale );
213 kernel[ (h + (size / 2)) * size + (w + (size / 2)) ] = v;
FilterLaplace()
Constructor.
fawkes::upoint_t start
ROI start.
unsigned int y
y coordinate
unsigned int x
x coordinate
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.
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.