23 #include <fvfilters/laplace.h> 25 #include <core/exception.h> 32 #elif defined(HAVE_OPENCV) 34 # include <opencv2/imgproc.hpp> 36 # error "Neither IPP nor OpenCV available" 68 kernel = (
int *)malloc( size * size *
sizeof(
int) );
71 kernel_float = (
float *)malloc(size * size *
sizeof(
float));
72 for (
unsigned int i = 0; i < size * size; ++i) {
73 kernel_float[i] = kernel[i];
82 if ( kernel != NULL ) {
85 if ( kernel_float != NULL ) {
101 if ( kernel == NULL ) {
105 size, ippMskSize5x5 );
107 IppiSize ksize = { kernel_size, kernel_size };
108 IppiPoint kanchor = { (kernel_size + 1) / 2, (kernel_size + 1) / 2 };
118 size, kernel, ksize, kanchor, 1 );
122 if ( status != ippStsNoErr ) {
149 #elif defined(HAVE_OPENCV) 158 src_roi[0]->line_step);
166 if ( kernel_float == NULL ) {
167 cv::Laplacian(srcm, dstm, CV_8UC1, 5);
169 cv::Mat kernel(kernel_size, kernel_size, CV_32F, kernel_float);
170 cv::Point kanchor((kernel_size + 1) / 2, (kernel_size + 1) / 2);
171 cv::filter2D(srcm, dstm, -1, kernel, kanchor);
203 for (
int h = (-(
int)(size / 2)); h <= (int)((size - 1) / 2); ++h) {
204 for (
int w = (-(
int)(size / 2)); w <= (int)((size - 1) / 2); ++w) {
207 int v = (int)roundf( - 1/( M_PI * sigma * sigma * sigma * sigma ) *
208 ( 1 - ( (w*w + h*h) / (2 * sigma * sigma) ) )
209 * exp( -( (w*w + h*h) / (2 * sigma * sigma) )) * scale );
211 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.