23 #include <core/exception.h> 24 #include <fvfilters/laplace.h> 31 #elif defined(HAVE_OPENCV) 32 # if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) 33 # include <opencv/cv.h> 35 # include <opencv/cv.hpp> 37 # error "Neither IPP nor OpenCV available" 40 namespace firevision {
63 kernel = (
int *)malloc((
size_t)size * (size_t)size *
sizeof(
int));
66 kernel_float = (
float *)malloc((
size_t)size * (size_t)size *
sizeof(
float));
67 for (
unsigned int i = 0; i < size * size; ++i) {
68 kernel_float[i] = kernel[i];
79 if (kernel_float != NULL) {
105 IppiSize ksize = {kernel_size, kernel_size};
106 IppiPoint kanchor = {(kernel_size + 1) / 2, (kernel_size + 1) / 2};
128 if (status != ippStsNoErr) {
155 #elif defined(HAVE_OPENCV) 160 cv::Mat srcm(
src_roi[0]->height,
174 if (kernel_float == NULL) {
175 cv::Laplacian(srcm, dstm, CV_8UC1, 5);
177 cv::Mat kernel(kernel_size, kernel_size, CV_32F, kernel_float);
178 cv::Point kanchor((kernel_size + 1) / 2, (kernel_size + 1) / 2);
179 cv::filter2D(srcm, dstm, -1, kernel, kanchor);
210 for (
int h = (-(
int)(size / 2)); h <= (int)((size - 1) / 2); ++h) {
211 for (
int w = (-(
int)(size / 2)); w <= (int)((size - 1) / 2); ++w) {
214 int v = (int)roundf(-1 / (M_PI * sigma * sigma * sigma * sigma)
215 * (1 - ((w * w + h * h) / (2 * sigma * sigma)))
216 * exp(-((w * w + h * h) / (2 * sigma * sigma))) * scale);
218 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.