mirror of
https://github.com/lovell/sharp.git
synced 2026-02-04 21:56:18 +01:00
Add convolve operation for kernel-based convolution (#479)
This commit is contained in:
committed by
Lovell Fuller
parent
ba5a8b44ed
commit
b70a7d9a3b
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user