Add convolve operation for kernel-based convolution (#479)

This commit is contained in:
Matt Hirsch
2016-07-04 15:48:00 -04:00
committed by Lovell Fuller
parent ba5a8b44ed
commit b70a7d9a3b
12 changed files with 202 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
#include <algorithm>
#include <tuple>
#include <memory>
#include <vips/vips8>
#include "common.h"
@@ -211,6 +212,24 @@ namespace sharp {
}
}
/*
* Convolution with a kernel.
*/
VImage Convolve(VImage image, int width, int height, double scale, double offset,
const std::unique_ptr<double[]> &kernel_v) {
VImage kernel = VImage::new_from_memory(
kernel_v.get(),
width * height * sizeof(double),
width,
height,
1,
VIPS_FORMAT_DOUBLE);
kernel.set("scale", scale);
kernel.set("offset", offset);
return image.conv(kernel);
}
/*
* Sharpen flat and jagged areas. Use sigma of -1.0 for fast sharpen.
*/